Uploaded by Allan c

MARCH MADNESS

advertisement
MARCH MADNESS
1.
Program 1: Lock 1 will attempt to acquire a thread and lock thread 2. While Lock 2 will attempt
to acquire a thread and lock thread 1. If they execute together each thread will be waiting for the
others lock to be released
Program 2: Each thread acquires the lock in the same order so no deadlock
Program 3: No deadlocks the first worker finishes before the second one starts
2.
2a. A= 2, B = 9, and C =9
2b.
2c. No safe sequence can be found because the available does not contain any value to
calculate the banker algo.
Max
Allocation
Available
Need
A B C
A B C
A B C
ABC
T0
0 0 1
0 0 1
000
T1
1 7 5
1 0 0
075
T2
2 3 5
1 3 5
100
T3
0 6 4
0 6 3
001
3.
4. It can be turned into a safe sequence when p2 is killed and the sequence goes from
r1 -> p1-> r2 -> r3
5. No deadlock because p3 does not go back to r1
6. Yes there is a cycle where p1 is allocating to resource 1 and requesting resource 2 and
process 2 is allocating to resource 2 and requesting resource 1 creating a path from process
one to process 2
7. If process 3 is requesting for resource 1 then there will exist a deadlock where the process is
stuck in a loop of resources.
8.
Download