Document

<Exercise 2>
Due date: April21, 11:59 P.M.
1. What is the meaning of the term busy waiting? What other kinds of waiting are there
in an operating system? Can busy waiting be avoided altogether? Explain your answer.
2. Solve the dining philosopher’s problem using monitors instead of semaphores.
3. The banker's algorithm is being run in a system with m resource classes and n
processes. In the limit of large m and n, the number of operations that must be
performed to check a state for safety is proportional to manb. What are the values of a
and b?
4. Compare the circular-wait scheme with the deadlock-avoidance schemes (like the
banker’s algorithm) with respect to the following issues:
a. Runtime overheads
b. System throughput
5. Consider the following snapshot of a system:
Allocation
Max
Available
ABCD
ABCD
P0 0 0 1 2
0012
1520
P1 1 0 0 0
1750
P2 1 3 5 4
2356
P3 0 6 3 2
0652
P4 0 0 1 4
0656
ABCD
Answer the following questions using the banker’s algorithm:
c. What is the content of the matrix Need?
d. Is the system in a safe state?
e. If a request from process P1 arrives for (0,4,2,0), can the request be granted
immediately?
6. What advantage is there in having different time-quantum sizes on different levels of
a multilevel queuing system?
7. Three processes are running on the following figure time line.
0
P0
10
CPU (10)
P1
P2
CPU(4)
20
I/O (11)
CPU(9)
I/O(16)
I/O(4) CPU (4)
I/O(12)
30
CPU(4)
40
50
CPU(8)
I/O (8)
CPU(7)
CPU(6)
I/O(4)
CPU (6)
For each of the following scheduling algorithms, draw four Gantt charts and determine
the average waiting time.
a. SJF (preemptive)
b. Priority (Non-preemptive) (Priority - P0: 1, P1: 2, P2: 3)
c. RR (Quantum = 5)
d. Multi-level queue (Priority - P0: 1, P1 & P2: 0), SJF (preemptive) with priority 0,
FCFS with priority 1, Fixed Priority Queue & Preemptive