[Solved] UCS1411 Exercise 7- Deadlock Avoidance

$25

File Name: UCS1411_Exercise_7__Deadlock_Avoidance.zip
File Size: 357.96 KB

SKU: [Solved] UCS1411 Exercise 7- Deadlock Avoidance Category: Tag:
5/5 - (1 vote)

Develop a C program to implement the bankers algorithm for deadlock avoidance.

Algorithm:

  1. Read the following
    1. Number of processes.
    2. Number of resources and number of instances of each resource available.
    3. Maximum requirement of each process,
    4. Allocated instances of resources
  2. Determine the need of each process
  3. Repeat the following till all processes are done.
    1. Check if request of process i less than or equal to need of that process
      1. If yes proceed
      2. Otherwise raise an error condition
    2. Check if request of process i less than or equal to available instances
      1. If yes proceed ii. Otherwise wait till available.
    3. Update the available vector, allocation vector and need vector
    4. Generate safety sequence by running safety algorithm.

SAMPLE INPUT & OUTPUT:

Bankers Algorithm

  1. Read Data
  2. Print Data
  3. Safety Sequence 4. Exit

Enter the option :1

Number of processes: 5 P0, P1, P2, P3, P4

Number of resources: 3 A B C

Number of Available instances of A: 3 Number of Available instances of B: 3

Number of Available instances of C: 2

Maximum requirement for P0: 7 5 3

Maximum requirement for P1: 3 2 2

Maximum requirement for P2: 9 0 2

Maximum requirement for P3: 2 2 2

Maximum requirement for P4: 4 3 3

Allocated instances to P0: 0 1 0

Allocated instances to P1: 2 0 0

Allocated instances to P2: 3 0 2

Allocated instances to P3: 2 1 1

Allocated instances to P4: 0 0 2

Enter the option: 2

Alloc Max Need Avail

A B C A B C A B C A B C

P0 0 1 0 7 5 3 * * * 3 3 2

P1 2 0 0 3 2 2 * * *

P2 3 0 2 9 0 2 * * *

P3 2 1 1 2 2 2 * * *

P4 0 0 2 4 3 3 * * *

Enter the option: 3 Display the Safety Sequence:

* * * * *

Enter the option: 4

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] UCS1411 Exercise 7- Deadlock Avoidance[Solved] UCS1411 Exercise 7- Deadlock Avoidance
$25