SlideShare una empresa de Scribd logo
1 de 31
izazroghani@gmail.com 1
•PROCESSOR/CPU
SCHEDULING
BY:
Izaz Khan Roghani
2
• Scheduling
 CPU is the brain of the computer system __ performs all the
processing inside the computer.
 Programs enter to systems ___becomes process __ handled by
OS.
 In a Multi-programming/Multi-user systems ___ many processes __
each process wait for its turn to utilize the CPU and to perform some
useful task.
 That’s why CPU requires some type of mechanism ___ to serve all
the processes uniformly.
 “This mechanism is handled by the OS and this management of the
CPU is called CPU/processor scheduling”.
 EXPLANATION: more than one processes in the Ready state __
OS decision __ which one to run first __ which one to wait.
 The part of OS which makes this decision is called “Scheduler”, the
algorithm it uses is called the scheduling algorithm.
izazroghani@gmail.com
3
• Scheduling
 Scheduling affects the performance of the system because it
determines which process will wait and which will progress.
 Simply we can say that the problem of determining, when processor
should be assigned to which process (currently in memory) is called
scheduling.
 Scheduling is a fundamental OS function.
 Since the CPU is such an important resource, it is very important to
develop good scheduling algorithms.
izazroghani@gmail.com
4
• Scheduling Objectives
 Scheduling typically attempts to achieve some combination of the
following goals, and the overall scheduling effort is intended to meet
system’s performance and behavior.
 THROUGHPUT: Maximize the number of jobs processed/completed
per unit time.
 UTILIZATION OF RESOURCES: Maximize utilization of other
resources (disks, printers etc).
 RESPONSE TIME: Minimize the response time for interactive users
(on-line users/time sharing) i.e. provide tolerable response time.
 TURNAROUND TIME: Minimize the time user wait for the output
(batch users) = waiting time + computation time + I/O time
 FAIRNESS: To make sure that each process gets its share of the
CPU i.e. treated equally.
 EFFICIENCY: To keep the CPU busy 100% of the time.
izazroghani@gmail.com
5
• Scheduling Objectives
 GRACEFUL DEGRADATION: If the system becomes overloaded, it
should not ‘collapse’, but avoid further loading and temporarily
reduce the level of service (response time).
izazroghani@gmail.com
6
• CPU I/O Burst Cycle
 The execution of a process consist of an alternation of CPU Bursts
and I/O Bursts.
 A process begins and ends with a CPU burst. In between, CPU
activity is suspended whenever an I/O operation is needed.
 I/O BOUND: If the CPU bursts are relatively short compared to the
I/O bursts, then the process is said to be I/O bound.
 For example, if the processor is capable of making rapid changes to
a large database stored on a disk faster than the drive mechanism
can perform the read and write operations, the computer is
input/output-bound.
 CPU Bound: If the CPU bursts are relatively long compared to the
I/O bursts, then the process is said to be CPU bound.
 For example, if a processor is involved in a long arithmetic
computations, then the process is CPU bound.
izazroghani@gmail.com
7
•SCHEDULING LEVEL
 HIGH LEVEL SCHEDULING
 INTERMEDIATE LEVE SCHEDULING
 LOW LEVEL SCEDULING
izazroghani@gmail.com
8
• SCHEDULING LEVELS
 In a process life cycle, scheduling can be used at THREE
levels/points. The scheduling levels discuss the level/point at which
scheduling mechanism can be used.
• High level Scheduling
 Also called Job/Admission/long term scheduling.
 When a job is entered into a system and become a process it is high
level scheduling.
 Often admission, a process start competing actively for the
resources of the system.
 HLS controls the admission of jobs into the system, i.e. it decides
which newly jobs are to be converted into processes and be put into
the READY queue to compete for the CPU.
 This activity is only really applicable to Batch systems.
izazroghani@gmail.com
9
• Intermediate level Scheduling (ILS)
 Also called Medium level scheduling (MLS).
 MLS is applicable to systems where a process within the system
(but not currently running i.e. in the Ready Queue) can be swapped
out of memory on to disk (Virtual Memory) in order to reduce the
system load.
 MLS determines that which process shall be allowed to compete for
the CPU and which shall be suspended/blocked in response to
Virtual memory.
 MLS acts as a buffer between the admission of jobs to the system,
and the assigning of the CPU to these jobs.
izazroghani@gmail.com
10
• Low level Scheduling (LLS)
 The LLS is the most complex and significant of the scheduling levels
 LLS determines that which Ready process will be assigned to the
CPU, when it is next available, and actually assign the CPU to this
process.
 LLS is performed by the Dispatcher, i.e. it dispatches a process to
