Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 08 Jun 2009 14:57:18 +0200
From:      Ivan Voras <ivoras@freebsd.org>
To:        freebsd-stable@freebsd.org
Subject:   Re: Unnamed POSIX shared semaphores
Message-ID:  <h0j1qa$umk$1@ger.gmane.org>
In-Reply-To: <200906020842.42330.jhb@freebsd.org>
References:  <ad79ad6b0906010833y20042080td1ebe0d3bfffbdc5@mail.gmail.com>	<20090601161903.GA40377@stack.nl> <4A24457C.6060100@FreeBSD.org> <200906020842.42330.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
John Baldwin wrote:
> On Monday 01 June 2009 5:17:48 pm Bruce Simpson wrote:
>> Jilles Tjoelker wrote:
>>> If process-shared semaphores really work, then the above structure is
>>> not a pathological case. Effectively, sem_t is carved in stone. So
>>> process-private semaphores should continue to have most of their stuff
>>> in a separately allocated structure, to preserve flexibility.
>>>   
>> There was an inadvertent race in FreeBSD's POSIX semaphores which I 
>> fixed in HEAD and STABLE about 6 weeks before 7.2 was released.
>>
>> I believe process-shared POSIX semaphores now work -- the Python 
>> 'multiprocessing' regression test now runs to completion with no errors 
>> on both HEAD and STABLE.
> 
> The semaphores in recent 7 and 8 are definitely not process-shared (at least 
> not intentionally).  They may work across a fork accidentally, but you can't 
> store it in an mmap() region and share it with an arbitrary process.
> 

On a completely unrelated subject I was reading about PHP APC cache
where they have the same need - cross-process locking with locks
embedded in data structures and they have adopted userland spinlock code
from PostgreSQL:

http://www.scribd.com/doc/3288293/brian-shireapc-facebook

(spin)locks are not the same as sempahores but maybe it will help the OP
or anyone else trying to implement this feature:

http://cvs.php.net/viewvc.cgi/pecl/apc/pgsql_s_lock.h?revision=3.4&view=markup

http://cvs.php.net/viewvc.cgi/pecl/apc/pgsql_s_lock.c?revision=3.3&view=markup




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?h0j1qa$umk$1>