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?
The question describes a resource allocation scheme in a computer system with the following key features:
We need to analyze each given option to determine which statements about the scheme are correct:
A deadlock occurs when a set of processes are blocked because each process is holding a resource and waiting for another that is held by another process. This scheme avoids deadlocks by ensuring that if a resource is already owned, the owning process is forcibly terminated and its resources are released, preventing circular wait. Therefore, this statement is correct.
A live-lock occurs when processes continuously change their state in response to other processes without making progress. In this scheme, if two or more processes frequently request the same resources, the constant termination and restarting of processes could cause them to remain in a state of flux without making progress. Thus, live-lock is a possibility, making this statement correct.
Starvation occurs when a process is perpetually denied necessary resources to proceed with its operation. Since a process could be continuously terminated if another process always requests its owned resources, starvation is a significant risk in this scheme. Hence, this statement is also correct.
The mutual exclusion property requires that a resource is held by only one process at a time. The scheme uses a global lock and ensures that resources are acquired and released such that mutual exclusion is maintained. Therefore, this statement is incorrect.
To summarize, the correct statements are:
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 __________.