Engineering
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;

} }

answer
Answers: 1

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:10, koolgurl2003
Apump is used to circulate hot water in a home heating system. water enters the well-insulated pump operating at steady state at a rate of 0.42 gal/min. the inlet pressure and temperature are 14.7 lbf/in.2, and 180°f, respectively; at the exit the pressure is 60 lbf/in.2 the pump requires 1/15 hp of power input. water can be modeled as an incompressible substance with constant density of 60.58 lb/ft3 and constant specific heat of 1 btu/lb or. neglecting kinetic and potential energy effects, determine the temperature change, in °r, as the water flows through the pump.
Answers: 1
image
Engineering, 04.07.2019 18:10, wirchakethan23
Hydraulic fluid with a sg. of 0.78 is flowing through a 1.5 in. i. d. pipe at 58 gal/min. the fluid has an absolute viscosity of 11.8 x 105 lbf-sec/ft2. is the flow laminar, turbulent or within the critical range? give both a numerical reynolds number and a term answer.
Answers: 3
image
Engineering, 04.07.2019 18:10, samanthabutryn
Which one from below is not one of the reasons of planning failures? (clo3) a)-planner is careless. b-planner spend less time in the field but more time on the desk c)-planner is not qualified d)-planner does not have sufficient time to properly plan
Answers: 3
image
Engineering, 04.07.2019 18:20, luisgonz5050
Find the kinematic pressure of 160kpa. for air, r-287 j/ kg k. and hair al viscosity of air at a temperature of 50°c and an absolute (10 points) (b) find the dynamic viscosity of air at 110 °c. sutherland constant for air is 111k
Answers: 3
Do you know the correct answer?
The decrease_count() function in the previous exercise currently returns 0 if sufficient resources a...

Questions in other subjects:

Konu
Biology, 16.04.2020 18:34
Konu
Social Studies, 16.04.2020 18:35
Konu
Mathematics, 16.04.2020 18:35
Konu
Mathematics, 16.04.2020 18:35