ch5 - basic Flashcards
CPU Scheduling (57 cards)
What CPU Scheduler do?
The CPU scheduler selects a process from the processes in the ready queue, and allocates a CPU core to it
the scheduler is defined by the ordering of that queue
When CPU scheduling decisions may take place?
CPU scheduling decisions may take place when a process:
1. Switches from running to waiting state
2. Switches from running to ready state
3. Switches from waiting to ready
4. Terminates
When scheduling scheme is nonpreemptive?
When scheduling takes place only under circumstances 1 and 4, the scheduling scheme is nonpreemptive.
A process:
1. Switches from running to waiting state
2. Switches from running to ready state
3. Switches from waiting to ready
4. Terminates
What is the meaning of nonpreemptive scheduling?
Under Nonpreemptive scheduling, once the CPU has been allocated to a process, the process keeps the CPU until it releases it either by terminating or by switching to the waiting state.
What is a problem with preemptive scheduling?
Preemptive scheduling can result in race conditions when data are shared among several processes.
can nonpreemtive scheduling result in race condition?
NO
That’s because the scheduler don’t interrupt the process, so it makes all the changes it should do to the shared data before switching to another process
What is a dispatcher?
Dispatcher module gives control of the CPU to the process selected by the CPU scheduler; this involves:
1. Switching context
2. Switching to user mode
3. Jumping to the proper location in the user program to restart that program
What is dispatch latency?
Dispatch latency – time it takes for the dispatcher to stop one process and start another running
What are scheduling Criteria?
- CPU utilization – keep the CPU as busy as possible
- Throughput – # of processes that complete their execution per time unit
- Turnaround time – amount of time to execute a particular process
- Waiting time – amount of time a process has been waiting in the ready queue
- Response time – amount of time it takes from when a request was submitted until the first response is produced.
Max CPU utilization
Max throughput
Min turnaround time
Min waiting time
Min response time
How First- Come, First-Served (FCFS) Scheduling works?
The processes are chosen according to their arrival time
a normal queue
What is convoy effect?
When it happens?
Convoy effect - short process behind long process
might happen in FCFS scheduling algorithm
How Shortest-Job-First (SJF) Scheduling works?
Associate with each process the length of its next CPU burst
Use these lengths to schedule the process with the shortest time
Is SJF optimal in terms of waiting time?
SJF is optimal – gives minimum average waiting time for a given set of processes
What is the preemptive version of SJF called?
Preemptive version called shortest-remaining-time-first
How do we determine the length of the next CPU burst?
Could ask the user or estimate
Use SJF to determine the order of these processes and the average waiting time
Process Burst Time
P1————6
P2————8
P3————7
P4————3
0-3sec: P4
3sec-9sec: P1
9sec-16sec: P3
16sec-24sec: P2
average waiting time = (3 + 16 + 9 + 0) / 4 = 7
What is the best estimate for the next CPU burst length based on?
It should be similar to the previous one.
Which process is chosen when using estimated CPU bursts for scheduling?
The process with the shortest predicted next CPU burst.
What method is used to estimate the next CPU burst length?
Exponential averaging based on previous CPU burst lengths.
What does tₙ represent?
The actual length of the nth CPU burst.
What does τₙ₊₁ represent?
The predicted value for the next CPU burst.
What is the range of α in exponential averaging?
0 ≤ α ≤ 1.
What is the formula for predicting the next CPU burst length?
τₙ₊₁ = α * tₙ + (1 - α) * τₙ.