Exercise 4
Exercise 4
Questions are taken from Stallings, Operating Systems Internals and Design Principles, fifth edition
and Silberschatz et al., Operating System Concepts, seventh edition.
1 – Silberschatz 5.4
Consider the following set of processes, with the length of the CPU burst given in milliseconds.
a) Draw four Gantt charts that illustrate the execution of these processes using the follow-
ing scheduling algorithms: FCFS, SJF, non-preemptive priority (a smaller priority number
implies a higher priority), and RR (quantum = 1).
b) What is the turnaround time of each process for each of the scheduling algorithms in part a?
c) What is the waiting time of each process for each of the scheduling algorithms in part a?
d) Which of the algorithms om part a results in the minimum average waiting time (over all
processes)?
2
Consider the following set of processes, with the length of the CPU burst and arrival time given
in milliseconds.
a) Draw four Gantt charts that illustrate the execution of these processes using the following
scheduling algorithms: FCFS, SJF, Clairvoyant SJF (the algorithm can look into the future
and wait for a shorter process that will arrive).
b) What is the turnaround time of each process for each of the scheduling algorithms in part a?
c) What is the waiting time of each process for each of the scheduling algorithms in part a?
d) Which of the algorithms om part a results in the minimum average waiting time (over all
processes)?
1
3 – Stallings 3.4
Consider the state transition diagram in the figure. Suppose that it is time for the operating system
to dispatch a process and that there are processes in both the Ready state and the Ready/Suspend
state, and that at least one process in the Ready/Suspend state has higher scheduling priority than
any of the processes in the Ready state. Two extreme policies are:
1. Always dispatch from a process in the Ready state, to minimize swapping.
2. Always give preference to the highest-priority process, even though that may mean swapping
when swapping is not necessary.
Suggest an intermediate policy that tries to balance the concerns of priority and performance.
4 – Stallings 3.9
In a number of early computers, an interrupt caused the register values to be stored in fixed
locations associated with the given interrupt signal. Under what circumstances is this a practical
technique? Explain why it is inconvenient in general.
2
5 – Stallings 4.7
A multiprocessor with eight processors has 20 attached tape drives. There is a large number of jobs
submitted to the system that each require a maximum of four tape drives to complete execution.
Assume that each job starts running with only three tape drives for a long period before requiring
the fourth tape drive for a short period toward the end of its operation. Also assume an endless
supply of such jobs.
a) Assume the scheduler in the OS will not start a job unless there are four tape drives available.
When a job is started, four drives are assigned immediately and are not released until the
job finishes. What is the maximum number of jobs that can be in progress at once? What
is the maximum and minimum number of tape drives that may be left idle as a result of this
policy?
b) Suggest an alternative policy to improve tape drive utilization and at the same time avoid
system deadlock. What is the maximum number of jobs that can be in progress at once?
What are the bounds on the number of idling tape drives?
6 – Stallings 10.3
Consider the Rate Monotonic scheduling that schedules periodic tasks with priority based on length
of the periods. Short period, high priority and vice versa.
C1 C1 Cn
+ + ... + ≤ n(21/n − 1) (1)
T1 T1 Tn
This problem demonstrates that, although the following equation is a sufficient condition for suc-
cessful scheduling, it is not a necessary condition. Sometimes successful scheduling is possible even
if the equation is not satisfied.
Using rate monotonic scheduling, will all three deadlines be met? What about deadlines for
future repetitions of each task?
7 – Silberschatz 5.6
Consider a variant of the Round Robin (RR) scheduling algorithm in which the entries in the ready
queue are pointers to the PCBs.
a) What would be the effect of putting two pointers to the same process in the ready queue?
b) What would be major advantages and disadvantages of this scheme?
c) How would you modify the basic RR algorithm to achieve the same effect without the dupli-
cate pointers?
3
8 – Silberschatz 5.10
Explain the differences in the degree to which the following scheduling algorithms discriminate in
favor of short processes: