- The implementation of a semaphore with a waiting queue may result in a situation where two or more processes are waiting indefinitely for an event that can be caused only by one of the waiting processes.
- The event in question is the execution of a operation. When such a state is reached, these processes are said to be deadlocked.
- To illustrate this, we consider a system consisting of two processes, and , each accessing two semaphores, and , set to the value 1:
- Suppose that executes and then executes .
- When executes , it must wait until executes .
- Similarly, when executes , it must wait until executes .
- Since these operations cannot be executed, and are deadlocked.
- Another problem related to deadlocks is indefinite blocking, or starvation, a situation in which processes wait indefinitely within the semaphore.
- Indefinite blocking may occur if we add and remove processes from the list associated with a semaphore in LIFO (last-in, first-out) order.
Cem Ozdogan
2010-04-06