365 views
1 1 vote

A new OS uses a hybrid prevention scheme to manage a single non-preemptable resource. Each process $P_i$ has a Fixed Priority $\operatorname{Pri}\left(P_i\right)$ and a Unique Timestamp $T\left(P_i\right)$ (where a smaller value means the process is older).

When $P_r$ requests a resource held by $P_h$, the following rules are applied:

  1. If $\operatorname{Pri}\left(P_r\right)>\operatorname{Pri}\left(P_h\right), P_r$ is allowed to Wait.
     
  2. If $\operatorname{Pri}\left(P_r\right)<\operatorname{Pri}\left(P_h\right)$, the system checks timestamps:
     
    • If $T\left(P_r\right)<T\left(P_h\right), P_h$ is Killed (Preempted).
       
    • If $T\left(P_r\right)>T\left(P_h\right), P_r$ is Killed.
       
  3. Restarted processes keep their original timestamp but have their Priority incremented by $1$.
     

Which one of the following is TRUE regarding this scheme?

  1. THE SCHEME GUARANTEES DEADLOCK-FREE OPERATION BUT MAY LEAD TO STARVATION.
     
  2. THE SCHEME GUARANTEES STARVATION-FREE OPERATION BUT MAY LEAD TO DEADLOCK.
     
  3. THE SCHEME IS BOTH DEADLOCK-FREE AND STARVATION-FREE.
     
  4. THE SCHEME IS NEITHER DEADLOCK-FREE NOR STARVATION-FREE.

2 Answers

1 1 vote

1. Deadlock Analysis: Is it Deadlock-Free?

For a deadlock to occur, we must be able to form a Circular Wait. Let's test if a cycle can be created using Rule 1 (the only rule that allows a process to wait):

  • Rule 1 states: $P_r$ waits for $P_h$ only if $\operatorname{Pri}\left(P_r\right)>\operatorname{Pri}\left(P_h\right)$.
     
  • Suppose we have a chain: $P_1$ waits for $P_2, P_2$ waits for $P_3$, and $P_3$ waits for $P_1$.
     
  • According to the rule, this requires: $\operatorname{Pri}\left(P_1\right)>\operatorname{Pri}\left(P_2\right)>\operatorname{Pri}\left(P_3\right)>\operatorname{Pri}\left(P_1\right)$.
     
  • This is mathematically impossible $\left(\operatorname{Pri}\left(P_1\right)>\operatorname{Pri}\left(P_1\right)\right.$ is a contradiction).

Because the "Wait" condition is based on a strict ordering of priorities, a cycle can never form. If Rule 2 triggers, a process is killed, which breaks any potential hold-and-wait chain.
 

Result: The scheme is DEADLOCK-FREE.



2. Starvation Analysis: Is it Starvation-Free?

Starvation occurs if a process can be killed infinitely many times without ever completing. Let's look at the "Restart" mechanic:

  • When a process is killed, it keeps its original Timestamp and its Priority increases.
     
  • The Priority Boost: Since priority increases every time a process is killed, $\operatorname{Pri}\left(P_r\right)$ will eventually become higher than any other $\operatorname{Pri}\left(P_h\right)$ in the system. Once it is the highest priority, Rule 1 triggers, and it is allowed to Wait instead of being killed.
     
  • The Timestamp Protection: Even if it hasn't reached the highest priority yet, its original (old) timestamp helps it in Rule 2. As the oldest process ( $T\left(P_r\right)$ is smallest), it would kill $P_h$ rather than being killed itself.
     

Since every time a process "fails," it returns stronger (higher priority) or older relative to new processes, it is guaranteed to eventually acquire the resource.
 

Result: The scheme is STARVATION-FREE.

1 1 vote
The best way to solve these kind of questions is ask yourself four questions:

1. Is the requested process force the process already holding the current resource. (Deadlock Freedom)

Here we see in case 2 exactly that happening.

2. Is there any one way edge like here we have a dependency as Younger -> Older (Deadlock Freedom)

3. Is the aborted process priority or the checking condition may get increasing continuously without getting back to its original value.(Starvation Free) .Yes that's exactly happening in case 2.

4. Can a process repeatedly posponed (Stravation Hurts)

HENCE (C) is the answer
Answer:
Position:
Show:

Related questions

1 1 vote
1 1 answer
305
305 views
GO Classes asked Dec 29, 2025
305 views
A system manages resources that can be held in two modes: EXCLUSIVE (only one process) or SHARED (multiple processes, but they can only read, not write).When a process $P...
1 1 vote
2 2 answers
518
518 views
GO Classes asked Dec 29, 2025
518 views
A system uses a modified Counting Semaphore $S$ to manage access to a pool of 3 identical resources. The semaphore is initialized to $S=3$. The $\verb|Wait (S)|$ and $\ve...
3 3 votes
2 2 answers
429
429 views
GO Classes asked Dec 29, 2025
429 views
A system uses a Buddy System memory allocator to manage a $\mathbf{1 0 2 4}$ KB physical memory space. The system currently has three active processes allocated as follow...
2 2 votes
1 1 answer
280
280 views
GO Classes asked Dec 29, 2025
280 views
A storage server uses a Single-Level Indexed Allocation scheme. The disk parameters and file requirements are as follows:Disk Capacity $: \mathbf{128 ~ GB}$. Block Size $...