SlideShare ist ein Scribd-Unternehmen logo
1 von 18
• In computer science, scheduling is the method
by which threads, processes or data flows are
given access to system resources
• Long-term scheduling
• Medium-term scheduling
• Short-term scheduling
• CPU utilization
• Throughput
• Turnaround time
• Waiting time
• Response time
• is the simplest scheduling algorithm, FIFO
simply queues processes in the order that
they arrive in the ready queue.
• The FCFS scheduling algorithm is non
preemptive. Once the CPU has been allocated
to a process, that process keeps the CPU until
it releases the CPU.
Process Burst Time
P1 24
P2 3
P3 3
• Suppose that the processes arrive in the order: P1
, P2 , P3
The Gantt Chart for the schedule is:
• Waiting time for P1 = 0; P2 = 24; P3 = 27
• Average waiting time: (0 + 24 + 27)/3 = 17
P1 P2 P3
24 27 300
P1 P2 P3
• Associate with each process the length of its next
CPU burst. When the CPU is available, it is assigned
to the process that has the smallest next CPU burst.
– Non-preemptive – once CPU given to the process
it cannot be preempted until completes its CPU
burst
– preemptive – if a new process arrives with CPU
burst length less than remaining time of current
executing process, preempt. This scheme is know
as the
Shortest-Remaining-Time-First (SRTF)
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
• SJF (non-preemptive)
• Average waiting time = (0 + 6 + 3 + 7)/4 = 4
P1 P3 P2
73 160
P4
8 12
P1 P3 P2 P4
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
• SJF (preemptive)
• Average waiting time = (9 + 1 + 0 +2)/4 = 3
P1 P3P2
42 110
P4
5 7
P2 P1
16
P1 P3P2 P4 P1P2
• 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
– non preemptive
• SJF is a priority scheduling where priority is the predicted next CPU burst
time
• Problem  Starvation – low priority processes may never execute
• Solution  Aging – as time progresses increase the priority of the
process
Process Burst Time Arrival Time Priority
P1 10 0 3
P2 1 0 1
P3 2 0 4
P4 1 0 5
P5 5 0 2
P3P5P2
61 190 16 18
P3P5P2
61 190 16 18
P4P1P2 P5 P1 P3 P4
• Each process gets a small unit of CPU time (time quantum),
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.
Process Burst Time Arrival
P1 24 0
P2 3 0
P3 3 0
• The Gantt chart is:
• Average waiting time: (0+4+7+(10-4))/3 = 5.66
With FCFS: (0+24+27)/3 = 17
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
P2 P3 P1 P1P1 P1P1P1
• FCFS (First-come, First-Served)
– Non-preemptive
• SJF (Shortest Job First)
– Can be either
– Choice when a new (shorter) job arrives
– Can preempt current job or not
• Priority
– Can be either
– Choice when a processes priority changes or when a higher priority
process arrives
Presentation by adeel

Weitere ähnliche Inhalte

Was ist angesagt?

First-Come-First-Serve (FCFS)
First-Come-First-Serve (FCFS)First-Come-First-Serve (FCFS)
First-Come-First-Serve (FCFS)nikeAthena
 
Ch6
Ch6Ch6
Ch6C.U
 
