Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

What were my siblings like?

Answered: 1 week ago