0% found this document useful (0 votes)
22 views

Exercises On Scheduling

Uploaded by

Huy Đặng
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Exercises On Scheduling

Uploaded by

Huy Đặng
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Some 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?

2. Can a process change states inside a same CPU burst?

(a) If yes, what are the states in which a process can be while been in the same
CPU burst?

3. If process P is executing a CPU burst of 12 units of time, in which ready queue


process P goes once it is de-scheduled by the RR that has a quantum time of 8 units
of time as in the first queue of the figure below?

(a) For its next CPU burst, in which queue process P goes after completing the
last 4 units of its current CPU burst time?

4. Given a multilevel queue scheduling, in which queue a process P goes if it performs


an I/O after executing for 6 units of 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?

9. If a process is given a fixed priority, can it be scheduled in a multilevel feedback


queue?

10. Consider the following set of processes, with the length of the CPU burst time given
in milliseconds

Processes Burst Time Priority


P1 10 3
P2 5 1
P3 6 2
P4 3 4
P5 8 2

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?

15. What is the relationship between FCFS and FIFO?

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:

(a) Most processes are in some I/O queue


(b) Few processes are running in the system
(c) Many processes are active (heavy load) with several highly CPU bound pro-
cesses

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?

25. RR is costly in terms of context switches. Assume we change slightly the RR


scheduling policy such that when the remaining execution time of a process is less
1.5 the quantum time, then the process is allowed to execute until completion. Will
this reduce the number of context switches? Which kind of processes are likely to
benefit from this policy in terms of turnaround and waiting time, cpu bound or I/O
bound processes?

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.

Priority Quantum time Time quantum Return from I/O


expired
0 10 0 2
1 8 0 2
2 6 0 3
3 4 1 4
4 2 1 4

We have 3 processes P0 , P1 and P2 which have execution cycles as described below.


For example, the arrival time of P0 is 0, its first CPU burst last 5ms, then enters
into an I/O queue for 3ms, then a CPU burst of 5ms, an I/O of 4ms, CPU burst of
4ms and then exit.
P0 CPU I/O CPU I/O CPU exit P1 CPU I/O CPU exit
0 5 3 5 4 4 1 8 4 4

P2 CPU I/O CPU exit


2 2 6 2

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

Time line of the processes states for the first 20ms:


0-4 5-7 8-10 11-14 15-16 17 18-21 1-4 5-10 11-17 18-19
P0 RU-2 I/O-3 RY-3 RU-3 RY-1 RU-1 I/O-2 P1 RY-2 RU-2 RY-0 RU-0

2-14 15-16 17-23


P2 RY-2 RU-2 I/O-3

You might also like