Suppose we have 3 processes running at the same time as shown in the following table. Each resource only has one instance.
Show a possible scenario of resource allocation that results in deadlock. Using a resource allocation graph to show the scenario.
To prevent the possibility of any deadlock, you may modify the order of getting resource requests of some process. Explain how and why. You can also use a resource allocation graph to justify your answer.
P1
|
P2
|
P3
|
while (1) {
get(A);
get(B);
get(C);
// critical region
// use A, B, C
release(A);
release(B);
release(C);
}
|
while (1) {
get(D);
get(E);
get(B);
// critical region
// use D, E, B
release(D);
release(E);
release(B);
}
|
While (1) {
get(C);
get(F);
get(D);
// critical region
// use C, F, D
release(C);
release(F);
release(D);
}
|