• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

50 Operating System MCQs with Answers

Question 21

What is the minimum number of resources required to ensure that deadlock will never occur, if there are currently three processes P1, P2 and P3 running in a system whose maximum demand for the resources of same type are 3, 4, and 5 respectively.
  • 3
  • 7
  • 9
  • 10

Question 22

Consider a system having ‘m’ resources of the same type. The resources are shared by 3 processes A, B, C, which have peak time demands of 3, 4, 6 respectively. The minimum value of ‘m’ that ensures that deadlock will never occur is
  • 11
  • 12
  • 13
  • 14

Question 23

Which of the following is not true with respect to deadlock prevention and deadlock avoidance schemes ?
  • In deadlock prevention, the request for resources is always granted if resulting state is safe
  • In deadlock avoidance, the request for resources is always granted, if the resulting state is safe
  • Deadlock avoidance requires knowledge of resource requirements a priori
  • Deadlock prevention is more restrictive than deadlock avoidance

Question 24

Three concurrent processes X, Y, and Z execute three different code segments that access and update certain shared variables. Process X executes the P operation (i.e., wait) on semaphores a, b and c; process Y executes the P operation on semaphores b, c and d; process Z executes the P operation on semaphores c, d, and a before entering the respective code segments. After completing the execution of its code segment, each process invokes the V operation (i.e., signal) on its three semaphores. All semaphores are binary semaphores initialized to one. Which one of the following represents a deadlockfree order of invoking the P operations by the processes? (GATE CS 2013)

  • X: P(a)P(b)P(c) Y:P(b)P(c)P(d) Z:P(c)P(d)P(a)

  • X: P(b)P(a)P(c) Y:P(b)P(c)P(d) Z:P(a)P(c)P(d)

  • X: P(b)P(a)P(c) Y:P(c)P(b)P(d) Z:P(a)P(c)P(d)

  • X: P(a)P(b)P(c) Y:P(c)P(b)P(d) Z:P(c)P(d)P(a)

Question 25

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

  • In deadlock prevention, the request for resources is always granted if the resulting state is safe

  • In deadlock avoidance, the request for resources is always granted if the result state is safe

  • Deadlock avoidance is less restrictive than deadlock prevention

  • Deadlock avoidance requires knowledge of resource requirements a priori

Question 26

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? 
  • All processes will finish without any deadlock
  • Only P1 and P2 will be in deadlock.
  • Only P1 and P3 will be in a deadlock.
  • All three processes will be in deadlock

Question 27

A system has n resources R0,...,Rn-1,and k processes P0,....Pk-1.The implementation of the resource request 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?
  • n=40, k=26
  • n=21, k=12
  • n=20, k=10
  • n=41, k=19

Question 28

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. GATECS2014Q42 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?
  • Only REQ1 can be permitted.
  • Only REQ2 can be permitted.
  • Both REQ1 and REQ2 can be permitted.
  • Neither REQ1 nor REQ2 can be permitted

Question 29

Consider the following snapshot of a system running n processes. Process i is holding Xi instances of a resource R, 1 <= i <= n. currently, all instances of R are occupied. Further, for all i, process i has placed a request for an additional Yi instances while holding the Xi instances it already has. There are exactly two processes p and q such that Yp = Yq = 0. Which one of the following can serve as a necessary condition to guarantee that the system is not approaching a deadlock?
  • min (Xp, Xq) < max (Yk) where k != p and k != q
  • Xp + Xq >= min (Yk) where k != p and k != q
  • max (Xp, Xq) > 1
  • min (Xp, Xq) > 1

Question 30

Suppose n processes, P1, …. Pn share m identical resource units, which can be reserved and released one at a time. The maximum resource requirement of process Pi is Si, where Si > 0. Which one of the following is a sufficient condition for ensuring that deadlock does not occur?
  • A
  • B
  • C
  • D

There are 50 questions to complete.

Last Updated :
Take a part in the ongoing discussion