Smarter Scheduling (Priorities, Preemptive Priority Scheduling, Lottery and S...
Smarter Scheduling (Priorities, Preemptive Priority Scheduling, Lottery and S...Smarter Scheduling (Priorities, Preemptive Priority Scheduling, Lottery and S...
Smarter Scheduling (Priorities, Preemptive Priority Scheduling, Lottery and S...David Evans
 
Process scheduling algorithms
Process scheduling algorithmsProcess scheduling algorithms
Process scheduling algorithmsShubham Sharma
 
First Come First Serve
First Come First ServeFirst Come First Serve
First Come First ServeKavya Kapoor
 
CPU Scheduling in OS Presentation
CPU Scheduling in OS  PresentationCPU Scheduling in OS  Presentation
CPU Scheduling in OS Presentationusmankiyani1
 
RR and priority scheduling
RR and priority schedulingRR and priority scheduling
RR and priority schedulingA. S. M. Shafi
 
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 algorithmsShanu Kumar
 
OS - CPU Scheduling
OS - CPU SchedulingOS - CPU Scheduling
OS - CPU Schedulingvinay arora
 
Comparision of scheduling algorithms
Comparision of scheduling algorithmsComparision of scheduling algorithms
Comparision of scheduling algorithmsTanya Makkar
 
OPERATING SYSTEM-"Scheduling policies"
OPERATING SYSTEM-"Scheduling policies"OPERATING SYSTEM-"Scheduling policies"
OPERATING SYSTEM-"Scheduling policies"Ankit Surti
 
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
 
Round robin scheduling
Round robin schedulingRound robin scheduling
Round robin schedulingRaghav S
 
Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)ritu98
 

Was ist angesagt? (20)

Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
First-Come-First-Serve (FCFS)
First-Come-First-Serve (FCFS)First-Come-First-Serve (FCFS)
First-Come-First-Serve (FCFS)
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Ch6
Ch6Ch6
Ch6
 
Smarter Scheduling (Priorities, Preemptive Priority Scheduling, Lottery and S...
Smarter Scheduling (Priorities, Preemptive Priority Scheduling, Lottery and S...Smarter Scheduling (Priorities, Preemptive Priority Scheduling, Lottery and S...
Smarter Scheduling (Priorities, Preemptive Priority Scheduling, Lottery and S...
 
Process scheduling algorithms
Process scheduling algorithmsProcess scheduling algorithms
Process scheduling algorithms
 
First Come First Serve
First Come First ServeFirst Come First Serve
First Come First Serve
 
CPU Scheduling in OS Presentation
CPU Scheduling in OS  PresentationCPU Scheduling in OS  Presentation
CPU Scheduling in OS Presentation
 
RR and priority scheduling
RR and priority schedulingRR and priority scheduling
RR and priority scheduling
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
 
CPU Scheduling algorithms
CPU Scheduling algorithmsCPU Scheduling algorithms
CPU Scheduling algorithms
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
OS - CPU Scheduling
OS - CPU SchedulingOS - CPU Scheduling
OS - CPU Scheduling
 
Comparision of scheduling algorithms
Comparision of scheduling algorithmsComparision of scheduling algorithms
Comparision of scheduling algorithms
 
OPERATING SYSTEM-"Scheduling policies"
OPERATING SYSTEM-"Scheduling policies"OPERATING SYSTEM-"Scheduling policies"
OPERATING SYSTEM-"Scheduling policies"
 
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.
 
Round robin scheduling
Round robin schedulingRound robin scheduling
Round robin scheduling
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)
 

Andere mochten auch

Andere mochten auch (11)

Network Layer by-adeel
Network Layer by-adeelNetwork Layer by-adeel
Network Layer by-adeel
 
Network Layer
Network LayerNetwork Layer
Network Layer
 
Computer network ppt
Computer network pptComputer network ppt
Computer network ppt
 
Transport services
Transport servicesTransport services
Transport services
 
Network layer - design Issues
Network layer - design IssuesNetwork layer - design Issues
Network layer - design Issues
 
TCP/IP Model
TCP/IP ModelTCP/IP Model
TCP/IP Model
 
IEEE Standards
IEEE StandardsIEEE Standards
IEEE Standards
 
Dns ppt
Dns pptDns ppt
Dns ppt
 
TCP/IP Basics
TCP/IP BasicsTCP/IP Basics
TCP/IP Basics
 
Transportation ppt of suppy chain management
Transportation ppt of suppy chain managementTransportation ppt of suppy chain management
Transportation ppt of suppy chain management
 
TCP/IP Network ppt
TCP/IP Network pptTCP/IP Network ppt
TCP/IP Network ppt
 

Ähnlich wie Presentation by adeel

Ähnlich wie Presentation by adeel (20)

ch5_CPU Scheduling_part1.pdf
ch5_CPU Scheduling_part1.pdfch5_CPU Scheduling_part1.pdf
ch5_CPU Scheduling_part1.pdf
 
OS Process Chapter 3.pdf
OS Process Chapter 3.pdfOS Process Chapter 3.pdf
OS Process Chapter 3.pdf
 
Operating system 29 non preemptive scheduling
Operating system 29 non preemptive schedulingOperating system 29 non preemptive scheduling
Operating system 29 non preemptive scheduling
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Os2
Os2Os2
Os2
 
Ch5
Ch5Ch5
Ch5
 
OS_Ch6
OS_Ch6OS_Ch6
OS_Ch6
 
OSCh6
OSCh6OSCh6
OSCh6
 
Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-scheduling
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Ch6 cpu scheduling
Ch6   cpu schedulingCh6   cpu scheduling
Ch6 cpu scheduling
 
CPU Scheduling Lecture 5 - 6.pptx
CPU Scheduling Lecture 5 - 6.pptxCPU Scheduling Lecture 5 - 6.pptx
CPU Scheduling Lecture 5 - 6.pptx
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
 
Cpu Scheduling Galvin
Cpu Scheduling GalvinCpu Scheduling Galvin
Cpu Scheduling Galvin
 
ch_scheduling (1).ppt
ch_scheduling (1).pptch_scheduling (1).ppt
ch_scheduling (1).ppt
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithms
 
Csc4320 chapter 5 2
Csc4320 chapter 5 2Csc4320 chapter 5 2
Csc4320 chapter 5 2
 
Os..
Os..Os..
Os..
 
CPU Scheduling Part-III.pdf
CPU Scheduling Part-III.pdfCPU Scheduling Part-III.pdf
CPU Scheduling Part-III.pdf
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 

Mehr von Goodthingbetter

Mehr von Goodthingbetter (9)

financial accounting ppt
financial accounting  pptfinancial accounting  ppt
financial accounting ppt
 
Discrete mathamatic by adeel
Discrete mathamatic by adeelDiscrete mathamatic by adeel
Discrete mathamatic by adeel
 
Circuit and packet_switching111
Circuit and packet_switching111Circuit and packet_switching111
Circuit and packet_switching111
 
Computer ports
Computer portsComputer ports
Computer ports
 
Graph by adeel
Graph by adeelGraph by adeel
Graph by adeel
 
Tree by adeel
Tree by adeelTree by adeel
Tree by adeel
 
Set{m adeel rajput}
Set{m adeel rajput}Set{m adeel rajput}
Set{m adeel rajput}
 
Presentation by adeel
Presentation by adeelPresentation by adeel
Presentation by adeel
 
Presentation mas rajput
Presentation mas rajputPresentation mas rajput
Presentation mas rajput
 

Kürzlich hochgeladen

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
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
 
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
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
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
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 

Kürzlich hochgeladen (20)

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
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
 
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
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
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
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 

Presentation by adeel

  • 1.
  • 2.
  • 3.
  • 4. • In computer science, scheduling is the method by which threads, processes or data flows are given access to system resources • Long-term scheduling • Medium-term scheduling • Short-term scheduling
  • 5. • CPU utilization • Throughput • Turnaround time • Waiting time • Response time
  • 6. • is the simplest scheduling algorithm, FIFO simply queues processes in the order that they arrive in the ready queue. • The FCFS scheduling algorithm is non preemptive. Once the CPU has been allocated to a process, that process keeps the CPU until it releases the CPU.
  • 7.
  • 8. Process Burst Time P1 24 P2 3 P3 3 • Suppose that the processes arrive in the order: P1 , P2 , P3 The Gantt Chart for the schedule is: • Waiting time for P1 = 0; P2 = 24; P3 = 27 • Average waiting time: (0 + 24 + 27)/3 = 17 P1 P2 P3 24 27 300 P1 P2 P3
  • 9. • Associate with each process the length of its next CPU burst. When the CPU is available, it is assigned to the process that has the smallest next CPU burst.
  • 10. – Non-preemptive – once CPU given to the process it cannot be preempted until completes its CPU burst – preemptive – if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is know as the Shortest-Remaining-Time-First (SRTF)
  • 11. Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 • SJF (non-preemptive) • Average waiting time = (0 + 6 + 3 + 7)/4 = 4 P1 P3 P2 73 160 P4 8 12 P1 P3 P2 P4
  • 12. Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 • SJF (preemptive) • Average waiting time = (9 + 1 + 0 +2)/4 = 3 P1 P3P2 42 110 P4 5 7 P2 P1 16 P1 P3P2 P4 P1P2
  • 13. • 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 – non preemptive • SJF is a priority scheduling where priority is the predicted next CPU burst time • Problem  Starvation – low priority processes may never execute • Solution  Aging – as time progresses increase the priority of the process
  • 14. Process Burst Time Arrival Time Priority P1 10 0 3 P2 1 0 1 P3 2 0 4 P4 1 0 5 P5 5 0 2 P3P5P2 61 190 16 18 P3P5P2 61 190 16 18 P4P1P2 P5 P1 P3 P4
  • 15. • Each process gets a small unit of CPU time (time quantum), 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.
  • 16. Process Burst Time Arrival P1 24 0 P2 3 0 P3 3 0 • The Gantt chart is: • Average waiting time: (0+4+7+(10-4))/3 = 5.66 With FCFS: (0+24+27)/3 = 17 P1 P2 P3 P1 P1 P1 P1 P1 0 4 7 10 14 18 22 26 30 P2 P3 P1 P1P1 P1P1P1
  • 17. • FCFS (First-come, First-Served) – Non-preemptive • SJF (Shortest Job First) – Can be either – Choice when a new (shorter) job arrives – Can preempt current job or not • Priority – Can be either – Choice when a processes priority changes or when a higher priority process arrives