Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Operating System Concepts: CPU Scheduling Algorithms and Criteria, Exams of Computer Science

An excerpt from the 'operating system concepts' textbook by silberschatz, galvin, and gagne. It covers the basics of cpu scheduling, including concepts such as maximum cpu utilization, cpu-i/o burst cycle, cpu scheduler, and dispatcher. The document also discusses various scheduling algorithms, including first-come-first-served (fcfs), shortest-job-first (sjf), and priority scheduling. The authors also touch upon the importance of scheduling criteria, such as cpu utilization, throughput, turnaround time, waiting time, and response time.

What you will learn

  • What are the basic concepts of CPU scheduling?
  • What is exponential averaging and how is it used in predicting the length of the next CPU burst?
  • What is the role of scheduling criteria in selecting a CPU scheduling algorithm?
  • What is the convoy effect in FCFS scheduling?
  • What are the different CPU scheduling algorithms discussed in the document?

Typology: Exams

2016/2017

Uploaded on 05/06/2017

avijeet-singh
avijeet-singh 🇮🇳

1 document

1 / 55

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Silberschatz, Galvin and Gagne ©2009
Operating System Concepts – 8th Edition,
Chapter 5: CPU Scheduling
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37

Partial preview of the text

Download Operating System Concepts: CPU Scheduling Algorithms and Criteria and more Exams Computer Science in PDF only on Docsity!

Silberschatz, Galvin and Gagne © 2009 Operating System Concepts – 8

th

Edition,

Chapter 5: CPU Scheduling

5. 2

Silberschatz, Galvin and Gagne © 2009 th

Chapter 5: CPU Scheduling

 Basic Concepts

 Scheduling Criteria

 Scheduling Algorithms

 Thread Scheduling

 MultipleProcessor Scheduling

 Operating Systems Examples

 Algorithm Evaluation

5. 4

Silberschatz, Galvin and Gagne © 2009 th

Basic Concepts

 Maximum CPU utilization obtained with multiprogramming

 CPU–I/O Burst Cycle – Process execution consists of a cycle of

CPU execution and I/O wait

CPU burst distribution

5. 5

Silberschatz, Galvin and Gagne © 2009 th

Histogram of CPU-burst Times

5. 7

Silberschatz, Galvin and Gagne © 2009 th

CPU Scheduler

 Selects from among the processes in memory that are ready to execute,

and allocates the CPU to one of them

 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

 Scheduling under 1 and 4 is nonpreemptive

 All other scheduling is preemptive

5. 8

Silberschatz, Galvin and Gagne © 2009 th

Dispatcher

 Dispatcher module gives control of the CPU to the process

selected by the shortterm scheduler; this involves:

switching context

switching to user mode

jumping to the proper location in the user program to restart

that program

Dispatch latency – time it takes for the dispatcher to stop one

process and start another running

5. 10

Silberschatz, Galvin and Gagne © 2009 th

Scheduling Algorithm Optimization Criteria

 Max CPU utilization

 Max throughput

 Min turnaround time

 Min waiting time

 Min response time

5. 11

Silberschatz, Galvin and Gagne © 2009 th

First-Come, First-Served (FCFS) Scheduling

Process Burst Time

P

1

P

2

P

3

 Suppose that the processes arrive in the order: P

1

, P

2

, P

3

The Gantt Chart for the schedule is:

 Waiting time for P

1

= 0; P

2

= 24; P

3

 Average waiting time: (0 + 24 + 27)/3 = 17

P

1

P

2

P

3

5. 13

Silberschatz, Galvin and Gagne © 2009 th

Shortest-Job-First (SJF) Scheduling

 Associate with each process the length of its next CPU burst. Use these

lengths to schedule the process with the shortest time

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

processes

The difficulty is knowing the length of the next CPU request

5. 14

Silberschatz, Galvin and Gagne © 2009 th

Example of SJF

Process Arrival Time Burst Time

P

1

P

2

P

3

P

4

 SJF scheduling chart

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

P

4

P

3 P

1

P

2

5. 16

Silberschatz, Galvin and Gagne © 2009 th

Prediction of the Length of the Next CPU Burst

5. 17

Silberschatz, Galvin and Gagne © 2009 th

Examples of Exponential Averaging

  =

n+

n

Recent history does not count

  =

n+

=  t

n

Only the actual last CPU burst counts

 If we expand the formula, we get:

n+

=  t

n

+(1 ) t

n

j

 t

n j

n +

0

 Since both  and (1 ) are less than or equal to 1, each successive term

has less weight than its predecessor

5. 19

Silberschatz, Galvin and Gagne © 2009 th

Round Robin (RR)

 Each process gets a small unit of CPU time (time quantum),

usually 10100 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 (n1) q time units.

 Performance

q large  FIFO

q small  q must be large with respect to context switch,

otherwise overhead is too high

5. 20

Silberschatz, Galvin and Gagne © 2009 th

Example of RR with Time Quantum = 4

Process Burst Time

P

1

P

2

P

3

 The Gantt chart is:

 Typically, higher average turnaround than SJF, but better response

P

1

P

2

P

3

P

1

P

1

P

1

P

1

P

1