Question

How do you use the Banker’s Algorithm to detect deadlock? How do you use the Banker’s...

How do you use the Banker’s Algorithm to detect deadlock? How do you use the Banker’s Algorithm to detect an unsafe state?

0 0
Add a comment Improve this question Transcribed image text
Answer #1


these data structures used in algorithm to detect deadlock:  
Available- A vector of length m indicates the number of available resources of each type.
Allocation- An n*m matrix defines the number of resources of each type currently allocated to a process. Column represents resource and resource represent process.
Request- An n*m matrix indicates the current request of each process. If request[i][j] equals k then process Pi is requesting k more instances of resource type Rj.
We treat rows in the matrices Allocation and Request as vectors, we refer them as Allocationi and Requesti.

Steps to detect deadlock:

Let Work and Finish be vectors of length m and n respectively. Initialize Work= Available. For i=0, 1, …., n-1, if Requesti = 0, then Finish[i] = true; otherwise, Finish[i]= false.
Find an index i such that both
a) Finish[i] == false
b) Requesti <= Work
If no such i exists go to step 4.
Work= Work+ Allocationi
Finish[i]= true
Go to Step 2.
If Finish[i]== false for some i, 0<=i<n, then the system is in a deadlocked state.
Moreover, if Finish[i]==false the process Pi is deadlocked.
now, if a system is deadlocked then it is in unsafe state

Add a comment
Know the answer?
Add Answer to:
How do you use the Banker’s Algorithm to detect deadlock? How do you use the Banker’s...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT