SlideShare a Scribd company logo
1 of 17
Scheduling
Algorithms
Presented By:
Shekhar Singh Tomar
ContentsContents
 Introduction
 Scheduling Algorithms-
 First Come, First Served (FCFS)
 Shortest Job First (SJF)
 Priority
 Round Robin (RR)
IntroductionIntroduction
CPU scheduling deals with the problem of deciding which
of the processes in the ready queue is to be allocated the
CPU.
1- First Come, First Served (FCFS)1- First Come, First Served (FCFS)
SchedulingScheduling
 Implementation:
As each process becomes ready, it joins the ready queue.
When the current process finishes, the oldest process is selected
next.
 Characteristics:
Simple to implement
Non-preemptive
First-Come, First-Served (FCFS)First-Come, First-Served (FCFS)
SchedulingScheduling
Example- Process Burst Time
P1 24
P2 3
P3 3
 With FCFS, the process that requests the CPU first is allocated the CPU first
 Case 1: Suppose that the processes arrive in the order: P1 , P2 , P3
The Chart for the schedule is:
 Waiting time for P1 = 0; P2 = 24; P3 = 27
 Average waiting time: (0 + 24 + 27)/3 = 17
 Average turn-around time: (24 + 27 + 30)/3 = 27
P1 P2 P3
24 27 300
FCFS Scheduling (Cont.)FCFS Scheduling (Cont.)
 Case 2: Suppose that the processes arrive in the order: P2 , P3 , P1
 The chart for the schedule is:
 Waiting time for P1 = 6; P2 = 0; P3 = 3
 Average waiting time: (6 + 0 + 3)/3 = 3 (Much better than Case #1)
 Average turn-around time: (3 + 6 + 30)/3 = 13
P1P3P2
63 300
2-Shortest-Job-First (SJF) Scheduling2-Shortest-Job-First (SJF) Scheduling
 The SJF algorithm associates with each process the length of its
next CPU burst
 When the CPU becomes available, it is assigned to the process
that has the smallest next CPU burst (in the case of matching
bursts, FCFS is used)
 Two schemes:
Non-preemptive – once the CPU is given to the process, it
cannot be preempted until it completes its CPU burst.
Preemptive – It will preempt the currently executing process.
This scheme is know as the Shortest-Remaining-Time-First
(SRTF)
SJF Scheduling…SJF Scheduling…
Exponential Averaging
 Estimation based on historical data
 tn = length of the nth CPU burst
 τn = Estimate for nth CPU burst (stores past history)
 τn+1 = predicted value for n+1st
or next CPU burst
 α, 0 ≤ α 1≤
τn+1 = αtn + (1- α) τn
09/24/13 8
Process Arrival Time Burst Time
P1 0.0 6
P2 0.0 4
P3 0.0 1
P4 0.0 5
SJF (non-preemptive, simultaneous arrival)
Average waiting time = (0 + 1 + 5 + 10)/4 = 4
Average turn-around time = (1 + 5 + 10 + 16)/4 = 8
Example 1: Non-Preemptive SJFExample 1: Non-Preemptive SJF
(simultaneous arrival)(simultaneous arrival)
P1P3 P2
51 160
P4
10
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
SJF (non-preemptive, varied arrival times)
Average waiting time
= ( (0 – 0) + (8 – 2) + (7 – 4) + (12 – 5) )/4
= (0 + 6 + 3 + 7)/4 = 4
Average turn-around time:
= ( (7 – 0) + (12 – 2) + (8 - 4) + (16 – 5))/4
= ( 7 + 10 + 4 + 11)/4 = 8
Example 2: Non-Preemptive SJFExample 2: Non-Preemptive SJF
(varied arrival times)(varied arrival times)
P1 P3 P2
73 160
P4
8 12
Waiting time : sum of time that a process has spent waiting in the ready queue
Example 3: Preemptive SJFExample 3: Preemptive SJF
(Shortest-remaining-time-first)(Shortest-remaining-time-first)
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
SJF (preemptive , varied arrival times)
Average waiting time
= ( [(0 – 0) + (11 - 2)] + [(2 – 2) + (5 – 4)] + (4 - 4) + (7 – 5) )/4
= 9 + 1 + 0 + 2)/4
= 3
Average turn-around time = (16 + 7 + 5 + 11)/4 = 9.75
P1 P3P2
42 110
P4
5 7
P2 P1
16
Waiting time : sum of time that a process has spent waiting in the ready queue
3- Priority Scheduling3- Priority Scheduling
 The SJF algorithm is a special case of the general priority scheduling
