SlideShare a Scribd company logo
CPU
Scheduling
Algorithms

       Group No. 2   1
Overview
   Basic Concepts
   Scheduling Criteria
   Scheduling Algorithms
   Implementation in C++
   Demonstration
   Involvement of Operating System

                            CPU Scheduling Algorithms   2
Basic Concepts
   Main objective of multiprogramming is to keep on
    running processes all the time for maximum CPU
    utilization.

   Scheduling is fundamental function of OS.

   The task of selecting the processes in memory that
    are ready to execute, and allocating them to the
    CPU is performed by the CPU Scheduler.




                                 CPU Scheduling Algorithms   3
CPU Scheduler
   CPU scheduling decisions may take place when a
    process:
    o 1. Switches from running to waiting state

    o 2. Switches from running to ready state

    o 3. Switches from waiting to ready

    o 4. Terminates

   Scheduling under 1 and 4 is non preemptive.
   All other scheduling is preemptive.




                                CPU Scheduling Algorithms   4
CONT…
CPU Scheduler
   Nonpreemptive
      Once a process is allocated the CPU, it does not
      leave unless:
      o it has to wait, e.g., for I/O request 

      o it terminates  

   Preemptive
      o OS can force (preempt) a process from CPU at

        anytime
      o E.g., to allocate CPU to another higher-priority

        process 


                                  CPU Scheduling Algorithms           5
Scheduling Criteria

 CPU   utilization: keep the CPU as busy as possible
  ◦ Maximize
 Throughput: No of processes that complete their
  execution per time unit
  ◦ Maximize
 Turnaround time: amount of time to execute a
  particular process (time from submission to
  termination)
  ◦ Minimize



                               CPU Scheduling Algorithms   6
CONT…
Scheduling Criteria

   Waiting time: amount of time a process has been
    waiting in the ready queue (sum of time waiting in
    ready queue)
    o Minimize

   Response time – amount of time it takes from when
    a request was submitted until the first response is
    produced,     not    output   (for     time-sharing
    environment)
    o Minimize




                                 CPU Scheduling Algorithms           7
Scheduling Algorithms
   First Come, First Served
   Shortest Job First
   Priority
   Round Robin




                               CPU Scheduling Algorithms   8
Implementation in C++
   Class: cpuschedule
   Attributes:
         o n     – number of processes
         o Bu[ ] – Array to store Burst Time

         o A[ ]  – Array to store Arrival Time
         o Wt[ ] – Array to store Waiting Time

         o Twt   – Total Waiting Time
         o Awt   – Average Waiting Time



                                 CPU Scheduling Algorithms   9
CONT…

Implementation in C++
 Operations:
   o   Getdata() – To get number of processes and
       Burst Times from the user
   o   Fcfs() – First Come, First Served Algorithm
   o   Sjf() – Shortest Job First (normal) Algorithm
   o   SjfP() – Shortest Job First (Preemption)
       Algorithm
   o   SjfNp() – Shortest Job First (non
       preemption) Algorithm
   o   Priority() – Priority Algorithm
   o   RoundRobin() – Round Robin Algorithm

                                  CPU Scheduling Algorithms           10
First Come, First Served
                    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:
                   P1                   P2          P3


    0                              24        27           30

       Waiting time for P1 = 0; P2 = 24; P3 = 27
       Average waiting time: (0 + 24 + 27)/3 = 17
                                         CPU Scheduling Algorithms   11
First Come First                                                      CONT…


Served
   Suppose that the processes arrive in the order :
    P2 , P3 , P1 (P1:24,P2:3,P3:3)
   The Gantt chart for the schedule is:
          P2       P3                P1


      0        3        6                                  30

   Waiting time for P1 = 6; P2 = 0; P3 = 3
   Average waiting time: (6 + 0 + 3)/3 = 3
   Much better than previous case
   Convoy effect - short process behind long process


                                          CPU Scheduling Algorithms       12
Shortest Job First
                         Normal SJF
               Process               Burst Time
                 P1                        7
                   P2                        3
                   P3                        4

   The Gantt Chart for SJF (Normal) is:
          P2        P3          P1

      0        3         7                 14

   Average waiting time = (0 + 3 + 7)/3 = 3.33
                                      CPU Scheduling Algorithms   13
Shortest Job First
                                                                          CONT…



                   Non-Preemptive SJF

    Process                Arrival Time                        Burst Time
    P1                       0.0                                   7
    P2                          2.0                                       4
    P3                          4.0                                       1
    P4                          5.0                                       4
   The Gantt Chart for SJF (non-preemptive) is:
              P1                P3       P2           P4


         0    2    4   5    7        8        12               16

   Average waiting time = (0 + 6 + 3 + 7)/4 = 4
                                              CPU Scheduling Algorithms           14
