Question: Problem E. Consider the following code example for allocating and releasing, which can be concurrently called by multiple processes to fork new processes. #de fine

 Problem E. Consider the following code example for allocating and releasing,which can be concurrently called by multiple processes to fork new processes.

Problem E. Consider the following code example for allocating and releasing, which can be concurrently called by multiple processes to fork new processes. #de fine MAX PROCESSES 255 int number_of_processes-0 11 a shared variable /*the implementation of fork) calls this function int new_pid; int allocate_process() t if (number-of_processes return -1; .-MAX PROCESSES) else allocate necessary process resources; ++number_of processes; return new pid; /*the implementation of exit) calls this function */ void release_process) t release process resources; --number of processes; a. Which variable has race condition(s)? b. Using a mutex lock named available with hardware atomic acquire and release ), to prevent the race condition(s) b.1 Write a C statement to initialize the shared Boolean mutex lock named available b.2 Re-write the allocate process function to call acquire and/or release in Slide 3.22 b.3 Re-write the release process function to call acquire and/or release in Slide 3.22 Problem E. Consider the following code example for allocating and releasing, which can be concurrently called by multiple processes to fork new processes. #de fine MAX PROCESSES 255 int number_of_processes-0 11 a shared variable /*the implementation of fork) calls this function int new_pid; int allocate_process() t if (number-of_processes return -1; .-MAX PROCESSES) else allocate necessary process resources; ++number_of processes; return new pid; /*the implementation of exit) calls this function */ void release_process) t release process resources; --number of processes; a. Which variable has race condition(s)? b. Using a mutex lock named available with hardware atomic acquire and release ), to prevent the race condition(s) b.1 Write a C statement to initialize the shared Boolean mutex lock named available b.2 Re-write the allocate process function to call acquire and/or release in Slide 3.22 b.3 Re-write the release process function to call acquire and/or release in Slide 3.22

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!