Process A program in execution
But, What does it mean to be “in execution”?
Process States New ReadyRunning Terminated Waiting Admitted Exit I/O or Event Completion Scheduler Dispatch I/O or Event Wait Interrupt
What to keep track of?
Process Control Block Process Number Program Counter I/O Status Info Registers Memory Limits Accounting Info Scheduling Info
Process Scheduling Choose processes for execution (ready Q) Decide which process goes from ready to running
Context Switch Change “running” process Move info from running job to PCB? Move info for new job from PCB into registers, PC etc. Typical time about 1 sec
Types of Schedulers Short term CPU Scheduler Selects from ready Q Runs every few milliseconds Must be quick/small Long term scheduler Controls degree of multiprogramming Balance CPU-bound, I/O-bound processes Decide what goes into ready Q?
Scheduling Algorithms Metrics CPU utilization (%) Throughput – jobs completed/time Turnaround time Submission to completion Waiting time Time in ready queue Response time Interactive systems
Scheduling Algorithms First-Come, First-Served Shortest-Job-First Priority Round-Robin Multilevel Queue
First-Come, First-Served Non-preemptive Process must voluntarily relinquish by terminating or by making a system call Intrinsic priority: Arrival time Expected performance ? Limitations ? Benefits ?
Shortest-Job-First Non-preemptive Better response for short jobs Provably optimal min avg. waiting time for a pool of jobs Disadvantage(s) ?
Priority Associate priority with each process One queue for each priority level FCFS within each level Problem(s) with priority? SJF is special case
Priority Starvation possible Solution? Increase priority with “age” Implement aging ? Nice (Unix)
Round-Robin Preemptive Process “runs” time-slice (q) units FCFS special case of RR (q = infinity) Time sharing Each process “executes” at speed 1/n. q = ??? Balance q with context switch time
Multilevel Queues Partition Ready Queue Each Q has own schedule method E.g. foreground (interactive, RR) and background (batch, FCFS) queues Approaches Higher queues have absolute priority over lower level queues OR Time slice among queues
Evaluation Modeling Deterministic - Requires exact numbers Queueing - Uses distribution of bursts Simulation Create software models of systems. Lots of work, time consuming Actual implementation & test Cost May change behavior