Friday, 15 March 2013

semaphore p3 blocked forever? -


I have the following code, and I want to know whether the printf prints: < Br> I did this, but I'm not sure about your answer.

variable: d = 0, A = 1, B = 1, C = 0

  p1 p2 p3 while (1) {while (1) {while (1) {p (a); P (B); P (A); P (B); P (c); P (c); D = 2 * D; D = d + 1; Printf ("% d \ n", d); V (C) V (C); V (A); V (b);   

My attempt was:

C = 0, P3 process of initiating process

  P1a = 0, B = 0 and D = 0 and C = 1 P2 block because A = 0 and B = 0, P3   

this second P ( C) . A = 0, B = 0, C = 0 is a dead end, and printf does not print anything. Is it true?

You are right - deadlock - nothing printed.

Deadlock: P3 is waiting on other P (C). Either P1 or P2 have repetitioned their first, second - zero running P1 and P2 are waiting on both P (A) values ​​of D depends on the race between P1 and P2 - Which was previously registered to walk.

No comments:

Post a Comment