CPU SCHEDULING

the CPU scheduling mechanism is the ready queue and clock interrupts

the CPU scheduling policy is determined by parameters input by the system administrator and the policy is implemented by the mechanism

definition of process: executing program including its current state

general process state: running, ready, blocked, suspended, exited/aborted

complete process state is above plus: current CPU register values, current RAM contents (data, heap, stack), files read and written and what read or written in them,

possible state transitions (draw state transition directed graph)

note the only way to enter the running state is from the ready state first

CPU scheduling policy issues (things that affect choice of policy)

foreground is usually interactive job, batch jobs should be run in the background at a lower priority

IO bound is usually interactive job or lots of file copying in a batch job or lots of network use in a server

CPU bound is like multiplying matrices or computing large prime numbers

the CPU scheduling policy comes into play when

voluntary release only policy, also called non-preemptive: a running process keeps the CPU until it blocks on IO or exits/aborts or yields the CPU or suspends itself (equivalent to infinite MAX_TICKS_ALLOWED)

involuntary release policy, also called preemptive: a running process might lose the CPU at other times, too, for example MAX_TICKS_ALLOWED = 7 and a CPU bound process running

policy goals

the throughput, turnaround, and response goals are in conflict

some non-preemptive CPU scheduling policies with unrealistic assumptions of knowing all running times in advance, all jobs CPU-bound, and no new jobs appear

some preemptive CPU scheduling policies

general guideline is to give IO bound jobs priority by linking them into the front of the ready queue when they become ready instead of the rear

general guideline: use multiple ready queues to implement priorities (batch versus interactive, foreground versus background, president versus provost versus dean versus faculty versus student)

round robin, i.e., MAX_TICKS_ALLOWED < infinity

SRTN: preemptive version of SJF assuming new jobs can arrive at any time but still unrealistic assumption of knowing all running times in advance

OS must not allow starvation to occur: jobs in a lower priority queue never get any CPU time because the higher priority queue(s) are never empty

analogy: grocery store shopping carts in a checkout line

analogy for RR: tabbed browser loading multiple Web pages simultaneously through a fixed bandwidth Internet connection, where each Web page has a different byte count (proportional to time to download)

pick six random numbers between 1 and 500 and calculate average completion times for FCFS, SJN, and RR

Other CPU scheduling algorithms in the text book: for batch systems three-level scheduling; for interactive systems guaranteed scheduling, lottery scheduling, fair-share scheduling.


home page: http://elvis.rowan.edu/~hartley/index.html
e-mail: hartley@elvis.rowan.edu