The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+6 votes
582 views
  1. A system of four concurrent processes, $P, Q, R$ and $S$, use shared resources $A, B$ and $C$. The sequences in which processes, $P, Q, R$ and $S$ request and release resources are as follows:

$$\begin{array}{ll} 
\text{ Process  P: } &  \text{1.}& \text{ P requests A } &&  \\  
\text{  } &  \text{2.}& \text{ P requests B } && \\ 
 \text{ } &  \text{3.}& \text{ P releases A } &&\\
\text{} &  \text{4.}& \text{ P releases B } && \\
\text{ Process  Q: } &  \text{1.}& \text{ Q requests C } &&  \\  
\text{  } &  \text{2.}& \text{ Q requests A } && \\ 
\text{ } &  \text{3.}& \text{ Q releases C } &&\\
\text{} &  \text{4.}& \text{ P releases  A } &&\\
\text{ Process  R: } &  \text{1.}& \text{ R requests B } \\
 \text{  } &  \text{2.}& \text{ R requests C } \\
\text{ } &  \text{3.}& \text{ R releases B } &&\\
\text{} &  \text{4.}& \text{ R releases C } &&\\
\text{ Process  S: } &  \text{1.}& \text{ S requests A } &&  \\  
\text{  } &  \text{2.}& \text{ S requests C } && \\ 
\text{ } &  \text{3.}& \text{ S releases A } &&\\
\text{} &  \text{4.}& \text{ S releases C } &&  \end{array}$$

If a resource is free, it is granted to a requesting process immediately. There is no preemption of granted resources. A resource is taken back from a process only when the process explicitly releases it.

Can the system of four processes get into a deadlock? If yes, give a sequence (ordering) of operations (for requesting and releasing resources) of these processes which leads to a deadlock.

  1. Will the processes always get into a deadlock? If your answer is no, give a sequence of these operations which leads to completion of all processes.
  2. What strategies can be used to prevent deadlocks in a system of concurrent processes using shared resources if preemption of granted resources is not allowed?
asked in Operating System by Boss (29.5k points)
edited by | 582 views

4 Answers

+3 votes

Can the system of four processes get into a deadlock? If yes, give a sequence (ordering) of operations (for requesting and releasing resources) of these processes which leads to a deadlock.

Answer: YES...Process $Q\to R(C)$, Process $S\to R(A)$, Process $Q \to R(A)$ Process $S \to R(C)$ Process $P\to R(A)$, Process $R\to R(B)$ Process $R \to R(C)$

Will the processes always get into a deadlock? If your answer is no, give a sequence of these operations which leads to completion of all processes.

Answer: NO, PQRS

answered by Loyal (7.1k points)
edited by
0

@rishu_darkshadow Ans: NO....!!! PQRS - all are concurrent process so sequence is not possible 

0
@arjun sir

please give the answer of this question 2nd part
0
Here what is meaning of  explicitly  release?
0
Explicit release in the sense, the process should release the resource by itself, for this purpose they used 'P releases B' convention, telling that the process P is releasing resource B.
+2 votes

i) Assuming only one instance of a resource is available,

Process P: Hold A, request B

Process Q: Hold C, request A

Process R: Hold B, request C

Process S: Request A, request C

In this instance, Process P,Q,R and S are waiting for the release of resources among each other and none of them can proceed. This is deadlock.

ii) Any sequential ordering will be free from deadlock. An instance(concurrent) can be:

Process P Process Q Process R Process S
request A      
request B      
  request C    
release A      
  request A    
  release C    
release B      
    request B  
    request C  
  release A    
      request A
    release B  
    release C  
      request C

All the requests of all processes are satisfied and leads to completion of all processes.

iii) To prevent deadlock:

  • Resources can be shared (violating mutual exclusion)
  • Not allowing processes to hold a resource and request for another( violating hold and wait)
  • Break circular wait by allocating resources in some order
  • Banker's algorithm(safe state)- to avoid deadlock
answered by Boss (11k points)
0
Do we need Bankers algorithm for single instance resources?
+3
No Sir, we can use resource-allocation graph.(for single instances of resource RAG can be easily converted to wait-for graph and if cycle exists in wait-for graph then deadlock exists)
+3
Yes because bankers algorithm is more expensive.
+1 vote
Can the system of four processes get into a deadlock? If yes, give a sequence (ordering) of operations (for requesting and releasing resources) of these processes which leads to a deadlock.

Ans: Yes . The system may leads to dead lock. Considering the sequence like

  Process Q: R(c)  , Process S:R(A) ,Process Q : R(A) Process S :R(c) Process P: R(A) ,Process R: R(B) got it. , Process R : R(C) all of them in dead lock because none of them request not will fullfil.

(ii) Will the processes always get into a deadlock? If your answer is no, give a sequence of these operations which leads to completion of all processes.

Ans: The processs Q and S will always be in dead lock because they request resource in reverse order of each other..

(iii) What strategies can be used to prevent deadlocks in a system of concurrent processes using shared resources if preemption of granted resources is not allowed?

Ans: For this we need to change order of request of any Q or S process.
answered by Active (2.3k points)
+1 vote

processes, P,Q,R,S, and resources A,B,C

let process request resource :  P() and Process release resource : V()

P Q R S
P1(A) P2(C) P3(B) P4(A)
P1(B) P2(A) P3(C) P4(C)
V1(A) V2(C) V3(B) V4(A)
V1(B) V2(A) V3(C) V4(C)

Can the system of four processes get into a deadlock ?

   Yes : P1(A) -> P2(C) -> P3(B) -> P4(A) busy wait -> P1(B) busy wait -> P2(A)  busy wait-> P3(C) busy wait

Will the processes always get into a deadlock ? 

   No  : any sequential execution of processes not going to Deadlock. Ex- PQRS.

strategies can be used to prevent deadlocks in a system :

     1. there are 4 processes and each process is requesting to resources so we can allow maximum to processes at a  time                     until any process releases there resource.\

 

suggest some more strategies to prevent deadlocks in a system.

answered by Active (3.4k 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
49,814 questions
54,518 answers
188,351 comments
75,294 users