Deadlock: Bankers Algorithm

Consider the following snapshot of the system.

Process

Allocation

Max

Available

A

B

D

A

B

C

A

B

C

P1

0

1

0

7

5

3

3

3

2

P2

2

0

0

3

2

2

P3

3

0

2

9

0

2

P4

2

1

1

2

2

2

P5

0

0

2

4

3

3

Answer the following
  • What is the content of the need matrix?
  • Is the system in a safe state?
  • If the request for process P2 arrives for (1, 0, 2) can it be granted immediately.

Consider the following snapshot of the system.

Process

Allocation

Max

Available

A

B

C

A

B

C

A

B

C

P0

0

0

2

0

0

4

1

0

2

P1

1

0

0

2

0

1

P2

1

3

5

1

3

7

P3

6

3

2

8

4

2

P4

1

4

3

1

5

7

Answer the following
  • What is the content of the need matrix?
  • Is the system in a safe state?
  • If the request for process P2 arrives for (0, 0, 2) can it be granted immediately.

Consider the following snapshot of the system.

Process

Allocation

Max

Available

A

B

C

D

A

B

C

D

A

B

C

D

P1

0

0

1

2

0

0

1

2

1

5

2

0

P2

1

0

0

0

1

7

5

0

P3

1

3

5

4

2

3

5

6

P4

0

6

3

2

0

6

5

2

P5

0

0

1

4

0

6

5

6

Answer the following
  • What is the content of the need matrix?
  • Is the system in a safe state?
  • If the request for process P1 arrives for (0,4,2,0) can it be granted immediately.

Consider the following snapshot of the system.

Process

Allocation

Max

Available

A

B

C

D

A

B

C

D

A

B

C

D

P1

4

0

0

1

6

0

1

2

3

2

1

1

P2

1

1

0

0

1

7

5

0

P3

1

2

5

4

2

3

5

6

P4

0

6

3

3

1

6

5

3

P5

0

2

1

2

1

6

5

6

Answer the following
  • What is the content of the need matrix?
  • Is the system in a safe state?
  • If the request for process P4 arrives for (1,2,0,0) can it be granted immediately.

The OS contains 3 resources, the number of instance of each resource type are 7, 7, 10. The current resource allocation state is as shown below.

Process

Current allocation

Maximum need

R1

R2

R3

R1

R2

R3

P1

2

2

3

3

6

8

P2

2

0

3

4

3

3

P3

1

2

4

3

4

4

Is the current allocation in a safe state?

Consider the following system snapshot using data structures in the Bankers algorithm, with resources A, B, C and D and process P0 to P4.

Process

Allocation

Max

Available

A

B

C

D

A

B

C

D

A

B

C

D

P0

6

0

1

2

4

0

0

1

3

2

1

1

P1

1

7

5

0

1

1

0

0

P2

2

3

5

6

1

2

5

4

P3

1

6

5

3

0

6

3

3

P4

1

6

5

6

0

2

1

2

Using Bankers algorithm answer the following
  • How many resources of Type A, B, C and D are there?
  • What is the content of the need matrix?
  • Is the system in a safe state? Why?
  • If the request for process P4 arrives for additional resources of (1,2,0,0) can it be granted immediately. Show the system state and other criteria

Consider the following snapshot of a system. Execute Bankers algorithm to answer the following

Process

Allocation

Max

Available

A

B

C

D

A

B

C

D

A

B

C

D

P0

2

0

1

2

2

0

1

2

2

4

2

1

P1

1

0

0

0

2

7

5

0

P2

1

3

5

4

2

3

5

6

P3

0

6

3

2

0

7

5

2

P4

0

0

1

4

0

7

5

6

  • Is the system in a safe state?
  • If the system is in a safe state, show how all the process could complete their execution successfully. If the system is unsafe, show how deadlock might occur. Explain.
  • If the request for process P1 arrives (1, 4, 2, 0) can the request be granted immediately?

Consider the following snapshot of the system.

Process

Allocation

Max

Available

A

B

D

A

B

C

A

B

C

P1

0

1

0

7

5

3

3

3

2

P2

2

0

0

3

2

2

P3

3

0

2

9

0

2

P4

2

1

1

2

2

2

P5

0

0

2

4

3

3

Answer the following
  • What is the content of the need matrix?
  • Is the system in a safe state?
  • If the request for process P2 arrives for (0, 2, 0) can it be granted immediately.

Consider the following snapshot of the system. Execute Bankers algorithm to answer the following.

Process

Allocation

Max

Available

A

B

D

A

B

C

A

B

C

P0

0

0

1

0

0

1

1

5

2

P1

1

0

0

1

7

5

P2

1

3

5

2

3

5

P3

0

6

3

1

6

5

P4

0

0

1

5

6

5

Answer the following
  • What is the content of the need matrix?
  • Is the system in a safe state?
  • If the system is in a safe state, show how all the process could complete their execution successfully. If the system is unsafe, show how deadlock might occur. Explain.
  • If the request for process P1 arrives for (0, 4, 2) can it be granted immediately. If granted write the safe sequence.

Assume a system with four resource types R0, R1, R2 and R3. The number of instances of each resource type is 6, 4, 4 and 2 respectively. The maximum claim and the current allocation are shown in the following table. Is this a safe state? Why or why not?

Process

Maximum claim

Allocation

R0

R1

R2

R3

R0

R1

R2

R3

P0

3

2

1

1

2

0

1

1

P1

1

2

0

2

1

1

0

0

P2

1

1

2

0

1

1

0

0

P3

3

2

1

0

1

0

1

0

P4

2

1

0

1

0

1

0

1