the CPU, which operates many times per second.
 The dispatcher must therefore resides all the time in main memory
 The LLS will be invoked whenever the current process relinquishes
(leave/remove) control ( because of any I/O call or interrupt arises).
 A number of policies have been devised for use in LLS, each of
which has its own advantages and disadvantages.
 HOME WORK: Pages # 287….291 from H.M. Deitel.
izazroghani@gmail.com
11
• Scheduling Levels
Job waiting for
Entry
Job waiting for
initiation
Suspended
Process waiting
For initiation
Active
processes
Running
Processes
Completed
izazroghani@gmail.com
12
•SCHEDULING TYPES
 PREEMPTIVE SCHEDULING
NON-PREEMPTIVE SCHEDULING
izazroghani@gmail.com
13
• SCHEDULING TYPES
 Scheduling types determines how the processes use the CPU after
dispatching or at LLS.
 Either the process remain in the CPU until its completion or it
remains there for a short time (quantum or time slice).
• Preemptive Scheduling
 Preemption basically means that a process may be forcibly removed
from the CPU even if does not want to release the CPU i.e. it is still
executing but a higher priority process needs the CPU.
 In preemptive scheme, the LLS may remove a process from the
RUNNING state in order to allow another process to run.
 In a preemptive scheme, a running process may be forced to yield
the CPU ( thus returning to the ready list) by an external rather than
by its own action. Such external events can be:
 A higher priority process enters the systems.
 A waited process becomes ready (because of I/O interrupt).
izazroghani@gmail.com
14
• Non-Preemptive Scheduling
 In Non-Preemptive scheme, a process once given to the processor,
will be allowed to run until its completion or until it terminates or
incurs an I/O wait.
 OR we can say that when a process can not “forcibly” lose the
processor.
 Non-Preemptive scheduling is also known as “Run-to-Completion”,
which is slightly inaccurate, since the process will lose the processor
if it incurs an I/O wait.
ASSIGNMENT:
Q1: Compare Preemptive with Non-preemptive scheduling?
izazroghani@gmail.com
15
• Preemptive VS Non-Preemptive Scheduling
 Preemptive scheduling is useful, where high priority process
required rapid attention.
 In a real time system and in a interactive timesharing system,
preemptive scheduling is important.
 In Preemptive scheduling, interrupts disturbs the efficiency of the
CPU.
 In a Non-preemptive scheduling systems, short job are made to wait
by long jobs.
 Non-preemptive scheduling is easy to implement, they are simple.
 In Non-preemptive scheme, high-priority jobs can not displace
waiting jobs.
izazroghani@gmail.com
16
• Scheduling Criteria
 There are many scheduling algorithms, and various criteria to judge
their performance. Different algorithms may favor different types of
processes. A few criteria are:
 Max CPU utilization – try to keep the CPU as busy as possible
 Max Throughput – Number of processes completed in a unit
time.
 Min Turnaround time – Time needed to execute a process.
 Min Response time & waiting time.
 The CPU scheduling algorithm should try to maximize the above
points.
izazroghani@gmail.com
17
•SCHEDULING
ALGORITHMS/POLICIES
izazroghani@gmail.com
18
• FIFO or FCFS (First-come-first-served)
 The simplest scheduling algorithm/policy.
 As the name implies, the FCFS policy simply assigns the processor to the
process which is first in the READY queue.
 This is the Non-preemptive scheme. (Run-to-completion)
 FAIR in a sense: Run the jobs till completion
 UNFAIR in a sense: Long job make short job to wait for a long time and un-
important jobs make important job wait.
 Its response time is predictable. ( By Gantt Chart)
 FIFO/FCFS is rarely used as a master scheme in today’s system, but it is
often embedded with other schemes.
------- P4 P3 P2 P1 P 1
izazroghani@gmail.com
19
• Illustration of FCFS policy
 We assume the arrival in the READY queue for processes in the
numbered sequence, we can calculate how long each process has
to wait.
(a) (b)
Job Est. Burst/Run Time waiting
1 2 (unit time) 0
2 60 2
3 1 62
4 3 63
5 50 66
The average waiting time= (0+2+62+63+66)/5= ?
izazroghani@gmail.com
20
• SJF (Shortest Job First – Non-Preemptive)
 It is a Non-preemptive scheduling policy.
 In this policy waiting jobs with shortest (shortest) estimated run-time is run
or dispatch next.
 It is a priority scheme, in which SJF favors short job at the expense of
longer jobs.
 If we use this scheme on the jobs in Table 1, above, we get a rather
