Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!news2.arglkargh.de!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Rainer Weikusat Newsgroups: comp.os.linux.development.apps Subject: Re: mkdir() and thread safety() Date: Wed, 30 Mar 2011 15:44:40 +0100 Lines: 23 Message-ID: <878vvw652f.fsf@sapphire.mobileactivedefense.com> References: <9d56213c-a054-428e-866c-559da29fbbc3@o21g2000prh.googlegroups.com> <2d58ece6-bb9c-42e0-a990-fc13b92723ec@a21g2000prj.googlegroups.com> <87oc4vtn8o.fsf@sapphire.mobileactivedefense.com> <616f7ca6-9853-4c8d-af92-983ca41365e6@g3g2000prg.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: individual.net lugVa/7U+oQG0k9iT+mm+gs3f+LmnTU0q7cWWy7xcLm3wQLt8= Cancel-Lock: sha1:GHfD8qIZqB5qNn1q3NDS6Rc5ehM= sha1:hhlIy7q8mfHXj1qlTSTo5efcjSA= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) Xref: x330-a1.tempe.blueboxinc.net comp.os.linux.development.apps:55 mkaushik writes: > On Mar 28, 5:59 am, Rainer Weikusat wrote: >> David Schwartz writes: >> > On Mar 25, 5:56 pm, mkaushik wrote: >> >> I have two threads, each tries to create a directory of the same name >> >> at the same location using mkdir(). The threads need to be oblivious >> >> of each others' existence. Do I have to worry about concurrency when I >> >> use mkdir() to create this directory? Or will mkdir() always return >> >> success in one thread and EEXIST in the other? [...] > Thanks for the answers everyone! Something which hasn't been mentioned explicitly so far: It is possible that both calls fail with EEXIST despite one created the directory: Provided that some kind of network filesystem with a stateless server is being used (IOW, NFS). It is possible that the server crashes after it created the directory but before it could send a reply to the client which requested the action. Once the server is again available, the retransmitted 'create this directory' requests from the client should lead to EEXIST.