Questions & Answers of Deadlock

Weightage of Deadlock

Total 11 Questions have been asked from Deadlock topic of Operating System subject in previous GATE papers. Average marks 1.82.

Consider a system with 3 processes that share 4 instances of the same resource type. Each process can request a maximum of K instances. Resource instances can be requested and released only one at a time. The largest value of K that will always avoid deadlock is ____.

In a system, there are three types of resources: E, F and G. Four processes P0, P1, P2 and P3 execute concurrently. At the outset, the processes have declared their maximum resource requirements using a matrix named Max as given below. For example, Max[P2,F] is the maximum number of instances of F that P2 would require. The number of instances of the resources allocated to the various processes at any given state is given by a matrix named Allocation.
 
Consider a state of the system with the Allocation matrix as shown below, and in which 3 instances of E and 3 instances of F are the only resources available.

Allocation
  E F G
P0 1 0 1
P1 1 1 2
P2 1 0 3
P3 2 0 0
Max
  E F G
P0 4 3 1
P1 2 1 4
P2 1 3 3
P3 5 4 1

From the perspective of deadlock avoidance, which one of the following is true?

A system shares 9 tape drives. The current allocation and maximum requirment of tape drives for three processes are shown below:

Process  Current Allocation Maximum Requirment
P1 3 7
P2 1 6
P3 3 5

which of the following best describes current state of the system?

A system has 6 identical resources and N processes competing for them. Each process can request atmost 2 resources. Which one of the following values of N could lead to a deadlock?

Consider the following policies for preventing deadlock in a system with mutually exclusive resources.

  1. Processes should acquire all their resources at the beginning of execution. If any resource is not available, all resources acquired so far are released
  2. The resources are numbered uniquely, and processes are allowed to request for resources only in increasing resource numbers
  3. The resources are numbered uniquely, and processes are allowed to request for resources only in decreasing resource numbers
  4. The resources are numbered uniquely. A process is allowed to request only for a resource with resource number larger than its currently held resources

Which of the above policies can be used for preventing deadlock?

An operating system uses the Banker’s algorithm for deadlock avoidance when managing the allocation of three resource types X, Y, and Z to three processes P0, P1, and P2. The table given below presents the current system state. Here, the Allocation matrix shows the current number of resources of each type allocated to each process and the Max matrix shows the maximum number of resources of each type required by each process during its execution.

There are 3 units of type X, 2 units of type Y and 2 units of type Z still available. The system is currently in a safe state. Consider the following independent requests for additional resources in the current state:
REQ1: P0 requests 0 units of X, 0 units of Y and 2 units of Z
REQ2: P1 requests 2 units of X, 0 units of Y and 0 units of Z

Which one of the following is TRUE?

Consider the procedure below for the Producer-Consumer problem which uses semaphores:

semaphore n = 0;
semaphore s = 1;
   
void producer()
{
    while(true)
   {
     produce();
     semWait(s);
     addToBuffer();
     semSignal(s);
     semSignal(n);
   }
}
 

void consumer()
{
  while(true)
  {
    semWait(s);
    semWait(n);
    removeFromBuffer();
    semSignal(s);
    consume();
  }
}

Which one of the following is TRUE?

A system has n resources R0Rn-1, and k processes P0Pk-1. The implementation of the resourcerequest logic of each process Pi. is as follows:
if (i%2==0) {
    if (i<n) request Ri ;
    if (i+2 < n)request Ri+2 ;
}
else {
     if (i<n) request Rn-i ;
     if (i+2<n)request Rn-i-2 ;
}

In which one of the following situations is a deadlock possible?

Consider a system with 4 types of resources R1 (3 units), R2 (2 units), R3 (3 units), R4 (2 units). A non-preemptive resource allocation policy is used. At any given instance, a request is not entertained if it cannot be completely satisfied. Three processes P1, P2, P3 request the sources as follows if executed independently.

Process P1:
t=0: requests 2 units of R2
t=1: requests 1 unit of R3
t=3: requests 2 units of R1
t=5: releases 1 unit of R2
       and 1 unit of R1.
t=7: releases 1 unit of R3
t=8: requests 2 units of R4
t=10: Finishes

Process P2:
t=0: requests 2 units of R3
t=2: requests 1 unit of R4
t=4: requests 1 unit of R1
t=6: releases 1 unit of R3
t=8: Finishes

Process P3:
t=0: requests 1 unit of R4
t=2: requests 2 units of R1
t=5: releases 2 units of R1
t=7: requests 1 unit of R2
t=8: requests 1 unit of R3
t=9: Finishes

Which one of the following statements is TRUE if all three processes run concurrently starting at time t=0?

Which of the following is NOT true of deadlock prevention and deadlock avoidance schemes?

A single processor system has three resource types X, Y and Z, which are shared by three processes. There are 5 units of each resource type. Consider the following scenario, where the column alloc denotes the number of units of each resource type allocated to each process, and the column request denotes the number of units of each resource type requested by a process in order to complete execution. Which of these processes will finish LAST?

  alloc request
  X Y Z X Y Z
P0 1 2 1 1 0 3
P1 2 0 1 0 1 2
P2 2 2 1 1 2 0