CS 432 Lecture 16- 10/10/97

Introduction

1. Please do exercise 5.7 in text for Wednesday.

2. Read Holt’s paper!

The banker’s algorithm

1. In general, how can one determine when allocating some resource will leave the system in a state from which it may not be possible to provide the resources needed to complete all processes in the system?

2. The banker’s algorithm answers such questions in contexts where:

• all resources are reusable

• all processes provide the system with upper bounds on the units of each available resource they might need to complete.

• No process’ upper bounds exceeds the available amount of any resource.

3. Basically, the banker’s algorithm works by assuming the worst. That is, it assumes that every process in the system will require its limit of each resource category available in order to complete. Thus, the fact that it declares a state unsafe does not mean deadlock is inevitable. In an unsafe state, however, it is the actions of “user” processes rather than the actions of the system that determine whether or not deadlock occurs.

4. Under this “worst case” assumption, the banker’s algorithm checks to see if there is some order in which processes can be allowed to complete.

Assume the following data structures:

available(resource-class) a vector with one entry for each resource indicating the number of units available.

max(process,resource-class) a matrix with one entry for each process/resource pair giving the upper bound on the units of the resource class the specified process may request.

allocation(process,resource-class) a matrix indicating the number of units of each resource class allocated to each process.

need(process,resource-class) a matrix obtained by subtracting corresponding entries of “allocation” from “max”.

Note: assume all the quantities in these tables reflect the state that would exist if the request being considered were satisfied.

The idea is that if a process makes a request, we update available and allocation as if the request was accepted and then run the algorithm below. If it “completes” all processes, the allocation is safe. Otherwise the requesting process must wait. The algorithm is then:

repeat
    look for a process whose ``needs'' are less
    than units ``available''  (i.e. compare rows of ``needs''
                               to the ``available'' vector)
    if a process is found then
         add that process' row of ``allocation'' to
         available
         delete the ``completed'' process
until no more processes can be completed

Holt’s model of resource allocation

1. I’d like to start with a quick overview of the resource allocation model described in the paper by Holt.

2. If nothing else was clear, about Holt’s model, it should still be clear that it is entirely based on using directed graphs to describe the aspects of systems involving resource allocation. I’ll assume general familiarity with the notion of a directed graph, but I will remind you that a:

Bipartite Graph is a graph whose vertices can be partitioned into two sets in such a way that all the graph’s edges connect elements from different sets.

3. The graphs used in Holt’s model are all bipartite directed graphs. The vertices of the graph correspond to the processes and resources in a computer system. The partition (that makes the graph bipartite) is formed by viewing the resource vertices as one set and the process vertices as another set.

4. To completely represent the state of a system the graph must be augmented with some additional specifications:

• the set of vertices associated with resources is further partitioned into vertices corresponding to reusable resources and consumable resources • for each reusable resource, the total number of units of the resource available

must be specified.

5. The interpretation of edges in one of Holt’s graphs depends on their direction.

• An edge directed from a process vertex to a resource vertex indicates that the process has requested (and not yet been granted) one unit of the resource (multiple unit requests are indicated by multiple edges or by edge weights).

• An edge directed from a resource vertex to a process vertex indicates that the process is capable of releasing one or more units of the resources. The precise meanings of these edges depends on the type of resource involved:

– If the resource is reusable, then in order to release a unit, the process which is the target of the edge must be currently allocated use of a unit of the resource. In other words, the number of edges between a reusable resource node and a process indicates the number of units of the resource allocated to the process.

– If the resource is consumable, an edge to a process indicates that the process is a producer of the resource.

6. A particular instance of one of Holt’s graphs is intended to represent the state of a “General resource system” at some point in time. The states of such systems change over time, and Holt attempts to capture the possible changes in terms of transformations that can be performed on his graphs. He identifies three such transformations:

Requests A process which currently has no requests outstanding can request one or more units of one or more distinct resource classes. In the graph model, this is accomplished by adding edges pointing from the node to one or more resource nodes.

Acquisitions A process with outstanding requests can be allocated the resources requested if sufficient units are available of all the resource classes requested by the process. In the system graph, this is accomplished by reversing all edges that point to reusable resource nodes and deleting edges pointing to consumable resource nodes.

Releases A process:

• to which resusable resources have been allocated, or

• which is a producer of consumable resources

which has no resource requests outstanding can release the some or all of the reusable resources allocated to it and/or units of any consumable resources it produces. In the graph, this is accomplished by deleting one or more of the request edges directed toward the process node (in the case of a reusable resource) or increasing the available count (in the case of a consumable resource).