Shortest Job First
                                                                                 CONT…


                              Preemptive SJF
  Process                          Arrival Time                       Burst Time
  P1                                 0.0                                  7
  P2                                 2.0                                  4
  P3                                 4.0                                  1
  P4                                 5.0                                  4

 The   Gantt Chart for SJF (preemptive) is:

            P1       P2       P3       P2       P4                  P1


        0        2        4        5        7           11                       16
 Average        waiting time = (9 + 1 + 0 +2)/4 = 3

                                                     CPU Scheduling Algorithms           15
Shortest Job First
                                                                CONT…



 Associate with each process the length of its next CPU
  burst.
 Use these lengths to schedule the process with the
  shortest time.
 Two schemes:
  o Non-Preemptive: once CPU given to the process it
    cannot be preempted until completes its CPU burst.
  o 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).
 SJF is optimal: gives minimum average waiting time for a
  given set of processes.


                                    CPU Scheduling Algorithms           16
Priority
      Process                 Burst Time                        Priority
       P1                        10                               3
       P2                         1                               1
       P3                         2                               4
       P4                         1                               5
       P5                         5                               2

   Gantt Chart
            P2       P5          P1                 P3          P4


        0        1        6                   16          18           19

   Average waiting time = (6 + 0 + 16 + 18 + 1)/5 = 8.2
                                           CPU Scheduling Algorithms        17
Priority
                                                              CONT…


A   priority number (integer) is associated with each
  process.
 Lager the CPU burst lower the priority.
 The CPU is allocated to the process with the highest
  priority (smallest integer ≡ highest priority)
 Starvation (Infinity blocking): low priority processes
  may never execute.
 Aging: as time progresses increase the priority of the
  process.




                                  CPU Scheduling Algorithms           18
Round Robin
                             Process                   Burst Time
                               P1                          24
                               P2                           3
                               P3                           3

 Quantum  time = 4 milliseconds
 The Gantt chart is:


           P1       P2       P3        P1        P1        P1        P1        P1

       0        4        7        10        14        18        22        26        30
 Average   waiting time = {[0+(10-4)]+4+7}/3 = 5.6


                                                                 CPU Scheduling Algorithms   19
Round Robin
                                                               CONT…



   Typically, higher average turnaround than SJF, but
    better response
   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.
   Performance
    o q large ⇒ FCFS
    o q small ⇒ q must be large with respect to
      context switch, otherwise overhead is too high




                                   CPU Scheduling Algorithms           20
Involvement of OS
              Source Code    (.c)



  Compiler     Conversion        (.i , .o)



              Executable   (.exe)




  Microsoft                       (load executable
               Micro-kernel
  Windows                        directly to memory)


                 Memory

    CPU
                    Scheduling
                    Algorithms
    Execut
      e
                        CPU Scheduling Algorithms      21
CPU
Scheduling
Algorithms
  Group No. 2

          Group No. 2   22

More Related Content

What's hot

INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptx
LECO9
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.
Ravi Kumar Patel
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
Ritu Ranjan Shrivastwa
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Ravindra Raju Kolahalam
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
Mukesh Chinta
 
Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"
Ra'Fat Al-Msie'deen
 
System calls
System callsSystem calls
System calls
Bernard Senam
 
Deadlock Prevention
Deadlock PreventionDeadlock Prevention
Deadlock Prevention
prachi mewara
 
Semophores and it's types
Semophores and it's typesSemophores and it's types
Semophores and it's types
Nishant Joshi
 
Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)
ritu98
 
Operating system services 9
Operating system services 9Operating system services 9
Operating system services 9myrajendra
 
MULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULINGMULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULING
garishma bhatia
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
Deepika Balichwal
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
Mukesh Chinta
 
Thread scheduling in Operating Systems
Thread scheduling in Operating SystemsThread scheduling in Operating Systems
Thread scheduling in Operating SystemsNitish Gulati
 
6 multiprogramming & time sharing
6 multiprogramming & time sharing6 multiprogramming & time sharing
6 multiprogramming & time sharingmyrajendra
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
NEERAJ BAGHEL
 

What's hot (20)

INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptx
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.
 
operating system structure
operating system structureoperating system structure
operating system structure
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
 
Semaphores
SemaphoresSemaphores
Semaphores
 
Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"
 
System calls
System callsSystem calls
System calls
 
Deadlock Prevention
Deadlock PreventionDeadlock Prevention
Deadlock Prevention
 
