subject

We consider a 201-threaded process with multiple phases. Whenever a thread finishes a phase, it will call checkpoint(). If fewer than half of all the 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 checkpoint() 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); * Put any additional variables and/or their initial values below * /* It is called whenever a thread finishes a phase */ void checkpoint () {

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:30
The β€œrule of 72” is used to approximate the time required for prices to double due to inflation. if the inflation rate is r%, then the rule of 72 estimates that prices will double in 72/r years. for instance, at an inflation rate of 6%, prices double in about 72/6 or 12 years. write a program to test the accuracy of this rule. for each interest rate from 1% to 20%, the program should display the rounded value of 72/r and the actual number of years required for prices to double at an r% inflation rate. (assume prices increase at the end of each year.)
Answers: 1
question
Computers and Technology, 22.06.2019 22:50
Assume the existence of a bankaccount class. define a derived class, savingsaccount that contains two instance variables: the first a double, named interestrate, and the second an integer named interesttype. the value of the interesttype variable can be 1 for simple interest and 2 for compound interest. there is also a constructor that accepts two parameters: a double that is used to initialize the interestrate variable, and a string that you may assume will contain either "simple", or "compound", and which should be used to initialize the interesttype variable appropriately. there should also be a pair of functions getinterestrate and getinteresttype that return the values of the corresponding data members (as double and int respectively).
Answers: 2
question
Computers and Technology, 24.06.2019 00:00
For the following example of making a peanut butter and jelly sandwich, identify which are inputs, processes, or outputs: bread scooping and spreading peanut butter plate scooping and spreading jelly finished sandwich putting two pieces of covered bread together dirty plate crumbs
Answers: 2
question
Computers and Technology, 24.06.2019 21:00
How does a vaccine prevent sickness and individual?
Answers: 2
You know the right answer?
We consider a 201-threaded process with multiple phases. Whenever a thread finishes a phase, it will...
Questions
question
Computers and Technology, 05.11.2020 17:40
question
Social Studies, 05.11.2020 17:40
question
Mathematics, 05.11.2020 17:40
question
Mathematics, 05.11.2020 17:40
question
Mathematics, 05.11.2020 17:40
Questions on the website: 13722363