Page 149 - DCAP103_Principle of operating system
P. 149
Principles of Operating Systems
Notes
l1->Release();
}
void q() {
l2->Acquire();
l1->Acquire();
code that manipulates data that l1 and l2 protect
l1->Release();
l2->Release();
}
If p and q execute concurrently, consider what may happen. First, p acquires 11 and q
acquires 12. Then, p waits to acquire 12 and q waits to acquire 11. How long will they
wait? Forever. This case is called deadlock.
Questions:
1. What are conditions for deadlock?
2. How can p and q avoid deadlock? Order the locks, and always acquire the locks in that
order. Eliminates the circular wait condition.
1. Consider four processes arrived at different times and needed CPU time
differ from process to other according to the next table:
Process Arrived Time CPU time (minute)
P 1 10:00 4 m
P 2 10:10 3 m
P 3 10:15 2 m
P 4 10:25 2 m
2. Calculate the termination time for each process, If the probability of
I/O=0.7 in each of the following cases:
(a) Mono-programming.
(b) Multi-programming.
Self Assessment
Multiple choice questions:
5. .................. is a high level abstraction over Semaphore.
( a) Shared memory (b) Message passing
( c) Monitor (d) Mutual exclusion
6. The process related to process control, file management, device management, information
about system and communication that is requested by any higher level language can be
performed by .................. .
( a) Editors (b) Compilers
( c) System Call (d) Caching
142 LOVELY PROFESSIONAL UNIVERSITY