|
|
coherent
semop() COHERENT System Call semop() Perform semaphore operations #include <sys/sem.h> sseemmoopp(_s_e_m_i_d, _s_o_p_s, _n_s_o_p_s) iinntt _s_e_m_i_d, _n_s_o_p_s; ssttrruucctt sseemmbbuuff(_s_o_p_s)[]; semop can atomically perform a number of operations on the set of semaphores associated with the semaphore identifier semid. sops pointer to the array of semaphore-operation structures. nsops is the number of such structures in the array. Each structure in- cludes the following members: short sem_num; /* semaphore number */ short sem_op; /* semaphore operation */ short sem_flg; /* operation flags */ Each semaphore operation specified by sem_op is performed on the semaphore specified by semid and sem_num. sem_op specifies one of three semaphore operations, as follows: * If sem_op is negative, one of the following occurs: 11. If semval is greater than or equal to the absolute value of sem_op, the absolute value of sem_op is subtracted from sem- val. 22. If semval is less than the absolute value of sem_op and (_s_e_m__f_l_g & IIPPCC_NNOOWWAAIITT) is true, semop sets errno to EGAIN and returns -1. 33. If semval is less than the absolute value of sem_op and (_s_e_m__f_l_g & IIPPCC_NNOOWWAAIITT) is false, semop increments the semncnt associated with the specified semaphore and suspend execution of the calling process until one of the following occurs: aa. semval becomes greater than or equal to the absolute value of _s_e_m__o_p. When this occurs, the value of semncnt associated with the specified semaphore is decremented, and the absolute value of sem_op is subtracted from semval. bb. The semid for which the calling process is awaiting action is removed from the system. cc. The calling process receives a signal. When this occurs, the value of semncnt associated with the specified semaphore is decremented, and the calling process resumes execution in the manner prescribed in signal. * If sem_op is positive, the value of sem_op is added to semval. COHERENT Lexicon Page 1 semop() COHERENT System Call semop() * If sem_op is zero, one of the following occurs: 11. If semval is zero, semop returns immediately. 22. If semval does not equal zero and (_s_e_m__f_l_g & IIPPCC_NNOOWWAAIITT) is true, semop immediately returns -1, with eerrrrnnoo set to EGAIN. 33. If semval is not equal to zero and (_s_e_m__f_l_g & IIPPCC_NNOOWWAAIITT) is false, semop increments the semzcnt associated with the specified semaphore and suspends execution of the calling process until one of the following occurs: aa. semval becomes zero, at which time the value of semzcnt as- sociated with the specified semaphore is decremented. bb. The semid for which the calling process is awaiting action is removed from the system. cc. The calling process receives a signal. When this occurs, the value of semzcnt associated with the specified semaphore is decremented, and the calling process resumes execution in the manner prescribed in signal. semop fails if one or more of the following are true for any of the semaphore operations specified by sops: * semid is not a valid semaphore identifier. semop sets errno to EINVAL * sem_num is less than zero or greater than or equal to the num- ber of semaphores in the set associated with semid (EEFFBBIIGG). * nsops is greater than the system imposed maximum (EE22BBIIGG). * Operation permission is denied to the calling process (EEAACCCCEESS). * The operation would result in suspension of the calling process but (_s_e_m__f_l_g & IIPPCC_NNOOWWAAIITT) is true (EEAAGGAAIINN). * An operation would cause a semval to overflow the system im- posed limit (EERRAANNGGEE). * sops points to an illegal address (EEFFAAUULLTT). Upon successful completion, the value of sempid for each semaphore specified in the array pointed to by sops is set equal to the process identifier of the calling process. ***** Return Value ***** If semop returns due to the receipt of a signal, it returns -1 to the calling process and sets errno to EINTR. If it returns due to the removal of a semid from the system, it returns -1 and sets errno to EDOM. COHERENT Lexicon Page 2 semop() COHERENT System Call semop() Upon successful completion, semop returns the value of semval at the time of the call for the last operation in the array pointed to by sops. Otherwise, it returns -1 and sets errno to an ap- propriate value. ***** Files ***** /usr/include/sys/ipc.h /usr/include/sys/sem.h /dev/sem /drv/sem ***** See Also ***** COHERENT system calls, sem, semctl(), semget() ***** Notes ***** The flag SEM_UNDO is not supported. This flag would allow semaphore operations to be undone upon the termination of the process which performed the operations. To improve portability, the COHERENT system implements semaphore operations as a device driver rather than as an actual system call. COHERENT Lexicon Page 3
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.