Exercises On Scheduling
Exercises On Scheduling
1. In the figure below, what are two scheduling events that may interrupt a process
and cause it to return directly to the ready queue?
(a) If yes, what are the states in which a process can be while been in the same
CPU burst?
(a) For its next CPU burst, in which queue process P goes after completing the
last 4 units of its current CPU burst time?
5. In which ready queue a multilevel queue scheduling a process P returns once it has
completed its I/O?
1
6. In multilevel scheduling, usually each queue has a different scheduling algorithm.
On the left of the figure below, 3 queues, 2 RR with different quantum time and
a FCFS. Nonetheless, implicitly, queues represent different priorities, inside a same
CPU burst (can you see it). On the contrary, for Solaris, queues have an explicit
priority and different quantum times.
In the Solaris multilevel scheduling, if a process does not complete it CPU burst
inside the quantum time of the queue, does it priorities increases or decreases?
7. If a process P is in queue with priority 25, and its CPU burst is 150 units, in which
queue it goes once it has exhausted the quantum time of queue 25?
8. If a process P is in queue with priority 25, and its CPU burst is 70 units, in which
queue it goes once its I/O is completed?
10. Consider the following set of processes, with the length of the CPU burst time given
in milliseconds
The processes are assumed to have arrived in the order P1 , P2 , P3 , P4 , P5 all at time
0.
(a) Draw four Gantt charts that illustrate the execution of these processes using
the following scheduling algorithms: FCFS, SJF, nonpreemptive priority (a
smaller priority number implies a higher priority), and RR (quantum = 2).
(b) What is the turnaround time of each process for each of the scheduling algo-
rithms in part a?
(c) What is the waiting time of each process for each of these scheduling algo-
rithms?
2
(d) Which of the algorithms results in the minimum average waiting time (over all
processes)?
11. Round Robin (RR) is a scheduling algorithm with one parameter, quantum time.
How would you transform RR into a FCFS scheduling algorithm?
12. Describe the kind of data structure that can be used to implement the ready queue
of a RR scheduling algorithm.
13. Assume a scheduling algorithm brake the tie between two processes having the same
priority by scheduling the process that has been in the ready queue the longest.
What is the name of the basic scheduling algorithm corresponding to this strategy
to brake the ties?
14. Processes that reach the lowest level of a multilevel feedback queues remain in this
queue until they finish, as a consequence this queue tend to run a FCFS scheduling
policy. Can we run a RR instead at the lowest level and what will the advantage of
such policy?
16. Describe the kind of data structure that can be used to implement the ready queue
of a FCFS scheduling algorithm.
17. All the scheduling algorithms we have seen assume that processes are independent
and are competing for a single CPU. What could make these scheduling algorithms
to become obsolete soon?
18. Multilevel feedback queues is a form of priority scheduling algorithm, explain why?
19. What is the relation between the ready queue and level 1 of a multilevel feedback
queues?
20. Assume we have a scheduling algorithm that rise the priority of processes that have
not used much the CPU recently. How this impact the priority I/O processes?
21. Multilevel feedback queues scheduling algorithms may cause some processes to
starve. In which queue(s) starvation is most likely to occur?
22. Under which circumstance(s) processes may starve in multilevel feedback queue:
23. Which kind of processes you have in the lowest level queues of multilevel feedback
queues scheduling algorithms, is it CPU bound or I/O bound processes?
3
24. Replacing FCFS policy in each queue of a multilevel feedback queue by a SJF policy
will impact short CPU burst processes, in which way?
26. Describe the kind of data structure that can be used to implement the ready queue
of a priority based scheduling algorithm.
27. For each sub-question choose a subset of correct answers. For example, in (a), is
{b, c} correct or is {a, b} correct or just {a} is correct or none of them {∅} is correct,
etc.
(a) Possible next states for a process in the Ready state a) New, b) Ready, c)
Running, d) Blocked, e)Terminated
(b) Possible next states for a process in the Running state
a) New, b) Ready, c) Running, d) Blocked, e)Terminated
28. The table below describes a 5 levels feedback queue similar to Solaris feedback queue
for time-sharing and interactive threads, where 0 is the lowest priority. In this table
”Time quantum expired” is the new priority of a process that did not complete its
current CPU burst in the allocated time quantum of the queue, while ”Return from
I/O” is the new priority of a process that enters an I/O phase before the end of the
allocated time quantum of the queue.
4
There is one CPU. The possible states of a process are the following: 1) ready to
execute: ”RY-x” where x is the priority queue in which the process is waiting; 2)
running: ”RU-x” where x is the priority queue in which the process was before been
scheduled to run; 3) waiting in an I/O queue: ”I/O-x” where x refers to the priority
queue in which the process will be placed after completing its I/O; 4) exited: ”EX”
All the processes start in priority queue 2. Arrival times of process P0 is 0, process P1
is 1 and process P2 is 2. The scheduler always empty first the queue of higher priority
before it starts to run processes in the next lower priority queue. The scheduler never
preempts a currently running lower priority process. The tables below describe 3
possible scheduling for the first 20 ms, which one is correct considering the CPU
bursts and I/O bursts of P0 , P1 and P2 .
4 6 14 19
P0 RU-2 I/O-3 RU-3 I/O-2
a)
P1 RY-2 RU-2 RY-0 RU-0
P2 RY-2 RY-2 RY-2 I/O-3
4 6 14 19
P0 RU-2 I/O-0 RY-0 RU-0
b)
P1 RY-2 RU-2 I/O-3 RY-3
P2 RY-2 RY-2 RU-2 RU-2
4 6 14 19
P0 RU-2 I/O-3 RU-3 EX
c)
P1 RY-2 RY-2 RY-0 RY-0
P2 RY-2 RU-2 RY-3 RU-3