CPU Scheduling Flashcards
What is a burst cycle?
CPU does not work continuously. It computes in bursts, before waiting for a I/O burst. The distribution of these bursts, is the main concern of the OS.
Do most processes use short CPU bursts or longer bursts?
Most OS processes are interactive, therefore spend the majority of their time waiting for I/O, interleaved with short bursts of computation.
Which two state transition scenarios doesn’t require any decisions from the scheduler?
From running to wait state, and process termination.
What is the difference between pre-emptive and co- operating scheduling?
Pre-emptive is when OS interrupts process while it is running. This leads to race conditions. Co-operative scheduling means the process releases CPU when it doesn’t need it anymore.
Why is pre-emptive scheduling preferred?
CPU is most valuable resource. OS should keep control over how it used.
What does the dispatcher do?
It does a context switch. Save current process info to its PCB, and move in PCB of new process. It may have to switch hardware from user to kernel mode or vice versa. may also have to jump to the correct location in the current program instructions.
What is the dispatch latency?
The time it takes for the dispatcher to do a context switch.
What is the CPU utilization criteria?
Keep the CPU as busy as possible
What is throughput?
How many process finish execution in a given time unit
What is turnaround time?
The amount of time it takes to execute a process from creation to termination.
What is waiting time?
How long a process spends in ready queue.
What is response time?
How long it takes from request submission till first response.
Explain FCFS.
First Come First Serve. Non-preempitive. CPU is allocated to whichever process comes first, and the process is allowed to run till it terminates.
Advantages of FCFS?
Minimal context-switches (only when process is finished). scheduler doesn’t have to make any decisions so time saved.
Disadvantages of FCFS?
Convoy Effect. If computationally intensive process comes first, then all other processes has to wait till it finishes. Severely decreases response time. Affects interactivity.
Explain Round Robin
Preemptive version of FCFS. Processes are switched after time slice in the order they came in.
Explain Round Robin
Pre-emptive version of FCFS. Processes are switched after time slice in the order they came in.
How does time slice length affect RR.
Context switches are expensive. Short time slice results in more switches decreasing CPU utilisation. Longer slice increases throughput, but will get closer and closer to FCFS.
Disadvantages of RR
processes are not prioritised. Higher priority processes will have to wait for lower priority.
Explain SJF.
Shortest Job First. Most optimal algorithm, however it is impossible to calculate process CPU burst. Can be estimated based on how long it took last time, but not very accurate.
Is there a pre-emptive version of SJF?
Yes. We also need to know arrival time of processes. While a process is running, if a shorter process arrives, the running process is pre-empted, and has to wait until the shorter one finishes. It’s leftover burst time is updated.