The Linux Programming Interface

(nextflipdebug5) #1
System V Semaphores 995

47-5. For the VMS operating system, Digital provided a synchronization method similar
to a binary semaphore, called an event flag. An event flag has two possible values,
clear and set, and the following four operations can be performed: setEventFlag, to
set the flag; clearEventFlag, to clear the flag; waitForEventFlag, to block until the flag
is set; and getFlagState, to obtain the current state of the flag. Devise an implementa-
tion of event flags using System V semaphores. This implementation will require two
arguments for each of the functions above: a semaphore identifier and a semaphore
number. (Consideration of the waitForEventFlag operation will lead you to realize
that the values chosen for clear and set are not the obvious choices.)


47-6. Implement a binary semaphores protocol using named pipes. Provide functions to
reserve, release, and conditionally reserve the semaphore.


47-7. Write a program, analogous to the program in Listing 46-6 (svmsg_ls.c, on page 953),
that uses the semctl() SEM_INFO and SEM_STAT operations to obtain and display a list of
all semaphore sets on the system.

Free download pdf