Machine-translated by Google. Questions are authored in English.
Top

Deadlocks Questions and Answers

Direction for [ Question No: 1 To 1 ] :

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.

1.

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.

AllocationMax
EFGEFG
P0101431
P1112214
P2103133
P3200541

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

Exam Year(s)

GATE CS - 2018,

Answer: A

The system is in a safe state.

Need = Max − Allocation gives P0 (3, 3, 0), P1 (1, 0, 2), P2 (0, 3, 0) and P3 (3, 4, 1), with (3, 3, 0) available. The banker's safety check finds an order in which every process can finish:

  1. P0 needs (3, 3, 0), which is available. It finishes and releases (1, 0, 1): available becomes (4, 3, 1).
  2. P2 needs (0, 3, 0). It finishes and releases (1, 0, 3): available becomes (5, 3, 4).
  3. P1 needs (1, 0, 2). It finishes and releases (1, 1, 2): available becomes (6, 4, 6).
  4. P3 needs (3, 4, 1). It finishes.

The safe sequence P0, P2, P1, P3 exists, so the state is safe and none of the options claiming it is unsafe can be right, whichever extra resource they add.

Please log in or register to report this question.

2.

Let m[0] ...... m[4] be mutexes (binary semaphores) and P[0] ........ P[4] be processes. Suppose each process P[i] executes the following :

wait (m[i]); wait (m[(i+1) mod 4]);
.......................
release (m[i]); release (m[(i+1) mod 4]);

This could be :

Exam Year(s)

MH SET - 2020, SET Exam - 2020,

Answer: B

This could lead to Deadlock.

Process P[i] locks m[i] and then m[(i+1) mod 4]. For P[0] to P[3] this gives a circular chain: P[0] holds m[0] and wants m[1], P[1] holds m[1] and wants m[2], P[2] holds m[2] and wants m[3], and P[3] holds m[3] and wants m[0]. If all four acquire their first mutex before any gets its second, each waits for the next forever: hold-and-wait with circular wait, a deadlock.

Thrashing is excessive paging and has nothing to do with mutexes, and since a deadlock is possible, 'starvation but not deadlock' and 'none of the above' are wrong.

Please log in or register to report this question.

3.

Consider a system with seven processes A through G and six resources R through W. Resource ownership is as follows :

Process A holds R and wants T
Process B holds nothing but wants T
Process C holds nothing but wants S
Process D holds U and wants S and T
Process E holds T and wants V
Process F holds W and wants S
Process G holds V and wants U

Are there any processes deadlocked ?

Exam Year(s)

MH SET - 2021, SET Exam - 2021,

Answer: C

Yes, D, E and G are deadlocked.

Follow who waits for whom. D holds U and wants T; T is held by E. E wants V, held by G. G wants U, held by D. This gives the cycle D, E, G, D, and since each resource has a single instance, the three are deadlocked.

A and B also want T, so they are blocked waiting for E, but they are not part of the cycle. C and F want S, which nobody holds, so they can proceed. So the processes involved in the deadlock are D, E and G, which rules out 'no process' and the sets containing A, B, C or F.

Please log in or register to report this question.

4.

An operating system contains 3 user processes each requiring 2 unit of resources 'R'. The minimum number of units of 'r' such that no deadlocks will ever arise is :

Exam Year(s)

MH SET - 2024, SET Exam - 2024,

Answer: C

The minimum is 4 units.

With n processes each needing at most k units, deadlock is impossible if there are at least \(n(k - 1) + 1\) units. In the worst case each process holds k - 1 units and waits for one more; one extra unit lets one process finish and release its resources.

\[ 3(2 - 1) + 1 = 4 \]

With 3 units, each process can hold one and wait forever for a second, which is a deadlock. Five or six units also avoid deadlock but are not the minimum.

Please log in or register to report this question.

5.

A computer system has 6 tape drives, with 'n' processes competing for them. Each process may need 3 drives. The maximum value of 'n' for which the system is guaranteed to be deadlock free is

Exam Year(s)

Tripura Public Service Commission - 2019,

Answer: B

The maximum value of n is 2.

Deadlock is possible only if every process can be holding some drives while waiting for more. In the worst case each process holds one fewer than it needs, 2 drives. The system is guaranteed deadlock-free if, even then, one drive is left to let some process finish:

\[ \begin{aligned} n(3 - 1) + 1 &\le 6 \\ 2n &\le 5,\ n \le 2 \end{aligned} \]

With 3 processes, each could hold 2 drives, using all 6, and all would wait for a third that never comes: a deadlock. With 1 process there is no competition, but 2 is the maximum that is still safe.

Please log in or register to report this question.

6.

Which of the following is NOT a necessary condition for deadlock ?

Exam Year(s)

Tripura Public Service Commission - 2026,

Answer: C

The item that is not a deadlock condition is preemption.

Coffman's four necessary conditions for deadlock are mutual exclusion, hold and wait, no preemption and circular wait. All four must hold at once. Allowing preemption, so that resources can be taken away from a process, breaks one of the conditions and is a way of preventing deadlock.

Mutual exclusion, hold and wait, and circular wait are all on the list, so each of them is a necessary condition.

Please log in or register to report this question.

7.

In the Banker's algorithm, what does the "safe state" represent ?

Exam Year(s)

Tripura Public Service Commission - 2026,

Answer: B

A safe state means the system can allocate resources to processes without deadlock.

In the Banker's algorithm a state is safe if there is at least one order (a safe sequence) in which every process can be given its remaining maximum need and run to completion, releasing its resources for the next. A request is granted only if the resulting state is still safe.

Being outside a critical section, having equal priorities, or having no page faults has nothing to do with the algorithm, which is about avoiding deadlock in resource allocation.

Please log in or register to report this question.

Answer: C

The scheme that is NOT a valid prevention scheme is Never request a resource after releasing any resource.

Deadlock prevention works by breaking one of its necessary conditions. Releasing all held resources before requesting a new one, or requesting everything before execution, breaks hold and wait. Numbering resources and requesting them only in increasing order breaks circular wait.

Forbidding requests after any release breaks none of the conditions: a process can still hold some resources while waiting for others, and a cycle of such waits can still form.

Please log in or register to report this question.

9.

A computer has six tape drives, with n processes competing for them. Each process may need two drives. What is the maximum value of n for the system to be deadlock free ?

Exam Year(s)

Tripura Public Service Commission - 2025, Tripura Public Service Commission - 2026,

Answer: B

The maximum value of n is 5.

Deadlock is possible only if every process holds one drive and waits for a second with none left. If n processes each hold one drive and at least one drive is still free, some process can finish and release its drives. So the system is deadlock-free when

\[ \begin{aligned} n(2 - 1) + 1 &\le 6 \\ n &\le 5 \end{aligned} \]

With 6 processes each could hold one drive and wait forever, so 6 is too many; 4 and 3 are safe but not the maximum.

Please log in or register to report this question.

Loading…
Tags: Deadlocks Questions and Answers || Deadlocks MCQ Questions and Answers || Deadlocks GK Questions and Answers || Deadlocks GK MCQ Questions || Deadlocks Multiple Choice Questions and Answers || Deadlocks GK || GK on Deadlocks || Operating Systems Questions and Answers || Operating Systems MCQ Questions and Answers || Operating Systems GK Questions and Answers || GK on Operating Systems