algorithm
 Each process (or class of processes) is given a priority (integer
number).
 The CPU is allocated to the process with the highest priority (smallest
integer = highest priority)
 Priority scheduling can be either preemptive or non-preemptive
A preemptive approach will preempt the CPU if the priority of the
newly-arrived process is higher than the priority of the currently
running process
A non-preemptive approach will simply put the new process
(with the highest priority) at the head of the ready queue
 SJF is a priority scheduling algorithm where priority is the predicted
next CPU burst time.
 The main problem with priority scheduling is starvation, that is, low
priority processes may never execute.
 A solution is aging; as time progresses, the priority of a process in the
ready queue is increased
Example of Priority SchedulingExample of Priority Scheduling
Process Burst time Priority
P1 10 3
P2 1 1
P3 2 4
P4 1 5
P5 5 2
0 1 6 16 18 19
Average wating time = (6+0+16+18+1)/5=8.2 milliseconds
P2 P5 P1 P3 P4
4- Round-Robin Scheduling4- Round-Robin Scheduling
 Developed in response to time-sharing systems.
 Each process gets a small unit of CPU time (time quantum),
 Each job is given control of the CPU for that time quantum.
(In the range of 10-100 milliseconds.)
 Control then passes to the next job (FIFO?)
 Average waiting time dependent on job size, quantum size
 RR scheduling algorithm is preemptive.
Example of RR with Time Quantum =Example of RR with Time Quantum =
44
Process Burst Time
P1 24
P2 3
P3 3
 The chart is:
 Typically, higher average turnaround than SJF, but better response.
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
Time Quantum and Context SwitchTime Quantum and Context Switch
TimeTime
Thank YouThank You

More Related Content

What's hot

Operating systems chapter 5 silberschatz
Operating systems chapter 5 silberschatzOperating systems chapter 5 silberschatz
Operating systems chapter 5 silberschatzGiulianoRanauro
 
Priority driven scheduling of periodic tasks
Priority driven scheduling of periodic tasksPriority driven scheduling of periodic tasks
Priority driven scheduling of periodic tasksKamal Acharya
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal BootloaderSatpal Parmar
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithmssathish sak
 
shortest job first
shortest job firstshortest job first
shortest job firsti i
 
FCFS scheduling OS
FCFS scheduling OSFCFS scheduling OS
FCFS scheduling OSTotan Banik
 
Process management in os
Process management in osProcess management in os
Process management in osMiong Lazaro
 
cpu scheduling
cpu schedulingcpu scheduling
cpu schedulinghashim102
 
CPU scheduling
CPU schedulingCPU scheduling
CPU schedulingAmir Khan
 
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round RobinComparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round RobinUniversitas Pembangunan Panca Budi
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Mukesh Chinta
 
SFO15-302: Energy Aware Scheduling: Progress Update
SFO15-302: Energy Aware Scheduling: Progress UpdateSFO15-302: Energy Aware Scheduling: Progress Update
SFO15-302: Energy Aware Scheduling: Progress UpdateLinaro
 
HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted FirmwareHKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted FirmwareLinaro
 
Module 3-cpu-scheduling
Module 3-cpu-schedulingModule 3-cpu-scheduling
Module 3-cpu-schedulingHesham Elmasry
 
