Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ () — Coherent 3.1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought


semget()               COHERENT System Call              semget()




Get a set of semaphores

#include <sys/sem.h>
semget(key, nsems, semflg)
key_t key; int nsems, semflg;

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 (semflg & IPC_CREAT) 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 (EACCES).

*   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 (EINVAL).

*  A  semaphore identifier does  not exist for key  and (semflg &
   IPC_CREAT) is false (ENOENT).

*  The number  of semaphore identifiers allowed system-wide would
   be exceeded (ENOSPC).



COHERENT Lexicon                                           Page 1



semget()               COHERENT System Call              semget()



*  The number of semaphores allowed system-wide would be exceeded
   (ENOSPC).

*   A  semaphore  identifier  exists  for  key but  (  (semflg  &
   IPC_CREAT) && (semflg & IPC_EXCL) ) is true (EEXIST).

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

Upon  successful completion,  semget returns  a  non-negative in-
teger, namely  a semaphore identifier.  Otherwise,  it returns -1
and sets errno 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


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026