CPU Scheduling Part-I.pdf

Harika525369 40 views 15 slides Jun 30, 2022
Slide 1
Slide 1 of 15
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15

About This Presentation

CPU scheduling is the basis of multi-programmed operating systems. By switching the CPU among processes, the operating system can make the computer more productive
- To introduce CPU scheduling, which is the basis for multi-programmed operating systems
- To describe various CPU-scheduling algorithms...


Slide Content

Amrita School of Engineering, Bangalore
Ms. Harika Pudugosula
Teaching Assistant
Department of Electronics & Communication Engineering

•Basic Concepts
•Scheduling Criteria
•Scheduling Algorithms
•Thread Scheduling
•Multiple-Processor Scheduling
•Real-Time CPU Scheduling
•Operating Systems Examples
•Algorithm Evaluation
2

Objectives
CPUschedulingisthebasisofmultiprogrammedoperatingsystems.By
switchingtheCPUamongprocesses,theoperatingsystemcanmakethe
computermoreproductive
•TointroduceCPUscheduling,whichisthebasisformultiprogrammed
operatingsystems
•TodescribevariousCPU-schedulingalgorithms
•TodiscussevaluationcriteriaforselectingaCPU-schedulingalgorithmfor
aparticularsystem
•Toexaminetheschedulingalgorithmsofseveraloperatingsystems
3

Basic Concepts
•Inasingle-processorsystem,onlyoneprocesscanrunatatime
•OthersmustwaituntiltheCPUisfreeandcanberescheduled
•Theobjectiveofmultiprogrammingistohavesomeprocessrunningat
alltimes,tomaximizeCPUutilization
•Aprocessisexecuteduntilitmustwait,typicallyforthecompletionof
someI/Orequest
•Inasimplecomputersystem,theCPUthenjustsitsidle.Allthiswaiting
timeiswasted;nousefulworkisaccomplished
•Withmultiprogramming,wetrytousethistimeproductively,maximum
CPUutilization
4

Basic Concepts
•Withmultiprogramming,wetrytousethistimeproductively
•Severalprocessesarekeptinmemoryatonetime
•Whenoneprocesshastowait,theoperatingsystemtakestheCPU
awayfromthatprocessandgivestheCPUtoanotherprocess
•Thispatterncontinues...
5

Basic Concepts
•Processexecutionconsistsofa
cycleofCPUexecutionandI/O
wait-CPU-I/OBurstCycle
•CPUBurst-whentheprocessis
beingexecutedintheCPU
•I/OBurst-whentheCPUis
waitingforI/Oforfurtherexection
•CPUburstfollowedbyI/Oburst
•Eventually,thefinalCPUburst
endswithasystemrequestto
terminateexecution
6

Histogram of CPU-burst Times
7
•AnI/O-boundprogramtypicallyhasmanyshortCPUbursts
•ACPU-boundprogrammighthaveafewlongCPUbursts.

CPU Scheduler
•Short-term/CPUscheduler selects from among the processes inready
queue, and allocates the CPU to one of them
•Queue may be ordered in various ways
•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
•For situations 1 and 4, there is no choice in terms of scheduling
A new process(if one exists in the ready queue) must be selected for
execution
•However, there is achoice for situations 2 and 3
8

CPU Scheduler
•Whenschedulingtakesplaceonlyundercircumstances1and4,wesay
thattheschedulingschemeisnonpreemptiveorcooperative
•Otherwise,itispreemptive
•Undernonpreemptivescheduling,oncetheCPUhasbeenallocatedto
aprocess,theprocesskeepstheCPUuntilitreleasestheCPUeitherby
terminatingorbyswitchingtothewaitingstate
•Underpreemptivescheduling,CPUhasbeentakenawayfroma
process,beforetheprocesshascompleteditsexecutionorbeforeitis
swictingtothewaitingstate
•Schedulingunder1and4isnonpreemptive
•Allotherschedulingispreemptive
•Consideraccesstoshareddata
•Considerpreemptionwhileinkernelmode
•ConsiderinterruptsoccurringduringcrucialOSactivities
9

Dispatcher
•DispatchermodulegivescontroloftheCPUtotheprocessselectedby
theshort-termscheduler;thisinvolves:
•switchingcontext
•switchingtousermode
•jumpingtotheproperlocationintheuserprogramtorestartthat
program
•Dispatchlatency–timeittakesforthedispatchertostoponeprocess
andstartanotherrunning
10

Scheduling Criteria
•CPUutilization–
•keeptheCPUasbusyaspossible
•Conceptually,CPUutilizationcanrangefrom0to100percent
•Inarealsystem,itshouldrangefrom40percent(foralightlyloaded
system)to90percent(foraheavilyloadedsystem).
•Throughput–
•Numberofprocessesthatcompletetheirexecutionpertimeunit
•Forlongprocesses,thisratemaybeoneprocessperhour
•Forshorttransactions,itmaybetenprocessespersecond
•Turnaroundtime–
•amountoftimetoexecuteaparticularprocess
•Theintervalfromthetimeofsubmissionofaprocesstothetimeof
completionistheturnaroundtime
11

Scheduling Criteria
•Turnaroundtime–
•Turnaroundtimeisthesumoftheperiodsspentwaitingtogetinto
memory,waitinginthereadyqueue,executingontheCPU,anddoing
I/O
•Waitingtime–
•TheCPU-schedulingalgorithmdoesnotaffecttheamountoftime
duringwhichaprocessexecutesordoesI/O
•Itaffectsonlytheamountoftimethataprocessspendswaitinginthe
readyqueue
•Waitingtimeisthesumoftheperiodsspentwaitingintheready
queue
•Responsetime–
•amountoftimeittakesfromwhenarequestwassubmitteduntilthe
firstresponseisproduced,notoutput(fortime-sharingenvironment)
12

Scheduling Algorithm Optimization Criteria
•Max CPU utilization
•Max throughput
•Min turnaround time
•Min waiting time
•Min response time
13

14
References
1.SilberscatnzandGalvin,“OperatingSystemConcepts,”NinthEdition,John
WileyandSons,2012.

15
Thank you