SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
CPU Scheduling

   Organized By: Vinay Arora
                 Assistant Professor
                 CSED, TU




                                   Vinay Arora
                                    CSED,TU
Disclaimer

           This is NOT A COPYRIGHT          MATERIAL


   Content has been taken mainly from the following books:

        Operating Systems Concepts By Silberschatz & Galvin,
Operating Systems: Internals and Design Principles By William Stallings
                        www.os-book.com
         www.cs.jhu.edu/~yairamir/cs418/os2/sld001.htm
     www.personal.kent.edu/~rmuhamma/OpSystems/os.html
 http://msdn.microsoft.com/en-us/library/ms685096(VS.85).aspx
http://www.computer.howsttuffworks.com/operating-system6.htm
         http://williamstallings.com/OS/Animations.html
                               Etc…

                              Vinay Arora
                               CSED,TU
CPU Scheduling
  CPU Scheduling – Basis of Multiprogrammed Operating Systems.

  Multiprogramming is to have some process running at all times, to
  maximize CPU Utilization.

  Process Execution consists of a cycle of CPU execution and I/O wait.

  All the processes in the ready queue are lined up waiting for a chance to
  run on the CPU.

  The Records in the QUEUE are PCB of the Processes.



                                 Vinay Arora
                                  CSED,TU
CPU – I/O Burst




                  Vinay Arora
                   CSED,TU
Dispatcher
    Module that gives control of the CPU to the Process selected by the
    Short Term Scheduler.

    Functions Involved are:

        Switching Context.
        Switching to User Mode.
        Jumping to proper location in the user program to restart that program.


 Dispatch Latency – Time it takes for the Dispatcher to Stop one process and
                    Start another Running.



                                     Vinay Arora
                                      CSED,TU
Scheduling Criteria
   CPU Utilization – Keep the CPU as busy as possible

   Throughput – Number of Processes that complete their execution per
   time unit

   Turnaround Time – Amount of time to Execute a Particular Process

   Waiting Time – Amount of Time a Process has been waiting in the
   Ready Queue

   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)


                                 Vinay Arora
                                  CSED,TU
Optimization Criteria
   Max CPU Utilization

   Max Throughput

   Min Turnaround Time

   Min Waiting Time

   Min Response Time




                         Vinay Arora
                          CSED,TU
FCFS
     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


                                  Vinay Arora
                                   CSED,TU
FCFS
 Suppose that the processes arrive in the order
          P2 , P3 , P1
    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

                                    Vinay Arora
                                     CSED,TU
SJF
  Associate with each process the length of its next CPU burst. Use these
  lengths to schedule the process with the shortest time

  Two Schemes:
     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)

  SJF is Optimal – Gives minimum average waiting time for a given set of
  processes


                                Vinay Arora
                                 CSED,TU
SJF (Non Preemptive)
     Process      Arrival Time           Burst Time
       P1              0.0                     7
        P2             2.0                     4
        P3             4.0                     1
        P4             5.0                     4
  SJF (Non-Preemptive)

                  P1                P3        P2        P4

          0        3            7        8         12        16
  Average waiting time = (0 + 6 + 3 + 7)/4 = 4


                               Vinay Arora
                                CSED,TU
SJF (Preemptive)
      Process           Arrival Time             Burst Time
        P1                  0.0                       7
        P2                  2.0                       4
        P3                  4.0                       1
        P4                  5.0                       4

  SJF (Preemptive)

          P1       P2       P3       P2            P4         P1


      0        2        4        5         7            11         16

  Average waiting time = (9 + 1 + 0 +2)/4 = 3


                                          Vinay Arora
                                           CSED,TU
Priority Scheduling
   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 in Priority scheduling is STARVATION – Low Priority processes may
   never execute

   Solution for above mentioned Problem is AGING – as time progresses increase
   the priority of the process

                                     Vinay Arora
                                      CSED,TU
Priority Scheduling

                 Process       Priority      Burst Time
                    P1           3               10
                    P2            1               1
                    P3           4                2
                    P4           5                1
                    P5           2                5


        P2            P5           P1              P3          P4

    0        1             6                  16          18    19



                               Vinay Arora
                                CSED,TU