CPU scheduling algorithms in OS
CPU scheduling algorithms in OSCPU scheduling algorithms in OS
CPU scheduling algorithms in OSharini0810
 
Cpu scheduling (1)
Cpu scheduling (1)Cpu scheduling (1)
Cpu scheduling (1)Ayush Oberai
 
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all startedKernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all startedAnne Nicolas
 

What's hot (20)

Lecture 4 process cpu scheduling
Lecture 4   process cpu schedulingLecture 4   process cpu scheduling
Lecture 4 process cpu scheduling
 
Operating systems chapter 5 silberschatz
Operating systems chapter 5 silberschatzOperating systems chapter 5 silberschatz
Operating systems chapter 5 silberschatz
 
Priority driven scheduling of periodic tasks
Priority driven scheduling of periodic tasksPriority driven scheduling of periodic tasks
Priority driven scheduling of periodic tasks
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal Bootloader
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithms
 
shortest job first
shortest job firstshortest job first
shortest job first
 
FCFS scheduling OS
FCFS scheduling OSFCFS scheduling OS
FCFS scheduling OS
 
Process management in os
Process management in osProcess management in os
Process management in os
 
cpu scheduling
cpu schedulingcpu scheduling
cpu scheduling
 
CPU scheduling
CPU schedulingCPU scheduling
CPU scheduling
 
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round RobinComparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
 
SFO15-302: Energy Aware Scheduling: Progress Update
SFO15-302: Energy Aware Scheduling: Progress UpdateSFO15-302: Energy Aware Scheduling: Progress Update
SFO15-302: Energy Aware Scheduling: Progress Update
 
HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted FirmwareHKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
 
Module 3-cpu-scheduling
Module 3-cpu-schedulingModule 3-cpu-scheduling
Module 3-cpu-scheduling
 
CPU scheduling algorithms in OS
CPU scheduling algorithms in OSCPU scheduling algorithms in OS
CPU scheduling algorithms in OS
 
Cpu scheduling (1)
Cpu scheduling (1)Cpu scheduling (1)
Cpu scheduling (1)
 
SCHEDULING ALGORITHMS
SCHEDULING ALGORITHMSSCHEDULING ALGORITHMS
SCHEDULING ALGORITHMS
 
Rtos Concepts
Rtos ConceptsRtos Concepts
Rtos Concepts
 
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all startedKernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all started
 

Similar to Sa by shekhar

Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-schedulingNazir Ahmed
 
Ch6
Ch6Ch6
Ch6C.U
 
cpu sechduling
cpu sechduling cpu sechduling
cpu sechduling gopi7
 
csc4320chapter5-2-101203002830-phpapp01.pdf
csc4320chapter5-2-101203002830-phpapp01.pdfcsc4320chapter5-2-101203002830-phpapp01.pdf
csc4320chapter5-2-101203002830-phpapp01.pdfAkarshNag
 
Csc4320 chapter 5 2
Csc4320 chapter 5 2Csc4320 chapter 5 2
Csc4320 chapter 5 2pri534
 
Preemptive process example.pptx
Preemptive process example.pptxPreemptive process example.pptx
Preemptive process example.pptxjamilaltiti1
 
Operating Systems Third Unit - Fourth Semester - Engineering
Operating Systems Third Unit  - Fourth Semester - EngineeringOperating Systems Third Unit  - Fourth Semester - Engineering
Operating Systems Third Unit - Fourth Semester - EngineeringYogesh Santhan
 
Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Nagarajan
 
Cpu scheduling(suresh)
Cpu scheduling(suresh)Cpu scheduling(suresh)
Cpu scheduling(suresh)Nagarajan
 

Similar to Sa by shekhar (20)

OSCh6
OSCh6OSCh6
OSCh6
 
OS_Ch6
OS_Ch6OS_Ch6
OS_Ch6
 