different picture as shown in Table 2.
(a) (b)
Job Est. Burst/Run Time waiting
3 1 0
1 2 (unit time) 1
4 3 3
5 50 6
2 60 56
izazroghani@gmail.com
21
• SJF (preemptive version)
 We also have a Preemptive version of SJF.
 In the preemptive version of SJF, a long job in the queue may be
delayed by a succession of smaller jobs arriving in the queue.
 In the example of Table 2, it is assumed that the job list is constant,
but, in practice, before Time 3 is when job 5 is due to start, another
job of length, say, 10 minutes could arrive and be placed ahead of
job5.
 This queue jumping effect could recur (occur again) many times,
effectively preventing job 5 from starting at all; this situation is
known as Starvation.
(a) (b)
Job Est. Burst/Run Time waiting
3 1 0
1 2 (unit time) 1
4 3 3
x 10
5 50 6
2 60 56
izazroghani@gmail.com
22
• SRT ( Shortest Remaining Time)
 SRT is a preemptive version of SJF, and is useful in timesharing
environment.
 In SRT, suppose a process “A” is dispatched to the CPU and started
processing, however, during of this process, another process say “B”
arrives who’s Run-time is shorter than Job “A’s” remaining run time,
then job “A” will be preempted and job “B” will be allow to execute.
 SRT favors short jobs even more than SJF, since a currently running
long job could be ousted (removed) by a new shorter one.
 DANGER OF STARVATION:
 The danger of starvation of longer jobs also exists in this scheme.
 Longer jobs --- waits for shorter jobs.
 Implementation of SRT requires an estimate of Total-run-time and
measurement of Elapsed run-time.
 So SRT has a higher over head than SJF
izazroghani@gmail.com
23
• HRN (Highest Response Ratio Next)
 To correct some of the weaknesses (Danger of starvation) of the
SJF policy, Brinch Hansen developed the HRN strategy.
 HRN is a Non-preemptive scheduling, (Run-to-completion).
 In HRN, a job with the highest priority value will be selected for
running.
 The priority of job is a function of its Service time and its waited
time
 Dynamic priorities are calculated in HRN according to the formula
Priority, P = time waiting + runt time / burst time
run time
 Longer and shorter job’s are both given a favorable treatment.
 Time waiting and run-time is the system response time.
izazroghani@gmail.com
24
• HRN
 When processes first appear in the READY queue, the “time
waiting” will be zero and hence P will be equal to 1 for all processes.
 Consider two jobs ‘A’ and ‘B, with run-time of 10 and 50 minutes
respectively. After each has waited 5 minutes, their respective
priorities are:
 A : P = (5+10) = 1.5 B: P = (5 + 50) = 1.1
10 50
 On this basis, the shorter job A will be selected.
 However, that if ‘A’ has just started (wait time=0), then according to
the formula the priority of process ‘A’ will be P = 1, and since the
priority for process ‘B’ is p= 1.1, then in this situation process “B” will
be chosen in preference to ‘A’.
 This technique that a job can’t be starved.
izazroghani@gmail.com
25
• ASSIGNMENT
 Q1: GIVE AN EXAMPLE OF HRN POLICY WITH THE HELP OF
GANTT CHART?
 WHAT IS ONE OF THE MAJOR PROBLEM WITH PRIORITY
BASED SCHEDULING AND WHAT IS THEIR SOLUTION?
 BOOK: CHAPTER # 6, BY SILBERSCHATZ
izazroghani@gmail.com
26
• ROUND ROBIN SCHEDULING (RRS)
 The oldest, simplest, fairest and most widely used scheduling policy.
 In the RR scheme, a process is selected for running from the READY queue in
FIFO (First in First out) sequence.
 Each process which enters in the CPU, is given limited amount of CPU time,
called a “time slice / quantum”.
 However, if the process runs beyond the time slice, then it is interrupted and
returned to the end of the READY queue.
 In other words, each active process is given a “time slice” in rotation.
 Time slice is usually 10 – 100 millisecond.
------- P4 P3 P2 P1 P 1PA
izazroghani@gmail.com
27
• RR Scheduling
 RR is effective in timesharing environment in which the system
needs to guarantee reasonable response time for interactive users.
 The RR scheme is preemptive, but preemption occurs only by
expiry of the time quantum.
izazroghani@gmail.com
28
• Multi-level Feedback Queues (MFQ)
 The MFQ scheme is an attempt to provide a more adaptive policy
which will treat processes in the basis of their past behavior.
 Figure shows a typical set up for a MFQ system. It consists of a
number of separate queues of entries which represent active
processes.
 Each queue represents a different priority, with the top queue being