Round Robin
  Each Process gets a Small Unit of CPU time (Time Quantum).

  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 at most q time units at once.

  PERFORMANCE

  q Large ⇒ FIFO

  q Small ⇒ q must be large with respect to Context Switch, Otherwise
            overhead is too high


                                Vinay Arora
                                 CSED,TU
Round Robin
      Process             Burst Time
        P1                   53
        P2                  17
        P3                  68
        P4                  24

  The Gantt Chart is:



          P1        P2    P3        P4        P1     P3      P4   P1   P3   P3

      0        20    37        57        77        97 117 121 134 154 162



                                               Vinay Arora
                                                CSED,TU
Time Quantum and Context Switch




               Vinay Arora
                CSED,TU
Vinay Arora
 CSED,TU
MultiTasking




               Vinay Arora
                CSED,TU
Multilevel Queue
   Ready Queue is partitioned into separate Queues:
      Foreground
      Background

   Each QUEUE has its own Scheduling Algorithm
       Foreground – RR
       Background – FCFS

   Scheduling must be done between the queues

       Fixed Priority Scheduling - (i.e., Serve all from foreground then from
       background). Possibility of Starvation.

       Time Slice – Each Queue gets a certain amount of CPU time which it can
       schedule amongst its processes; i.e., 80% to foreground in RR

       20% to background in FCFS
                                     Vinay Arora
                                      CSED,TU
Multilevel Queue Scheduling




                Vinay Arora
                 CSED,TU
Algorithm Evaluation
   Deterministic Modeling:-

        Takes a particular Predetermined workload
        Defines the Performance of each Algorithm for that workload

   Queuing Models

   Implementation




                               Vinay Arora
                                CSED,TU
Vinay Arora
 CSED,TU
Thnx…



  Vinay Arora
   CSED,TU

Weitere ähnliche Inhalte

Was ist angesagt?

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
 
First-Come-First-Serve (FCFS)
First-Come-First-Serve (FCFS)First-Come-First-Serve (FCFS)
First-Come-First-Serve (FCFS)
nikeAthena
 
Lecture 5, 6 and 7 cpu scheduling
Lecture 5, 6 and 7  cpu schedulingLecture 5, 6 and 7  cpu scheduling
Lecture 5, 6 and 7 cpu scheduling
Rushdi Shams
 

Was ist angesagt? (20)

Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
5 Process Scheduling
5 Process Scheduling5 Process Scheduling
5 Process Scheduling
 
17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria 17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria
 
Os module 2 ba
Os module 2 baOs module 2 ba
Os module 2 ba
 
Priority scheduling algorithms
Priority scheduling algorithmsPriority scheduling algorithms
Priority scheduling algorithms
 
CPU scheduling algorithms in OS
CPU scheduling algorithms in OSCPU scheduling algorithms in OS
CPU scheduling algorithms in OS
 
Scheduling
SchedulingScheduling
Scheduling
 
CPU Scheduling algorithms
CPU Scheduling algorithmsCPU Scheduling algorithms
CPU Scheduling algorithms
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)
 
scheduling algorithm
scheduling algorithmscheduling algorithm
scheduling algorithm
 
Ch6 CPU Scheduling galvin
Ch6 CPU Scheduling galvinCh6 CPU Scheduling galvin
Ch6 CPU Scheduling galvin
 
cpu scheduling OS
 cpu scheduling OS cpu scheduling OS
cpu scheduling OS
 
cpu scheduling
cpu schedulingcpu scheduling
cpu scheduling
 
CPU scheduling
CPU schedulingCPU scheduling
CPU scheduling
 
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)
 
Lecture 5, 6 and 7 cpu scheduling
Lecture 5, 6 and 7  cpu schedulingLecture 5, 6 and 7  cpu scheduling
Lecture 5, 6 and 7 cpu scheduling
 
PPT CPU
PPT CPUPPT CPU
PPT CPU
 
9 cm402.19
9 cm402.199 cm402.19
9 cm402.19
 
Process scheduling algorithms
Process scheduling algorithmsProcess scheduling algorithms
Process scheduling algorithms
 

Ähnlich wie OS - CPU Scheduling

