Department of Computer Engineering PSU Wannarat Suntiamorntut 240

  • Slides: 16
Download presentation
Department of Computer Engineering, PSU Wannarat Suntiamorntut 240 -323, Part II CPU Scheduling 240

Department of Computer Engineering, PSU Wannarat Suntiamorntut 240 -323, Part II CPU Scheduling 240 -323 OS, 2000 1

Department of Computer Engineering, PSU Wannarat Suntiamorntut Basic Concepts The basic problem is as

Department of Computer Engineering, PSU Wannarat Suntiamorntut Basic Concepts The basic problem is as follows: How can OS schedule the allocation of CPU cycles to processes in system, to achieve “good performance”? Scheduling is a fundamental OS function. 240 -323 OS, 2000 2

Department of Computer Engineering, PSU Wannarat Suntiamorntut CPU- I/O Burst Cycle cpu burst I/O

Department of Computer Engineering, PSU Wannarat Suntiamorntut CPU- I/O Burst Cycle cpu burst I/O burst CPU burst 240 -323 OS, 2000 I/O burst 3

Department of Computer Engineering, PSU Wannarat Suntiamorntut Preemptive Scheduling • process switches from running

Department of Computer Engineering, PSU Wannarat Suntiamorntut Preemptive Scheduling • process switches from running -> waiting )I/O request(. . , • process switches from running -> ready )interrupt occur( • process switches from waiting -> ready )completion of I/O( • process terminate 240 -323 OS, 2000 4

Department of Computer Engineering, PSU Wannarat Suntiamorntut Dispatcher Module to give control of CPU

Department of Computer Engineering, PSU Wannarat Suntiamorntut Dispatcher Module to give control of CPU to process selected by short-term scheduler. This function involves: -Switching context -Switching to user mode -Jumping to the proper location in user program to restart that program 240 -323 OS, 2000 5

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Criteria • CPU utilization : in

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Criteria • CPU utilization : in a real system, it range from 90 - 40 percents. • Throughput : number of processes that are completed. • Turnaround time : interval from time of submission to completion. • Waiting time : time that a process spends waiting in ready queue. • Response time : time from the submission of a request until the first response. 240 -323 OS, 2000 6

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Algorithms • First-come, First-served Scheduling (FCFS(

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Algorithms • First-come, First-served Scheduling (FCFS( mange with FIFO Process P 1 P 2 P 3 Burst Time 24 3 3 P 1 Average wait time = 17 P 2 P 3 3027240 240 -323 OS, 2000 7

Department of Computer Engineering, PSU Wannarat Suntiamorntut FCFS Process P 1 P 2 P

Department of Computer Engineering, PSU Wannarat Suntiamorntut FCFS Process P 1 P 2 P 3 Burst Time 24 3 3 P 2 306 3 240 -323 OS, 2000 Average wait time = 3 P 1 0 8

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Algorithm • Shortest-Job-First Scheduling mange with

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Algorithm • Shortest-Job-First Scheduling mange with SJF , minimum average wait time Process P 1 P 2 P 3 P 4 Burst Time 6 8 7 3 P 4 2416 Average wait time = 7 P 1 9 240 -323 OS, 2000 P 3 3 0 P 2 9

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Algorithm • Shortest-remaining-time-First Scheduling mange with

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Algorithm • Shortest-remaining-time-First Scheduling mange with SJF , minimum average wait time Process P 1 P 2 P 3 P 4 P 1 2617 Arrival time 0 1 2 3 P 2 240 -323 OS, 2000 10 P 4 Burst Time 8 4 9 5 P 1 5 1 0 Average wait time = 6. 5 P 3 10

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Algorithm • Priority Scheduling scheduling in

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Algorithm • Priority Scheduling scheduling in term of high priority and low. Process P 1 P 2 P 3 P 4 P 5 Burst Time 10 1 2 1 5 P 2 P 5 19 18 16 240 -323 OS, 2000 Priority 3 1 3 4 2 P 1 6 1 0 Average wait time = 8. 2 P 3 P 4 11

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Algorithm • Round-Robin Scheduling round-robin (RR),

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Algorithm • Round-Robin Scheduling round-robin (RR), especially for time-sharing. -time quantum , time slice = small unit of time Process P 1 P 2 P 3 302622 18 240 -323 OS, 2000 Burst Time 24 3 3 P 1 14 P 1 10 If time quantum = 4 P 1 7 P 1 4 Average wait time = 5. 66 P 1 0 12

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Algorithm • Multilevel Queue Scheduling Highest

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Algorithm • Multilevel Queue Scheduling Highest priority System process Interactive editing process Bath process student process lowest priority 240 -323 OS, 2000 13

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Algorithm • Multilevel Feedback Queue Scheduling

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Algorithm • Multilevel Feedback Queue Scheduling Quantum = 8 Quantum = 16 FCFS 240 -323 OS, 2000 14

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Algorithm Do the example Process P

Department of Computer Engineering, PSU Wannarat Suntiamorntut Scheduling Algorithm Do the example Process P 1 P 2 P 3 P 4 P 5 240 -323 OS, 2000 Burst Time Priority 10 3 5 1 4 3 2 Arrival time 0 2 3 5 7 15

Department of Computer Engineering, PSU Wannarat Suntiamorntut Next Lecture in Process Synchronization 240 -323

Department of Computer Engineering, PSU Wannarat Suntiamorntut Next Lecture in Process Synchronization 240 -323 OS, 2000 16