From owner-svn-src-all@FreeBSD.ORG Thu Dec 10 13:59:29 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 8E48A106566C; Thu, 10 Dec 2009 13:59:29 +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 5CF3E8FC17; Thu, 10 Dec 2009 13:59:29 +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 0BD6146B38; Thu, 10 Dec 2009 08:59:29 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 59B9A8A01F; Thu, 10 Dec 2009 08:59:28 -0500 (EST) From: John Baldwin To: Robert Watson Date: Thu, 10 Dec 2009 08:59:20 -0500 User-Agent: KMail/1.12.1 (FreeBSD/7.2-CBSD-20091103; KDE/4.3.1; amd64; ; ) References: <200912082048.nB8Km6aP099420@svn.freebsd.org> <4B1FAC12.6080907@cs.duke.edu> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200912100859.20208.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Thu, 10 Dec 2009 08:59:28 -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, Andrew Gallatin , Jilles Tjoelker 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: Thu, 10 Dec 2009 13:59:29 -0000 On Wednesday 09 December 2009 7:24:28 pm Robert Watson wrote: > On Wed, 9 Dec 2009, Andrew Gallatin wrote: > > > John Baldwin wrote: > > > >> 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. > > > > FWIW, this is what confused me. It tends to be kind of a land-mine, since > > programs can be ported from Linux, and appear to work at first for casual > > use. If we don't support pshared, we should return an error from sem_init() > > to make it obvious. > > > > Also, perhaps the sem_init() man page should mention sem_open(), since that > > seems to be the only way to really share a semaphore between processes on > > FreeBSD. > > It's beginning to sound like our POSIX semaphores should be behaving more like > umtx, which requires only a shared page, and less like file descriptors. Of > course, that would make the global namespace more tricky... I believe even that would be tricky since umtx uses the userland address of the umtx as a cookie and that is not guaranteed safe aside from the fork(2) case. Oh, hmm, I'm wrong on that one. You can make a PROCESS_SHARED umtx and it uses the offset relative to the start of the containing vm_object for it's hash key. That's cute. Note that you really only need for the pshared variant. The file descriptors do provide many of the desired semantics (Solaris implements many of the POSIX IPC primitives by mmap()'ing files in /tmp using the provided name for example). One possibility is to make sem_t use the kernel-backed fd-based semaphores for named semaphores and non-pshared semaphores but to use umtx for pshared semaphores. The threads library already does a similar trick where it uses umtx for !pshared semaphores and the kernel for everything else. -- John Baldwin