Presentation is loading. Please wait.

Presentation is loading. Please wait.

CH 5. CPU Scheduling 2015-04-14. 5.1 Basic Concepts F CPU Scheduling  context switching u CPU switching for another process u saving old PCB and loading.

Similar presentations


Presentation on theme: "CH 5. CPU Scheduling 2015-04-14. 5.1 Basic Concepts F CPU Scheduling  context switching u CPU switching for another process u saving old PCB and loading."— Presentation transcript:

1 CH 5. CPU Scheduling

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 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  If arriving order  1, 2, 3  If arriving order is 2, 3, 1 A.T.T = ( ) / 3 = 13 A.W.T = ( ) / 3 = 3 Job1 Job2 Job Average Turnaround Time = ( )/3 = 27 Average Waiting Time = ( )/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 = ( (10 - 4)) / 3 = 17 / 3 = 5.66 ms  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 Showing how a smaller time quantum increases context switching

8 5.3 Scheduling Algorithms Average turnaround time 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 = ( )/4 = 7 ms. –FCFS A.W.T = ( )/4 = 41/4 = ms. –AVG Turnaround Time = ( )/4 = 52/4 = 13 ms. Job Burst Time 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 = ms. –SJF A.W.T = 5.75 ms. Ex) Job Arrive Time Burst Time * Assign the Thrasholded Value J 1 J 2 J 4 J 1 J

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 J 2 J 5 J 1 J 3 J 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


Download ppt "CH 5. CPU Scheduling 2015-04-14. 5.1 Basic Concepts F CPU Scheduling  context switching u CPU switching for another process u saving old PCB and loading."

Similar presentations


Ads by Google