Lab · Lecture 8

Deadlock lab

Two tools: the Banker's algorithm on editable matrices, and a resource-allocation graph you can draw and analyse.

Theory first? Read Lecture 8
  1. 1

    Banker's tab: the slide example is loaded. Need is computed for you. Press Run safety algorithm and step through it with Next.

  2. 2

    Use the Resource request panel to test a request. The three checks light up in order, exactly as you would write them in an exam.

  3. 3

    Switch to the graph tab, load a preset or draw your own, and press Analyse to find cycles and decide whether they mean deadlock.

Try this first: run the safety algorithm on the slide example, then request (1,0,2) for P1 and see it granted, then (0,2,0) for P0 and see why it must wait.

5 processes
3 resources

State

Edit any cell. Need is computed as Max minus Allocation.

Allocation

ABC
P0
P1
P2
P3
P4

Max

ABC
P0
P1
P2
P3
P4

Need

ABC
P0743
P1122
P2600
P3011
P4431

Available

ABC

Total instances (Allocation + Available)

ABC
1057

Safety algorithm

Work starts as Available. Scan P0, P1, ... in order. A process whose Need fits in Work runs, finishes, and releases its Allocation into Work. Repeat until nothing runs.

Resource request

Three checks, in order. The third one pretends to grant and reruns the safety algorithm.

Request vector

P0 Need (7,4,3), Available (3,3,2)