Sunday, January 1, 2012

Semaphore and Deadlock

How semaphore can lead to a deadlocked situation.Explain with example

1 comment:

  1. Two processes accessing two semaphores:---

    P0 P1
    wait(S); wait(Q);
    Wait(Q); wait(S);


    ................................

    signal(S); Signal(Q);
    signal(Q); Signal(S);

    P0 executes wait(S)
    |
    P1 executes wait(Q)
    |
    P0 executes wait(Q)

    P0 has to wait until P1 executes signal(Q)

    Similarly
    when P1 executes wait(S) it must wait until P0 executes signal(S)

    Since these signal operations cant be executed so DEADLOCK

    ReplyDelete