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?
Step 1: Analyze deadlock possibility.
Deadlock requires circular wait, hold-and-wait, mutual exclusion, and no preemption.
In this scheme, if a process \(P\) holds a resource needed by another process, \(P\) is forcibly terminated and its resources are released. This introduces preemption. Hence, circular wait cannot persist.
Therefore, the scheme ensures that deadlocks will not occur. Option (A) is correct.
Step 2: Analyze possibility of live-lock.
Live-lock occurs when processes continuously change state but make no progress.
Here, a process may repeatedly acquire a resource, get terminated by another process requesting the same resource, and then get restarted. Such repeated termination and restart cycles can prevent any process from making forward progress.
Hence, the scheme may lead to live-lock. Option (B) is correct.
Step 3: Analyze starvation.
Starvation occurs when a process is perpetually denied access to a resource.
In this scheme, a process may be repeatedly terminated whenever it acquires a resource, due to higher-priority or frequently executing competing processes. Thus, it may never complete execution successfully.
Hence, the scheme may lead to starvation. Option (C) is correct.
Step 4: Mutual exclusion property.
Each resource instance can be owned by only one process at a time, and access is protected using the global lock \(L\). Hence, mutual exclusion is preserved.
Therefore, option (D) is incorrect.
Step 5: Conclusion.
The correct choices are (A), (B), and (C).
Final Answer: (A), (B), (C)
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 __________.