cpu sheduling

Views:
 
     
 

Presentation Description

Basic Concepts Scheduling Criteria Scheduling Algorithms

Comments

By: delmo22 (15 month(s) ago)

Hi Dear sawanprasad, This is a good presentation... Please can you allow us to download it or f you don't mind to email t to me at delomongoto@yahoo.co.uk Many thanks Delo

By: piyushkhandelwal993 (15 month(s) ago)

Nice presentation................................

Presentation Transcript

CPU Scheduling : 

CPU Scheduling Prof.Prasad Sawant Lecturer MCA MACS College Pune Operating System Concepts Prasad Sawant

Alternating Sequence of CPU And I/O Bursts : 

Alternating Sequence of CPU And I/O Bursts Operating System Concepts Prasad Sawant

CPU Scheduler : 

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

Dispatcher : 

Dispatcher Dispatcher module gives control of the CPU to the process selected by the short-term scheduler. Operating System Concepts Prasad Sawant

Scheduling Criteria : 

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

Keep in mind : 

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

Optimization Criteria : 

Optimization Criteria Max CPU utilization Max throughput Min turnaround time Min waiting time Min response time Operating System Concepts Prasad Sawant

First-Come, First-Served (FCFS) Scheduling : 

First-Come, First-Served (FCFS) Scheduling Operating System Concepts Prasad Sawant Suppose that the processes arrive in the order: P1 , P2 , P3 0 10 20 30 P1 24 P2 27 P3 30 Waiting time for P1 = 0; P2 = 24; P3 = 27 Average waiting time: (0 + 24 + 27)/3 = 17 schedule schedule schedule

First-Come, First-Served (FCFS) Scheduling Gantt Chart : 

First-Come, First-Served (FCFS) Scheduling Gantt Chart Operating System Concepts Prasad Sawant Suppose that the processes arrive in the order: P1 , P2 , P3 Waiting time for P1 = 0; P2 = 24; P3 = 27 Average waiting time: (0 + 24 + 27)/3 = 17 schedule schedule schedule 0 P1 24 P2 27 P3 30

Exercise : 

Exercise Find Average waiting time for Suppose that the processes arrive in the order: P2 , P3 , P1 Operating System Concepts Prasad Sawant

Shortest-Job-First (SJR) Scheduling : 

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

Example of Non-Preemptive SJF : 

Example of Non-Preemptive SJF Operating System Concepts Prasad Sawant 0 P1 7 P3 8 P2 12 P4 16 schedule schedule schedule schedule Average waiting time = (0+6+3+7)/4=4

Example of Non-Preemptive SJF : 

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

Preemptive SJF : 

Preemptive SJF Operating System Concepts Prasad Sawant 0 P1 1 P2 5 P schedule P4 10 schedule 7 P1 17 schedule P3 26 schedule 10 1 17 5 10-1=9 1-1=0 17-2=15 5-3=2

Priority Scheduling : 

Priority Scheduling Operating System Concepts Prasad Sawant 0 P2 1 0 P5 6 P1 16 P3 18 P4 19 Schedule Schedule Schedule Schedule Schedule 6 0 16 18 1 6 0 16 18 1 41/5=8.2 ms

SJF Preemptive Priority Scheduling : 

SJF Preemptive Priority Scheduling Operating System Concepts Prasad Sawant 0 P1 3 P 5 P4 12 scheduled P3 19 scheduled P1 24 scheduled P2 30 scheduled 19 24 12 3 19-3=16 24-1=23 12-3=9 3-3=0 48/4=12 ms

Round Robin Scheduling : 

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/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. Operating System Concepts Prasad Sawant

Time Quantum and Context Switch Time : 

Time Quantum and Context Switch Time Operating System Concepts Prasad Sawant 0 1 9 0 10 6 10 2 3 4 5 6 7 8 9 10 1

Round Robin Time Quantum 4 : 

Round Robin Time Quantum 4 Operating System Concepts Prasad Sawant 0 P1 4 24-4=20 P2 7 scheduled P3 10 scheduled P1 14 20-4=16 P1 18 16-4=12 P1 22 12-4=8 P1 26 8-4=4 P1 30 4-4=0 scheduled 30 7 10

Questions : 

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

Bibliography : 

Bibliography Operating System Principle-Peter Galvin Galvin Prof.S.G.Lakhdive (Dept .Computer Sci ) Prof.Ramkirshna More A.C.S College Akurdi Mr. Abhishek Nagar Web Administrator at Symbiois Operating System Concepts Prasad Sawant

Slide 22: 

Thanks you Operating System Concepts Prasad Sawant