GATE / CS ARCHIVE

SIMILAR QUESTIONS / OPERATING SYSTEMS

Prove timestamp ordered wound wait liveness

3 questions solved the same way, newest first. Back to Operating Systems

How these are solved

Analyze the same older-requester-wounds-younger-holder rule: remaining wait edges follow strict timestamp order, excluding cycles; retained restart timestamps and eventual completion underpin starvation freedom.

2 marks · MCQ
Report issue

Deadlocks

Question 42, GATE 2017: Transactions receive unique Lamport timestamps. T1 holds resource R; T2 requests a conflicting lock. If TS(T2)<TS(T1), kill T1; otherwise T2 waits. Killed transactions restart with the same timestamp; any transaction not killed eventually terminates. A both deadlock-free and starvation-free; B deadlock-free only; C starvation-free only; D neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

1. Smaller timestamps denote older transactions. An older requester wounds a younger holder; a younger requester waits rather than aborting the older holder. This is wound-wait.

2. Every actual waiting edge points from a younger transaction to an older one, so timestamps strictly decrease along waits. A directed cycle would require returning to the original timestamp after strict decreases, impossible. Hence no deadlock.

3. A restarted transaction keeps its old timestamp, so it does not repeatedly become youngest. With the stated eventual-termination assumption and finitely many older predecessors, those predecessors finish and it ultimately becomes able to proceed. This is the intended starvation-free guarantee, A.

Original paper, page 19 · Answer key

3 marks · Descriptive
Report issue

Deadlock freedom of wound-wait

Deadlocks

Question 75(a), GATE 1997: Each process receives a unique timestamp when it starts, increasing with time; smaller means older. On requesting a resource: if it is free, the OS grants it; if holder Q is older than requester P (TS(Q)<TS(P)), P waits; if Q is younger (TS(Q)>TS(P)), the OS restarts Q and grants the resource to P. Restarting takes back all Q's resources, kills Q, and starts it again with the same timestamp. When a resource is released, the waiting process with smallest timestamp receives it. A process asks for resources, uses them for some time, then exits. Can deadlock ever arise? Prove your answer.
Question 75(a), GATE 1997: Each process receives a unique timestamp when it starts, increasing with time; smaller means older. On requesting a resource: if it is free, the OS grants it; if holder Q is older than requester P (TS(Q)<TS(P)), P waits; if Q is younger (TS(Q)>TS(P)), the OS restarts Q and grants the resource to P. Restarting takes back all Q's resources, kills Q, and starts it again with the same timestamp. When a resource is released, the waiting process with smallest timestamp receives it. A process asks for resources, uses them for some time, then exits. Can deadlock ever arise? Prove your answer.
Tap to enlarge
Answer & solution

Answer: No resource deadlock: every wait-for edge points from a younger process to an older process, so a cycle is impossible. (no official key was published)

Form a wait-for graph whose vertices are active processes. Add an edge P→Q when P is blocked waiting for a resource currently held by Q. The rules allow that wait only when TS(Q)<TS(P). If the holder is younger, the requester does not wait; it wounds the holder, whose resources are released on restart. Therefore timestamps strictly decrease along every wait-for edge.

Suppose a resource deadlock existed. For ordinary exclusive resources, a finite set of processes each blocked on resources held within the set contains a directed cycle P1→P2→…→Pk→P1. The edge rule would imply
TS(P1)>TS(P2)>…>TS(Pk)>TS(P1),
which is impossible for distinct ordered timestamps. Thus the wait-for graph is acyclic and the stated resource protocol cannot create deadlock.

For intuition, an older process can force a younger holder to release its resources rather than becoming dependent on it. A younger process may depend on an older one, but dependencies can never turn back toward a younger timestamp to close a cycle. This is the wound-wait scheme, not wait-die: the older requester survives and restarts the younger holder.

The restart must release all resources of the victim, as the source explicitly states; retaining them while the victim cannot proceed would not implement this proof's protocol. Resource grants, victim removal and wait-queue updates are assumed to be performed consistently by the OS. The argument rules out resource deadlock, not every possible lack of progress. An unfair CPU scheduler or a process that never finishes could still delay other processes indefinitely; those are separate starvation/liveness issues addressed under additional assumptions in the next part.

Original paper, page 12

2 marks · Descriptive
Report issue

Starvation analysis with retained timestamps

Deadlocks

Question 75(b), GATE 1997: Each process receives a unique timestamp when it starts, increasing with time; smaller means older. On requesting a resource: if it is free, the OS grants it; if holder Q is older than requester P (TS(Q)<TS(P)), P waits; if Q is younger (TS(Q)>TS(P)), the OS restarts Q and grants the resource to P. Restarting takes back all Q's resources, kills Q, and starts it again with the same timestamp. When a resource is released, the waiting process with smallest timestamp receives it. A process asks for resources, uses them for some time, then exits. Can a process be starved? Prove or qualify your answer.
Question 75(b), GATE 1997: Each process receives a unique timestamp when it starts, increasing with time; smaller means older. On requesting a resource: if it is free, the OS grants it; if holder Q is older than requester P (TS(Q)<TS(P)), P waits; if Q is younger (TS(Q)>TS(P)), the OS restarts Q and grants the resource to P. Restarting takes back all Q's resources, kills Q, and starts it again with the same timestamp. When a resource is released, the waiting process with smallest timestamp receives it. A process asks for resources, uses them for some time, then exits. Can a process be starved? Prove or qualify your answer.
Tap to enlarge
Answer & solution

Answer: No protocol-induced starvation under finite older predecessors, finite terminating work, and fair execution; an unconditional guarantee without these progress assumptions is not justified. (no official key was published)

Fix a process P. When it begins there are only finitely many older processes in the usual finite-system model, and every later arrival has a larger timestamp. Because a restarted process keeps its original timestamp, repeated restarts do not move P behind newcomers. Only processes older than P can wound it or outrank it on a waiting queue.

First consider the oldest active process. It cannot be wounded, and it cannot be forced to wait for a younger holder: it wounds that holder and obtains the resource. Under fair CPU execution and the stated assumption that a process does finite work and exits, this oldest process eventually completes and releases its resources. Apply the same argument successively to the remaining older processes. Since P has finitely many older predecessors, eventually they have all completed.

P is then the oldest remaining process. New arrivals remain younger and cannot wound P. A resource held by a younger process is obtained by wounding that holder; if P is already waiting when a resource is released, smallest-timestamp selection gives it precedence over younger waiters. With finite resource requests/work and fair execution, P therefore finishes. This proves absence of starvation caused by the allocation protocol under the usual progress assumptions.

Retaining timestamps is crucial. Assigning a fresh, ever-larger timestamp after every restart would destroy the fixed finite-predecessor argument. Conversely, deadlock freedom by itself would not prove starvation freedom: an acyclic system could still repeatedly favor newcomers under a different queue rule.

The question's finite-use-and-exit wording motivates the normal no-starvation answer, but scheduler fairness is not explicitly specified. If the CPU never schedules P, or an older process never finishes, P may wait indefinitely despite the timestamp rules. Those countermodels violate the progress assumptions used in the proof; they do not exhibit a starvation defect in wound-wait itself. State the assumptions rather than claiming unconditional termination from timestamp ordering alone.

Original paper, page 12