Controlling Semaphores
The previous sections showed how semaphore sets could be created and accessed. This section will show you how you can query the set that you have and make changes to it.
Querying Semaphore Sets
The semctl(2) function provides the IPC_STAT command to allow you to retrieve information about the semaphore set. Of particular interest is the value that indicates how many semaphores are in the set and the permission information. Information for IPC_STAT is returned in the structure semid_ds, which is shown in the following synopsis:
struct semid_ds { struct ipc_perm sem_perm; /* operation permission struct */ struct sem *sem_base; /* pointer to first semaphore in set */ u_short sem_nsems; /* number of sems in set */ time_t sem_otime; ...
Get Advanced UNIX Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.