highest priority and lower queues successively lower priorities.
 Within each queue, the queued processes are treated in a
FIFO/FCFS fashion, with a time quantum being allotted to each
process in the queue.
 A new process enters the system at the end of the top queue, and
will be execute for a time slice allotted to it.
 Upon expiry of quantum, it will moves to the end of next lower
queue.
 At last it will move to the Lowest level queue, where a RR scheme
is applied and then it execute their till the completion of the process.
izazroghani@gmail.com
29
•Multilevel Feedback Queues
izazroghani@gmail.com
30
•Example of Multilevel Feedback Queue
 Three queues:
 Q0 – RR with time quantum 8 milliseconds
 Q1 – RR time quantum 16 milliseconds
 Q2 – FCFS
 Scheduling
 A new job enters queue Q0 which is served FCFS. When it gains
CPU, job receives 8 milliseconds. If it does not finish in 8
milliseconds, job is moved to queue Q1.
 At Q1 job is again served FCFS and receives 16 additional
milliseconds. If it still does not complete, it is preempted and
moved to queue Q2.
izazroghani@gmail.com
31
ASSIGNMENT
 Q1: WHAT IS DISPATCHER, AND WHAT IS MEANT BY
DISPATCH LATENCY?
 Q2: WHAT ARE THE ADVANTAGES AND DIS-ADVANTAGES OF
PEEMPTIVE AND NON-PREEMPTIVE SCHEDULING
ALGORITHMS?
 Q3: WHAT IS STATIC AND DYNAMIC PRIORITIES ?
 Q4: WHAT IS CONVOY EFFECT IN FCFS SCHEDULING
ALGORITHM?
izazroghani@gmail.com

Más contenido relacionado

La actualidad más candente

CPU Scheduling in OS Presentation
CPU Scheduling in OS  PresentationCPU Scheduling in OS  Presentation
CPU Scheduling in OS Presentationusmankiyani1
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)Harshit Jain
 
CPU Scheduling algorithms
CPU Scheduling algorithmsCPU Scheduling algorithms
CPU Scheduling algorithmsShanu Kumar
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithmsPaurav Shah
 
CPU scheduling algorithms in OS
CPU scheduling algorithms in OSCPU scheduling algorithms in OS
CPU scheduling algorithms in OSharini0810
 
Process scheduling in Light weight weight and Heavy weight processes.
Process scheduling in Light weight weight and Heavy weight processes.Process scheduling in Light weight weight and Heavy weight processes.
Process scheduling in Light weight weight and Heavy weight processes.Shreya Kumar
 
Ch6 CPU Scheduling galvin
Ch6 CPU Scheduling galvinCh6 CPU Scheduling galvin
Ch6 CPU Scheduling galvinShubham Singh
 
17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria 17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria myrajendra
 
OS - CPU Scheduling
OS - CPU SchedulingOS - CPU Scheduling
OS - CPU Schedulingvinay arora
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process SchedulingShipra Swati
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling AlgorithmsTayba Farooqui
 

La actualidad más candente (20)

CPU Scheduling in OS Presentation
CPU Scheduling in OS  PresentationCPU Scheduling in OS  Presentation
CPU Scheduling in OS Presentation
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)
 
CPU Scheduling algorithms
CPU Scheduling algorithmsCPU Scheduling algorithms
CPU Scheduling algorithms
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Cpu Scheduling Galvin
Cpu Scheduling GalvinCpu Scheduling Galvin
Cpu Scheduling Galvin
 
Scheduling
SchedulingScheduling
Scheduling
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
CPU scheduling algorithms in OS
CPU scheduling algorithms in OSCPU scheduling algorithms in OS
CPU scheduling algorithms in OS
 
Os module 2 ba
Os module 2 baOs module 2 ba
Os module 2 ba
 
CPU Sheduling
CPU Sheduling CPU Sheduling
CPU Sheduling
 
Process scheduling in Light weight weight and Heavy weight processes.
Process scheduling in Light weight weight and Heavy weight processes.Process scheduling in Light weight weight and Heavy weight processes.
Process scheduling in Light weight weight and Heavy weight processes.
 
Ch6 CPU Scheduling galvin
Ch6 CPU Scheduling galvinCh6 CPU Scheduling galvin
Ch6 CPU Scheduling galvin
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
PPT CPU
PPT CPUPPT CPU
PPT CPU
 
17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria 17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria
 
Chapter4
Chapter4Chapter4
Chapter4
 
OS - CPU Scheduling
OS - CPU SchedulingOS - CPU Scheduling
OS - CPU Scheduling
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 

