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 multithreaded process with threads with multiple phases. Whenever a thread finishes a phase, it will call check: If fewer than 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;
mutexinitm NULL; condinitc NULL;
mutexlockm; mutexunlockm; condwaitcm; condsignalc; condbroadcastc;
Use the following code framework.
mutex m;
cond c;
mutexinitm NULL;
condinitc NULL;
Pt any additional variables andor their initial values below
It is called whenever a thread finishes a phase
void check
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
