This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Semaphores in libc
- From: Petr Baudis <pasky at suse dot cz>
- To: Mark Brown <bmark at us dot ibm dot com>
- Cc: libc-help at sourceware dot org
- Date: Tue, 5 Jan 2010 01:00:36 +0100
- Subject: Re: Semaphores in libc
- References: <11b141710912310338k673aff61i6c20419af2403788@mail.gmail.com><20091231122655.GG2249@machine.or.cz><11b141710912310514k7910e63fke438d06af44e5252@mail.gmail.com><20091231132227.GS24109@machine.or.cz><11b141710912310526k633efc1l7488512231690a68@mail.gmail.com><20091231135523.GT24109@machine.or.cz><OF92FF385D.9BB61F4B-ON862576A1.00617B7D-862576A1.0062AF20@us.ibm.com>
On Mon, Jan 04, 2010 at 11:57:35AM -0600, Mark Brown wrote:
> All-
>
> > Petr Baudis <pasky@suse.cz>
>
> > mkdir() should be atomic, so each process will always pick a different
> > name.
>
>
> POSIX does not guarantee an atomic mkdir(). Section 2.9.7 of the System
> Interfaces volume of 1003.1-2008 will give you the list of
> "guaranteed-atomic" interfaces.
Yes, as I said, it isn't described as atomic, which I found curious.
A possible workaround might be to change the loop to pseudo-do
mkdir(...) && open(..."/.used", O_CREAT|O_EXCL)
Petr "Pasky" Baudis