Deadlock can be prevented by breaking at least one of its necessary conditions.
Eliminate Mutual Exclusion. Resources are made shareable whenever possible so multiple tasks can access them simultaneously without blocking.
Eliminate Hold and Wait. Processes must either request all required resources at once before starting execution, or release all currently held resources before asking for new ones. This ensures a task never sits idle holding one lock while waiting on another.
Allow Preemption (Break No Preemption). If a process holding resources requests another resource that is busy, the system forcibly takes away (preempts) its current resources and adds them to a waiting list.
Eliminate Circular Wait (Resource Ordering). Assign a strict ordering (like priorities) to resources and require processes to request them in increasing order, preventing waiting loops.
Loading…