Sobes.tech
Junior — Middle

When and under what conditions can resource deadlock occur in a system?

sobes.tech AI

Answer from AI

Mutual exclusion (deadlock) of resources occurs when multiple processes or threads simultaneously hold resources and wait for the release of resources occupied by each other, creating a cyclic dependency.

Conditions for deadlock:

  1. Mutual exclusion — resources can only be held by one process at a time.
  2. Hold and wait — a process holds one resource and waits for another.
  3. No preemption — resources cannot be forcibly taken away from a process.
  4. Circular wait — there exists a cycle 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 — a deadlock occurs.