Junior — Middle
Can you explain what mutual locking in operating systems is and how it occurs?
sobes.tech AI
Answer from AI
A deadlock is a situation in an operating system where two or more processes permanently block each other, waiting for resources held by the other.
It occurs when four conditions are met simultaneously:
- Mutual exclusion — a resource can only be held by one process at a time.
- Hold and wait — a process holds one resource and waits for another.
- No preemption — a process cannot be forcibly removed from a resource.
- Circular wait — a cycle exists of processes, each waiting for a resource held by the next in the cycle.
Example: Process A has acquired resource 1 and is waiting for resource 2, while process B has acquired resource 2 and is waiting for resource 1 — both are permanently blocked.