• Home
  • Textbooks
  • Operating System Concepts Essentials
  • CPU Scheduling

Operating System Concepts Essentials

Abraham Silberschatz, Peter B. Galvin, Greg Gagne

Chapter 5

CPU Scheduling - all with Video Answers

Educators


Chapter Questions

01:08

Problem 1

A CPU-scheduling algorithm determines an order for the execution of its scheduled processes. Given $n$ processes to be scheduled on one Practice Exercises $\quad \mathbf{2 1 1}$
processor, how many different schedules are possible? Give a formula in terms of $n$.

Breanna Ollech
Breanna Ollech
Numerade Educator

Problem 2

Explain the difference between preemptive and nonpreemptive scheduling.

Check back soon!

Problem 3

Suppose that the following processes arrive for execution at the times indicated. Each process will run for the amount of time listed. In answering the questions, use nonpreemptive scheduling and base all decisions on the information you have at the time the decision must be made.
$$
\begin{array}{cccc}
\text { Process } & & \text { Arrival Time } & \text { Burst Time } \\
{} P_1 & & 0.0 & \\
P_2 & & 0.4 & 4 \\
P_3 & & 1.0 & 1
\end{array}
$$
a. What is the average turnaround time for these processes with the FCFS scheduling algorithm?
b. What is the average turnaround time for these processes with the SJF scheduling algorithm?
c. The SJF algorithm is supposed to improve performance, but notice that we chose to run process $P_1$ at time 0 because we did not know that two shorter processes would arrive soon. Compute what the average turnaround time will be if the CPU is left idle for the first 1 unit and then SJF scheduling is used. Remember that processes $P_1$ and $P_2$ are waiting during this idle time, so their waiting time may increase. This algorithm could be known as future-knowledge scheduling.

Check back soon!
03:04

Problem 4

What advantage is there in having different time-quantum sizes at different levels of a multilevel queueing system?

Guilherme Barros
Guilherme Barros
Numerade Educator

Problem 5

Many CPU-scheduling algorithms are parameterized. For example, the RR algorithm requires a parameter to indicate the time slice. Multilevel feedback queues require parameters to define the number of queues, the scheduling algorithm for each queue, the criteria used to move processes between queues, and so on.
These algorithms are thus really sets of algorithms (for example, the set of RR algorithms for all time slices, and so on). One set of algorithms may include another (for example, the FCFS algorithm is the RR algorithm with an infinite time quantum). What (if any) relation holds between the following pairs of algorithm sets?
a. Priority and SJF
b. Multilevel feedback queues and FCFS
c. Priority and FCFS
d. RR and SJF

Check back soon!
01:29

Problem 6

Suppose that a scheduling algorithm (at the level of short-term CPU scheduling) favors those processes that have used the least processor time in the recent past. Why will this algorithm favor 1/O-bound programs and yet not permanently starve CPU-bound programs?

Adam Conner
Adam Conner
Numerade Educator

Problem 7

Distinguish between PCS and SCS scheduling.

Check back soon!

Problem 8

Assume that an operating system maps user-level threads to the kernel using the many-to-many model and that the mapping is done through the use of LWPs. Furthermore, the system allows program developers to create real-time threads. Is it necessary to bind a real-time thread to an LWP?

Check back soon!
01:29

Problem 9

Why is it important for the scheduler to distinguish $1 / \mathrm{O}-$ bound programs from CPU-bound programs?

Adam Conner
Adam Conner
Numerade Educator

Problem 10

Discuss how the following pairs of scheduling criteria conflict in certain settings.
a. CPU utilization and response time
b. Average turnaround time and maximum waiting time
c. 1/O device utilization and CPU utilization

Check back soon!
11:24

Problem 11

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. $\alpha=0$ and $\tau_0=100$ milliseconds
b. $\alpha=0.99$ and $\tau_0=10$ milliseconds

Prakash Hampole
Prakash Hampole
Numerade Educator

Problem 12

