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 __________.
In a 4-bit ripple counter, if the period of the waveform at the last flip-flop is 64 microseconds, then the frequency of the ripple counter in kHz is ______________. {(Answer in integer)}
Consider the following C code segment:
int x = 126, y = 105;
do {
if (x > y)
x = x - y;
else
y = y - x;
} while (x != y);
printf("%d", x);
The output of the given C code segment is ____________. (Answer in integer)
The following two signed 2’s complement numbers (multiplicand \( M \) and multiplier \( Q \)) are being multiplied using Booth’s algorithm:
| Multiplicand (\( M \)) | Multiplier (\( Q \)) |
|---|---|
| 1100 1101 1110 1101 | 1010 0100 1010 1010 |
The total number of addition and subtraction operations to be performed is __________. (Answer in integer)
The maximum value of \(x\) such that the edge between the nodes B and C is included in every minimum spanning tree of the given graph is __________ (answer in integer).
Consider the following C program
The value printed by the given C program is __________ (Answer in integer).