9. Consider the code example for allocating and releasing processes as shown below. #define MAX PROCESSES 255 int number.of-processes = 0; /+ the implementation of fork() calls this function / int allocate.process () { int new.pid; if (number.of.processes - MAX PROCESSES) return -1; else { /* allocate necessary process resources / ++number.of.processes; return new.pid; /+ the implementation of exit () calls this function / void release.process () { /* release process resources +/ --number.of.processes; Figure 5.23 Allocating and releasing processes. a. Identify the race condition(s). b. Assume you have a mutex lock named mutex with the operations acquire() and release(). Indicate where the locking needs to be placed to prevent the race condition(s).

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 7RQ
icon
Related questions
Question
100%

Don't copied please i will upvote.

9. Consider the code example for allocating and releasing processes as shown below.
#define MAXPROCESSES 255
int number.of-processes = 0;
/+ the implementation of fork () calls this function /
int allocate.process () {
int new-pid;
if (number_of-processes - MAX PROCESSES)
return -1;
else {
/* allocate necessary process resources */
++number.of.processes;
return new.pid;
+ the implementation of exit() calls this function /
void release.process () {
/* release process resources */
--number.of.processes;
Figure 5.23 Allocating and releasing processes.
a. Identify the race condition(s).
b. Assume you have a mutex lock named mutex with the operations acquire() and release().
Indicate where the locking needs to be placed to prevent the race condition(s).
Transcribed Image Text:9. Consider the code example for allocating and releasing processes as shown below. #define MAXPROCESSES 255 int number.of-processes = 0; /+ the implementation of fork () calls this function / int allocate.process () { int new-pid; if (number_of-processes - MAX PROCESSES) return -1; else { /* allocate necessary process resources */ ++number.of.processes; return new.pid; + the implementation of exit() calls this function / void release.process () { /* release process resources */ --number.of.processes; Figure 5.23 Allocating and releasing processes. a. Identify the race condition(s). b. Assume you have a mutex lock named mutex with the operations acquire() and release(). Indicate where the locking needs to be placed to prevent the race condition(s).
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Analysis of Performance Measurement
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,