# Starvation is possible or not?

let S and Q to be initialized to 1

process p0:          process p1:

wait(S);             wait(Q);
wait(Q);             wait(S);

..                    ..
..                    ..
Signal(S);           Signal(Q);
Signal(Q);           Signal(S);


I know there is a deadlock , where both the process will be going into the sleep , so what about starvation and bounded waiting?

My approach:

as only p0 can be executed any number of times i think there will be starvation and no bounded waiting.But answer is given that there is No Starvation.

• I don't understand why "the answer" is "no starvation". Note that starvation freedom implies deadlock freedom. Since it suffers from deadlocks, it must also suffer from starvations. Dec 15 '16 at 7:16
• @hengxin you meant to say that if there is deadlock then that implies starvation? Dec 15 '16 at 7:27
• No starvation $\implies$ No deadlock. So deadlock $\implies$ starvation. Dec 15 '16 at 7:31
• i was thinking this way cs.stackexchange.com/questions/67406/… Dec 15 '16 at 7:34

Say p0 executes wait(S); and then p1 executes wait(Q);. Now both the semaphores S and Q have value = 0.Now p0 will keep on waiting due to statement wait(Q); and p1 will keep on waiting due to statement wait(S);.