Question: There are 4 processes, executing concurrently. Process P0 is in an infinite loop, incrementing the value of the variable x ( x is initialized to

There are 4 processes, executing concurrently. Process P0 is in an infinite loop, incrementing the value of the variable x (x is initialized to 0). P0 is the only process that changes the value of x.

The rest of the processes Pi (1 <= i<=3) monitor the value of x. Whenever x reaches a value such that it is divisible by i, Pi prints the value of x. For example, P3 will print the sequence 3 6 9 12 .. as the value of xreaches 3, 6, 9, 12 and so on.

A] Write the code for all the 4 processes using semaphores. Note that P1 - P3 should be identical.

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 Databases Questions!