Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Apr 2017 12:16:38 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Drake Talley <axylos@doge.city>
Cc:        freebsd-arch@freebsd.org
Subject:   Re: sysctl for named posix semaphores
Message-ID:  <20170430091638.GR1622@kib.kiev.ua>
In-Reply-To: <20170429154018.GA3703@kunai.nyc.rr.com>
References:  <20170429154018.GA3703@kunai.nyc.rr.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Apr 29, 2017 at 11:40:18AM -0400, Drake Talley wrote:
> I'm interested in being able to display information about all active named POSIX
> semaphores.  I have not been able to find a sane way to do this, and
> unless there's something obvious I've missed,
There is no way to do this ...

> it may be worth
> considering building a sysctl or some other interface for accessing this
> information.  A while back in the mailing list there seems to have been
... be it sysctl or any other word.

> some discussion about building out a "semfs" or some other file system
> interface akin to /dev/shm in Linux, but there were concerns about the
> POSIX compatibility of that approach.  
> 
> On a related note in /src/sys/kern/uipc_shm.c there is the following
> TODO:
> 
>  * (1) Need to export data to a userland tool via a sysctl.  Should ipcs(1)
>  *     and ipcrm(1) be expanded or should new tools to manage both POSIX
>  *     kernel semaphores and POSIX shared memory be written?
> 
> 
> So, it's been acknowledged that a sysctl or some new utility is on the
> table, and exporting this data to userland isn't blasphemous, although
> perhaps not the most pressing need at the moment.  Setting Sys V IPC on
> the side, has there been discussion or consideration of similar tools
> for POSIX semaphores?
No, such discussion does not make sense, see below.

> 
> 
> 
> Whether or not it's deemed worth doing, I'd appreciate any info or
> references to discussions about this topic since I'm like
> to tinker with it on my own if nothing else.

The current POSIX semaphores implementation is mostly userspace, see
the lib/libc/gen/sem_new.c source file for details. From the birds view,
a POSIX semaphore is constructed from the shared mapping of a file in
/tmp (presumably tmpfs-backed), and some umtx(2) features to assist in
implementing the acquisition and release operations. Kernel does not
provide complete abstracted object for semaphores.

In other words, there is no way for kernel to enumerate userspace
entities which semaphores are.

The implementation in sys/kern/uipc_sem.c AKA sem.ko is obsoleted ('legacy')
and is provided for ABI compatibility with <= 8.x libc.



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