ch5 - basic Flashcards

CPU Scheduling (57 cards)

1
Q

What CPU Scheduler do?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When CPU scheduling decisions may take place?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When scheduling scheme is nonpreemptive?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the meaning of nonpreemptive scheduling?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a problem with preemptive scheduling?

A

Preemptive scheduling can result in race conditions when data are shared among several processes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

can nonpreemtive scheduling result in race condition?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a dispatcher?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is dispatch latency?

A

Dispatch latency – time it takes for the dispatcher to stop one process and start another running

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are scheduling Criteria?

A
  1. CPU utilization – keep the CPU as busy as possible
  2. Throughput – # of processes that complete their execution per time unit
  3. Turnaround time – amount of time to execute a particular process
  4. Waiting time – amount of time a process has been waiting in the ready queue
  5. 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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How First- Come, First-Served (FCFS) Scheduling works?

A

The processes are chosen according to their arrival time
a normal queue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is convoy effect?
When it happens?

A

Convoy effect - short process behind long process
might happen in FCFS scheduling algorithm

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How Shortest-Job-First (SJF) Scheduling works?

A

Associate with each process the length of its next CPU burst
Use these lengths to schedule the process with the shortest time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Is SJF optimal in terms of waiting time?

A

SJF is optimal – gives minimum average waiting time for a given set of processes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the preemptive version of SJF called?

A

Preemptive version called shortest-remaining-time-first

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do we determine the length of the next CPU burst?

A

Could ask the user or estimate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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

A

0-3sec: P4
3sec-9sec: P1
9sec-16sec: P3
16sec-24sec: P2

average waiting time = (3 + 16 + 9 + 0) / 4 = 7

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the best estimate for the next CPU burst length based on?

A

It should be similar to the previous one.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Which process is chosen when using estimated CPU bursts for scheduling?

A

The process with the shortest predicted next CPU burst.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What method is used to estimate the next CPU burst length?

A

Exponential averaging based on previous CPU burst lengths.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What does tₙ represent?

A

The actual length of the nth CPU burst.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What does τₙ₊₁ represent?

A

The predicted value for the next CPU burst.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is the range of α in exponential averaging?

A

0 ≤ α ≤ 1.

22
Q

What is the formula for predicting the next CPU burst length?

A

τₙ₊₁ = α * tₙ + (1 - α) * τₙ.

23
What value is α commonly set to?
½ or 0.5
24
What does alpha = 0 mean in Exponential Averaging? what about alpha = 1?
if alpha = 0 history does not count (only the very first prediction) if alpha = 1 Only the actual last CPU burst counts
25
What is Shortest Remaining Time First Scheduling?
Preemptive version of SJN Whenever a new process arrives in the ready queue, the decision on which process to schedule next is redone using the SJN algorithm.
26
Which scheduling algorithm is *more optimal* than SJN for minimum **average waiting time** when pre‑emption is allowed?
SRT (Shortest Remaining Time)
27
Why does **SRT** achieve a lower average waiting time than SJN?
It always runs the process with the **least remaining burst time** and can pre‑empt when a shorter job arrives, minimizing the time other processes wait.
28
Is **SJN** pre‑emptive?
No — SJN (Shortest Job Next) is **non‑preemptive**.
29
What key metric does **SRT** use to choose the next process?
**Remaining burst time**.
30
On what basis does **SJN** pick the next process?
The **total burst time**; it chooses the shortest job among those already waiting.
31
In the example P1(0,8 ms) P2(1,4 ms) P3(2,2 ms), what is the **average waiting time under SRT**?
≈ 2.33 ms
32
In the same example, what is the **average waiting time under SJN**?
≈ 5.33 ms
33
When should you prefer **SRT**?
When processes arrive at different times, pre‑emption is allowed, and you care about minimizing average waiting time.
34
When might **SJN** be preferred over SRT?
When pre‑emption is not allowed or you need a simpler implementation.
35
Which algorithm offers better **real‑time responsiveness**?
SRT — it can switch immediately to a shorter incoming job.
36
Which algorithm is **simpler to implement**?
SJN.
37
How the RR algorithm works?
Each process gets a small unit of CPU time (time quantum q), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue.
38
provide an upper bound to the waiting time of a process if using RR, given that there are n processes in the ready queue
If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time units.
39
Like what RR performs when q is small / large?
q large -> FIFO (FCFS) q small -> RR
40
When is q too small?
If it's not large with respect to the context switch ## Footnote q must be large with respect to context switch, otherwise overhead is too high.
41
is SJF a type of Priority Scheduling?
Yes! and the priority is the predicted next CPU burst time
42
What's the problem with Priority Scheduling?
Starvation – low priority processes may never execute
43
A solution to starvation problem in Priority Scheduling?
Aging – as time progresses increase the priority of the process
44
How are Priority Scheduling and RR merged?
use RR for processes with the same priority
45
What is Multilevel Queue in CPU scheduling?
The ready queue consists of multiple queues Multilevel queue scheduler defined by the following parameters: Number of queues Scheduling algorithms for each queue Method used to determine which queue a process will enter when that process needs service Scheduling among the queues
46
What is Priority Scheduling in terms of Multilevel Queue?
Have separate queues for each priority. Schedule the process in the highest-priority queue!
47
# True or False? When threads supported, threads scheduled, not processes
True
48
What is Symmetric multiprocessing?
Symmetric multiprocessing (SMP) is where each processor is self scheduling.
49
What is load balancer and what it does?
Load balancing attempts to keep workload evenly distributed
50
What Push migration does?
Push migration – periodic task checks load on each processor, and if found pushes task from overloaded CPU to other CPUs
51
What Pull migration does?
Pull migration – idle processors pulls waiting task from busy processor
52
What are soft and hard affinities?
**Soft affinity** – the operating system attempts to keep a thread running on the same processor, but no guarantees. **Hard affinity** – allows a process to specify a set of processors it may run on.
53
What is Interrupt latency?
Interrupt latency – time from arrival of interrupt to start of routine that services interrupt
54
What is Dispatch latency ?
Dispatch latency – time for schedule to take current process off CPU and switch to another
55
What is the conflict phase of dispatch latency
Conflict phase of dispatch latency: Preemption of any process running in kernel mode Release by low-priority process of resources needed by high-priority processes | (this a part of the dispatching process)