From owner-freebsd-current@FreeBSD.ORG Fri Jan 30 06:11:15 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A3F6916A4CE for ; Fri, 30 Jan 2004 06:11:15 -0800 (PST) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5695143D5D for ; Fri, 30 Jan 2004 06:11:10 -0800 (PST) (envelope-from eischen@vigrid.com) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mail.pcnet.com (8.12.10/8.12.1) with ESMTP id i0UEB9iw008706; Fri, 30 Jan 2004 09:11:09 -0500 (EST) Date: Fri, 30 Jan 2004 09:11:09 -0500 (EST) From: Daniel Eischen X-Sender: eischen@pcnet5.pcnet.com To: Andrey Chernov In-Reply-To: <20040130135802.GA57662@nagual.pp.ru> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: current@freebsd.org Subject: Re: POSIX semaphores? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Jan 2004 14:11:15 -0000 On Fri, 30 Jan 2004, Andrey Chernov wrote: > Could anybody enlighten me, please? > > 1) What is current status of POSIX semaphores? Are they at the production > quality? Are they better implemented than SYSV ones? > 2) What is kernel option to turn them on? Why I don't find it in NOTES or > GENERIC? You need option P1003_1B_SEMAPHORES. It's in sys/conf/NOTES. > The reason why I ever ask is that some ports try to sense POSIX semaphores > at configure stage (looking for sem_init()) and then compiled program > fails with "Unknown system call" diagnostic. They must be trying to use shared semaphores which currently don't work across processes (unless they are forked and semaphore is created before the fork). The problem is that semaphores (and mutexes, condition variables, etc) are all pointers to an allocated structure. You can't place this (the pointer) in shared memory and have processes other than the creating process access it. This probably won't be fixed until 6.0 because we'll need to change these synchronization types to be the actual structures instead of pointers (breaking binary compatibility). So we do support semaphores, but not pshared semaphores even though the library call honors pshared. And if you do try to use a pshared semaphore, then the kernel support (P1003_1B_SEMAPHORES) has to be there. -- Dan (currently reworking semaphores)