Process Scheduling Flashcards
Processor manager
Uses one or more scheduling algorithms to dispatch processes.
Non-preemptive scheduling
Process stays on the CPU until it terminates or blocks for I/O, implements multiprogramming.
Preemptive scheduling
Implements multitasking and can be interrupted and replaced with another process.
Processor Manager Objectives
Maximise throughput
Minimise turnaround time
Minimise waiting time
Maximise CPU efficiency
Minimise latency
Its not possible to have all of these criteria fulfilled at once as they clash with one another, therefore the processor manager tries to ensure fairness.
Burst Time
Time a process takes on the CPU before it blocks or terminates.
Arrival Time
Time a process is first put into the ready state.
First Come First Served
Deals with processes according to their arrival time.
Uses a FIFO order to store ready processes.
When a new process is added, its PCD is added to the back of the ready queue.
FCFS Average Wait Time
The time can change if the biggest one is last, as the biggest time is not considered as part of the equation.
FCFS Advantages and Disadvantages
Advantages:
- Very simply implementation.
- Scheduling overhead is minimal during content switch, since you just get the next one in the ready queue that the pointer points to.
- No starvation of processes, which means they will run eventually.
Disadvantages:
- Throughput can be low due to long processes staying on CPU.
- Average wait time is not minimal.
- Turnaround time and latency are therefore hard to predict.
- No ability to prioritise processes.
If bigger processes went last, speed would increase.
Shortest Job First
When the CPU becomes free, the scheduler will choose the process with the shortest burst time. If two are the same, we just choose by arrival time. Similar to FCFS, it stays there until terminated.
SJF Average Wait Time
The average wait time will be shorter than FCFS, because it does the minimal one first.
SJF Advantages and Disadvantages
Advantages:
- Reduces overall average wait time.
- Probably optimal in giving AWT for given (average wait time) processes.
Disadvantages:
- Can lead to process starvation, could lead to starving the OS.
- Difficult to estimate burst times for new processes, since it relies on prior history.
Shortest Remaining Time First
Instead of looking at burst time, it simply just looks at how long it has left to process. So whatever is on the CPU can be taken off before it finishes, and whatever has a shorter remaining time until it terminates or it is blocked. This is very hard to calculate, and therefore it is hard to draw a Gaant chart for.
SRTF Advantages and Disadvantages
Advantages:
- Short processes are handled very quickly.
- Gives maximum throughput in most situations.
- Requires little overhead during context switch.
Disadvantages:
- Starvation is still possible.
- Introduces extra context switches.
- Waiting time can increase for longer processes.
Throughput
-> get through x amount of processes in y amount of time.