edited by
29,247 views
149 votes
149 votes

A system has $n$ resources $R_0, \dots,R_{n-1}$, and $k$ processes $P_0, \dots, P_{k-1}$. The implementation of the resource request logic of each process $P_i$ is as follows:

$\text{if} (i\%2==0) \{$
$\quad\text{if} (i<n) \text{ request } R_i;$
$\quad\text{if} (i+2 < n) \text{ request } R_{i+2}; \}$
$\text{else} \{$
$\quad\text{if} (i<n) \text{ request } R_{n-i};$
$\quad\text{if} (i+2 <n) \text{ request } R_{n-i-2}; \}$

In which of the following situations is a deadlock possible?

  1. $n=40,\: k=26$
  2. $n=21,\:k=12$
  3. $n=20,\:k=10$
  4. $n=41,\:k=19$
edited by

6 Answers

1 votes
1 votes

(k-3) processes will take 2 resources and other 3 processes will take 1 resource each.

Total n resources. Deadlock will arise when : (((k-3) * 2) + (3*1)) = n

If k=12, n will be 21.

 

Answer:

Related questions

61 votes
61 votes
6 answers
1
go_editor asked Sep 30, 2014
26,223 views
The following program consists of $3$ concurrent processes and $3$ binary semaphores. The semaphores are initialized as $S0=1, S1=0$ and $S2=0.$$$\begin{array}{|l|l|}\hli...
23 votes
23 votes
2 answers
2
41 votes
41 votes
2 answers
4