Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Dec 2004 18:11:00 -0800
From:      Joe Kelsey <joe@zircon.seattle.wa.us>
To:        Peter Pentchev <roam@ringlet.net>
Cc:        Robert Watson <rwatson@freebsd.org>
Subject:   Re: Fixing Posix semaphores
Message-ID:  <1103681460.30309.799.camel@zircon.zircon.seattle.wa.us>
In-Reply-To: <20041222011506.GG801@straylight.m.ringlet.net>
References:  <1102975803.30309.196.camel@zircon.zircon.seattle.wa.us> <Pine.NEB.3.96L.1041221235624.62809A-100000@fledge.watson.org> <20041222011506.GG801@straylight.m.ringlet.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 2004-12-22 at 03:15 +0200, Peter Pentchev wrote:
> On Wed, Dec 22, 2004 at 12:01:51AM +0000, Robert Watson wrote:
> > 
> > On Mon, 13 Dec 2004, Joe Kelsey wrote:
> > 
> > > I have a desire to fix posix semaphores in at least 5.3.  The current
> > > implementation doesn't actually follow the "spirit" of the standard,
> > > even though it technically qualifies in a somewhat degraded sense.  I
> > > refer to the fact that the current implementation treats posix
> > > semaphores as completely contained inside the kernel and essentially
> > > divorced from the filesystem.  The true "spirit" of the standard places
> > > the semaphores directly in the file system, similar to named pipes. 
> > > However the current implementation treats the supplied "name" as a
> > > 14-character identifier, required to begin with a slash and contain no
> > > other slashes.  Pretty weak. 
> > > 
> > > Well, in order to fix this, we need to add file system code and come up
> > > with a new type.  I currently have some time to spend on something like
> > > this and am willing to put in whatever effort it takes.  Does anyone
> > > want to add their own ideas or requirements? 
> > 
> > >From my perspective, the biggest win here is that it would permit
> > different name spaces to trivially exist using multiple mountpoints of a
> > "semfs".  This would make it easy to allow applications in different jails
> > to use identical names without colliding. 
> > 
> > FWIW, my only experience with POSIX semaphores on a system other than
> > FreeBSD is on Darwin, where a similar model is used to that on FreeBSD: a
> > flat kernel-maintained name space is present.
> 
> I seem to remember either W. Richard Stevens's APUE, or Marc Rochkind's
> AUP stating that:
> 
> 1. the standards say that semaphore names ought to have filesystem
>    semantics, but...
> 2. the standards leave it to the implementation to define whether
>    slashes should be allowed at all except in the first position, so...
> 3. portable programs should only depend on a flat namespace,
>    especially as...
> 4. there are widely-used OS's (ISTR Solaris, but ICBW) that only provide
>    a flat namespace.
> 
> Thus, it would seem that even if somebody would do the work to really
> tie the semaphore naming fully to the filesystem, still programs that
> want to be Really Really Portable would not dare use this feature,
> wonderful as it would be for those that do :(

I never said I wanted file system tieing.  I just want pathname
semantics.

Here is a direct quote from the Single UNIX Specification:

        The name argument points to a string naming a semaphore object.
        It is unspecified whether the name appears in the file system
        and is visible to functions that take pathnames as arguments.
        The name argument conforms to the construction rules for a
        pathname. If name begins with the slash character, then
        processes calling sem_open() with the same value of name shall
        refer to the same semaphore object, as long as that name has not
        been removed. If name does not begin with the slash character,
        the effect is implementation-defined. The interpretation of
        slash characters other than the leading slash character in name
        is implementation-defined.

So, there are words there that can be interpreted many different ways.
The most restricted way to view them is as 14-character names optionally
beginning with a slash.  That also seems to me to be the stupidest way
to view them.  Robert's idea of semfs seems brilliant, allowing multiple
name spaces for jailed processes.  I plan to start thinking and working
on that idea shortly.

/Joe




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1103681460.30309.799.camel>