Professional Documents
Culture Documents
Exercises in Deadlock Avoidance
Exercises in Deadlock Avoidance
1. A garden has four spades and three wheelbarrows. Four gardeners are working:
- Gardener 1 needs to use two spades and two wheelbarrows.
- Gardener 2 needs to use two spades and one wheelbarrows.
- Gardener 3 needs to use one spades and two wheelbarrows.
- Gardener 4 needs to use three spades and three wheelbarrows.
At a certain point in time
- Gardener 1 is using a wheelbarrow
- Gardener 2 is using a spade
- Gardener 3 is using a wheelbarrow
- Gardener 4 is using two spades
Exam 2011
2. A restaurant has two saucepans and two frying pans. Three chefs are cooking.
- Chef 1 needs to use a frying pan and two saucepans.
- Chef 2 needs to use two frying pans and a saucepan.
- Chef 3 needs to use a frying pan and a saucepan.
At a certain point in time
- Chef 1 is using a frying pan.
- Chef 2 is using a saucepan.
- Chef 3 is using a frying pan.
Exam 2003
3. A restaurant has four frying pans, two woks and three saucepans. Four chefs are cook-
ing.
- Chef 1 needs to use two frying pans, two woks and two saucepans.
- Chef 2 needs to use two frying pans and one wok.
- Chef 3 needs to use two frying pans and two saucepans.
- Chef 4 needs to use three frying pans, two woks and two saucepans.
At a certain point in time
- Chef 1 is using a frying pan and a saucepan.
- Chef 2 is using a frying pan.
- Chef 3 is using a saucepan.
- Chef 4 is using a frying pan and a wok.
Exam 2005
(a) Use the bankers algorithm to show if this system is in a safe state or not.
(b) If it is in a safe state, give a safe sequence.
(c) If is is unsafe, identify the resource types that would be involved in the resulting
deadlock.
(a) Draw a table showing the allocated and needed resources at this point in time.
(b) What resources are available?
(c) Use the bankers algorithm to find out if this system is in a safe state.
(d) If it is in a safe state, give a safe sequence, if not, identify the resources involved
in the resulting deadlock.
6. A sushi restaurant employs three people to make sushi, they share 1 chopping board,
2 knives and 1 rolling mat.
- Person 1 needs to use 1 knife, and 1 rolling mat.
- Person 2 needs to use 1 knife, and 1 chopping board.
- Person 3 needs to use 1 knife, 1 rolling mat and 1 chopping board.
At a certain point in time:
- Person 1 is using 1 rolling mat.
- Person 2 is not using anything.
- Person 3 is using 1 knife and 1 chopping board.
(a) Draw a resource allocation graph to illustrate the state of the system. (show
future claims as dashed lines)
(b) Draw a table to illustrate maximum, used, needed, and available resources in the
system.
(c) Use the bankers algorithm to find out if this system is in a safe state.
(d) If it is in a safe state, give a safe sequence, if not, identify the resources involved
in the resulting deadlock.
8. Four teams of builders are working on a construction project and sharing tools (5 saws
and 4 drills).
- Team 1 needs to use 2 saws and 2 drills.
- Team 2 needs to use 3 saws and 2 drills.
- Team 3 needs to use 4 saws and 4 drills.
- Team 4 needs to use 4 saws and 1 drill.
At a certain point in time
- Team 1 is using 1 drill.
- Team 2 is using 1 saw.
- Team 3 is using 2 saws and 1 drill.
- Team 4 is using 1 drill.
Exam 2008
9. An Italian restaurant employs three chefs, they share 1 frying pan, 3 saucepans and 1
knife.
- Chef 1 needs to use 1 knife, and 1 frying pan.
- Chef 2 needs to use 1 frying pan, and 2 saucepans.
- Chef 3 needs to use 1 knife, 1 frying pan and 2 saucepans.
At a certain point in time:
- Chef 1 is using 1 knife.
- Chef 2 is using 1 saucepan.
- Chef 3 is using 1 frying pan and 1 saucepan.
(a) Draw a resource allocation graph to illustrate the state of the system. (show
future claims as dashed lines)
(b) Draw a table to illustrate maximum, used, needed, and available resources in the
system.
(c) Use the bankers algorithm to find out if this system is in a safe state.
(d) If it is in a safe state, give a safe sequence, if not, identify the resources involved
in the resulting deadlock.
Exam 2009
10. Consider the following system which has three resource types A,B and C. There are 5
instances of A, 4 instances of B and 7 instances of C
(a) Is this system in a safe state? Use the safety algorithm to prove your answer.
(b) If P3 now requests 2 more instances of resource C is the system still safe? Use the
Resource-Request algorithm to prove your answer.
Exam 1997
11. Consider the following system which has three resource types A,B and C. There are 5
instances of A, 4 instances of B and 7 instances of C
(a) Is this system in a safe state? Use the safety algorithm to prove your answer.
(b) If P3 now releases 1 instance of resource C is the system safe? Use the Resource-
Request algorithm to prove your answer.
Exam 1998
12. A simple operating system allows three files to be open at once and one printer to be
used at a time. The following processes are running:
P1 : open file, open file, get printer, open file, release printer, close all files.
P2 : open file, get printer, release printer, close file.
13. Consider the following system which has 3 resource types, A, B and C. There are 3
instances of A, 2 instances of B and 3 instances of C.
15. A Restaurant has three saucepans and two frying pans. Four chefs are cooking.
- Chef 1 needs to use a frying pan and three saucepans.
- Chef 2 needs to use a frying pan and a saucepan.
- Chef 3 needs to use two frying pans and three saucepans.
- Chef 4 needs to use two frying pans and a saucepan
At a certain point in time
- Chef 1 is using one saucepan.
- Chef 2 is using one saucepan.
- Chef 3 is using one saucepan.
- Chef 4 is using one frying pan.
Use the safety algorithm to show if this system is in a safe state or not.
Exam 2002 semester 1