1 votes 1 votes Shared Boolean waitIn [2] = false; Shared int turn = 1; int myPid = 0; // For process 0. Set to 1 for process 1 int otherPid = 1 - myPid; wantIn [MyPid] = true; turn = OtherPid; while (wantIn [OtherPid] && turn == OtherPid); // Critical section wantIn [MyPid] = false; How to find the necessary condition for semaphore is satisfied? Soumyashree asked Nov 23, 2015 Soumyashree 550 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes it is the same implementation of peterson algorithm , just they have changed the turn = process , to turn = others process, the primary purpose of semaphore is to provide mutual exclusion which is definitely guaranteed. Tendua answered Nov 23, 2015 Tendua comment Share Follow See all 0 reply Please log in or register to add a comment.