From owner-freebsd-current Fri Dec 13 8:16:18 2002 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 6297937B401 for ; Fri, 13 Dec 2002 08:16:16 -0800 (PST) Received: from puffin.mail.pas.earthlink.net (puffin.mail.pas.earthlink.net [207.217.120.139]) by mx1.FreeBSD.org (Postfix) with ESMTP id DEE4E43EC5 for ; Fri, 13 Dec 2002 08:16:10 -0800 (PST) (envelope-from tlambert2@mindspring.com) Received: from rev208-187-98-122.wolsi.com ([208.187.98.122] helo=mindspring.com) by puffin.mail.pas.earthlink.net with asmtp (SSLv3:RC4-MD5:128) (Exim 3.33 #1) id 18MsTr-0006rS-00; Fri, 13 Dec 2002 08:16:04 -0800 Message-ID: <3DFA0771.BDFC87A8@mindspring.com> Date: Fri, 13 Dec 2002 08:14:41 -0800 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Joe Kelsey Cc: freebsd-current@freebsd.org Subject: Re: Posix Semaphores in -CURRENT References: <3DF8F08E.8050809@mail.flyingcroc.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ELNK-Trace: b1a02af9316fbb217a47c185c03b154d40683398e744b8a455d76b880b3a28e4f8670b0f0b0f24ab667c3043c0873f7e350badd9bab72f9c350badd9bab72f9c Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Joe Kelsey wrote: > I have been looking at the implementation of POSIX semaphores in > -CURRENT. I noticed that there are several missing pieces, specifically > the man pages and the removal of uthread_sem.c from libc_r. > > I suppose the man pages are not critical, but it seems silly to keep > uthread_sem.c in libc_r if there is a completely new kernel-based > implementation of the sem_* routines in -CURRENT. First, realize that there is no such kernel implementation, in the non-KSE case, and that the default in 5.0 is going to be non-KSE (which will wait until at least 5.1). Second, realize that even if there were a shiny, happy kernel implementation, it would be a bad idea to use it directly from a threaded program. This is because, even in the KSE world, the thread scheduler is a hybrid, and it's possible to have a multiplicity of threads in user space backed by a single kernel context. When this happens, crossing the user/kernel boundary does nothing for you... except to make your program run slower. > There are some other things about uipc_sem.c that seem unnecessarily > restrictive. For one thing, it *requires* named semaphores to begin > with a '/' but not contain embedded '/'. This seems like a severe > portabliity issue as TRU64 (at least) allows arbitrary pathnames as > sempahores, probably storing some sort of marker in the directories (I > get this only from examining the TRU64 online manual pages at > http://www.tru64unix.compaq.com/docs/base_doc/DOCUMENTATION/HTML/APS33DTE_html/DOCU_010.HTM I guess the question to ask at this point is whether it's talking about disallowing embedding a '/' in a component, or disallowing it as a component seperator. I think you will find that it's the former. > There seems to be some broad interpretation of the POSIX semantice in > TRU64 to allow for negative semaphore values, one of their questionable > choices, although their example code is instructive). Since the > semaphore names are merely stored in kernel structures, what difference > does it make if they contain embedded '/' characters or not? And why > not allow names without leading '/'? I don't think that there is any > wording in POSIX preventing this. In general, an application should not assume interpretation of standards. If a standard is written such that it can be interpreted in more than one way, then the application writer should assume that some OS vendor has interpreted it in every possible way, and should not depend on behaviour that requires a single interpretation to be implemented by everyone. Sucks, I know, but the only way around it is to write your POSIX congressman. In general, I think these types of ambiguities arise *intentionally*: the standard is written so that existing implementations already comply with it, so that vendors don't have to change things, and can still claim compliance. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message