CPU Scheduling: Exercises
CPU Scheduling: Exercises
CPU Scheduling: Exercises
CHAPTER
5
Scheduling
Exercises
5.11 Of these two types of programs:
a. I/O-bound
b. CPU-bound
5.14 Most scheduling algorithms maintain a run queue, which lists processes
eligible to run on a processor. On multicore systems, there are two
general options: (1) each processing core has its own run queue, or
(2) a single run queue is shared by all processing cores. What are the
advantages and disadvantages of each of these approaches?
19
20 Chapter 5 CPU Scheduling
5.15 Consider the exponential average formula used to predict the length of
the next CPU burst. What are the implications of assigning the following
values to the parameters used by the algorithm?
a. α = 0 and τ0 = 100 milliseconds
b. α = 0.99 and τ0 = 10 milliseconds
5.16 A variation of the round-robin scheduler is the regressive round-robin
scheduler. This scheduler assigns each process a time quantum and a
priority. The initial value of a time quantum is 50 milliseconds. However,
every time a process has been allocated the CPU and uses its entire time
quantum (does not block for I/O), 10 milliseconds is added to its time
quantum, and its priority level is boosted. (The time quantum for a
process can be increased to a maximum of 100 milliseconds.) When a
process blocks before using its entire time quantum, its time quantum is
reduced by 5 milliseconds, but its priority remains the same. What type
of process (CPU-bound or I/O-bound) does the regressive round-robin
scheduler favor? Explain.
5.17 Consider the following set of processes, with the length of the CPU burst
given in milliseconds:
Process Burst Time Priority
P1 5 4
P2 3 1
P3 1 2
P4 7 2
P5 4 3
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 pro-
cesses using the following scheduling algorithms: FCFS, SJF, non-
preemptive priority (a larger priority number implies a higher
priority), and RR (quantum = 2).
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 these schedul-
ing algorithms?
d. Which of the algorithms results in the minimum average waiting
time (over all processes)?
5.18 The following processes are being scheduled using a preemptive,
Each process is assigned a numerical priority, with a higher number indi-
priority-based, round-robin scheduling algorithm.
cating a higher relative priority. The scheduler will execute the highest-
priority process. For processes with the same priority, a round-robin
scheduler will be used with a time quantum of 10 units. If a process is
preempted by a higher-priority process, the preempted process is placed
at the end of the queue.
a. Show the scheduling order of the processes using a Gantt chart.
Exercises 21
When a process is waiting for the CPU (in the ready queue, but not run-
ning), its priority changes at a rate α. When it is running, its priority
changes at a rate β. All processes are given a priority of 0 when they
enter the ready queue. The parameters α and β can be set to give many
different scheduling algorithms.
a. What is the algorithm that results from β > α > 0?
b. What is the algorithm that results from α < β < 0?
5.25 Explain the how the following scheduling algorithms discriminate either
in favor of or against short processes:
a. FCFS
b. RR
c. Multilevel feedback queues
5.26 Describe why a shared ready queue might suffer from performance
problems in an SMP environment.
5.27 Consider a load-balancing algorithm that ensures that each queue has
approximately the same number of threads, independent of priority.
How effectively would a priority-based scheduling algorithm handle
this situation if one run queue had all high-priority threads and a second
queue had all low-priority threads?
5.28 Assume that an SMP system has private, per-processor run queues.
When a new process is created, it can be placed in either the same queue
as the parent process or a separate queue.
a. What are the benefits of placing the new process in the same queue
as its parent?
b. What are the benefits of placing the new process in a different
queue?
5.29 Assume that a thread has blocked for network I/O and is eligible to
run again. Describe why a NUMA-aware scheduling algorithm should
reschedule the thread on the same CPU on which it previously ran.
5.30 Using the Windows scheduling algorithm, determine the numeric pri-
ority of each of the following threads.
a. A thread in the REALTIME PRIORITY CLASS with a relative priority
of NORMAL
b. A thread in the ABOVE NORMAL PRIORITY CLASS with a relative
priority of HIGHEST
c. A thread in the BELOW NORMAL PRIORITY CLASS with a relative
priority of ABOVE NORMAL
5.31 Assuming that no threads belong to the REALTIME PRIORITY CLASS and
that none may be assigned a TIME CRITICAL priority, what combination
Exercises 23
5.33 Assume that two tasks, A and B, are running on a Linux system. The nice
values of A and B are −5 and +5, respectively. Using the CFS scheduler as
a guide, describe how the respective values of vruntime vary between
the two processes given each of the following scenarios:
• Both A and B are CPU-bound.
• A is I/O-bound, and B is CPU-bound.
• A is CPU-bound, and B is I/O-bound.
5.34 Provide a specific circumstance that illustrates where rate-monotonic
scheduling is inferior to earliest-deadline-first scheduling in meeting
real-time process deadlines?
24 Chapter 5 CPU Scheduling
5.35 Consider two processes, P1 and P2 , where p1 = 50, t1 = 25, p2 = 75, and
t2 = 30.
a. Can these two processes be scheduled using rate-monotonic
scheduling? Illustrate your answer using a Gantt chart such as the
ones in Figure 5.21–Figure 5.24.
b. Illustrate the scheduling of these two processes using earliest-
deadline-first (EDF) scheduling.
Exercises 25
5.36 Explain why interrupt and dispatch latency times must be bounded in a
hard real-time system.
5.37 Describe the advantages of using heterogeneous multiprocessing in a
mobile system.