Download presentation

Presentation is loading. Please wait.

Published byMicah Jennings Modified over 2 years ago

1
CH 5. CPU Scheduling 2015-04-14

2
5.1 Basic Concepts F CPU Scheduling context switching u CPU switching for another process u saving old PCB and loading new PCB dispatcher u give control of the CPU to the process selected by the CPU scheduler F CPU-I/O Burst Cycle Process execution begins with a CPU burst

3
5.1 Basic Concepts Alternating sequence of CPU and I/O bursts Load store add store read from file Wait for I/O Store increment index write to file Wait for I/O Load store add store read from file Wait for I/O CPU burst I/O burst CPU burst I/O burst frequency 160 140 120 100 80 60 40 20 0816243240 burst duration (milliseconds) Histogram of CPU-burst times

4
5.2 Scheduling Criteria F Performance comparison criteria of CPU scheduling algorithm CPU utilization : 40% ~ 90% throughput : finished job # per time unit turnaround time : waiting time in the Ready Queue response time : interactive system F preemptive & nonpreemptive Scheduling context switching : pure overhead (PCB save, load) F Interval timer & interrupting clocking prevent a monopoly of system F Deadline Scheduling pay remnant cost for processing in explicit time

5
5.3 Scheduling Algorithms 1.FIFO(FCFS) CBACPU Finish Nonpreemptive Ex) Job Burst Time 1 24 2 3 3 3 If arriving order 1, 2, 3 If arriving order is 2, 3, 1 A.T.T = (3 + 6 + 30) / 3 = 13 A.W.T = (0 + 3 + 6) / 3 = 3 Job1 Job2 Job3 24 27 30 Average Turnaround Time = (24 + 27 + 30)/3 = 27 Average Waiting Time = (0 + 24 + 27)/3 = 17 ms

6
5.3 Scheduling Algorithms 2.Round Robin Scheduling for Timesharing System Time Quantum of Time Slice (10 ~ 100 msec) New job Preemptive Finish Ex) In the case of jobs in previous example, if time quantum is 4, Average turnaround time is -- J1 J2 J3 J1 J1 · · · · · J1 47 / 3 16 Average Waiting Time = (4 + 7 + (10 - 4)) / 3 = 17 / 3 = 5.66 ms 4 7 10 14 30 R.R Scheduling = Preemptive Scheduling Time Quantum : if large FCFS short like processor sharing context switching overhead

7
5.3 Scheduling Algorithms Process time = 10 Quantum Context switches 12 0 6 1 1 9 0 10 0 1 2 3 4 5 6 7 8 9 10 6 Showing how a smaller time quantum increases context switching

8
5.3 Scheduling Algorithms Average turnaround time 12.5 12.0 11.5 11.0 10.5 10.0 9.5 9.0 1 2 3 4 5 6 7 Process time P 1 6 P 2 3 P 3 1 P 4 7 Time quantum Showing how turnaround time varies with the time quantum

9
5.3 Scheduling Algorithms 3.Shortest - Job - First (SJF) Non preemptive Scheduling Long - Term Scheduling in Batch system : good. Short-Term Scheduling : impossible u A.W.T = (3 + 16 + 9 + 0)/4 = 7 ms. –FCFS A.W.T = (0 + 6 + 14 + 21)/4 = 41/4 = 10.25 ms. –AVG Turnaround Time = (3 + 9 + 16 + 24)/4 = 52/4 = 13 ms. Job Burst Time 1 6 2 8 3 7 4 3 0 3 9 16 24 J 4 J 1 J 3 J 2

10
5.3 Scheduling Algorithms 4.Shortest-Remaining-Time-First(SRT) Transformation of Shortest-Job-First Preemptive SJF u A.W.T = ((10-1) + (1-1) + (17 -2) + (5-3))/4 = 26/4 = 6.5 ms. –A.T.T = 17 + (5-1) + (26-2) + (10-3) =52/4 = 13 ms. –SJF A.T.T = 14.25 ms. –SJF A.W.T = 5.75 ms. Ex) Job Arrive Time Burst Time 1 0 8 2 1 4 3 2 9 4 3 5 * Assign the Thrasholded Value J 1 J 2 J 4 J 1 J 3 0 1 5 10 17 26

11
5.3 Scheduling Algorithms 5.Priority Scheduling SJF : Special case of the general priority scheduling. FCFS : Equal priority. Major problem : indefinite blocking or starvation. u Solution HRN Ex) Job Burst Time Priority 110 3 2 1 1 3 2 3 4 1 4 5 5 2 J 2 J 5 J 1 J 3 J 4 0 1 6 16 18 19 A.W.T = 8.2 ms A.T.T = 12 ms

12
5.3 Scheduling Algorithms 6.HRN(Highest-Response-ratio-Next) : Brinch Hansen priority = (Waiting Time + Service Time) / Service Time Nonpreemptive method that apply process service time and total time to wait service

13
5.3 Scheduling Algorithms 7.Multilevel Queue processes each job classified into queues ex) classify into Foreground and Background (80% : 20%) u F.G is scheduled by Round Robin algorithm u B.G is scheduled by an FCFS algorithm system processes Interactive processes Interactive editing processes batch processes student processes highest priority lowest priority Multilevel Queue scheduling

14
5.3 Scheduling Algorithms 8.Multilevel Feedback Queue allow a process to move between queues quantum = 8 quantum = 16 FCFS Fig 5.7 Multilevel feedback queues

15
5.5 Real-Time Scheduling F Hard real-time within a guaranteed time F soft real-time less restrictive

16
5.6 Algorithm Evaluation F Deterministic modeling ProcessBurst Time P 1 10 P 2 1 P 3 2 P 4 1 P 5 5 maximize CPU utilization maximize throughput) F Queueing Models result mathematical formula that estimate the distribution of CPU and I/O bursts. F Simulations

17
5.6 Algorithm Evaluation FCFS RR (Quantum=1) S.J.F F Evaluation method Analytical evaluation u use mathematical analysis by predetermined workload, … u ex) Deterministic modeling Queuing Model u mathematical formula, arrival rate, service rate èutilization, queue length, wait time Simulation

Similar presentations

Presentation is loading. Please wait....

OK

Chapter 5-CPU Scheduling

Chapter 5-CPU Scheduling

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on consumer protection act 1986 india Ppt online templates Ppt on synthesis and degradation of purines and pyrimidines a g Ppt on nmr spectroscopy Ppt on index numbers economics Ppt on class ab power amplifier Ppt on training and development in india Ppt on rbi reforms Ppt on save environment poster Ppt on object-oriented concepts in java with examples