-1
$\begingroup$

In the code below, three processes are competing for six resources labeled A to F.How can I modify the get request in each procedure in this graph to avoid dead lock You cannot move requests across procedures, only change the order
inside each procedure.

GRAPH

$\endgroup$
  • 1
    $\begingroup$ You should edit your answer to show us what you think about this problem, and how you tried to resolve it. $\endgroup$ – user80502 Jun 3 '18 at 10:42
  • $\begingroup$ Take the proof of correctness as an exercise. $\endgroup$ – Sumeet Jun 6 '18 at 8:46
0
$\begingroup$

The main resources to be focused here are the common ones : $B$ , $C$ and $D$. To prevent deadlock from ever occurring you should focus on breaking $circular wait$, which is one of the 4 necessary conditions for deadlock.

For that lets make the common resources request as early as possible: Consider this:

$P_{o}()$ $\ $$\ $$\ $$\ $$\ $$\ $$\ $ $P_{1}()$ $\ $$\ $$\ $$\ $$\ $$\ $$\ $ $P_{2}()$

$get(B)$ $\ $$\ $$\ $$\ $ $get(B)$ $\ $$\ $$\ $$\ $ $get(C)$

$get(C)$ $\ $$\ $$\ $$\ $ $get(D)$ $\ $$\ $$\ $$\ $ $get(D)$

$get(A)$ $\ $$\ $$\ $$\ $ $get(E)$ $\ $$\ $$\ $$\ $ $get(F)$

The proof that the above sequence never leads to deadlock is easy and can be got by considering the different orders in which common resources are acquired.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.