Question: We consider a multi - threaded process ( with 8 0 threads ) with multiple phases. Whenever a thread finishes a phase, it will call

We consider a multi-threaded process (with 80 threads) with multiple phases. Whenever a thread finishes a phase, it will call check(): If fewer than \(3/4\) of all threads are in sleep it will be put into sleep as well, otherwise it will wake up all of the sleeping thread and they will together proceed to the next phase. Implement check() with help of mutex and condition variable, the pseudo syntax of which is defined here:
```
mutex m; cond c;
mutex_init(m, NULL); cond_init(c, NULL);
mutex_lock(m); mutex_unlock(m); cond_wait(c,m); cond_signal(c); cond_broadcast(c);
```
Use the following code framework.
```
mutex m;
cond c;
mutex_init(m, NULL);
cond_init(c, NULL);
/* Pt any additional variables and/or their initial values below */
```
/* It is called whenever a thread finishes a phase */
void check()\{
We consider a multi - threaded process ( with 8 0

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!