Table of Contents

NAME

SYNOPSIS

DESCRIPTION

The system call provides a number of control operations on the semaphore specified by and The operation to be performed is specified in (see below). is a union of the following fields: int val; /* value for SETVAL */
struct semid_ds *buf; /* buffer for IPC_{STAT,SET} */
u_short *array; /* array for GETALL & SETALL */

The semid_ds structure used in the IPC_SET and IPC_STAT commands is defined as follows in struct semid_ds { struct ipc_perm sem_perm; /* operation permissions */
struct sem *sem_base; /* semaphore set */
u_short sem_nsems; /* number of sems in set */
time_t sem_otime; /* last operation time */
time_t sem_ctime; /* last change time */
};

The ipc_perm structure used inside the semid_ds structure is defined in and looks like this: struct ipc_perm { ushort cuid; /* creator user id */
ushort cgid; /* creator group id */
ushort uid;     /* user id */
ushort gid;     /* group id */
ushort mode; /* r/w permission (see chmod(2) ) */
ushort seq;     /* sequence # (to generate unique msg/sem/shm id) */
key_t key;     /* user specified msg/sem/shm key */
};

provides the following operations: Return the value of the semaphore. Set the value of the semaphore to Return the pid of the last process that did an operation on this semaphore. Return the number of processes waiting to acquire the semaphore. Return the number of processes waiting for the value of the semaphore to reach 0. Return the values for all the semaphores associated with Set the values for all the semaphores that are associated with the semaphore identifier to the corresponding values in Gather statistics about a semaphore and place the information in the semid_ds structure pointed to by (see above). Set the value of the and fields in the structure associated with the semaphore. The values are taken from the corresponding fields in the structure pointed to by This operation can only be executed by the super-user, or a process that has an effective user id equal to either or in the data structure associated with the message queue. Remove the semaphores associated with from the system and destroy the data structures associated with it. Only the super-user or a process with an effective uid equal to the or values in the data structure associated with the semaphore can do this.

The permission to read or change a message queue (see is determined by the field in the same way as is done with files (see but the effective uid can match either the field or the field, and the effective gid can match either or

RETURN VALUES

For the GETVAL, GETPID, GETNCNT and GETZCNT operations, returns one of the values described above if successful. All other operations will make return 0 if no errors occur. Otherwise -1 is returned and set to reflect the error.

ERRORS

will fail if: is equal to IPC_SET or IPC_RMID and the caller is not the super-user, nor does the effective uid match either the or fields of the data structure associated with the message queue. The caller has no operation permission for this semaphore. is not a valid message semaphore identifier.

is not a valid command. specifies an invalid address.

SEE ALSO


Table of Contents