Chapter2.3-CPU Sched - Qeuestion
Chapter2.3-CPU Sched - Qeuestion
1 A CPU-scheduling algorithm determines an order for the execution of its scheduled processes.
Given n processes to be scheduled on one processor, how many different schedules are possible?
Give a formula in terms of n.
DA: n!
2 Explain the difference between preemptive and nonpreemptive scheduling.
DA:
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
P1 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 P1 and P2 are waiting during this idle time, so their
waiting time may increase. This algorithm could be called future-knowledge scheduling.
4 What advantage is there in having different time-quantum sizes at different levels of a multilevel
queueing system?
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 algorithmfor each queue, the criteria used tomove 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 algorithmis the RR algorithm with an infinite time quantum).What (if any)
relation holds between the following pairs of algorithm sets?
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
I/O-bound programs and yet not permanently starve CPU-bound programs?
It will favor the I/O bound programs because of the relatively short CPU burst
request by them; however, the CPU-bound programs will not starve because the
I/O-bound programs will relinquish the CPU relatively often to do their I/O.
7 Distinguish between PCS and SCS scheduling.
9 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:
Priority = (recent CPU usage / 2) + base
where base = 60 and recent CPU usage refers to a value indicating how often a process has used the
CPU since priorities were last recalculated.
Assume that recent CPU usage is 40 for process P1, 18 for process P2, and 10 for process P3. 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?
10 Why is it important for the scheduler to distinguish I/O-bound programs from CPU-bound
programs?
17 The following processes are being scheduled using a preemptive, round-robin scheduling algorithm.
Each process is assigned a numerical priority, with a higher number indicating a higher relative priority.
In addition to the processes listed below, the system also has an idle task (which consumes no CPU
resources and is identified as Pidle ). This task has priority 0 and is scheduled whenever the system has no
other available processes to run. The length of a time quantum is 10 units. If a process is preempted by a
higher-priority process, the preempted process is placed at the end of the queue.