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
Abrake has a normal braking torque of 2.8 kip in and heat-dissipating cast-iron surfaces whose mass is 40 lbm. suppose a load is brought to rest in 8.0 s from an initial angular speed of 1600 rev/min using the normal braking torque; estimate the temperature rise of the heat dissipating surfaces.
Answers: 3
question
Engineering, 04.07.2019 18:10
Which of the following refers to refers to how well the control system responds to sudden changes in the system. a)-transient regulation b)- distributed regulation c)-constant regulation d)-steady-state regulation
Answers: 1
question
Engineering, 04.07.2019 18:10
Which from the following instrument is commonly used to detect the high pitch butzing sound in bearings? [clo4] a)-digital ultrasonic meter b)-infrared camera c)-spectroscopic d)-vibrometer
Answers: 2
question
Engineering, 04.07.2019 19:10
Tom is having a problem with his washing machine. he notices that the machine vibrates violently at a frequency of 1500 rpm due to an unknown rotating unbalance. the machine is mounted on 4 springs each having a stiffness of 10 kn/m. tom wishes to add an undamped vibration absorber attached by a spring under the machine the machine working frequency ranges between 800 rpm to 2000 rpm and its total mass while loaded is assumed to be 80 kg a) what should be the mass of the absorber added to the machine so that the natural frequency falls outside the working range? b) after a first trial of an absorber using a mass of 35 kg, the amplitude of the oscillation was found to be 10 cm. what is the value of the rotating unbalance? c) using me-3.5 kg.m, find the optimal absorber (by minimizing its mass). what would be the amplitude of the oscillation of the absorber?
Answers: 3
You know the right answer?
The decrease_count() function in the previous exercise currently returns 0 if sufficient resources a...
Questions
question
Mathematics, 17.12.2019 01:31
Questions on the website: 13722361