Chapter 5: CPU Scheduling

0.0(0)
studied byStudied by 0 people
full-widthCall with Kai
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/43

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

44 Terms

1
New cards

CPU–I/O Burst Cycle

Basic Concepts

  • Maximum CPU utilization obtained with multiprogramming

  • — Process execution consists of a cycle of CPU execution and I/O wait

2
New cards
<p>I/O burst  </p>

I/O burst

Basic Concepts

  • CPU burst followed by —

  • CPU burst distribution is of main concern

3
New cards
<p>Histogram of CPU-burst Times</p>

Histogram of CPU-burst Times

  • Large number of short bursts

  • Small number of longer bursts

4
New cards

CPU scheduler

selects from among the processes in ready queue, and allocates a CPU core to one of them

  • Queue may be ordered in various ways

5
New cards

1. Switches from running to waiting state

2. Switches from running to ready state

3. Switches from waiting to ready

4. Terminates

CPU scheduling decisions may take place when a process (4)

6
New cards
  • 1 and 4

  • 2 and 3

  • For situations , there is no choice in terms of scheduling. A new process (if one exists in the ready queue) must be selected for execution.

  • For situations —, however, there is a choice.

7
New cards
  • nonpreemptive

  • preemptive

  • When scheduling takes place only under circumstances 1 and 4, the scheduling scheme is —

  • Otherwise, it is—

8
New cards

Nonpreemptive scheduling

Under —, 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.

9
New cards

preemptive scheduling algorithms

Virtually all modern operating systems including Windows, MacOS, Linux, and UNIX use

10
New cards

race conditions

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

  • Consider the case of two processes that share data. While one process is updating the data, it is preempted so that the second process can run. The second process then tries to read the data, which are in an inconsistent state.

11
New cards

Dispatcher module

— gives control of the CPU to the process selected by the CPU scheduler; this involves:

  • Switching context

  • Switching to user mode

  • Jumping to the proper location in the user program to restart that program

12
New cards
<p>Dispatch latency</p>

Dispatch latency

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

13
New cards
  • CPU utilization

  • Throughput

  • Turnaround time

  • Waiting time

  • Response time

5 Scheduling Criteria

14
New cards

CPU utilization

keep the CPU as busy as possible

15
New cards

Throughput

# of processes that complete their execution per time unit

16
New cards

Turnaround time

amount of time to execute a particular process

17
New cards

Waiting time

amount of time a process has been waiting in the ready queue

18
New cards

Response time

amount of time it takes from when a request was submitted until the first response is produced.

19
New cards
  • Max CPU utilization

  • Max throughput

  • Min turnaround time

  • Min waiting time

  • Min response time

5 Scheduling Algorithm Optimization Criteria

20
New cards

First- Come, First-Served (FCFS) Scheduling

(0 + 24 + 27)/3 = 17

Waiting time for P1 = 0; P2 = 24; P3 = 27

Average waiting time: —

<p>—</p><p>Waiting time for P1 = 0; P2 = 24; P3 = 27</p><p>Average waiting time: —</p>
21
New cards

(6 + 0 + 3)/3 = 3

Waiting time for P1 = 6; P2 = 0 ; P3 = 3

Average waiting time: —

Much better than previous case

<p>Waiting time for P1 = 6; P2 = 0 ; P3 = 3 </p><p>Average waiting time: —</p><p>Much better than previous case</p>
22
New cards

Convoy effect

— short process behind long process

  • Consider one CPU-bound and many I/O-bound processes

23
New cards

Shortest-Job-First (SJF) Scheduling

  • optimal

  • Associate with each process the length of its next CPU burst

    • Use these lengths to schedule the process with the shortest time

  • — gives minimum average waiting time for a given set of processes

24
New cards

shortest-remaining-time-first

  • Preemptive version called

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

    • Could ask the user

    • Estimate

25
New cards
  • (9+24+16+3) / 4 =13

  • (3 + 16 + 9 + 0) / 4 = 7

  • Average turnaround time(finish - arrival) =

  • Average waiting time(turnaround - burst) =

