Sleep and Wakeup

As we have seen, busy waiting can be wasteful. Processes waiting to enter their critical sections waste processor time checking to see if they can proceed. A better solution to the mutual exclusion problem, which can be implemented with the addition of some new primitives, would be to block processes when they are denied access to their critical sections. Two primitives, Sleep and Wakeup, are often used to implement blocking in mutual exclusion.

How do Sleep and Wakeup Work?

Essentially, when a process is not permitted to access its critical section, it uses a system call known as Sleep, which causes that process to block. The process will not be scheduled to run again, until another process uses the Wakeup system call. In most cases, Wakeup is called by a process when it leaves its critical section if any other processes have blocked.

In the next few sections, illustrated by the pink line on the subway map, we will discuss three different implementations of mutual exclusion policies which do not require busy waiting. The first, semaphores, is a solution proposed by E.W. Dijkstra in 1965. Dijkstra's semaphores closely model the Sleep and Wakeup principle. Secondly, we have monitors , which are a solution to the mutual exclusion problem implemented in certain programming languages. Lastly we will discuss message passing , which has the advantage of being able to work in distributed operating systems.


             
IPC Home   Subway     Solution      Busy  
  Page      Map        Types      Waiting