Computers and Technology
Computers and Technology, 14.11.2019 20:31, Briii582

Assume that a finite number of resources of a single resource type must be managed. processes may ask for a number of these resources and —once finished—will return them. as an example, many commercial software packages provide a given number of licenses, indicating the number of applications that may run concurrently. when the applicationis started, the license count is decremented. when the application is terminated, the license count is incremented. if all licenses are in use, requests to start the application are denied. such requests will only be granted when an existing license holder terminates the application and a license is returned. the following program segment is used to manage a finite number of instances of an available resource. the maximum number of resources and the number of available resources are declared as follows: #define max resources 5int 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; }}when a process wants to return a number of resources, it calls the increase_count() function: /* increase available resources by count */int increase_count(int count) {available resources += count; return 0; }the preceding program segment produces a race condition. do the following: identify the location and variables involved in the race condition and use a semaphore to fix the race condition.

answer
Answers: 1

Similar questions

Do you know the correct answer?
Assume that a finite number of resources of a single resource type must be managed. processes may as...

Questions in other subjects:

Konu
History, 05.05.2020 08:23