From owner-freebsd-stable@FreeBSD.ORG Mon Jun 8 12:56:57 2009 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CBEAE10656C2 for ; Mon, 8 Jun 2009 12:56:57 +0000 (UTC) (envelope-from freebsd-stable@m.gmane.org) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by mx1.freebsd.org (Postfix) with ESMTP id 862BA8FC1C for ; Mon, 8 Jun 2009 12:56:57 +0000 (UTC) (envelope-from freebsd-stable@m.gmane.org) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MDePF-0005ck-FL for freebsd-stable@freebsd.org; Mon, 08 Jun 2009 12:56:53 +0000 Received: from lara.cc.fer.hr ([161.53.72.113]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 08 Jun 2009 12:56:53 +0000 Received: from ivoras by lara.cc.fer.hr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 08 Jun 2009 12:56:53 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-stable@freebsd.org From: Ivan Voras Date: Mon, 08 Jun 2009 14:57:18 +0200 Lines: 33 Message-ID: References: <20090601161903.GA40377@stack.nl> <4A24457C.6060100@FreeBSD.org> <200906020842.42330.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: lara.cc.fer.hr User-Agent: Thunderbird 2.0.0.21 (X11/20090409) In-Reply-To: <200906020842.42330.jhb@freebsd.org> Sender: news Subject: Re: Unnamed POSIX shared semaphores X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jun 2009 12:56:58 -0000 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