1,008 views
1 votes
1 votes

Ans is B) ...but after z...y should not printed since b would become 0 then....so II should not be a possible output...

Plz explain......

1 Answer

3 votes
3 votes
When b becomes 1, the while loop in P2 breaks. Now the next instruction is printf("y"). But before this instruction gets executed, the instructions
b=0;
printf("z");
CAN be executed by P1. (There is a possibility for that). So, B is the correct answer.

Related questions

0 votes
0 votes
1 answer
2
N3314nch41 asked Sep 10, 2023
360 views
How to approach synchronization (specifically semaphore) question, there size are really intimidating and i’m unable to decode the code written? What to do??