struct sem_array {

struct kern_ipc_perm time_t time_t struct sem struct sem_queue struct sem_queue struct sem_undo unsigned long

*sem_base; /* ptr to first semaphore in array */

*sem_pending; /* pending operations to be processed **sem_pending_last; /* last pending operation */

*undo; /* undo requests on this array */

sem_nsems; /* no. of semaphores in array */

There is exactly one instance of this data structure in the system for each semaphore set. The instance is used to manage all the semaphores that make up the set.

□ Semaphore access permissions are held in sem_perm of the familiar kern_ipc_perm type. This must be located at the beginning of the structure so that a trick can be used involving the ipc_ids->entries arrays employed to manage all semaphore sets. Because the individual elements point to areas in which sufficient memory is reserved not only for kern_ipc_perm but also for sem_array, the kernel can switch between both representations by means of typecasts.

This trick is also used for other SysV-IPC objects, as you will see further below.

□ sem_nsems specifies the number of semaphores in a user semaphore.

□ sem_base is an array, each of whose entries describes a semaphore in the set. It holds the current semaphore value and the PID of the process that last accessed it.

Continue reading here: Info

Was this article helpful?

0 0