Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Operating systems question 3.. The following program segment is used to manage a nite number of instances of an available resource.. The maximum number of

Operating systems question

3.. The following program segment is used to manage a nite number of instances of an available resource.. The maximum number of resourc es and the number of available resources are declared

#ddefine MAX RESOURCES 5

int available resources = MAX RESOURCES;;

When a process wishes to obtain a number of resources,, it invokes the decrease count(()) function::

/** decrease available resources by coun t resources *//

/** return 0 if sufficient resources available,, *//

/** otherwise return - 1 *//

int decrease count((iint count)) {

if (aavailable resources < count))

return - 1;;

else {

available resources - = count;;

return 0;;

}

}

When a process wants to return a number of resources,, it calls the decrease count(()) function::

/** increase available resources by count *//

int increase count((iint count)) {

available resources +== count;;

return 0;;

}

The preceding program segment produces a race condition.. Do the following::

a.. Identify the data involved in the race condition..

b.. Identify the location (oor locations)) in the code where the race condition occurs..

c.. Using a semaphore,, x the race condition..

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_2

Step: 3

blur-text-image_3

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: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago