Lecture 7: CPU Scheduling 1 Flashcards
Process States: New
Process is being created
Process States: Running
Instructions are being executed
Process States: Waiting
Process is waiting for some event to occur
Process States: Ready
Process is waiting to be assigned the CPU
Process States: Terminated
Process has finished execution
One processor → one process running at a time
- All other processers wait for CPU to be free
* Often running process does need CPU (e.g., I/O requests)
Multi programming goal: avoid CPU idle times → some
process is using the CPU all the time
- Keep multiple processes in memory at one time
- When one process has to wait the CPU is allocated to another process
- Scheduling algorithms: decide which process goes into the CPU
CPU (Short-Term) Scheduler:
- first example of resource manager(manages sharing of CPU)
- applicable to either multiprocessing or multi-threading (we’ll assume former)
- What? A kernel process that is always active (daemon)
- responsible for choosing process to run from ready queue
When Does the Scheduler Get Invoked?
- When there’s an interrupt
• from timer: moves process from running to ready state
• upon I/O interrupt: moves process from wait to ready state - When running process terminates
- When running process issues an I/O request (block) and moves to wait state
Non-Preemptive:
Processes only give up CPU voluntarily
• simpler to implement (no timer interrupts)
• greedy or buggy process can starve others
Preemptive:
Processes also may be preempted by an interrupt
• adds complexity
• adds protection, better at ensuring fairness, as well as
doing better in other scheduling metrics
Throughput:
Measured in # processes completed / time unit
Number of processes that complete execution per time unit (Good = High)
Turnaround Time:
Average (time of completion –time of creation)
- Related metric: Waiting Time (average time on ready queue)
- Waiting vs Turnaround: no penalty for processes w/ long processing times
(Turnaround Time = Processing /Blocked Time + Waiting Time)
Response Time:
Time of 1st response is produced–time of creation
Overhead:
Time spent related to scheduling (e.g., context switch time)