30.07.2015 Views

CS4023 Week06 Tutorial Solutions

CS4023 Week06 Tutorial Solutions

CS4023 Week06 Tutorial Solutions

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>CS4023</strong><strong>Week06</strong> <strong>Tutorial</strong> <strong>Solutions</strong>The following questions are taken from the exercises at the end of Chapter 5 ofSGG (ed. 8)1. Suppose that a scheduling algorithm (at the level of the short-term CPUscheduling) favours those processes that have used the least processor timein the recent past. Why will this algorithm favour I/O-bound programsand yet not permanently starve CPU-bound programs? (Q5.6)Answer: It will favour the I/O-bound programs because of the relativelyshort CPU burst request by them; however, the CPU-bound programswill not starve because the I/O-bound programs will relinquish the CPUrelatively often to do their I/O.2. Why is it important for the scheduler to distinguish I/O-bound programsfrom CPU-bound programs. (Q5.9)Answer: I/O-bound programs have the property of performing only asmall amount of computation before performing I/O. Such programs typicallydo not use up their entire CPU quantum. CPU-bound programs, onthe other hand, use their entire quantum without performing any blockingI/O operations. Consequently, one could make better use of the computer’sresouces by giving higher priority to I/O-bound programs andallow them to execute ahead of the CPU-bound programs.3. Discuss how the following pairs of scheduling criteria conflict in certainsettings.(a) CPU utilization and response time(b) Average turnaround time and maximum waiting time(c) I/O device utilization and CPU utilization(Q5.10)Answer:(a) CPU utilization and response time: CPU utilization is increased ifthe overheads associated with context switching is minimized. Thecontext switching overheads could be lowered by performing contextswitches infrequently. This could, however, result in increasing theresponse time for processes.(b) Average turnaround time and maximum waiting time: Average turnaroundtime is minimized by executing the shortest tasks first. Such ascheduling policy could, however, starve long-running tasks and therebyincrease their waiting time.1


(c) I/O device utilization and CPU utilization: CPU utilization is maximizedby running long-running CPU-bound tasks without performingcontext switches. I/O device utilization is maximized by schedulingI/O-bound jobs as soon as they become ready to run, thereby incurringthe overheads of context switches.4. Consider a preemptive priority scheduling algorithm based on dynamicallychanging priorities. Larger priority numbers imply higher priority. Whena process is waiting for the CPU (in the ready queue, but not running), itspriority 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 schedulingalgorithms. What are the algorithms that result from the following?(a) β > α > 0(b) α < β < 0(Q5.17)Answer: First case is FCFS; second case is LIFO (last in, first out).2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!