subject
Engineering, 10.04.2020 21:12 Osmin

The decrease_count() function in the previous exercise currently returns 0 if sufficient resources are available and −1 otherwise. This leads to awkward programming for a process that wishes to obtain a number of resources: while (decrease_count(count) == -1) ; Rewrite the resource-manager code segment using a monitor and condition variables so that the decrease_count() function suspends the process until sufficient resources are available. This will allow a process to invoke decrease_count() by simply calling:

decrease_count(count);

The process will return from this function call only when sufficient resources are available.

Previous Code:

#define MAX_RESOURCES 5

int available_resources = MAX_RESOURCES;

When a process wishes to obtain a number of resources, it invokes the decrease_count() function:

/* decrease available_resources by count resources */

/* return 0 if sufficient resources available, */

/* otherwise return -1 */

int decrease_count(int count)

{ if (available_resources < count)

return -1;

else {

available_resources -= count;

return 0;

} }

ansver
Answers: 1

Another question on Engineering

question
Engineering, 03.07.2019 15:10
Two flowing streams of argon gas are adiabatically mixed to form a single flow/stream. one stream is 1.5 kg/s at 400 kpa and 200 c while the second stream is 2kg/s at 500 kpa and 100 ? . it is stated that the exit state of the mixed single flow of argon gas is 150 c and 300 kpa. assuming there is no work output or input during the mixing process, does this process violate either the first or the second law or both? explain and state all your assumptions.
Answers: 1
question
Engineering, 04.07.2019 18:10
If a particle moves along a path such that r : (3 sin t) m and ? : 2t rad, where t is in seconds. what is the particle's acceleration in m/s in 4 seconds? a)- 16.43 b)- 16.29 c)- 15.21 d)- 13.79
Answers: 1
question
Engineering, 04.07.2019 18:10
Ifa component is made of two or more materials with different modulus of elasticity (e), it is called a composite member and we calculate the factor·n". mention the formula for calculating n". also, ifn> 1, explain what will happen to the 1. transformed.gi) ifn 1, what will happen to the material when transformed material when
Answers: 1
question
Engineering, 04.07.2019 18:10
Aturning operation is performed with following conditions: rake angle of 12°, a feed of 0.35 mm/rev, and a depth of cut of 1.1 mm. the work piece is aluminum alloy 6061 with t6 heat treatment (a16061-t6). the resultant chip thickness was measured to be 1.0 mm. estimate the cutting force, fc. use shear stress of 207 mpa and coefficient of friction on the tool face of 0.6.
Answers: 1
You know the right answer?
The decrease_count() function in the previous exercise currently returns 0 if sufficient resources a...
Questions
question
Mathematics, 25.04.2020 02:07
question
Mathematics, 25.04.2020 02:08
question
Biology, 25.04.2020 02:08
question
Mathematics, 25.04.2020 02:08
Questions on the website: 13722363