Ch5
Ch5Ch5
Ch5
 
Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-scheduling
 
Ch6
Ch6Ch6
Ch6
 
Os module 2 ba
Os module 2 baOs module 2 ba
Os module 2 ba
 
Ch05
Ch05Ch05
Ch05
 
cpu sechduling
cpu sechduling cpu sechduling
cpu sechduling
 
csc4320chapter5-2-101203002830-phpapp01.pdf
csc4320chapter5-2-101203002830-phpapp01.pdfcsc4320chapter5-2-101203002830-phpapp01.pdf
csc4320chapter5-2-101203002830-phpapp01.pdf
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Os..
Os..Os..
Os..
 
Csc4320 chapter 5 2
Csc4320 chapter 5 2Csc4320 chapter 5 2
Csc4320 chapter 5 2
 
Cpu Scheduling Galvin
Cpu Scheduling GalvinCpu Scheduling Galvin
Cpu Scheduling Galvin
 
Preemptive process example.pptx
Preemptive process example.pptxPreemptive process example.pptx
Preemptive process example.pptx
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Operating Systems Third Unit - Fourth Semester - Engineering
Operating Systems Third Unit  - Fourth Semester - EngineeringOperating Systems Third Unit  - Fourth Semester - Engineering
Operating Systems Third Unit - Fourth Semester - Engineering
 
Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Scheduling algorithm (chammu)
Scheduling algorithm (chammu)
 
CH06.pdf
CH06.pdfCH06.pdf
CH06.pdf
 
Cpu scheduling(suresh)
Cpu scheduling(suresh)Cpu scheduling(suresh)
Cpu scheduling(suresh)
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 

