Data structures

Each SysV semaphore set is represented in the kernel by a descriptor of type struct sem_array:

/* One sem_array data structure for each set of semaphores in the system. */
struct sem_array {
struct kern_ipc_perm ____cacheline_aligned_in_smp sem_perm;
time_t sem_ctime; /* last change time */
struct sem *sem_base; /*ptr to first semaphore in array */
struct list_head pending_alter; /* pending operations */
/* that alter the array */
struct list_head pending_const; /* pending complex operations */
/* that do not alter semvals */
struct list_head list_id; /* undo requests on this array */
int sem_nsems; /* no. of semaphores in array */
int complex_count; /* pending complex operations */
bool complex_mode; /* no parallel simple ops */
};

Each semaphore in the array is enumerated as an instance of struct sem defined in <ipc/sem.c>; the *sem_base pointer refers to the first semaphore object in the set. ;Each semaphore set contains a list of pending queue per process waiting; pending_alter is the head node for this pending queue of type struct sem_queue. Each semaphore set also contains per-semaphore undoable operations. list_id is a head node to a list of struct sem_undo instances; there is one instance in the list for each semaphore in the set. The following diagram sums up the semaphore set data structure and its lists:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.85.76