Sleep and Wakeup Calls

Q1. How are Sleep and Wakeup used for solving critical section problem.

Ans. Consider a computer with two processes, H, with high priority, and L, with low priority. The scheduling rules are such that H is run whenever it is in ready state. At a certain moment, with L in its critical region, H becomes ready to run (for example, an input/output operation completes). H now begins busy waiting, but since L is never scheduled while H is running, L never gets the chance to leave its critical region, so H loops forever. This situation is sometimes referred to as the priority inversion problem.

Now let us look at some interprocess communication primitives that block instead of waiting CPU time when they are not allowed to enter their critical regions. One of the simplest is the pair sleep and wakeup.

Sleep is a system call that causes the caller to block, that is, be suspended until another process wakes it up.

The wakeup call has one parameter, the process to be awakened.

Alternatively, both sleep and wakeup have one parameter, a memory address used to match sleeps with wakeups.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: