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

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago