Lecture 7 Flashcards
Scheduling Algorithms
- First Come, First Served
- Shortest Job First
- Priority
- Round Robin
- Multilevel Queues
First Come, First Served (FCFS)
Processes are executed in the order they arrive
Convey Effect
Short processes wait for one long process to get off CPU
Shortest Job First (SJF)
Processes with the shortest time (burst time + arrival time)
-Provably optimal
Burst Length Prediction
Use exponential average: Tau_(n+1) = alpha*t_n + (1-alpha)Tau_n - Tau is the predicted burst time - t is the actual burst length Raise (1-alpha) to higher powers to assign smaller weights to older values
Shortest Remaining Time First (SRTF)
Accounting for arrival time and burst time, execute the process with the shortest remaining time, sometimes interrupt processes if a shorter process arrives
Priority Scheduling
- A priority integer is associated with each process
- CPU is allocated to process with highest priority
- If priority is inverse of CPU burst length, it’s SJF
Problem with priority scheduling
- Starvation (low priority processes may never execute)
- Solution is dynamic priority change
Aging
- Increasing the priority of a process as it waits
Round Robin Scheduling
- Each process gets a small unit of CPU time (time quantum q) usually 10-100 msec
- After q elapses, the process is preempted and added to the end of the ready queue
- Ready queue is a circular queue
- Typically higher average turnaround time than SJF but better response time
- If q is large, it’s basically just FCFS
- If q is small, then the overhead is really high
Time Quantum Rule of Thumb
Time quantum should be longer than 80% of CPU bursts
Multilevel Queue Scheduling
- Ready queue is partitioned into multiple queues
- Each has its own scheduling algorithm
- Scheduling is needed among queue
Multilevel Feedback Queue Scheduling
- A process can move between various queues
- Dynamic priority change
- Process using too much CPU can be moved lower
MQS needs to define…
- Number of queues
- Scheduling algorithm for each queue
- Method to move process up/down in queues
- Start queue for each process
Multiprocessors
- Multiple CPUs
- Each CPU has many components (caches, data/instructions, decoders, execution units, etc)