Suppose a process is defined to behave as described in Figure. Design and implement a resource manager

Question:

Suppose a process is defined to behave as described in Figure. Design and implement a resource manager for reusable resources. When multiple processes are blocked on a resource and one or more units become available, call a policy function to select the process to receive resources. Implement any simple policy you like. Test your resource manager by creating a testbed with N different processes (N is a testbed parameter) and M different resources (M is a testbed parameter), where Ri initially has ci units of the resource (ci is a testbed parameter). Only one process can be running at a time, so you will also need a simple scheduler to allocate the processor to processes in the order in which they become ready. A running process should execute for a small random amount of time and then request one of the units of resource, transitioning to the blocked state. When the resource is allocated to the process, it should be moved to the ready state. Later, the testbed should release each resource it acquired. Your testbed processes need only simulate real work by real processed. For example, your testbed might have a code schema similar to this:

#define N 50

Scanf(“%d”, M); // define a value for M 

For(i=0; i<M; i++) { … } // Define values for c[i]

for(i=0; i<N; i++) {

waitTime = rand ();

for (j=0; j<waitTime; j++) { };   // simulate running

                                  // process

request(r[i%M],…);  // Ask for k < c[i%M] units 

waitTime = rand();

for(j=0; j<waitTime; j++) { };    // simulate running

                                  // process 

release(r[i%M], …)                // Release resource 

}

A more comprehensive test procedure would cause processed to hold more than one resource type at a time. If you have time, make your test driver check some of these more complex situations. 

            Experiment with various small values of N < 8, M < 10, and ci. The random amount of time a process runs should be kept as small as possible so that your tests do not take an inordinate amount of time. Be sure your test cases cause processes to block for unavailable resources. Hand in listing of your resource manager and testbed, along with a trace (fewer than five pages) of state transitions in a test session.  

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: