Lecture 10 - Scheduling
We talked a lot about running along until we block, then pick who gets to run, but how is this done?
Process States
Remember at any time we have one of 3 process states:
- Running
- Blocked
- Ready
We have the difference between a policy and a mechanism:
- policy: How we want things to behave (graduate students should finish within 7 years)
- mechanism: How we're going to make it happen (cut off funding vs. throwing them out)
Process Types
There's two types of process types:
- IO Bound: characterized by short bursts of computation before blocking IO
- Might want to give priority because they can get done and go back to sleep (hide IO latency)
- Also, more likely to be interactive
- Compute Bound: characterized by long bursts of computation before blocking on IO (or a semaphore).
Scheduling is mandatory in two cases:
- When a process exits
- When a process blocks
Scheduling Criteria
It might be desirable under a few other conditions:
- When a new process is created
- When an IO interrupt occurs
- When a timer interrupt occurs
What makes a good algorithm?
-
fairness: make sure each process can get its fair share
-
efficiency/utilization: keep the CPU busy as close to 100% of the time (don't have busy waits)
-
response time: minimize response time for interactive users
-
turnaround: minimize turnaround time for batch users.
-
throughput: maximize the number of jobs processed per time
Examples of Non-Preemptive Scheduling
For instance FCFS; first-come-first served. You do the shortest job first:
- provably optimal
- Problem: Starvation
This is the bubble-sort method of organizing jobs.
Another example is round-robin.