The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+16 votes

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?

  1. $6$
  2. $5$
  3. $4$
  4. $3$
asked in Operating System by Veteran (59.6k points)
edited by | 3.2k views

3 Answers

+22 votes
Best answer

Each process needs $2$ drives

Consider this scenario

$\mathbf{P1 \  \ P2 \  \ P3 \ \ P4 \ \ P5 \  \ P6}$

$1$      $1$       $1$      $1$      $1$      $1$             

This is scenario when a deadlock would happen, as each of the process is waiting for $1$ more process to run to completion. And there are no more Resources available as max $6$ reached. If we could have provided one more $R$ to any of the process, any of the process could have executed to completion, then released its resources, which further when assigned to other and then other would have broken the deadlock situation.

In case of processes, if there are less than $6$ processes, then no deadlock occurs.

Consider the maximum case of $5$ processes.

$P1$ $P2$  $P3$ $P4$ $P5$

$1$   $1$    $1$    $1$   $1$

In this case system has $6$ resources max,and hence we still have $1$ more $R$ left which can be given to any of the processes, which in turn runs to completion, releases its resources and in turn others can run to completion too.

Answer (B) $5$

answered by Active (3.5k points)
edited by
Here, they are asking max value of N to be deadlock free. from the options it can be 6 right?

Minimum no of n to be deadlock free is 5..
+13 votes
For a system to be deadlock free, Sum of max need of processes < No. of processes + No. of resources

2n < n+6

Max value of n = 5.
answered by Loyal (6.2k points)
edited by
Nice ans
May I know from where you got this equation ?
+4 votes

6 resources, n processes and maximum demand for each process is 2.

For getting maximum value of n,

Consider an extreme case of deadlock wherein a chain of n processes, each process just only needs 1 more resource to start execution. Means each process has been allocated resources equal to 1 less than its actual demand.

Now, if we have 1 more resource, in our system, then this chain of deadlock can be broken and then the deadlock will never occur.

N*(2-1) (Give all n processes 1 less resource than max demand) +1 (This extra resource will break deadlock ) = 6



Cross Check

P1 P2 P3 P4 P5
1 1 1 1 1

Now, only 1 resource remaining and this will break above chain of deadlocked processes.

Hence, answer-5

answered by Boss (16.1k points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

42,613 questions
48,609 answers
63,796 users