Step 1: Deadlock recovery strategies.
Once a deadlock has occurred, there are several ways to recover from it:
- **Process termination**: Terminating one or more processes involved in the deadlock to break the circular wait condition.
- **Resource preemption**: Forcibly taking resources away from processes to break the hold and wait condition.
Step 2: Analysis of other options.
- (2) **Non preemption of resources**: This condition is part of the deadlock model, not a way to recover from deadlock.
- (3) **Banker's algorithm**: It is a prevention algorithm to avoid deadlock but does not apply for recovering from an already occurred deadlock.
- (4) **Circular wait**: This is one of the conditions that causes deadlock, not a recovery method.
Step 3: Conclusion.
The correct method to recover from a deadlock is **process termination** (1).
Complete the following statement by choosing the correct option.
For a deadlock to occur, the four conditions namely Mutual Exclusion, Hold and Wait, No preemption, Circular wait __________.
Consider a computer system with multiple shared resource types, with one instance per resource type. Each instance can be owned by only one process at a time. Owning and freeing of resources are done by holding a global lock \(L\). The following scheme is used to own a resource instance:
function OwnResource(Resource R)
Acquire lock L // a global lock
if R is available then
Acquire R
Release lock L
else
if R is owned by another process P then
Terminate P, after releasing all resources owned by P
Acquire R
Restart P
Release lock L
end if
end if
end function
Which of the following choice(s) about the above scheme is/are correct?