Consider the following set of processes, with the length of the CPU burst given in milliseconds:
$$
\begin{array}{|c|c|c|}
\hline \text { Process } & \text { Burst Time } & \text { Priority } \\
\hline P_1 & 10 & 3 \\
\hline P_2 & 1 & 1 \\
\hline P_3 & 2 & 3 \\
\hline P_4 & 1 & 4 \\
\hline P_5 & 5 & 2 \\
\hline
\end{array}
$$
The processes are assumed to have arrived in the order $P_1, P_2, P_3, P_4, P_5$, 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 = 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 these scheduling algorithms?
d. Which of the algorithms results in the minimum average waiting time (over all processes)?

Check back soon!
01:29

Problem 13

Which of the following scheduling algorithms could result in starvation?
a. First-come, first-served
b. Shortest job first
c. Round robin
d. Priority

James Kiss
James Kiss
Numerade Educator
04:49

Problem 14

Consider a variant of the 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 two major advantages and two disadvantages of this scheme?
c. How would you modify the basic RR algorithm to achieve the same effect without the duplicate pointers?

Kris Bright
Kris Bright
Numerade Educator
01:31

Problem 15

Consider a system running ten 1/O-bound tasks and one CPU-bound task. Assume that the $1 / 0$-bound tasks issue an $1 / \mathrm{O}$ operation once for every millisecond of CPU computing and that each I/O operation takes 10 milliseconds to complete. Also assume that the context-switching overhead is 0.1 millisecond and that all processes are long-running tasks. Describe the CPU utilization for a round-robin scheduler when:
a. The time quantum is 1 millisecond
b. The time quantum is 10 milliseconds

James Kiss
James Kiss
Numerade Educator

Problem 16

Consider a system implementing multilevel queue scheduling. What strategy can a computer user employ to maximize the amount of CPU time allocated to the user's process?

Check back soon!

Problem 17

Consider a preemptive priority scheduling algorithm based on dynamically changing priorities. Larger priority numbers imply higher priority. When a process is waiting for the CPU (in the ready queue, but not running), its priority changes at a rate $\alpha$; when it is running, its priority changes at a rate $\beta$. All processes are given a priority of 0 when they enter the ready queue. The parameters $\alpha$ and $\beta$ can be set to give many different scheduling algorithms.
a. What is the algorithm that results from $\beta>\alpha>0$ ?
b. What is the algorithm that results from $\alpha<\beta<0$ ?

Check back soon!
01:29

Problem 18

Explain the differences in how much the following scheduling algorithms discriminate in favor of short processes:
a. FCFS
b. RR
c. Multilevel feedback queues

James Kiss
James Kiss
Numerade Educator
01:22

Problem 19

Using the Windows scheduling algorithm, determine the numeric priority of each of the following threads.
a. A thread in the REALTIME_PRIORITY_CL_ASS with a relative priority of HIGHEST
b. A thread in the NORMAL_PRIORITY_CLASS with a relative priority of NORMAL
c. A thread in the HIGH PRIORITY_CLASS with a relative priority of ABOVE_NORMAL

James Kiss
James Kiss
Numerade Educator

Problem 20

Consider the scheduling algorithm in the Solaris operating system for time-sharing threads.
a. What is the time quantum (in milliseconds) for a thread with priority 10 ? With priority 55 ?
b. Assume that a thread with priority 35 has used its entire time quantum without blocking. What new priority will the scheduler assign this thread?
c. Assume that a thread with priority 35 blocks for $1 / O$ before its time quantum has expired. What new priority will the scheduler assign this thread?

Check back soon!

Problem 21

The traditional UNIX scheduler enforces an inverse relationship between priority numbers and priorities: the higher the number, the lower the priority. The scheduler recalculates process priorities once per second using the following function:
$$
\text { Priority }=(\text { recent CPU usage } / 2)+\text { base }
$$
where base $=60$ and recent $C P U$ usage refers to a value indicating how often a process has used the CPU since priorities were last recalculated.
Assume that recent CPU usage for process $P_1$ is 40 , for process $P_2$ is 18 , and for process $P_3$ is 10 . What will be the new priorities for these three processes when priorities are recalculated? Based on this information, does the traditional UNIX scheduler raise or lower the relative priority of a CPU-bound process?

Check back soon!