Process management in os
Process management in osProcess management in os
Process management in os
Miong Lazaro
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
tech2click
 
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
 
AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...
AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...
AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...
Shanmuganathan C
 

Ähnlich wie OS - CPU Scheduling (20)

Cpu Scheduling Galvin
Cpu Scheduling GalvinCpu Scheduling Galvin
Cpu Scheduling Galvin
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Algorithm o.s.
Algorithm o.s.Algorithm o.s.
Algorithm o.s.
 
Process management in os
Process management in osProcess management in os
Process management in os
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
 
OS_Ch6
OS_Ch6OS_Ch6
OS_Ch6
 
OSCh6
OSCh6OSCh6
OSCh6
 
Ch5
Ch5Ch5
Ch5
 
CPU Scheduling.pdf
CPU Scheduling.pdfCPU Scheduling.pdf
CPU Scheduling.pdf
 
CPU Sheduling
CPU ShedulingCPU Sheduling
CPU Sheduling
 
CPU Sheduling
CPU Sheduling CPU Sheduling
CPU Sheduling
 
Window scheduling algorithm
Window scheduling algorithmWindow scheduling algorithm
Window scheduling algorithm
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Sa by shekhar
Sa by shekharSa by shekhar
Sa by shekhar
 
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
 
AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...
AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...
AlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorithmsAlgorit...
 
Reviewer cpu scheduling
Reviewer cpu schedulingReviewer cpu scheduling
Reviewer cpu scheduling
 
Fcfs and sjf
Fcfs and sjfFcfs and sjf
Fcfs and sjf
 
Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-scheduling
 

Mehr von vinay arora (20)

Search engine and web crawler
Search engine and web crawlerSearch engine and web crawler
Search engine and web crawler
 
Use case diagram (airport)
Use case diagram (airport)Use case diagram (airport)
Use case diagram (airport)
 
Use case diagram
Use case diagramUse case diagram
Use case diagram
 
Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)
 
SEM - UML (1st case study)
SEM - UML (1st case study)SEM - UML (1st case study)
SEM - UML (1st case study)
 
6 java - loop
6  java - loop6  java - loop
6 java - loop
 
4 java - decision
4  java - decision4  java - decision
4 java - decision
 
3 java - variable type
3  java - variable type3  java - variable type
3 java - variable type
 
2 java - operators
2  java - operators2  java - operators
2 java - operators
 
1 java - data type
1  java - data type1  java - data type
1 java - data type
 
Uta005 lecture3
Uta005 lecture3Uta005 lecture3
Uta005 lecture3
 
Uta005 lecture1
Uta005 lecture1Uta005 lecture1
Uta005 lecture1
 
Uta005 lecture2
Uta005 lecture2Uta005 lecture2
Uta005 lecture2
 
Security & Protection
Security & ProtectionSecurity & Protection
Security & Protection
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
 
CG - Output Primitives
CG - Output PrimitivesCG - Output Primitives
CG - Output Primitives
 
CG - Display Devices
CG - Display DevicesCG - Display Devices
CG - Display Devices
 
CG - Input Output Devices
CG - Input Output DevicesCG - Input Output Devices
CG - Input Output Devices
 
CG - Introduction to Computer Graphics
CG - Introduction to Computer GraphicsCG - Introduction to Computer Graphics
CG - Introduction to Computer Graphics
 
C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)
 

Kürzlich hochgeladen

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Kürzlich hochgeladen (20)

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.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)
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
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
 
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
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
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...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
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
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 

