• Nie Znaleziono Wyników

Project #2The Banker Problem

N/A
N/A
Protected

Academic year: 2021

Share "Project #2The Banker Problem"

Copied!
2
0
0

Pełen tekst

(1)

Design and Verification of Information Systems Prof. Dr. hab. inz.. Boleslaw Mikolajczak 12.5 points

Project #2 The Banker Problem

The “Banker’s Problem” was originally given by Dijkstra in 1986 as an example of resource sharing problem:

A banker has n clients, and a fixed capital g. Each client requires a predetermined amount, say f

i

for the ith client, for his project. He does not need all the money at the beginning, but periodically he requests a unit of capital from the bank until his requirement id fulfilled. Some time later he returns his full loan to the bank. The banker may satisfy a given request if he has the money available, but he may choose not to do so. In that case the client has to wait until his request is satisfied. The banker’s problem is to develop a strategy for distributing the money which will eventually satisfy all the clients’ requirements. The banker has to avoid situations in which he has insufficient money but there are clients’ requests still outstanding. These situations are called deadlocks.

An instance i =(n, f, g) of the problem is characterized by a positive integer n, and n-tuple f=(f

1

, f

2

, …,f

n

) and number g. All amounts are positive integers. Given a particular problem instance, a state is an n-tuple r=(r

1

, r

2

, …,r

n

).representing the amount required but not yet received by each client. Initially r = f. A state is safe if it does not necessarily lead to a deadlock.

Design a place/transition Petri net that represents the Banker’s problem as defined above. Distinguish the place BANK, holding the banker’s cash, initially contains g units of money (tokens). Places CREDIT

i

and CLAIM

i

stand for the loan and the remaining claim of client i, respectively. Through the transition GRANT

i

this client obtains one unit of money (token) as often as transition GRANT

i

fires. Transition RETURNi returns all the money back to the banker. RETURN

i

cannot fire unless the banker has fulfilled the maximal claim f

i

of the client. By the same transition this claim is restored in CLAIM

i

. You can use inscriptions on arcs, for instance representing amount of money transferred.

Study two specific instances of the Banker’s problem.

Instance #1: (2, (8, 6), 10); i.e. 2 clients with financial needs of 8 and 6 and with banker’s capital of 10.

Instance #2: (3, (8, 3, 9), 10), i.e. 3 clients with financial needs of 8, 3, 9 and with banker’s capital of 10.

For both instances create place/transition Petri nets. Check whether these nets have deadlocks. If YES then restructure the place/transition net in such a manner that deadlock can be avoided (if this is at all possible).

Compute also place and transition invariants for both place/transition nets and

explain in your own words the meaning of these invariants. Compute reachability graph

for both instances of the Banker’s problem.

(2)

For instance #1 present the reachability graph in 2-dimensional space of two variables CLAIM

1

and CLAIM

2

The initial state of this graph has corresponding values of 8 and 6, respectively. For this instance, it happens, that the remaining components of the state vector can be computed by knowing CLAIM

1

and CLAIM

2

and knowing place invariants. Having reachability graph show all occurrences sequences for this instance.

The occurrence sequences should be expressed in terms of four transitions: GRANT

1

, RETURN

1

, GRANT

2

, RETURN

2

. Indicate states of deadlock in terms of CLAIM

1

and CLAIM

2

. Four transitions GRANT

1

, RETURN

1

, GRANT

2

, RETURN

2

can be interpreted on the 2-dimensional reachability graph as moves to left, right, down and up.

One can distinguish in the reachability graph three category of nodes:

a) nodes representing deadlock states – what are these states for instance #1 b) unsafe states that inevitably lead to deadlock states – what are these states for

instance #1?

c) safe states – states from which it is possible to avoid deadlock; these states could be generated by minimal elements, i.e. nodes from which safe states can be generated; what are these states for instance #1?

How many states are safe, unsafe and deadlocked for Instance #1?

Modify the net in such a way that deadlock states can be avoided. What conditions have to be satisfied in executing transition GRANT to avoid deadlock? Hint:

use minimal elements to find this relation.

Design place/transition net for Instance #2. Compute place and transition invariants for this instance. Reachable markings can now be presented in a 3- dimentsional space defined by places CLAIM

i

. How many states are safe, unsafe, deadlocked? What are the minimal elements in the reachability graph?

For Instance #2 design a colored Petri net equivalent to the original place/transition net.

Implement all the Petri nets discussed here using CPNTools system, i.e. Instance

#1, Instance #2 (as place/transition nets) and Instance #2 as colored Petri net. Generate reachability graph for Instance #2.

2

Cytaty

Powiązane dokumenty

A general discussion for balanced domains of holomorphy (like the above for n-circled domains) is still lacking.... Proof of

So, the following theorem extends the Krengel–Lin decomposition which is discussed in [KL] only for compact groups..

Anycasting in connection-oriented computer networks: Models, algorithms and results Here ϕ denotes un upper bound on the dual function, which can be calculated using a

Let us now recall the notion of α-proper forcing for a countable ordinal α saying that, given an ∈-chain of length α of countable elementary sum- bodels of some large enough structure

Thus eigenfunctions of the Fourier transform defined by the negative definite form −x 2 in one variable are the same as eigenfunctions of the classical in- verse Fourier

We give a direct proof of this characterization and get stronger results, which allows us to obtain some other results on ω-limit sets, which previously were difficult to prove.. Let

As a corollary, we obtain the following main theorem of this paper: Chainable continua admit no expansive homeomorphisms2. There are no expansive homeomorphisms on chainable

While our interest in this problem is centered in ring theory, results concerning lengths of factorizations in a Krull domain D are combinatorial results based on the block