Deadlock · Operating System
23 questions · asked in 17 of 27 years (2000–2026)
MCQ 17 · MSQ 3 · NAT 31-mark 11 · 2-mark 12
2000Questions per year2026
Questions 21–23 of 23
In a certain operating system, deadlock prevention is attemped using the following scheme. Each process is assigned a unique timestamp, and is restarted with the same timestamp if killed. Let be the process holding a resource R, be a process requesting for the same resource R, and T() and T() be their timestamps respectively. The decision to wait or preempt one of the processes is based on the following algorithm.
if T(Pr) < T(Ph) then
kill Pr
else wait Which one of the following is TRUE?
Answer: (A)
Deadlock-free: a process waits only when its timestamp is larger than the holder's: . The requester is always the younger one. So every wait edge goes from a larger timestamp to a smaller one. A cycle of waiting processes would need timestamps that keep getting smaller and then return to the start, which is impossible. So no deadlock.
Not starvation-free: when , the requesting process is killed, even though it is the older one. It restarts with the same timestamp. If a younger process holds the resource each time it asks, it is killed again. New processes keep getting larger timestamps, so they can keep holding the resource whenever this old process asks, and it may never complete.
Answer: (A)
Not starvation-free: when , the requesting process is killed, even though it is the older one. It restarts with the same timestamp. If a younger process holds the resource each time it asks, it is killed again. New processes keep getting larger timestamps, so they can keep holding the resource whenever this old process asks, and it may never complete.
Answer: (A)
The following are the starting and ending times of activities A,B,C,D,E,F,G and
H respectively in chronological order: . Here, denotes the starting time and
denotes the ending time of activity X. W need
to schedule the activities in a set of rooms available to us. An activity can be
scheduled in a room only if the room is reserved for the activity for its entire
duration. What is the minimum number of rooms required?
Answer: (B)
Two activities need different rooms if their times overlap. Draw a node for each activity, and join two nodes if the activities overlap. The minimum number of rooms is the chromatic number of this graph, and the graph is an interval graph, so it equals the largest number of activities running at the same time.
Just after the activities running are B, D, E and F, since none of them has ended yet. They overlap pairwise, so they form a clique of 4 nodes (b, d, e, f) and need 4 different rooms. At no other time are more than 3 activities running.
4 rooms are enough: Room 1 gets B, G. Room 2 gets A, D, H. Room 3 gets C, E. Room 4 gets F. In each room the activities do not overlap (for example comes before , and before ).
Answer: (B)
Just after the activities running are B, D, E and F, since none of them has ended yet. They overlap pairwise, so they form a clique of 4 nodes (b, d, e, f) and need 4 different rooms. At no other time are more than 3 activities running.
4 rooms are enough: Room 1 gets B, G. Room 2 gets A, D, H. Room 3 gets C, E. Room 4 gets F. In each room the activities do not overlap (for example comes before , and before ).
Answer: (B)
Which of the following is not a valid deadlock prevention scheme?
Answer: (C)
(A) Valid. A process holds nothing while it asks for a new resource. This breaks the hold and wait condition, though it can lead to starvation.
(B) Valid. Requests follow the numbering, so a cycle of waiting processes cannot form. This breaks the circular wait condition.
(C) NOT valid. This only says that a process makes no request after its first release. Before that point it can still hold some resources while it waits for others, so hold and wait still exists. It also gives no ordering of requests, so circular wait is possible. For example, holds and requests , while holds and requests . Neither has released anything yet, so the rule is not broken, and they are in deadlock. None of the four conditions is prevented.
(D) Valid. All required resources are given before the process starts, so it never waits while holding something. This breaks the hold and wait condition.
Answer: (C)
(B) Valid. Requests follow the numbering, so a cycle of waiting processes cannot form. This breaks the circular wait condition.
(C) NOT valid. This only says that a process makes no request after its first release. Before that point it can still hold some resources while it waits for others, so hold and wait still exists. It also gives no ordering of requests, so circular wait is possible. For example, holds and requests , while holds and requests . Neither has released anything yet, so the rule is not broken, and they are in deadlock. None of the four conditions is prevented.
(D) Valid. All required resources are given before the process starts, so it never waits while holding something. This breaks the hold and wait condition.
Answer: (C)
Keep practising