Process A program in execution But What does

Process A program in execution

But, What does it mean to be “in execution”?

Process States New Admitted Exit Terminated Interrupt Ready Running Scheduler Dispatch I/O or Event Completion Waiting I/O or Event Wait

What to keep track of?

Process Control Block Process Number Program Counter Registers Scheduling Info Memory Limits I/O Status Info Accounting Info

Process Scheduling n n Choose processes for execution (ready Q) Decide which process goes from ready to running

Context Switch n Change “running” process n n n 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 n Short term n n n CPU Scheduler Selects from ready Q Runs every few milliseconds Must be quick/small Long term scheduler n n n Controls degree of multiprogramming Balance CPU-bound, I/O-bound processes Decide what goes into ready Q?

Scheduling Algorithms n Metrics n n n CPU utilization (%) Throughput – jobs completed/time Turnaround time n n Waiting time n n Submission to completion Time in ready queue Response time n Interactive systems

Scheduling Algorithms n n n First-Come, First-Served Shortest-Job-First Priority Round-Robin Multilevel Queue

First-Come, First-Served n Non-preemptive n n n Process must voluntarily relinquish by terminating or by making a system call Intrinsic priority: Arrival time Expected performance ? Limitations ? Benefits ?

Shortest-Job-First n n n Non-preemptive Better response for short jobs Provably optimal n n min avg. waiting time for a pool of jobs Disadvantage(s) ?

Priority n Associate priority with each process n n One queue for each priority level FCFS within each level n Problem(s) with priority? n SJF is special case

Priority n n Starvation possible Solution? n n n Increase priority with “age” Implement aging ? Nice (Unix)

Round-Robin n n Preemptive Process “runs” time-slice (q) units FCFS special case of RR (q = infinity) Time sharing n n n Each process “executes” at speed 1/n. q = ? ? ? Balance q with context switch time

Multilevel Queues n Partition Ready Queue n Each Q has own schedule method n n E. g. foreground (interactive, RR) and background (batch, FCFS) queues Approaches n n Higher queues have absolute priority over lower level queues OR Time slice among queues

Evaluation n Modeling n n n Simulation n Deterministic - Requires exact numbers Queueing - Uses distribution of bursts Create software models of systems. Lots of work, time consuming Actual implementation & test n n Cost May change behavior
- Slides: 17