OS - CPU Scheduling

  • 1. CPU Scheduling Organized By: Vinay Arora Assistant Professor CSED, TU Vinay Arora CSED,TU
  • 2. Disclaimer This is NOT A COPYRIGHT MATERIAL Content has been taken mainly from the following books: Operating Systems Concepts By Silberschatz & Galvin, Operating Systems: Internals and Design Principles By William Stallings www.os-book.com www.cs.jhu.edu/~yairamir/cs418/os2/sld001.htm www.personal.kent.edu/~rmuhamma/OpSystems/os.html http://msdn.microsoft.com/en-us/library/ms685096(VS.85).aspx http://www.computer.howsttuffworks.com/operating-system6.htm http://williamstallings.com/OS/Animations.html Etc… Vinay Arora CSED,TU
  • 3. CPU Scheduling CPU Scheduling – Basis of Multiprogrammed Operating Systems. Multiprogramming is to have some process running at all times, to maximize CPU Utilization. Process Execution consists of a cycle of CPU execution and I/O wait. All the processes in the ready queue are lined up waiting for a chance to run on the CPU. The Records in the QUEUE are PCB of the Processes. Vinay Arora CSED,TU
  • 4. CPU – I/O Burst Vinay Arora CSED,TU
  • 5. Dispatcher Module that gives control of the CPU to the Process selected by the Short Term Scheduler. Functions Involved are: Switching Context. Switching to User Mode. Jumping to proper location in the user program to restart that program. Dispatch Latency – Time it takes for the Dispatcher to Stop one process and Start another Running. Vinay Arora CSED,TU
  • 6. Scheduling Criteria CPU Utilization – Keep the CPU as busy as possible Throughput – Number of Processes that complete their execution per time unit Turnaround Time – Amount of time to Execute a Particular Process Waiting Time – Amount of Time a Process has been waiting in the Ready Queue 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) Vinay Arora CSED,TU
  • 7. Optimization Criteria Max CPU Utilization Max Throughput Min Turnaround Time Min Waiting Time Min Response Time Vinay Arora CSED,TU
  • 8. FCFS 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 Vinay Arora CSED,TU
  • 9. FCFS Suppose that the processes arrive in the order P2 , P3 , P1 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 Vinay Arora CSED,TU
  • 10. SJF Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time Two Schemes: 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) SJF is Optimal – Gives minimum average waiting time for a given set of processes Vinay Arora CSED,TU
  • 11. SJF (Non Preemptive) Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 SJF (Non-Preemptive) P1 P3 P2 P4 0 3 7 8 12 16 Average waiting time = (0 + 6 + 3 + 7)/4 = 4 Vinay Arora CSED,TU
  • 12. SJF (Preemptive) Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 SJF (Preemptive) P1 P2 P3 P2 P4 P1 0 2 4 5 7 11 16 Average waiting time = (9 + 1 + 0 +2)/4 = 3 Vinay Arora CSED,TU
  • 13. Priority Scheduling 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 in Priority scheduling is STARVATION – Low Priority processes may never execute Solution for above mentioned Problem is AGING – as time progresses increase the priority of the process Vinay Arora CSED,TU
  • 14. Priority Scheduling Process Priority Burst Time P1 3 10 P2 1 1 P3 4 2 P4 5 1 P5 2 5 P2 P5 P1 P3 P4 0 1 6 16 18 19 Vinay Arora CSED,TU
  • 15. Round Robin Each Process gets a Small Unit of CPU time (Time Quantum). 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 at most q time units at once. PERFORMANCE q Large ⇒ FIFO q Small ⇒ q must be large with respect to Context Switch, Otherwise overhead is too high Vinay Arora CSED,TU
  • 16. Round Robin Process Burst Time P1 53 P2 17 P3 68 P4 24 The Gantt Chart is: P1 P2 P3 P4 P1 P3 P4 P1 P3 P3 0 20 37 57 77 97 117 121 134 154 162 Vinay Arora CSED,TU
  • 17. Time Quantum and Context Switch Vinay Arora CSED,TU
  • 19. MultiTasking Vinay Arora CSED,TU
  • 20. Multilevel Queue Ready Queue is partitioned into separate Queues: Foreground Background Each QUEUE has its own Scheduling Algorithm Foreground – RR Background – FCFS Scheduling must be done between the queues Fixed Priority Scheduling - (i.e., Serve all from foreground then from background). Possibility of Starvation. Time Slice – Each Queue gets a certain amount of CPU time which it can schedule amongst its processes; i.e., 80% to foreground in RR 20% to background in FCFS Vinay Arora CSED,TU
  • 21. Multilevel Queue Scheduling Vinay Arora CSED,TU
  • 22. Algorithm Evaluation Deterministic Modeling:- Takes a particular Predetermined workload Defines the Performance of each Algorithm for that workload Queuing Models Implementation Vinay Arora CSED,TU
  • 24. Thnx… Vinay Arora CSED,TU