From owner-svn-src-all@FreeBSD.ORG Tue Dec 8 22:43:40 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3A4E3106566B; Tue, 8 Dec 2009 22:43:40 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 0A36A8FC13; Tue, 8 Dec 2009 22:43:40 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id B02A946B7F; Tue, 8 Dec 2009 17:43:39 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 0A21A8A01B; Tue, 8 Dec 2009 17:43:39 -0500 (EST) From: John Baldwin To: Jilles Tjoelker Date: Tue, 8 Dec 2009 17:42:58 -0500 User-Agent: KMail/1.12.1 (FreeBSD/7.2-CBSD-20091103; KDE/4.3.1; amd64; ; ) References: <200912082048.nB8Km6aP099420@svn.freebsd.org> <200912081645.37356.jhb@freebsd.org> <20091208221028.GA57735@stack.nl> In-Reply-To: <20091208221028.GA57735@stack.nl> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200912081742.58162.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Tue, 08 Dec 2009 17:43:39 -0500 (EST) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r200274 - head/lib/libc/gen X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Dec 2009 22:43:40 -0000 On Tuesday 08 December 2009 5:10:28 pm Jilles Tjoelker wrote: > On Tue, Dec 08, 2009 at 04:45:37PM -0500, John Baldwin wrote: > > On Tuesday 08 December 2009 3:48:06 pm Jilles Tjoelker wrote: > > > Author: jilles > > > Date: Tue Dec 8 20:48:06 2009 > > > New Revision: 200274 > > > URL: http://svn.freebsd.org/changeset/base/200274 > > > > Log: > > > sem_init(3): document process shared semaphores and their restrictions > > > I think the other language was more accurate. The new language has > > far less detail such as no longer documenting EPERM. > > It seems that EPERM longer happens, at least not for any process-shared > semaphore at all. This does seem true. > What's missing is the SIGSYS/ENOSYS you'll get if sem.ko is not loaded, > and you're requesting a process-shared semaphore or not linking with > the threading library. This is probably less important since it is now enabled by default in HEAD. I think ENOSYS is a bit of a special case as we don't document it for other optional services such as SYSV IPC primitives. > > I think it is also quite accurate to say that the current > > implementation is not capable of process shared semaphores. Several > > things would need to be changed including moving away from using file > > descriptors. > > There are some lines of code dedicated to make it work, and some people > seem to use it, although they notice that it does not work very well. > This topic has come up on the mailing lists several times recently. No, it doesn't really work. It happens to work across a fork(), but that is the only case. In particular, you can't mmap() a file (or a shared memory descriptor) and sem_init() a region of it and expect another process to be able to use it directly via sem_wait() (which is what pshared is supposed to mean): If the pshared argument has a non-zero value, then the semaphore is shared between processes; in this case, any process that can access the semaphore sem can use sem for performing sem_wait(), [TMO] [Option Start] sem_timedwait(), [Option End] sem_trywait(), sem_post(), and sem_destroy() operations. The fact that we don't fail attempts to use pshared outright is probably dubious. They cannot possibly work as currently implemented aside from fork() since the structure embeds a file descriptor and file descriptor indices are a per-process namespace, not a global namespace. -- John Baldwin