Recently uploaded

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Recently uploaded (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

Sa by shekhar

  • 2. ContentsContents  Introduction  Scheduling Algorithms-  First Come, First Served (FCFS)  Shortest Job First (SJF)  Priority  Round Robin (RR)
  • 3. IntroductionIntroduction CPU scheduling deals with the problem of deciding which of the processes in the ready queue is to be allocated the CPU.
  • 4. 1- First Come, First Served (FCFS)1- First Come, First Served (FCFS) SchedulingScheduling  Implementation: As each process becomes ready, it joins the ready queue. When the current process finishes, the oldest process is selected next.  Characteristics: Simple to implement Non-preemptive
  • 5. First-Come, First-Served (FCFS)First-Come, First-Served (FCFS) SchedulingScheduling Example- Process Burst Time P1 24 P2 3 P3 3  With FCFS, the process that requests the CPU first is allocated the CPU first  Case 1: Suppose that the processes arrive in the order: P1 , P2 , P3 The Chart for the schedule is:  Waiting time for P1 = 0; P2 = 24; P3 = 27  Average waiting time: (0 + 24 + 27)/3 = 17  Average turn-around time: (24 + 27 + 30)/3 = 27 P1 P2 P3 24 27 300
  • 6. FCFS Scheduling (Cont.)FCFS Scheduling (Cont.)  Case 2: Suppose that the processes arrive in the order: P2 , P3 , P1  The chart for the schedule is:  Waiting time for P1 = 6; P2 = 0; P3 = 3  Average waiting time: (6 + 0 + 3)/3 = 3 (Much better than Case #1)  Average turn-around time: (3 + 6 + 30)/3 = 13 P1P3P2 63 300
  • 7. 2-Shortest-Job-First (SJF) Scheduling2-Shortest-Job-First (SJF) Scheduling  The SJF algorithm associates with each process the length of its next CPU burst  When the CPU becomes available, it is assigned to the process that has the smallest next CPU burst (in the case of matching bursts, FCFS is used)  Two schemes: Non-preemptive – once the CPU is given to the process, it cannot be preempted until it completes its CPU burst. Preemptive – It will preempt the currently executing process. This scheme is know as the Shortest-Remaining-Time-First (SRTF)
  • 8. SJF Scheduling…SJF Scheduling… Exponential Averaging  Estimation based on historical data  tn = length of the nth CPU burst  τn = Estimate for nth CPU burst (stores past history)  τn+1 = predicted value for n+1st or next CPU burst  α, 0 ≤ α 1≤ τn+1 = αtn + (1- α) τn 09/24/13 8
  • 9. Process Arrival Time Burst Time P1 0.0 6 P2 0.0 4 P3 0.0 1 P4 0.0 5 SJF (non-preemptive, simultaneous arrival) Average waiting time = (0 + 1 + 5 + 10)/4 = 4 Average turn-around time = (1 + 5 + 10 + 16)/4 = 8 Example 1: Non-Preemptive SJFExample 1: Non-Preemptive SJF (simultaneous arrival)(simultaneous arrival) P1P3 P2 51 160 P4 10
  • 10. Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 SJF (non-preemptive, varied arrival times) Average waiting time = ( (0 – 0) + (8 – 2) + (7 – 4) + (12 – 5) )/4 = (0 + 6 + 3 + 7)/4 = 4 Average turn-around time: = ( (7 – 0) + (12 – 2) + (8 - 4) + (16 – 5))/4 = ( 7 + 10 + 4 + 11)/4 = 8 Example 2: Non-Preemptive SJFExample 2: Non-Preemptive SJF (varied arrival times)(varied arrival times) P1 P3 P2 73 160 P4 8 12 Waiting time : sum of time that a process has spent waiting in the ready queue
  • 11. Example 3: Preemptive SJFExample 3: Preemptive SJF (Shortest-remaining-time-first)(Shortest-remaining-time-first) Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 SJF (preemptive , varied arrival times) Average waiting time = ( [(0 – 0) + (11 - 2)] + [(2 – 2) + (5 – 4)] + (4 - 4) + (7 – 5) )/4 = 9 + 1 + 0 + 2)/4 = 3 Average turn-around time = (16 + 7 + 5 + 11)/4 = 9.75 P1 P3P2 42 110 P4 5 7 P2 P1 16 Waiting time : sum of time that a process has spent waiting in the ready queue
  • 12. 3- Priority Scheduling3- Priority Scheduling  The SJF algorithm is a special case of the general priority scheduling algorithm  Each process (or class of processes) is given a priority (integer number).  The CPU is allocated to the process with the highest priority (smallest integer = highest priority)  Priority scheduling can be either preemptive or non-preemptive A preemptive approach will preempt the CPU if the priority of the newly-arrived process is higher than the priority of the currently running process A non-preemptive approach will simply put the new process (with the highest priority) at the head of the ready queue  SJF is a priority scheduling algorithm where priority is the predicted next CPU burst time.  The main problem with priority scheduling is starvation, that is, low priority processes may never execute.  A solution is aging; as time progresses, the priority of a process in the ready queue is increased
  • 13. Example of Priority SchedulingExample of Priority Scheduling Process Burst time Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 0 1 6 16 18 19 Average wating time = (6+0+16+18+1)/5=8.2 milliseconds P2 P5 P1 P3 P4
  • 14. 4- Round-Robin Scheduling4- Round-Robin Scheduling  Developed in response to time-sharing systems.  Each process gets a small unit of CPU time (time quantum),  Each job is given control of the CPU for that time quantum. (In the range of 10-100 milliseconds.)  Control then passes to the next job (FIFO?)  Average waiting time dependent on job size, quantum size  RR scheduling algorithm is preemptive.
  • 15. Example of RR with Time Quantum =Example of RR with Time Quantum = 44 Process Burst Time P1 24 P2 3 P3 3  The chart is:  Typically, higher average turnaround than SJF, but better response. P1 P2 P3 P1 P1 P1 P1 P1 0 4 7 10 14 18 22 26 30
  • 16. Time Quantum and Context SwitchTime Quantum and Context Switch TimeTime