<ul><li><p><span style="font-family: &quot;Helvetica Neue&quot;, sans-serif;">Average turnaround time(finish - arrival) =</span></p></li><li><p><span style="font-family: &quot;Helvetica Neue&quot;, sans-serif;">Average waiting time(turnaround - burst) = </span></p></li></ul><p></p>
26
New cards

shortest predicted next CPU burst

Determining Length of Next CPU Burst

  • Can only estimate the length which should be similar to the previous one

    • Then pick process with —

27
New cards
<ul><li><p>exponential averaging</p></li></ul><ul><li><p>½</p></li></ul><p></p>
  • exponential averaging

  • ½

Determining Length of Next CPU Burst

  • Can be done by using the length of previous CPU bursts, using —

  • Commonly, α set to —

<p><strong>Determining Length of Next CPU Burst</strong></p><ul><li><p><span>Can be done by using the length of previous CPU bursts, using —</span></p></li></ul><ul><li><p><span>Commonly, α set to —</span></p></li></ul><p></p>
28
New cards

less weight

Examples of Exponential Averaging

Since both α and (1 - α) are less than or equal to 1, each successor predecessor term has — than its predecessor

<p><strong>Examples of Exponential Averaging</strong></p><p>Since both α and (1 - α) are less than or equal to 1, each successor predecessor term has — than its predecessor</p>
29
New cards

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.

  • Is SRT more “optimal” than SJN in terms of the minimum average waiting time for a given set of processes?

30
New cards

[(10-1)+(1-1)+(17-2)+(5-3)]/4 = 26/4 = 6.5

Example of Shortest-remaining-time-first

Average waiting time =

<p>Example of Shortest-remaining-time-first</p><p>Average waiting time =</p>
31
New cards

Round Robin (RR)

  • 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.

  • 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.

32
New cards
  • FIFO (FCFS)

  • RR

Round Robin (RR)

  • Timer interrupts every quantum to schedule next process

  • Performance

    • q large ⇒ —

    • q small ⇒ —

  • Note that q must be large with respect to context switch, otherwise overhead is too high

33
New cards
  • response

  • context switch time

Example of RR with Time Quantum = 4

  • Typically, higher average turnaround than SJF, but better —

  • q should be large compared to —

    • q usually 10 milliseconds to 100 milliseconds,

    • Context switch < 10 microseconds

<p>Example of RR with Time Quantum = 4</p><ul><li><p>Typically, higher average turnaround than SJF, but better —</p></li><li><p>q should be large compared to —</p><ul><li><p>q usually 10 milliseconds to 100 milliseconds, </p></li><li><p>Context switch &lt; 10 microseconds</p></li></ul></li></ul><p></p>
34
New cards

Time Quantum and Context Switch Time

process time, quantum, context switches

<p>process time, quantum, context switches</p>
35
New cards

Turnaround Time Varies With The Time Quantum

80% of CPU bursts should be shorter than q

<p>80% of CPU bursts should be shorter than q</p>
36
New cards

Priority Scheduling

  • A priority number (integer) is associated with each process

  • The CPU is allocated to the process with the highest priority (smallest integer ≡ highest priority)

    • Preemptive

    • Nonpreemptive

37
New cards

SJF

is priority scheduling where priority is the inverse of predicted next CPU burst time

38
New cards
  • Starvation

  • Aging

  • Problem ≡ — low priority processes may never execute

  • Solution ≡ — as time progresses increase the priority of the process

39
New cards

8.2

Example of Priority Scheduling

Average waiting time =

<p>Example of Priority Scheduling</p><p>Average waiting time = </p>
40
New cards

Priority Scheduling w/ Round-Robin

Run the process with the highest priority. Processes with the same priority run round-robin

<p>Run the process with the highest priority. Processes with the same priority run round-robin</p>
41
New cards

Multilevel Queue

The ready queue consists of multiple queues

42
New cards
  • Number

  • Scheduling algorithms

  • needs service

  • Scheduling

Multilevel queue scheduler defined by the following parameters (4)

  • — of queues

  • — for each queue

  • Method used to determine which queue a process will enter when that process —

  • — among the queues

43
New cards
44
New cards