Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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. #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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started