

semget()               COHERENT System Call              semget()




Get a set of semaphores

#include <sys/sem.h>
sseemmggeett(_k_e_y, _n_s_e_m_s, _s_e_m_f_l_g)
kkeeyy_tt _k_e_y; iinntt _n_s_e_m_s, _s_e_m_f_l_g;

semget returns the  semaphore identifier associated with key.  It
creates a semaphore  identifier and associated data structure and
set  that contains  nsems semaphores  for key  should one  of the
following be true:

*  key equals IPC_PRIVATE.

*  key  does not have a semaphore  identifier associated with it,
   and (_s_e_m_f_l_g & IIPPCC_CCRREEAATT) is true.

When semget  creates a data  structure for a  new semaphore iden-
tifier, it initializes the structure as follows:

*  It sets the fields sem_perm.cuid, sem_perm.uid, sem_perm.cgid,
   and sem_perm.gid  equal to the effective  user identifier, the
   calling  process's identifier, and  the effective  group iden-
   tifier, respectively.

*  It sets the low-order  nine bits of sem_perm.mode equal to the
   low-order nine bits  of semflg.  These nine bits define access
   permissions:  the top  three bits  specify the  owner's access
   permissions (read, write,  execute), the middle three bits the
   owning group's access  permissions, and the low three bits ac-
   cess permissions for others.

*  sem_nsems is set equal to the value of nsems.

*  sem_otime is set to zero and sem_ctime to the current time.

semget fails if any of the following are true:

*  nsems  is either less than  or equal to zero,  or greater than
   the system imposed limit.  It sets errno to EINVAL.

*  A semaphore identifier exists for key but operation permission
   as specified by the low-order nine bits of semflg would not be
   granted (EEAACCCCEESS).

*   A  semaphore identifier  exists  for key  but  the number  of
   semaphores in  the set associated  with it is  less than nsems
   and nsems is not equal to zero (EEIINNVVAALL).

*  A  semaphore identifier does  not exist for key  and (_s_e_m_f_l_g &
   IIPPCC_CCRREEAATT) is false (EENNOOEENNTT).

*  The number  of semaphore identifiers allowed system-wide would
   be exceeded (EENNOOSSPPCC).



COHERENT Lexicon                                           Page 1




semget()               COHERENT System Call              semget()



*  The number of semaphores allowed system-wide would be exceeded
   (EENNOOSSPPCC).

*   A  semaphore  identifier  exists  for  key but  (  (_s_e_m_f_l_g  &
   IIPPCC_CCRREEAATT) && (_s_e_m_f_l_g & IIPPCC_EEXXCCLL) ) is true (EEEEXXIISSTT).

***** Return Value *****

Upon  successful completion,  semget returns  a  non-negative in-
teger, namely  a semaphore identifier.  Otherwise,  it returns -1
and sets eerrrrnnoo to an appropriate value.

***** Files *****

/usr/include/sys/ipc.h
/usr/include/sys/sem.h
/dev/sem
/drv/sem

***** See Also *****

COHERENT system calls, sem, semctl(), semop()

***** Notes *****

To  improve  portability,  the  COHERENT  system  implements  the
semaphore functions  as a device driver rather  than as an actual
system call.





























COHERENT Lexicon                                           Page 2


