Question: (30 points) Consider the code below for allocating and releasing processes: #define MAX PROCESSES 255 int number of processes = 0; /* The implementation of

 (30 points) Consider the code below for allocating and releasing processes:

(30 points) Consider the code below for allocating and releasing processes: #define MAX PROCESSES 255 int number of processes = 0; /* The implementation of fork() calls this function */ int allocate processes() { 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() { 1* release resources */ number_of_processes --; } Identify the race condition(s) on the above code segments (5 points). Assume you have a mutex lock named mutex with the operations acquire() and release() (or, equivalently lock() and unlock()). Indicate where the locking operations should be placed in the above code to prevent race condition(s) (5 points)

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!