Similar a Processor / CPU Scheduling

Process management- This ppt contains all required information regarding oper...
Process management- This ppt contains all required information regarding oper...Process management- This ppt contains all required information regarding oper...
Process management- This ppt contains all required information regarding oper...ApurvaLaddha
 
LM10,11,12 - CPU SCHEDULING algorithms and its processes
LM10,11,12 - CPU SCHEDULING algorithms and its processesLM10,11,12 - CPU SCHEDULING algorithms and its processes
LM10,11,12 - CPU SCHEDULING algorithms and its processesmanideepakc
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Mukesh Chinta
 
CPU scheduling in Operating System Explanation
CPU scheduling in Operating System ExplanationCPU scheduling in Operating System Explanation
CPU scheduling in Operating System ExplanationAnitaSofiaKeyser
 
In computing, scheduling is the action .
In computing, scheduling is the action .In computing, scheduling is the action .
In computing, scheduling is the action .nathansel1
 
PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptxDivyaKS18
 
Os unit 3 , process management
Os unit 3 , process managementOs unit 3 , process management
Os unit 3 , process managementArnav Chowdhury
 
Operating System
Operating SystemOperating System
Operating SystemGowriLatha1
 
CSI-503 - 3. Process Scheduling
CSI-503 - 3. Process SchedulingCSI-503 - 3. Process Scheduling
CSI-503 - 3. Process Schedulingghayour abbas
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.pptKeyreSebre
 

Similar a Processor / CPU Scheduling (20)

Operating System.pptx
Operating System.pptxOperating System.pptx
Operating System.pptx
 
Osy ppt - Copy.pptx
Osy ppt - Copy.pptxOsy ppt - Copy.pptx
Osy ppt - Copy.pptx
 
Process management- This ppt contains all required information regarding oper...
Process management- This ppt contains all required information regarding oper...Process management- This ppt contains all required information regarding oper...
Process management- This ppt contains all required information regarding oper...
 
LM10,11,12 - CPU SCHEDULING algorithms and its processes
LM10,11,12 - CPU SCHEDULING algorithms and its processesLM10,11,12 - CPU SCHEDULING algorithms and its processes
LM10,11,12 - CPU SCHEDULING algorithms and its processes
 
Scheduling
SchedulingScheduling
Scheduling
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
CPU scheduling in Operating System Explanation
CPU scheduling in Operating System ExplanationCPU scheduling in Operating System Explanation
CPU scheduling in Operating System Explanation
 
Section05 scheduling
Section05 schedulingSection05 scheduling
Section05 scheduling
 
In computing, scheduling is the action .
In computing, scheduling is the action .In computing, scheduling is the action .
In computing, scheduling is the action .
 
PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptx
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
Os unit 3 , process management
Os unit 3 , process managementOs unit 3 , process management
Os unit 3 , process management
 
Operating System
Operating SystemOperating System
Operating System
 
CSI-503 - 3. Process Scheduling
CSI-503 - 3. Process SchedulingCSI-503 - 3. Process Scheduling
CSI-503 - 3. Process Scheduling
 
Unit 2 notes
Unit 2 notesUnit 2 notes
Unit 2 notes
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
cpu scheduling.pdf
cpu scheduling.pdfcpu scheduling.pdf
cpu scheduling.pdf
 
Lecture 4 process cpu scheduling
Lecture 4   process cpu schedulingLecture 4   process cpu scheduling
Lecture 4 process cpu scheduling
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
 

Último

psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 

Último (20)

psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 