Semophores and it's types
Semophores and it's typesSemophores and it's types
Semophores and it's types
 
Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)Shortest job first Scheduling (SJF)
Shortest job first Scheduling (SJF)
 
Operating system services 9
Operating system services 9Operating system services 9
Operating system services 9
 
System call
System callSystem call
System call
 
MULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULINGMULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULING
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
 
Thread scheduling in Operating Systems
Thread scheduling in Operating SystemsThread scheduling in Operating Systems
Thread scheduling in Operating Systems
 
6 multiprogramming & time sharing
6 multiprogramming & time sharing6 multiprogramming & time sharing
6 multiprogramming & time sharing
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
 

Viewers also liked

Process Scheduling
Process SchedulingProcess Scheduling
Process Scheduling
Abhishek Nagar
 
Os Question Bank
Os Question BankOs Question Bank
Os Question Bank
Sonali Chauhan
 
CPU Scheduling algorithms
CPU Scheduling algorithmsCPU Scheduling algorithms
CPU Scheduling algorithms
Shanu Kumar
 
Scheduling Algorithms
Scheduling AlgorithmsScheduling Algorithms
Scheduling Algorithms
PT Mecoindo Itron
 
OS - CPU Scheduling
OS - CPU SchedulingOS - CPU Scheduling
OS - CPU Schedulingvinay arora
 
CPU scheduling algorithms in OS
CPU scheduling algorithms in OSCPU scheduling algorithms in OS
CPU scheduling algorithms in OS
harini0810
 
Programming Key terms Flash Cards
Programming Key terms Flash CardsProgramming Key terms Flash Cards
Programming Key terms Flash Cards
jog_glister
 
Cpu presentation
Cpu presentationCpu presentation
Cpu presentationHarry Singh
 
Central Processing Unit
Central Processing UnitCentral Processing Unit
Central Processing Unit
Jan Ralph
 
GCSE Compuitng Hardware Key terms
GCSE Compuitng Hardware Key termsGCSE Compuitng Hardware Key terms
GCSE Compuitng Hardware Key terms
jog_glister
 
Motherboard
MotherboardMotherboard
Motherboard
Nano Omega
 
Motherboard components and their functions
Motherboard components and their functionsMotherboard components and their functions
Motherboard components and their functions
BESOR ACADEMY
 
Chapter 4 Microprocessor CPU
Chapter 4 Microprocessor CPUChapter 4 Microprocessor CPU
Chapter 4 Microprocessor CPUaskme
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlockstech2click
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
Prasunjeet Soni
 
Motherboard and its components
Motherboard and its componentsMotherboard and its components
Motherboard and its components
Jishnu Pradeep
 

Viewers also liked (18)

Process Scheduling
Process SchedulingProcess Scheduling
Process Scheduling
 
Os Question Bank
Os Question BankOs Question Bank
Os Question Bank
 
CPU Scheduling algorithms
CPU Scheduling algorithmsCPU Scheduling algorithms
CPU Scheduling algorithms
 
Scheduling Algorithms
Scheduling AlgorithmsScheduling Algorithms
Scheduling Algorithms
 
OS - CPU Scheduling
OS - CPU SchedulingOS - CPU Scheduling
OS - CPU Scheduling
 
CPU scheduling algorithms in OS
CPU scheduling algorithms in OSCPU scheduling algorithms in OS
CPU scheduling algorithms in OS
 
Programming Key terms Flash Cards
Programming Key terms Flash CardsProgramming Key terms Flash Cards
Programming Key terms Flash Cards
 
Cpu presentation
Cpu presentationCpu presentation
Cpu presentation
 
Central Processing Unit
Central Processing UnitCentral Processing Unit
Central Processing Unit
 
Cpu ppt cse
Cpu ppt cseCpu ppt cse
Cpu ppt cse
 
GCSE Compuitng Hardware Key terms
GCSE Compuitng Hardware Key termsGCSE Compuitng Hardware Key terms
GCSE Compuitng Hardware Key terms
 
Cpu Scheduling Galvin
Cpu Scheduling GalvinCpu Scheduling Galvin
Cpu Scheduling Galvin
 
Motherboard
MotherboardMotherboard
Motherboard
 
Motherboard components and their functions
Motherboard components and their functionsMotherboard components and their functions
Motherboard components and their functions
 
Chapter 4 Microprocessor CPU
Chapter 4 Microprocessor CPUChapter 4 Microprocessor CPU
Chapter 4 Microprocessor CPU
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlocks
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
Motherboard and its components
Motherboard and its componentsMotherboard and its components
Motherboard and its components
 

Similar to CPU Scheduling Algorithms

cpu schduling ppt.pdf
cpu schduling ppt.pdfcpu schduling ppt.pdf
cpu schduling ppt.pdf
SangeethaBS4
 
5 Process Scheduling
5 Process Scheduling5 Process Scheduling
5 Process Scheduling
Dr. Loganathan R
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
Arafat Hossan
 
Operating System 5
Operating System 5Operating System 5
Operating System 5tech2click
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
Dr. Mazin Mohamed alkathiri
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
sammerkhan1
 
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
Yogesh Santhan
 
Fcfs and sjf
Fcfs and sjfFcfs and sjf
Fcfs and sjf
A. S. M. Shafi
 
Process management in os
Process management in osProcess management in os
Process management in os
Miong Lazaro
 
CH06.pdf
CH06.pdfCH06.pdf
CH06.pdf
ImranKhan880955
 
Operating systems - Processes Scheduling
Operating systems - Processes  SchedulingOperating systems - Processes  Scheduling
Operating systems - Processes Scheduling
Chandrakant Divate
 
Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Nagarajan
 

Similar to CPU Scheduling Algorithms (20)

cpu schduling ppt.pdf
cpu schduling ppt.pdfcpu schduling ppt.pdf
cpu schduling ppt.pdf
 
Os module 2 ba
Os module 2 baOs module 2 ba
Os module 2 ba
 
Algorithm o.s.
Algorithm o.s.Algorithm o.s.
Algorithm o.s.
 
5 Process Scheduling
5 Process Scheduling5 Process Scheduling
5 Process Scheduling
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Sa by shekhar
Sa by shekharSa by shekhar
Sa by shekhar
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
 
OS_Ch6
OS_Ch6OS_Ch6
OS_Ch6
 
OSCh6
OSCh6OSCh6
OSCh6
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
CPU Scheduling.pdf
CPU Scheduling.pdfCPU Scheduling.pdf
CPU Scheduling.pdf
 
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
 
Fcfs and sjf
Fcfs and sjfFcfs and sjf
Fcfs and sjf
 
Process management in os
Process management in osProcess management in os
Process management in os
 
Ch5
Ch5Ch5
Ch5
 
Reviewer cpu scheduling
Reviewer cpu schedulingReviewer cpu scheduling
Reviewer cpu scheduling
 
CH06.pdf
CH06.pdfCH06.pdf
CH06.pdf
 
Operating systems - Processes Scheduling
Operating systems - Processes  SchedulingOperating systems - Processes  Scheduling
Operating systems - Processes Scheduling
 
Scheduling algorithm (chammu)
Scheduling algorithm (chammu)Scheduling algorithm (chammu)
Scheduling algorithm (chammu)
 

Recently uploaded

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 

Recently uploaded (20)

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 

CPU Scheduling Algorithms

  • 2. Overview  Basic Concepts  Scheduling Criteria  Scheduling Algorithms  Implementation in C++  Demonstration  Involvement of Operating System CPU Scheduling Algorithms 2
  • 3. Basic Concepts  Main objective of multiprogramming is to keep on running processes all the time for maximum CPU utilization.  Scheduling is fundamental function of OS.  The task of selecting the processes in memory that are ready to execute, and allocating them to the CPU is performed by the CPU Scheduler. CPU Scheduling Algorithms 3
  • 4. CPU Scheduler  CPU scheduling decisions may take place when a process: o 1. Switches from running to waiting state o 2. Switches from running to ready state o 3. Switches from waiting to ready o 4. Terminates  Scheduling under 1 and 4 is non preemptive.  All other scheduling is preemptive. CPU Scheduling Algorithms 4
  • 5. CONT… CPU Scheduler  Nonpreemptive Once a process is allocated the CPU, it does not leave unless: o it has to wait, e.g., for I/O request  o it terminates    Preemptive o OS can force (preempt) a process from CPU at anytime o E.g., to allocate CPU to another higher-priority process  CPU Scheduling Algorithms 5
  • 6. Scheduling Criteria  CPU utilization: keep the CPU as busy as possible ◦ Maximize  Throughput: No of processes that complete their execution per time unit ◦ Maximize  Turnaround time: amount of time to execute a particular process (time from submission to termination) ◦ Minimize CPU Scheduling Algorithms 6
  • 7. CONT… Scheduling Criteria  Waiting time: amount of time a process has been waiting in the ready queue (sum of time waiting in ready queue) o Minimize  Response time – amount of time it takes from when a request was submitted until the first response is produced, not output  (for time-sharing environment) o Minimize CPU Scheduling Algorithms 7
  • 8. Scheduling Algorithms  First Come, First Served  Shortest Job First  Priority  Round Robin CPU Scheduling Algorithms 8
  • 9. Implementation in C++  Class: cpuschedule  Attributes: o n – number of processes o Bu[ ] – Array to store Burst Time o A[ ] – Array to store Arrival Time o Wt[ ] – Array to store Waiting Time o Twt – Total Waiting Time o Awt – Average Waiting Time CPU Scheduling Algorithms 9
  • 10. CONT… Implementation in C++  Operations: o Getdata() – To get number of processes and Burst Times from the user o Fcfs() – First Come, First Served Algorithm o Sjf() – Shortest Job First (normal) Algorithm o SjfP() – Shortest Job First (Preemption) Algorithm o SjfNp() – Shortest Job First (non preemption) Algorithm o Priority() – Priority Algorithm o RoundRobin() – Round Robin Algorithm CPU Scheduling Algorithms 10
  • 11. First Come, First Served 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: P1 P2 P3 0 24 27 30  Waiting time for P1 = 0; P2 = 24; P3 = 27  Average waiting time: (0 + 24 + 27)/3 = 17 CPU Scheduling Algorithms 11
  • 12. First Come First CONT… Served  Suppose that the processes arrive in the order : P2 , P3 , P1 (P1:24,P2:3,P3:3)  The Gantt chart for the schedule is: P2 P3 P1 0 3 6 30  Waiting time for P1 = 6; P2 = 0; P3 = 3  Average waiting time: (6 + 0 + 3)/3 = 3  Much better than previous case  Convoy effect - short process behind long process CPU Scheduling Algorithms 12
  • 13. Shortest Job First Normal SJF Process Burst Time P1 7 P2 3 P3 4  The Gantt Chart for SJF (Normal) is: P2 P3 P1 0 3 7 14  Average waiting time = (0 + 3 + 7)/3 = 3.33 CPU Scheduling Algorithms 13
  • 14. Shortest Job First CONT… Non-Preemptive SJF Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4  The Gantt Chart for SJF (non-preemptive) is: P1 P3 P2 P4 0 2 4 5 7 8 12 16  Average waiting time = (0 + 6 + 3 + 7)/4 = 4 CPU Scheduling Algorithms 14
  • 15. Shortest Job First CONT… Preemptive SJF Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4  The Gantt Chart for SJF (preemptive) is: P1 P2 P3 P2 P4 P1 0 2 4 5 7 11 16  Average waiting time = (9 + 1 + 0 +2)/4 = 3 CPU Scheduling Algorithms 15
  • 16. Shortest Job First CONT…  Associate with each process the length of its next CPU burst.  Use these lengths to schedule the process with the shortest time.  Two schemes: o Non-Preemptive: once CPU given to the process it cannot be preempted until completes its CPU burst. o 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).  SJF is optimal: gives minimum average waiting time for a given set of processes. CPU Scheduling Algorithms 16
  • 17. Priority Process Burst Time Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2  Gantt Chart P2 P5 P1 P3 P4 0 1 6 16 18 19  Average waiting time = (6 + 0 + 16 + 18 + 1)/5 = 8.2 CPU Scheduling Algorithms 17
  • 18. Priority CONT… A priority number (integer) is associated with each process.  Lager the CPU burst lower the priority.  The CPU is allocated to the process with the highest priority (smallest integer ≡ highest priority)  Starvation (Infinity blocking): low priority processes may never execute.  Aging: as time progresses increase the priority of the process. CPU Scheduling Algorithms 18
  • 19. Round Robin Process Burst Time P1 24 P2 3 P3 3  Quantum time = 4 milliseconds  The Gantt chart is: P1 P2 P3 P1 P1 P1 P1 P1 0 4 7 10 14 18 22 26 30  Average waiting time = {[0+(10-4)]+4+7}/3 = 5.6 CPU Scheduling Algorithms 19
  • 20. Round Robin CONT…  Typically, higher average turnaround than SJF, but better response  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.  Performance o q large ⇒ FCFS o q small ⇒ q must be large with respect to context switch, otherwise overhead is too high CPU Scheduling Algorithms 20
  • 21. Involvement of OS Source Code (.c) Compiler Conversion (.i , .o) Executable (.exe) Microsoft (load executable Micro-kernel Windows directly to memory) Memory CPU Scheduling Algorithms Execut e CPU Scheduling Algorithms 21
  • 22. CPU Scheduling Algorithms Group No. 2 Group No. 2 22

Editor's Notes

  1. Sonali C. UDIT CPU Scheduling Aging - Gradually increasing the priority of process that waits in the system for long time.