Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: jum@anubis.han.de (Jens-Uwe Mager)
Subject: Re: msem_lock?
Date: 1996/03/23	[thread overview]
Message-ID: <jum-2303961756500001@anubis.han.de> (raw)
In-Reply-To: DUKE.96Mar22130112@annwn.iscp.bellcore.com

In article <DUKE.96Mar22130112@annwn.iscp.bellcore.com>,
duke@annwn.iscp.bellcore.com (Duke Robillard) wrote:

> I've just come across msem_lock() and company in AIX (IBM's UNIX,
> for those not in comp.unix.aix). They are apparently some kind 
> of fast semaphore, implemented by setting/testing a value in shared
> memory (either mmap or shmget shared memory).
> 
> I've never seen these before--does anyone know where they came
> from?  The doc page mentions OSF's references, and the .h file
> has references to Mach and BSD.  They're in the same .h as mmap()
> (mman.h), 

These are from the OSF AES. They are also in HP-UX and I really would like
to have them everywhere.

> Does anyone know how they work?  Like, does msem_lock() spin if
> the value is set already, or does it go to sleep (maybe using
> msleep()/mwakeup())?  

The msem_lock call will attempt to lock the semaphore atomically using an
atomic processor instruction and if the lock is not free it will use the
call msleep to suspend the process in the kernel. Msleep will atomically
set the wanted flag before actually sleeping. The msem_unlock call will
unlock the semaphore and check the wanted flag. If the wanted flag is set,
it will call mwakeup to wake up all processes waiting for the semaphore
and to reset the wanted flag.

I did an implementation for BSDI/OS that should port over easily to other
386 based BSD implementations that use the MACH vm system. If you are
interested in it, drop me a message.
______________________________________________________________________________
Jens-Uwe Mager                  jum@anubis.han.de
30177 Hannover                  jum@helios.de
Brahmsstr. 3                    Tel.: +49 511 660238



      reply	other threads:[~1996-03-23  5:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-03-22  5:00 msem_lock? Duke Robillard
1996-03-23  5:00 ` Jens-Uwe Mager [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox