Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Experiment with the program in Example 47-8 (svsem_op.c) to confirm your understanding of the semop() system call.
Modify the program in Example 24-6 (fork_sig_sync.c, in Section 24.5) to use semaphores instead of signals to synchronize the parent and child processes.
Experiment with the program in Example 47-8 (svsem_op.c) and the other semaphore programs provided in this chapter to see what happens to the sempid value if an exiting process performs a SEM_UNDO adjustment to a semaphore.
Add a reserveSemNB() function to the code in Example 47-10 (binary_sems.c) to implement the reserve conditionally operation, using the IPC_NOWAIT flag.
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 implementation 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.)
Implement a binary semaphores protocol using named pipes. Provide functions to reserve, release, and conditionally reserve the semaphore.
Write a program, analogous to the program in Example 46-6 (svmsg_ls.c, in Section 46.7), that uses the semctl() SEM_INFO and SEM_STAT operations to obtain and display a list of all semaphore sets on the system.