Question: Operating Systems question The following program segment is used to manage a finite number of instances of a resource such as a commercial software license.

Operating Systems question

The following program segment is used to manage a finite number of instances of a resource such as a commercial software license. When a user starts the application, the license count is decremented. When it is terminated, the count is incremented. If all licenses are in use, requests to start the application are denied. There is no queuing of requests. Using a general solution, the maximum and available number of licenses is defined as follows:

#define MAX_RESOURCES 5

int available_resources = MAX_RESOURCES;

When a process wishes to obtain a license, it invokes the decrease_count() function passing in 1:Operating Systems question The following program segment is used to manage a

The preceding code produces a race condition. Do the following: (a) Identify the location (or locations) in the code where the race condition occurs. (10 pts) (b) Identify the data involved in the race condition. (5 pts) (c) Using a semaphore, fix the race condition. It is OK to modify decrease_count so that the calling process is blocked until sufficient resources are available. (20 pts)

When a process wishes to obtain a license, it invokes the decrease count) function passing in 1: // Decrease available resources by count resources // return O if no resources are available, I if successful int decrease_count(int count) if (available resources>count) available_resources --count; return return 0; When a process wants to return a number of resources, it calls increase_count0 with the count // Increases available_resources by count void increase_countint count) \ available resources +-count

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!