Question: Assume the two processes Batman and Superman are running concurrently. Both processes share two semaphore variables Sem1 and Sem2, which are initialized to 1.

Assume the two processes Batman and Superman are running concurrently. Both processes share two semaphore

Assume the two processes Batman and Superman are running concurrently. Both processes share two semaphore variables Sem1 and Sem2, which are initialized to 1. They share an integer variable integer1 that is initialized to 0. void Batman() { do { sleep(Sem1); sleep(Sem2); integerl++; void Superman() { do { sleep(Sem2); sleep(Sem1); integerl --; wakeUp(Sem1); wakeUp(Sem2); } while (1); wakeUp(Sem1); wakeUp(Sem2); } while (1); } Discuss what will happen if both processes run concurrently?

Step by Step Solution

3.39 Rating (158 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

If both processes run concurrently the outcome is unpredictable This is because the two processes ca... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!