Man page of MSEM182

Section: The sem182 library (3) Updated: RELEASE 2.4


mseminit, msemgrab, mP, mV, msemrm - Semaphore field operations  


#include <msem182.h>

int mseminit (key_t key, int semperm, int nsems, ...);
int msemgrab (key_t key, int nsems);
int mP (int semid, int nsems, ...);
int mV (int semid, int nsems, ...);
int msemrm (int semid);


These functions are easier to use than the standard interface.

mseminit creates a semaphore field of nsems semaphores with key using semperm as permissions and initializes the semaphore field to the specified values. On success this function returns a valid descriptor for the semaphore field. In case a semaphore field with the specified key already exists, mseminit returns -1.

msemgrab delivers a valid descriptor for an already existing semaphore field of at least nsems semaphores.

mP and mV perform a P resp. V operation on the semaphores indicated by the following nsems arguments in the field semid atomically. Thus mP (semid, 3, 1, 0, 2) is the same as P (semid1); P (semid0); P (semid2); except that mP is an atomic action, whereas the three P's are not. Using the same index twice in a single call to mP or mV results in undefined behaviour.

msemrm removes the semaphore field given by semid.  


All functions return -1 in case of error and set errno accordingly.  


You have to specify the library to the compiler, e.g.

c89 program.c -lsem182  


semget(2), semop(2), semctl(2), sem182(3)  


The sem182 library is provided "as is" for education purposes only. There is no warranty for the correct functionality and we do not accept any responsibility whatsoever for any loss or damage that is caused by the use of the sem182 library.  


Peter Holzer, by modifying an old version of sem182 by Günther Leber and Heinz Kantz, which had also been modified (the version, not Heinz) by Gustav Pospischil. Additional code contributed by Raimund Kirner.

Manual page written by Peter Holzer, by modifying a quite recent version of the manual page of sem182 by Günther Leber. Manual page clean-up and reformatting by Thomas Perl.