Computers and Technology
Computers and Technology, 12.12.2019 03:31, sonyav732

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 application
is 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 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;
}
}
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:
1. identify the location and variables involved in the race condition.

2. using a pthread_mutex_lock, fix the race condition.

3. the decreasecount() function currently returns 0 if sufficient resources are available and −1 otherwise. rewrite the two functions using a pthread mutex and a pthread condition so that the decreasecount() function suspends the process until sufficient resources are available. this will allow a process to invoke decreasecount() by simply calling decreasecount(count). the process will return from this function call only when sufficient resources are available.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 12:00, trippie4life
3. when you right-click a linked spreadsheet object, what commands do you choose to activate the excel features? a. linked worksheet object > edit b. edit data > edit data c. linked spreadsheet > edit d. object > edit data
Answers: 2
image
Computers and Technology, 24.06.2019 08:20, brinks7994
Which type of entity describes a fundamental business aspect of a database? a. linking b. lookup c. domain d. weak
Answers: 3
image
Computers and Technology, 24.06.2019 16:00, alexisbeasley2
Which of the following characters is acceptable to use in a filename? ? / – %
Answers: 1
image
Computers and Technology, 24.06.2019 16:00, bsrlee1115
Which type of cloud computing offers easily accessible software and applications on the machines
Answers: 1
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
Mathematics, 24.01.2022 23:30
Konu
Mathematics, 24.01.2022 23:30
Konu
Mathematics, 24.01.2022 23:30