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, 04.07.2019 18:10
Slip occurs via two partial dislocations because of (a) the shorter path of the partial dislocation lines; (b) the lower energy state through partial dislocations; (c) the charge balance.
Answers: 1
question
Engineering, 04.07.2019 18:20
Have a greater impact on maintenance productivity than any other support group. (clo5) a)-the top management b)-inventory and purchasing c)-sub-contracting d)-cmms
Answers: 2
question
Engineering, 04.07.2019 18:20
Athin walled concentric tube exchanger is used to cool engine oil from 160°c to 60°c with water that is available at 25°c acting as a coolant. the oil and water flow rates are each at 2 kg/s, and the diameter of the inner tube is 0.5 m and the corresponding value of the overall heat transfer coefficient is 250 w/m2. oc. how long must the heat exchanger be to accomplish the desired cooling? cpwater=4.187 kj/kg-candcpengine el=2.035 kj/kg·°c, oil . 120]
Answers: 1
question
Engineering, 04.07.2019 18:20
Along 8-cm diameter steam pipe whose external surface temperature is 900c connects two buildings. the pipe is exposed to ambient air at 70c with a wind speed of 50 km/hr blowing across the pipe. determine the heat loss from the pipe per unit length. (b) air at 500c enters a section of a rectangular duct (15 cm x 20 cm) at an average velocity of 7 m/s. if the walls of the duct are maintained at 100c. a) the length of the tube for an exit temperature of the air to be 40 0c. b)the rate of heat transfer from the air. c) the fan power needed to overcome the pressure drop in this section of the duct.
Answers: 1
You know the right answer?
The decrease_count() function in the previous exercise currently returns 0 if sufficient resources a...
Questions
Questions on the website: 13722363