Unit summary
- Cooperating processes communicate by shared memory or message passing, such as pipes and FIFOs.
- A race condition makes results depend on timing, and critical sections need mutual exclusion, progress and bounded waiting.
- Semaphores, with wait and signal, solve mutual exclusion and the producer-consumer problem.
- Monitors provide automatic mutual exclusion with condition variables, and the dining-philosophers problem tests deadlock-free design.
- Deadlock needs mutual exclusion, hold and wait, no preemption and circular wait, shown by resource-allocation graphs.
- Deadlocks are handled by prevention, avoidance with the Banker's algorithm, detection and recovery, or ignoring them.
Glossary
| Term | Meaning |
|---|---|
| Banker's algorithm | A deadlock-avoidance algorithm. |
| Bounded waiting | A limit on waiting before entry. |
| Circular wait | A cycle of processes each waiting on the next. |
| Condition variable | A queue used with wait and signal in a monitor. |
| Critical section | Code that accesses shared data. |
| Deadlock | Processes waiting on each other for ever. |
| IPC | Inter-process communication. |
| Monitor | A construct with automatic mutual exclusion. |
| Mutex | A lock for mutual exclusion. |
| Mutual exclusion | Only one process in its critical section. |
| Pipe | A one-way byte channel between processes. |
| Progress | The choice of the next entrant is not postponed for ever. |
| Race condition | Results depending on execution order. |
| Resource-allocation graph | A graph of requests and assignments. |
| Rollback | Returning a process to an earlier safe state. |
| Safe state | A state with a safe sequence. |
| Semaphore | A variable with atomic wait and signal. |
| Wait-for graph | A graph of processes waiting on processes. |
Question bank
Short Answer Questions (2 marks each)
- What is inter-process communication?
- Define a race condition.
- What is a critical section?
- State the requirements of a critical-section solution.
- Define a semaphore.
- What is a monitor?
- Define deadlock.
- State the four necessary conditions for deadlock.
- What is a safe state?
- What is a wait-for graph?
Medium Answer Questions (5 marks each)
- Explain shared memory and message passing.
- Explain Peterson's solution to the critical-section problem.
- Solve the producer-consumer problem using semaphores.
- Explain the dining-philosophers problem and its solutions.
- Explain the methods of deadlock prevention.
- Explain recovery from deadlock.
Long Answer Questions (15 marks each)
- Explain inter-process communication, race conditions and the critical-section problem with its solutions.
- Explain semaphores and monitors, with the producer-consumer and dining-philosophers problems.
- Explain deadlock, its necessary conditions, resource-allocation graphs and prevention.
- Explain deadlock avoidance with the Banker's algorithm, and deadlock detection and recovery.
Sources
- Official BCA syllabus Operating Systems, course code 25BCA402DS03, Unit III
