exercises

Share Embed Donate


Short Description

Download exercises ...

Description

Exercises in deadlock prevention 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 (a) Draw a resource allocation graph for this system (b) Is the system in a safe state? Prove using the bankers algorithm. (c) Gardener 1 wants to use another wheelbarrow. Should he be allowed to do this? Why? 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. (a) Draw a Resource Allocation Graph for this system. (b) Is this system in a safe state? Prove using the safety algorithm. (c) Chef 3 decides not to use the saucepan. Is the system in a safe state? Prove. Exam 2003

3. A restaurant has four frying pans, two woks and three saucepans. Four chefs are cooking. - 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. (a) Draw a Resource Allocation Graph for this system. (b) Is this system in a safe state? Prove using the safety algorithm. (c) One of the saucepans is broken and cannot be used. Is the system in a safe state? Prove. Exam 2005 4. A system has 3 resource types, A, B and C. There are 5 instances of A, 2 instances of B and 2 instances of C. At a certain point in time, the resources are being used as follows: Process P1 P2 P3

maximum A B C 1 0 2 1 2 1 3 1 2

allocation A B C 0 0 1 1 1 0 2 1 0

(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. Exam 2006 semester 1

5. A construction project employs three teams of workers, the teams share 2 diggers, 5 shovels and 2 cement mixers. - Team 1 needs to use 2 diggers, 3 shovels and 2 cement mixers. - Team 2 needs to use 1 digger, 3 shovels and 1 cement mixer. - Team 3 needs to use 1 digger, 2 shovels and 1 cement mixer. At a certain point in time: - Team 1 is using 1 digger and 2 shovels. - Team 2 is using 1 shovel and 1 cement mixer. - Team 3 is using 1 digger and 1 cement mixer. (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. Exam 2006 semester 2 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. Exam 2007 semester 1

7. A Restaurant has four frying pans and three saucepans. Four chefs are cooking. - Chef 1 needs to use two frying pans and two saucepans. - Chef 2 needs to use two frying pans and one saucepan. - Chef 3 needs to use one frying pans and two saucepans. - Chef 4 needs to use three frying pans and three saucepans. At a certain point in time - Chef 1 is using a saucepan. - Chef 2 is using a frying pan. - Chef 3 is using a saucepan. - Chef 4 is using two frying pans. (a) Draw a Resource Allocation Graph for this system. (b) Is this system in a safe state? Prove using the safety algorithm. (c) Chef 1 wants to use another saucepan. Should he be allowed to do this? Why? Exam 2007 semester 2 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. (a) Draw a Resource Allocation Graph for this system. (b) Is this system in a safe state? Prove using the bankers algorithm. (c) If the system is safe, give a safe sequence. If it is not safe, which teams will be involved in the deadlock? (d) Describe how deadlock prevention could be used in this situation. 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 Process P1 P2 P3 P4

maximum A B C 3 3 3 2 4 2 4 3 4 4 4 6

allocation A B C 0 0 2 1 0 1 1 2 1 0 1 0

(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 Process P1 P2 P3 P4

maximum A B C 1 3 1 1 3 1 0 4 3 1 2 4

allocation A B C 0 2 1 1 0 0 0 2 1 1 1 2

(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 ResourceRequest 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. (a) Give a sequence of execution for p1 and p2 which results in deadlock. (b) Draw a resource allocation diagram to illustrate this deadlock. (c) How could deadlock be avoided in this example? Exam 2000 semester 1 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. Process P1 P2 P3

maximum A B C 2 1 3 1 1 2 2 1 2

allocation A B C 1 0 1 0 1 1 2 1 0

(a) Draw a resource allocation graph to illustrate this system. (b) Use the safety algorithm to show if this system is in a safe state or not. Exam 2000 semester 2

14. A network application is allowed a maximum of 5 simultaneously open incoming connections and a maximum of 2 simultaneously open outgoing connections. The application has 3 threads. - Thread 1 uses up to 4 incoming connections and 1 outgoing connection. - Thread 2 uses up to 2 incoming connections and 2 outgoing connections. - Thread 3 uses up to 2 incoming connections and 1 outgoing connection. At a certain point in time - Thread 1 is using 1 incoming connection and 1 outgoing connection. - Thread 2 is using 2 incoming connections and no outgoing connections. - Thread 3 is using 1 incoming connection and 1 outgoing connection. (a) Draw a Resource Allocation Graph for this system. (b) Is this system in a safe state? Prove using the safety algorithm. (c) Thread 1 stops using its incoming connection; is the system in a safe state? Prove using the safety algorithm. Exam 2001 semester 1 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. (a) Draw a Resource Allocation Graph for this system. (b) Is this system in a safe state? Prove using the safety algorithm. (c) Chef 2 agrees to share a frying pan with Chef 4. Is the system in a safe state? Prove. Exam 2001 semester 2

16. A system has 3 resource types, A, B and C. There are 4 instances of A, 3 instances of B and 2 instances of C. At a certain point in time, the resources are being used as follows: Process P1 P2 P3

maximum A B C 2 1 2 1 2 1 3 3 1

allocation A B C 1 0 1 0 2 1 2 1 0

Use the safety algorithm to show if this system is in a safe state or not. Exam 2002 semester 1

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF