Question: Part B [ 1 2 marks ] : Sometimes it is necessary to synchronize two or more processes in a group so that every process

Part B [12 marks]: Sometimes it is necessary to synchronize two or more processes in a group so that every process must finish its first phase of computation before any other process is allowed to start its second phase. This is called barrier synchronization; For example, for two processes Pl and P 2, we can write:
Semaphores: sl =0, s2=0;
In this question, you are required to synchronize five processes P1, P2, P3, P4, and P5. The new rules are: 1) Process P1 must finish both phase I and phase II before any of the other processes can access any of their phases, 2) Process P5 must finish phase I next, followed by process P2, which must finish Phase I before both P3 and P4 can start their phase I's,3) all phase I's must finish before any phase II starts, and 4) all phase II's must proceed in the order "3254"(that is P3 must finish Phase II before P2, and P2 must finish Phase II before P5, and finally P5 must finish Phase II before P4). You are allowed to use any number of semaphores; however, semaphores cannot be initialized with negative values. Initializing or setting any semaphore to a negative value will result in a total discard of the solution. Fill in the missing synchronization code below:
Part B [ 1 2 marks ] : Sometimes it is necessary

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!