- 2073 Bhadra · 2+3+3 marks
Interprocess communication and deadlock
Short answer
Interprocess communication allows processes to exchange data using shared memory, messages, or semaphores. Deadlock happens when processes hold resources and wait for each other, forming a circular wait. Solutions include prevention (ordered resource acquisition), avoidance (Banker's algorithm), detection/recovery, and time-outs.
What is interprocess communication? How does dead lock occur? How can it be solved?
Interprocess communication (IPC)
IPC is the set of mechanisms by which cooperating processes exchange data and synchronise their actions. Main methods are shared memory, message passing, pipes, semaphores and signals. It is needed for information sharing, speed-up and modularity.
How deadlock occurs
Deadlock occurs when processes block each other while communicating or sharing resources. It needs four conditions together: mutual exclusion, hold and wait, no preemption and circular wait.
Example: P1 locks semaphore S1 and then waits for S2; P2 locks S2 and then waits for S1. Another example: P1 waits for a message from P2, while P2 waits for a message from P1. Both are blocked for ever.
P1: wait(S1); wait(S2); ...
P2: wait(S2); wait(S1); ... -> circular wait
How it can be solved
- Prevention: break one of the four conditions, for example, acquire locks in a fixed order (no circular wait) or request all resources at once (no hold and wait).
- Avoidance: grant a request only if the system stays in a safe state (Banker's algorithm).
- Detection and recovery: find a cycle in the wait-for graph, then kill a process or preempt a resource.
- Time-outs on message receive or lock requests, to break message deadlocks.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Parallelism, IPC deadlock and OS role · Microprocessor, chapter 6
- Lock; distributed CC; deadlock situation · Distributed System, chapter 8
- Lock, deadlock; deadlock avoidance · Distributed System, chapter 8
- PLL lock and capture range; FM demodulation · Communication Systems, chapter 3