• Like
CPU Sheduling
Upcoming SlideShare
Loading in...5
×
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,850
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
37
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. CPU Scheduling
    Prof.PrasadSawant
    Lecturer MCA
    MACS College Pune
    Operating System Concepts Prasad Sawant
  • 2. Alternating Sequence of CPU And I/O Bursts
    Operating System Concepts Prasad Sawant
  • 3. CPU Scheduler
    Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them.
    CPU scheduling decisions may take place when a process:
    1. Switches from running to waiting state.
    2. Switches from running to ready state.
    3. Switches from waiting to ready.
    4. Terminates.
    Scheduling under 1 and 4 is nonpreemptive.
    All other scheduling is preemptive.
    Operating System Concepts Prasad Sawant
  • 4. Dispatcher
    Dispatcher module gives control of the CPU to the process selected by the short-term scheduler.
    Operating System Concepts Prasad Sawant
  • 5. Scheduling Criteria
    CPU utilization – keep the CPU as busy as possible
    Throughput– # 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
    Operating System Concepts Prasad Sawant
  • 6. Keep in mind
    Waiting time (WT)=start time(ST)-Arrival time (AT)
    Finish time (FT)=start time(ST)+Burst Time(BT)
    Total turn around time(TOT)=Finish time(FT)-Arrival time (AT )
    Operating System Concepts Prasad Sawant
  • 7. Optimization Criteria
    Max CPU utilization
    Max throughput
    Min turnaround time
    Min waiting time
    Min response time
    Operating System Concepts Prasad Sawant
  • 8. First-Come, First-Served (FCFS) Scheduling
    Operating System Concepts Prasad Sawant
    Suppose that the processes arrive in the order: P1 , P2 , P3
    schedule
    schedule
    0 10 20 30
    schedule
    Waiting time for P1 = 0; P2 = 24; P3 = 27
    Average waiting time: (0 + 24 + 27)/3 = 17
    P3 30
    P2 27
    P1 24
  • 9. First-Come, First-Served (FCFS) Scheduling Gantt Chart
    Operating System Concepts Prasad Sawant
    Suppose that the processes arrive in the order: P1 , P2 , P3
    schedule
    schedule
    schedule
    Waiting time for P1 = 0; P2 = 24; P3 = 27
    Average waiting time: (0 + 24 + 27)/3 = 17
    0 P1 24
    P2 27
    P3 30
  • 10. Exercise
    Find Average waiting time for
    Suppose that the processes arrive in the order: P2 , P3 , P1
    Operating System Concepts Prasad Sawant
  • 11. Shortest-Job-First (SJR) Scheduling
    Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time.
    Two schemes:
    nonpreemptive – 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.
    Operating System Concepts Prasad Sawant
  • 12. Example of Non-Preemptive SJF
    Operating System Concepts Prasad Sawant
    schedule
    schedule
    schedule
    schedule
    0 P1 7
    P3 8
    P2 12
    P4 16
    Average waiting time = (0+6+3+7)/4=4
  • 13. Example of Non-Preemptive SJF
    Operating System Concepts Prasad Sawant
    P1 7
    P3 8
    P2 12
    P4 16
    Average waiting time = (0+6+3+7)/4=4
    Average TOT =(7+10+4+11)/4=8
  • 14. Preemptive SJF
    Operating System Concepts Prasad Sawant
    7
    P
    schedule
    10
    10-1=9
    schedule
    1
    1-1=0
    schedule
    17
    17-2=15
    schedule
    5
    5-3=2
    0 P1 1
    P2 5
    P4 10
    P1 17
    P3 26
  • 15. Priority Scheduling
    Operating System Concepts Prasad Sawant
    Schedule
    6
    6
    Schedule
    0
    0
    Schedule
    16
    16
    Schedule
    18
    18
    Schedule
    1
    1
    41/5=8.2 ms
    0 P2 1
    P5 6
    P1 16
    P3 18
    P4 19
    0
  • 16. SJF Preemptive Priority Scheduling
    Operating System Concepts Prasad Sawant
    P
    5
    scheduled
    19
    19-3=16
    scheduled
    24
    24-1=23
    scheduled
    12
    12-3=9
    scheduled
    3
    3-3=0
    48/4=12 ms
    0 P1 3
    P4 12
    P3 19
    P1 24
    P2 30
  • 17. Round Robin Scheduling
    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/nof the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time units.
    Operating System Concepts Prasad Sawant
  • 18. Time Quantum and Context Switch Time
    Operating System Concepts Prasad Sawant
    0
    0 10
    1
    6
    10
    9
    2
    3
    4
    5
    6
    7
    8
    9
    10
    1
  • 19. Round Robin Time Quantum 4
    Operating System Concepts Prasad Sawant
    24-4=20
    20-4=16
    16-4=12
    12-4=8
    8-4=4
    4-4=0
    scheduled
    30
    scheduled
    7
    scheduled
    10
    0 P1 4
    P2 7
    P3 10
    P1 14
    P1 18
    P1 22
    P1 26
    P1 30
  • 20. Questions
    Define the difference between pre-emptive and non-pre-emptive scheduling.
    Explain the concept of a priority used in scheduling. Why is priority working usually chosen for real time processes?
    Define by difference between preemptive and non-emptive scheduling.
    Comment on the principle disadvantage of each of these scheduling methods: FCFS, SJF, RR
    Operating System Concepts Prasad Sawant
  • 21. Bibliography
    Operating System Principle-Peter Galvin Galvin
    Prof.S.G.Lakhdive
    (Dept .Computer Sci )
    Prof.Ramkirshna More A.C.S College Akurdi
    Mr. AbhishekNagar
    Web Administrator at Symbiois
    Operating System Concepts Prasad Sawant
  • 22. Thanks you
    Operating System Concepts Prasad Sawant