Process Scheduling Flashcards

1
Q

What are the goals of process scheduling?

A

Main goal is to Maximize CPU utilization.

Secondary Goals:

  • Fairness
  • Throughput
  • predictability
  • Low overhead
  • Priorities
  • Efficient utilization of other resources held by processes
  • Quick response time
  • graceful degradation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When does the OS have an opportunity for a context switch?

A
  • When a process blocks for I/O (preemptive, nonpreemtive)
  • When a process ends (preemptive, nonpreemptive)
  • When a process switches from blocked to ready (preemptive)
  • When a process’ turn on the CPU ends and it returns to the ready state (preemptive)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Assume that a process Pi arrives at time Ai, runs on the CPU for time Ti and enters the Exit queue at time Ei.

  1. What is the CPU utilization?
  2. How do we define the throughput of the CPU?
  3. What is the turnaround time for Pi?
  4. What is the normalized turnaround time for Pi?
  5. What is the waiting time for Pi?
  6. What is the response time for Pi?
A
  1. CPU utilization: (time CPU is in use) / total time
  2. Throughput: number of processes completed per unit of time
  3. Turnaround time: Ei-Ai
  4. Normalized turnaround time: (Ei-Ai)/Ti
  5. Waiting time: Ei - Ai - Ti
  6. Response time: time between time slices for the process
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The performance of the CPU has three primary considerations - the maximum (worst-case) performance, average performance, and the variance of the performance (how much it deviates from the predicted performance). Which is considered most often, and why?

A

In general, we consider the average performance of the CPU. Unless the variance is large, there is no reason to consider it as a measure of performance. In addition, maximum cases are generally rare, making them comparatively uninformative.

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

Given the following, how do we estimate the burst time of a process?

Ti = estimated burst time
ti = actual burst time
a = tuning parameter.
A

We estimate the burst time as follows:

T(i+1) = ati + (1-a)Ti

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

Name four basic scheduling algorithms.

A

Most Important:

  • First Come First Served (FCFS)
  • Round Robin
  • Shortest Remaining Time First (SRTF)
  • Priority Queue

Other possibilities:

  • Fixed Schedule
  • Shortest Job First (SJF)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How does First Come First Served work?

A

First process in is first get CPU time

  • Simplest algorithm - inherently nonpreemptive
  • use a FIFO queue for ready queue
  • processes run till they are completed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the cons of First Come First Serve (FCFS)?

A
  • Bad for throughput, wait time, predictability, priorities,
    resource use, turnaround time, degradation
  • can be subject to queuing theory (impacts throughput and waiting time)
  • Suffers from convoy effect where small processes pile up behind large ones
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the pros of First Come First Serve (FCFS)?

A
  • good for fairness

- low overhead

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

What is Round Robin scheduling?

A
  • Handle processes in their order of arrival into the ready
    queue, but only allow a limited time on the CPU (CPU time allowed called time slice or time quantum)

Choice of time slice is the tricky part.

  • Too large becomes first come first serve.
  • small: with n processes each process thinks it has it’s own CPU running at 1/n the regular speed
  • Tiny: spend more time doing context switches then running processes
  • Ideal: each CPU burst fits into one time slice
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are some round robin variants?

A
  • Allow each process to have time slice size based on priority
  • Allow a process to appear more than once in a round robin cycle.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are advantages to Round Robin?

A
  • Fair
  • Predictable
  • low overhead
  • degrades well
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are disadvantages to Round Robin?

A
  • Doesn’t handle priorities well.

- Doesn’t balance resource usage

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

what is Shortest Job First (SJF)?

A
  • Nonpreemptive schedule
  • Each process knows the size of it’s CPU burst
  • Give the CPU the process with the shortest “next burst”
  • Provably minimizes average waiting time across all nonpreemptive schedules
  • Implemented with priority queue, sorted list, or heap
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Shortest Job First Advantages

A

Throughput, overhead, minimum wait time, minimum turnaround time.

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

Shortest Job First Disadvantages

A
  • Starvation, priories, predictability, degradation, prioritize resources
17
Q

What is starvation?

A

When a process doesn’t get to run.

18
Q

How does Shortest Remaining Time First (SRTF) work?

A
  • Preemptive version of SJF, anytime that a process is added to the ready queue, we select the one with the smallest remaining time first to run.
  • Biggest effect is when a process arrives from the new or blocked state (the process blocked on I/O night get access to the CPU immediately after the I/O is done if the predicted CPU burst is small
19
Q

how does Priority Scheduling work?

A
  • Assign a priority to each process
  • Decided whether high priority corresponds to high number or low number (varies by system)
  • Give the CPU to the process with the highest priority.
  • Can be implemented nonpreemptively or preemptively
20
Q

What are things to consider with Priority Scheduling?

A
  • on what do we base the priority?
  • Who sets the priority?
  • When is the priority set?
  • Can the priority change?
    what range of priority numbers are valid?
21
Q

Factors for Setting Priorities

A

Internal Factors:

  • Time limits
  • Memory requirements
  • Number of files to open
  • Average I/O burst length

External:

  • Type of job
  • individual submitting the job (root, user, batch job)
  • $
22
Q

Setting Priorities

A
  • Initial priority set by the OS as the process is created
  • Most general-purpose systems allow priorities to change dynamically
  • Depending on how you choose your priority, you can mimic some of the other schedules
23
Q

What are pros of using priority?

A
  • relatively low overhead

- Can value specific resource usage

24
Q

What are cons of using priority?

A
  • unpredictable wait time, turnaround time

- Not good for degradation