Scheduling Flashcards
What does the dispatcher do
it performs the actual process switch (mechanism)
- saving/restoring process context
-switching to user mode
What does CPU scheduler do?
It selects the next process to run (policy)
-schedulers try to meet goals, provide fairness and adhere to priorities
What are the two types of schedulers?
- Short-term Scheduler: selects which process should be executed next and allocates CPU, it is invoked frequently
- Long-term Scheduler: selects which processes should be brought into the ready queue, it is invoked infrequently, it controls the degree of multiprogramming
enumerate three different process scheduling queues
- Job queue: Set of all processes in the system
- Ready queue: Processes in main memory, state: ready and waiting
- Device queues: Process waiting for an I/O device
Explain the following terms:
Throughput
Turnaround time
Response time
Waiting time
Throughput: # of processes that complete per time unit
Turnaround time: time from submission to completion of a job
Response time: Time from request to first response (first time it is dispatched)
Waiting time: time each process waits in the ready queue
First-Come First-Served
Schedule the processes in the order of arrival
-prone to Convoy effect (a process with high burst time makes a process with lower burst time to wait until it’s completion)
=> Average turnaround time depends on arrival in queue
Shortest Job First
- has optimal average turnaround, waiting and response times
- challenge: can’t know job lengths in advance
- solution: predict length of next CPU burst for each process -> schedule the process with the shortest burst next
Preemptive Shortest Job First
Idea: SJF, but preempt periodically to make a new scheduling decision; at each time slice schedule job with the shortest remaining time next
Round Robin
Idea: each process runs for a small unit of CPU time
preempt processes that haven’t blocked by the end of the time slice
append current thread to end of run queue, run next thread
time slice length needs to balance interactivity and overhead
Virtual Round Robin
RR is unfair for I/O bound jobs, they block before they use up their entire quantum
Idea: Put jobs that didn’t use up their quantum into an additional queue
Priority scheduling
Associate priority number with each process
Strict priority scheduling: processes with low priorities never execute if there is always a process runnable with a higher priority => starvation
Multi-level Feedback Queue
Goals: give higher priority to I/O-bound jobs, give low priority to CPU-bound jobs, but run them for longer at a time
Idea: Different queues with different priorities and time slice lengths
Priority Donation
Problem: process B may wait for result of process A (A has lower priority than B)
Solution: Give priority of B as long as B waits for a
Lottery scheduling
Issue number of lottery tickets to processes
- more tickets for processes with higher priority
-amount of tickets controls average proportion of CPU for each process
What is the purpose of scheduling
To find a mapping of processes to resources, so that each process will eventually get the resources it needs.