From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f72b0,4d05389b4676d696 X-Google-Attributes: gidf72b0,public X-Google-Thread: fee84,4d05389b4676d696 X-Google-Attributes: gidfee84,public X-Google-Thread: 115614,4d05389b4676d696 X-Google-Attributes: gid115614,public X-Google-Thread: f66ab,4d05389b4676d696 X-Google-Attributes: gidf66ab,public From: jum@anubis.han.de (Jens-Uwe Mager) Subject: Re: msem_lock? Date: 1996/03/23 Message-ID: #1/1 X-Deja-AN: 143871423 sender: news@baghira.han.de (news at baghira.han.de) references: organization: At Home newsgroups: comp.unix.aix,comp.unix.misc,comp.unix.osf.osf1,comp.os.mach In article , 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