Presentation is loading. Please wait.

Presentation is loading. Please wait.

3. CPU Scheduling. CPU Scheduling Process execution – a cycle of CPU execution and I/O wait – figure Preemptive Non-Preemptive.

Similar presentations


Presentation on theme: "3. CPU Scheduling. CPU Scheduling Process execution – a cycle of CPU execution and I/O wait – figure Preemptive Non-Preemptive."— Presentation transcript:

1 3. CPU Scheduling

2 CPU Scheduling Process execution – a cycle of CPU execution and I/O wait – figure Preemptive Non-Preemptive

3 The four circumstance 1. When a process switches from the running state to the waiting state 2. When a process switches from the running state to the ready state 3. When a process switches from the waiting state to the ready state 4. When a process terminates

4 scheduler Select one of the processes in the ready queue Short-term scheduling

5 Dispatcher gives the control of the CPU to the process selected by the scheduler functions – switching context – switching to user mode – jumping to the proper location in the user program to restart that program Dispatch latency : – the time it takes for dispatcher to stop one process and start another running.

6 Scheduling Criteria CPU utilization – % of time device is busy Throughput – the number of jobs completed per unit time Turnaround time – including I/O Waiting time Response time

7 Scheduling Goal fair among all processes max. the CPU utilization and throughput min. the turnaround / waiting / response time optimize the average measure minimize the max. response time – consider the worst case – interactive systems minimize the variance in the response time

8 Scheduling Algorithm consider only one CPU burst per process – execution units – ex) 10 milliseconds our measure of compare – average waiting time

9 FiFO Scheduling (1) First-come First-served Easily managed with a FiFO queue Fair The average waiting time is often quite long – 129 pages(Fifth Edition) One CPU-bound process and many I/O bound processes – I/O devices idle or CPU sits ilde Non-preemptive Troublesome for time sharing system

10

11 FiFO Scheduling (2) main ( ) { intsum,j=0; while( ){ sum += j; j++; } main( ) { FILE*fp; int j, buf[512]; fp = open(“tmp.dat”, “r+”); while( ){ j = read( fp, buf, sizeof(buf)); sum( buf, 256 ); wirte( fp, buf, 1024 ); } CPU-Bound Pr.I/O-Bound Pr.

12 SJF Scheduling Shortest-Job-First Scheduling Assign the CPU to the process that has the smallest next CPU burst If the same burst, FCFS Minimize the average waiting time Difficulty with the SJF – knowing the length of the next CPU request Non_preemptive

13

14 SRT Scheduling Preemptive version – shortest-remaining time first – shorter CPU burst of new arrival process than what is left of currently executing process – p 133

15

16 Priority Scheduling (1) Allocate CPU to the highest priority process – SJF : a special case of the general priority scheduling – equal-priority processes : FCFS order

17 Priority Scheduling (2) Priority –is defined either internally or externally –Static priority do not change through out execution time easy to implement low-overhead –Dynamic priority response to change more complex greater overhead  the increased responsiveness of the system

18

19 Priority Scheduling (3) –Purchased priority willing to pay a extra charge Non_preemptive or preemptive – when a new process arrives at the ready queue, – new process priority > running process Problem – indefinite blocking or starvation – unfair  aging

20 Deadline scheduling Schedule the certain jobs to be completed by a specific time or deadline – high value if delivered on time – worthless if delivered later than the deadline Very complex Real time systems – control system – etc.

21 HRN scheduling Highest Response-Ratio Next Non-preemptive Compensated version of SJF – longer jobs given favored treatment – the priority of each job is a function P = (waiting_time + service_time) /service_time

22

23 Round-Robin Scheduling (1) Time sharing system FCFS + time_quantum or time_slice – a time quantum : 10~100 ms Ready queue : circular queue Preempted

24

25 Round-Robin Scheduling (2) Maximum waiting time – “ n ” processes in the ready queue – time quantum : q – (n – 1) * q The effect of context switching –time quantum vs. the number of context switching –figure 5.4/5.5 (p. 136 ~137)

26 Multi_level queue scheduling (1) For situation in which processes are easily classified into different groups – foreground( interactive ) processes – background( batch ) processes Permanently assigned to a queues on entry to the systems – low scheduling overhead – inflexible

27

28 Multi_level Feedback Queue Scheduling (1) allows a process to move between queues separate processes with different CPU_burst characteristics – I/O bound process – CPU bound process – aging

29

30 Multi_level Feedback Queue Scheduling (2) Parameters of multi_level feedback q. – the number of queues – the scheduling algorithm for each q. – the method used to determine when to upgrade a process to a higher priority queue. when to demote a process to a lower priority queue. Which queue a process will enter when that process needs service.


Download ppt "3. CPU Scheduling. CPU Scheduling Process execution – a cycle of CPU execution and I/O wait – figure Preemptive Non-Preemptive."

Similar presentations


Ads by Google