Processor / CPU Scheduling

  • 2. 2 • Scheduling  CPU is the brain of the computer system __ performs all the processing inside the computer.  Programs enter to systems ___becomes process __ handled by OS.  In a Multi-programming/Multi-user systems ___ many processes __ each process wait for its turn to utilize the CPU and to perform some useful task.  That’s why CPU requires some type of mechanism ___ to serve all the processes uniformly.  “This mechanism is handled by the OS and this management of the CPU is called CPU/processor scheduling”.  EXPLANATION: more than one processes in the Ready state __ OS decision __ which one to run first __ which one to wait.  The part of OS which makes this decision is called “Scheduler”, the algorithm it uses is called the scheduling algorithm. izazroghani@gmail.com
  • 3. 3 • Scheduling  Scheduling affects the performance of the system because it determines which process will wait and which will progress.  Simply we can say that the problem of determining, when processor should be assigned to which process (currently in memory) is called scheduling.  Scheduling is a fundamental OS function.  Since the CPU is such an important resource, it is very important to develop good scheduling algorithms. izazroghani@gmail.com
  • 4. 4 • Scheduling Objectives  Scheduling typically attempts to achieve some combination of the following goals, and the overall scheduling effort is intended to meet system’s performance and behavior.  THROUGHPUT: Maximize the number of jobs processed/completed per unit time.  UTILIZATION OF RESOURCES: Maximize utilization of other resources (disks, printers etc).  RESPONSE TIME: Minimize the response time for interactive users (on-line users/time sharing) i.e. provide tolerable response time.  TURNAROUND TIME: Minimize the time user wait for the output (batch users) = waiting time + computation time + I/O time  FAIRNESS: To make sure that each process gets its share of the CPU i.e. treated equally.  EFFICIENCY: To keep the CPU busy 100% of the time. izazroghani@gmail.com
  • 5. 5 • Scheduling Objectives  GRACEFUL DEGRADATION: If the system becomes overloaded, it should not ‘collapse’, but avoid further loading and temporarily reduce the level of service (response time). izazroghani@gmail.com
  • 6. 6 • CPU I/O Burst Cycle  The execution of a process consist of an alternation of CPU Bursts and I/O Bursts.  A process begins and ends with a CPU burst. In between, CPU activity is suspended whenever an I/O operation is needed.  I/O BOUND: If the CPU bursts are relatively short compared to the I/O bursts, then the process is said to be I/O bound.  For example, if the processor is capable of making rapid changes to a large database stored on a disk faster than the drive mechanism can perform the read and write operations, the computer is input/output-bound.  CPU Bound: If the CPU bursts are relatively long compared to the I/O bursts, then the process is said to be CPU bound.  For example, if a processor is involved in a long arithmetic computations, then the process is CPU bound. izazroghani@gmail.com
  • 7. 7 •SCHEDULING LEVEL  HIGH LEVEL SCHEDULING  INTERMEDIATE LEVE SCHEDULING  LOW LEVEL SCEDULING izazroghani@gmail.com
  • 8. 8 • SCHEDULING LEVELS  In a process life cycle, scheduling can be used at THREE levels/points. The scheduling levels discuss the level/point at which scheduling mechanism can be used. • High level Scheduling  Also called Job/Admission/long term scheduling.  When a job is entered into a system and become a process it is high level scheduling.  Often admission, a process start competing actively for the resources of the system.  HLS controls the admission of jobs into the system, i.e. it decides which newly jobs are to be converted into processes and be put into the READY queue to compete for the CPU.  This activity is only really applicable to Batch systems. izazroghani@gmail.com
  • 9. 9 • Intermediate level Scheduling (ILS)  Also called Medium level scheduling (MLS).  MLS is applicable to systems where a process within the system (but not currently running i.e. in the Ready Queue) can be swapped out of memory on to disk (Virtual Memory) in order to reduce the system load.  MLS determines that which process shall be allowed to compete for the CPU and which shall be suspended/blocked in response to Virtual memory.  MLS acts as a buffer between the admission of jobs to the system, and the assigning of the CPU to these jobs. izazroghani@gmail.com
  • 10. 10 • Low level Scheduling (LLS)  The LLS is the most complex and significant of the scheduling levels  LLS determines that which Ready process will be assigned to the CPU, when it is next available, and actually assign the CPU to this process.  LLS is performed by the Dispatcher, i.e. it dispatches a process to the CPU, which operates many times per second.  The dispatcher must therefore resides all the time in main memory  The LLS will be invoked whenever the current process relinquishes (leave/remove) control ( because of any I/O call or interrupt arises).  A number of policies have been devised for use in LLS, each of which has its own advantages and disadvantages.  HOME WORK: Pages # 287….291 from H.M. Deitel. izazroghani@gmail.com
  • 11. 11 • Scheduling Levels Job waiting for Entry Job waiting for initiation Suspended Process waiting For initiation Active processes Running Processes Completed izazroghani@gmail.com
  • 12. 12 •SCHEDULING TYPES  PREEMPTIVE SCHEDULING NON-PREEMPTIVE SCHEDULING izazroghani@gmail.com
  • 13. 13 • SCHEDULING TYPES  Scheduling types determines how the processes use the CPU after dispatching or at LLS.  Either the process remain in the CPU until its completion or it remains there for a short time (quantum or time slice). • Preemptive Scheduling  Preemption basically means that a process may be forcibly removed from the CPU even if does not want to release the CPU i.e. it is still executing but a higher priority process needs the CPU.  In preemptive scheme, the LLS may remove a process from the RUNNING state in order to allow another process to run.  In a preemptive scheme, a running process may be forced to yield the CPU ( thus returning to the ready list) by an external rather than by its own action. Such external events can be:  A higher priority process enters the systems.  A waited process becomes ready (because of I/O interrupt). izazroghani@gmail.com
  • 14. 14 • Non-Preemptive Scheduling  In Non-Preemptive scheme, a process once given to the processor, will be allowed to run until its completion or until it terminates or incurs an I/O wait.  OR we can say that when a process can not “forcibly” lose the processor.  Non-Preemptive scheduling is also known as “Run-to-Completion”, which is slightly inaccurate, since the process will lose the processor if it incurs an I/O wait. ASSIGNMENT: Q1: Compare Preemptive with Non-preemptive scheduling? izazroghani@gmail.com
  • 15. 15 • Preemptive VS Non-Preemptive Scheduling  Preemptive scheduling is useful, where high priority process required rapid attention.  In a real time system and in a interactive timesharing system, preemptive scheduling is important.  In Preemptive scheduling, interrupts disturbs the efficiency of the CPU.  In a Non-preemptive scheduling systems, short job are made to wait by long jobs.  Non-preemptive scheduling is easy to implement, they are simple.  In Non-preemptive scheme, high-priority jobs can not displace waiting jobs. izazroghani@gmail.com
  • 16. 16 • Scheduling Criteria  There are many scheduling algorithms, and various criteria to judge their performance. Different algorithms may favor different types of processes. A few criteria are:  Max CPU utilization – try to keep the CPU as busy as possible  Max Throughput – Number of processes completed in a unit time.  Min Turnaround time – Time needed to execute a process.  Min Response time & waiting time.  The CPU scheduling algorithm should try to maximize the above points. izazroghani@gmail.com
  • 18. 18 • FIFO or FCFS (First-come-first-served)  The simplest scheduling algorithm/policy.  As the name implies, the FCFS policy simply assigns the processor to the process which is first in the READY queue.  This is the Non-preemptive scheme. (Run-to-completion)  FAIR in a sense: Run the jobs till completion  UNFAIR in a sense: Long job make short job to wait for a long time and un- important jobs make important job wait.  Its response time is predictable. ( By Gantt Chart)  FIFO/FCFS is rarely used as a master scheme in today’s system, but it is often embedded with other schemes. ------- P4 P3 P2 P1 P 1 izazroghani@gmail.com
  • 19. 19 • Illustration of FCFS policy  We assume the arrival in the READY queue for processes in the numbered sequence, we can calculate how long each process has to wait. (a) (b) Job Est. Burst/Run Time waiting 1 2 (unit time) 0 2 60 2 3 1 62 4 3 63 5 50 66 The average waiting time= (0+2+62+63+66)/5= ? izazroghani@gmail.com
  • 20. 20 • SJF (Shortest Job First – Non-Preemptive)  It is a Non-preemptive scheduling policy.  In this policy waiting jobs with shortest (shortest) estimated run-time is run or dispatch next.  It is a priority scheme, in which SJF favors short job at the expense of longer jobs.  If we use this scheme on the jobs in Table 1, above, we get a rather different picture as shown in Table 2. (a) (b) Job Est. Burst/Run Time waiting 3 1 0 1 2 (unit time) 1 4 3 3 5 50 6 2 60 56 izazroghani@gmail.com
  • 21. 21 • SJF (preemptive version)  We also have a Preemptive version of SJF.  In the preemptive version of SJF, a long job in the queue may be delayed by a succession of smaller jobs arriving in the queue.  In the example of Table 2, it is assumed that the job list is constant, but, in practice, before Time 3 is when job 5 is due to start, another job of length, say, 10 minutes could arrive and be placed ahead of job5.  This queue jumping effect could recur (occur again) many times, effectively preventing job 5 from starting at all; this situation is known as Starvation. (a) (b) Job Est. Burst/Run Time waiting 3 1 0 1 2 (unit time) 1 4 3 3 x 10 5 50 6 2 60 56 izazroghani@gmail.com
  • 22. 22 • SRT ( Shortest Remaining Time)  SRT is a preemptive version of SJF, and is useful in timesharing environment.  In SRT, suppose a process “A” is dispatched to the CPU and started processing, however, during of this process, another process say “B” arrives who’s Run-time is shorter than Job “A’s” remaining run time, then job “A” will be preempted and job “B” will be allow to execute.  SRT favors short jobs even more than SJF, since a currently running long job could be ousted (removed) by a new shorter one.  DANGER OF STARVATION:  The danger of starvation of longer jobs also exists in this scheme.  Longer jobs --- waits for shorter jobs.  Implementation of SRT requires an estimate of Total-run-time and measurement of Elapsed run-time.  So SRT has a higher over head than SJF izazroghani@gmail.com
  • 23. 23 • HRN (Highest Response Ratio Next)  To correct some of the weaknesses (Danger of starvation) of the SJF policy, Brinch Hansen developed the HRN strategy.  HRN is a Non-preemptive scheduling, (Run-to-completion).  In HRN, a job with the highest priority value will be selected for running.  The priority of job is a function of its Service time and its waited time  Dynamic priorities are calculated in HRN according to the formula Priority, P = time waiting + runt time / burst time run time  Longer and shorter job’s are both given a favorable treatment.  Time waiting and run-time is the system response time. izazroghani@gmail.com
  • 24. 24 • HRN  When processes first appear in the READY queue, the “time waiting” will be zero and hence P will be equal to 1 for all processes.  Consider two jobs ‘A’ and ‘B, with run-time of 10 and 50 minutes respectively. After each has waited 5 minutes, their respective priorities are:  A : P = (5+10) = 1.5 B: P = (5 + 50) = 1.1 10 50  On this basis, the shorter job A will be selected.  However, that if ‘A’ has just started (wait time=0), then according to the formula the priority of process ‘A’ will be P = 1, and since the priority for process ‘B’ is p= 1.1, then in this situation process “B” will be chosen in preference to ‘A’.  This technique that a job can’t be starved. izazroghani@gmail.com
  • 25. 25 • ASSIGNMENT  Q1: GIVE AN EXAMPLE OF HRN POLICY WITH THE HELP OF GANTT CHART?  WHAT IS ONE OF THE MAJOR PROBLEM WITH PRIORITY BASED SCHEDULING AND WHAT IS THEIR SOLUTION?  BOOK: CHAPTER # 6, BY SILBERSCHATZ izazroghani@gmail.com
  • 26. 26 • ROUND ROBIN SCHEDULING (RRS)  The oldest, simplest, fairest and most widely used scheduling policy.  In the RR scheme, a process is selected for running from the READY queue in FIFO (First in First out) sequence.  Each process which enters in the CPU, is given limited amount of CPU time, called a “time slice / quantum”.  However, if the process runs beyond the time slice, then it is interrupted and returned to the end of the READY queue.  In other words, each active process is given a “time slice” in rotation.  Time slice is usually 10 – 100 millisecond. ------- P4 P3 P2 P1 P 1PA izazroghani@gmail.com
  • 27. 27 • RR Scheduling  RR is effective in timesharing environment in which the system needs to guarantee reasonable response time for interactive users.  The RR scheme is preemptive, but preemption occurs only by expiry of the time quantum. izazroghani@gmail.com
  • 28. 28 • Multi-level Feedback Queues (MFQ)  The MFQ scheme is an attempt to provide a more adaptive policy which will treat processes in the basis of their past behavior.  Figure shows a typical set up for a MFQ system. It consists of a number of separate queues of entries which represent active processes.  Each queue represents a different priority, with the top queue being highest priority and lower queues successively lower priorities.  Within each queue, the queued processes are treated in a FIFO/FCFS fashion, with a time quantum being allotted to each process in the queue.  A new process enters the system at the end of the top queue, and will be execute for a time slice allotted to it.  Upon expiry of quantum, it will moves to the end of next lower queue.  At last it will move to the Lowest level queue, where a RR scheme is applied and then it execute their till the completion of the process. izazroghani@gmail.com
  • 30. 30 •Example of Multilevel Feedback Queue  Three queues:  Q0 – RR with time quantum 8 milliseconds  Q1 – RR time quantum 16 milliseconds  Q2 – FCFS  Scheduling  A new job enters queue Q0 which is served FCFS. When it gains CPU, job receives 8 milliseconds. If it does not finish in 8 milliseconds, job is moved to queue Q1.  At Q1 job is again served FCFS and receives 16 additional milliseconds. If it still does not complete, it is preempted and moved to queue Q2. izazroghani@gmail.com
  • 31. 31 ASSIGNMENT  Q1: WHAT IS DISPATCHER, AND WHAT IS MEANT BY DISPATCH LATENCY?  Q2: WHAT ARE THE ADVANTAGES AND DIS-ADVANTAGES OF PEEMPTIVE AND NON-PREEMPTIVE SCHEDULING ALGORITHMS?  Q3: WHAT IS STATIC AND DYNAMIC PRIORITIES ?  Q4: WHAT IS CONVOY EFFECT IN FCFS SCHEDULING ALGORITHM? izazroghani@gmail.com