Homework #2
CMSC 421, Section 0101 (Spring 1999)
Assigned: 3 March 1999
Due: 10 March 1999 at 3:30 PM
Late homeworks will not be accepted.
- Problem 6.7 from the text.
- Problem 6.8 from the text.
- Problem 6.14 from the text.
- Consider the following snapshot of a system:
Process |
Allocation |
Max |
|
A |
B |
C |
D |
A |
B |
C |
D |
P0 |
0 |
0 |
1 |
2 |
0 |
0 |
1 |
2 |
P1 |
1 |
0 |
0 |
0 |
1 |
7 |
5 |
0 |
P2 |
1 |
3 |
5 |
4 |
2 |
3 |
5 |
6 |
P3 |
0 |
0 |
1 |
4 |
0 |
6 |
5 |
6 |
P4 |
0 |
6 |
3 |
2 |
0 |
6 |
5 |
2 |
Currently, the available resources are: 1-A, 5-B, 2-C, 0-D. Answer the following questions, assuming you're using the banker's algorithm to manage resources and avoid deadlock:
- What is the content of the Need matrix?
- Is the system currently in a safe state?
- If process P1 requests an additional (0,4,2,0) resources, can this request be granted immediately?
- Problem 7.4 from the text.
- Problem 7.5 from the text.
- Most modern computer systems don't use the banker's algorithm or similar methods to avoid deadlock. Why not? Can a modern system deadlock over limited resources? If so, how are deadlocks usually resolved?
- Many applications use multiple threads interacting via shared locks, and individual threads often require multiple locks to accomplish their tasks. Propose a way to write code so that threads can't deadlock. How does this method prevent deadlock?