Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribedimage text in transcribed

Problem A. Consider the following code example for allocating and releasing, which can be concurrently called by multiple processes to fork new processes #define MAX PROCESSES 255 int number of processes 0; // a shared variable /* the implementation of fork ) calls this function */ int allocate process) int new pid; if (number of processesMAX PROCESSES) return -1; allocate necessary process resources; ++number_of_processes; return new pid; else /* the implementation of exit) calls this function */ void release process )i release process resources --number of processes; Using the Semaphore structure in Slide 3.23 to declare & initialize a Semaphore named proc s only being accessed via atomic wait) and signal () operations, which are defined in Slide 3.24 for the input parameter named S. To prevent race condition(s), 1. Write C statements to declare and initialize the Semaphore named proc_s using the Semaphore structure in Slide 3.2:3 2. Re-write the allocate_process ) function to call wait) and/or signal () defined in Slide 3.24 3. Re-write the release _process ) function to call wait) and/or signal ) defined in Slide 3.24

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

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions