|
|
coherent
semget() COHERENT System Call semget() Get a set of semaphores #include <sys/sem.h> sseemmggeett(_k_e_y, _n_s_e_m_s, _s_e_m_f_l_g) kkeeyy_tt _k_e_y; iinntt _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 & IIPPCC_CCRREEAATT) 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 (EEAACCCCEESS). * 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 (EEIINNVVAALL). * A semaphore identifier does not exist for key and (_s_e_m_f_l_g & IIPPCC_CCRREEAATT) is false (EENNOOEENNTT). * The number of semaphore identifiers allowed system-wide would be exceeded (EENNOOSSPPCC). COHERENT Lexicon Page 1 semget() COHERENT System Call semget() * The number of semaphores allowed system-wide would be exceeded (EENNOOSSPPCC). * A semaphore identifier exists for key but ( (_s_e_m_f_l_g & IIPPCC_CCRREEAATT) && (_s_e_m_f_l_g & IIPPCC_EEXXCCLL) ) is true (EEEEXXIISSTT). ***** Return Value ***** Upon successful completion, semget returns a non-negative in- teger, namely a semaphore identifier. Otherwise, it returns -1 and sets eerrrrnnoo 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
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.