Question

In the code below, three processes are competing for six resources labeled A to F. a....

In the code below, three processes are competing for six resources labeled A to F.

a. Determine a sequence of requests and locks that results in a deadlock among the 3 processes. You could, for example, for each process list which resources it currently has locked (Allocated) and which resource it is requesting. Hint: it might be useful to draw a resource allocation graph to help you find a deadlock.

b. Modify the order of some of the get requests to prevent the possibility of any deadlock. You cannot move requests to another process, only change the order inside each one.

void P0()
{
while (true) {
get(A);
get(B);
get(C);
// critical region:
// use A, B, C
release(A);
release(B);
release(C);
}
}

void P1()
{
while (true) {
get(D);
get(E);
get(B);
// critical region:
// use D, E, B
release(D);
release(E);
release(B);
}
}

void P2()
{
while (true) {
get(C);
get(F);
get(D);
// critical region:
// use C, F, D
release(C);
release(F);
release(D);
}
}

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
In the code below, three processes are competing for six resources labeled A to F. a....
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