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.

Loading…

Other Subjects

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