100 likes | 211 Views
CPU Scheduling. CSCI 4534. Introduction. By switching the CPU among processes, the O.S. can make the system more productive Some process is running at all times Several processes are kept in memory A process is executed until it must wait typically for I/O
E N D
CPU Scheduling CSCI 4534
Introduction • By switching the CPU among processes, the O.S. can make the system more productive • Some process is running at all times • Several processes are kept in memory • A process is executed until it must wait • typically for I/O • When this process waits, another runs • running means the CPU is executing it
CPU-I/O Burst Cycle • Observed Property of Processes: • Processesalternate between a cycle of CPU execution and I/O wait • CPU burst • I/O burst (read from file/write to file) • CPU burst • … • CPU burst (to terminate)
CPU-I/O Burst Cycle • Durations of CPU bursts vary, but curve is similar to Figure 5.2 histogram, typically: • large number of short CPU bursts • small number of long CPU bursts • I/O bound programs have many short CPU bursts • CPU bound programs have a few long CPU bursts
CPU Scheduler • When CPU is idle, the O.S. selects a process in the ready queue • Done by short-term scheduler / CPU scheduler • Ready Queue is set of PCBs in: • FIFO queue • priority queue (actually a Ready State, not queue) • tree • unordered linked list
CPU Scheduling Decisions • CPU scheduling decisions are made when: • A process switches from running to waiting • A process switches from running to ready • A process switches from waiting to ready • A process terminates • What is preemptive? • What are problems? • What is nonpreemptive?
Dispatcher • The dispatcher gives control of CPU to the process selected by short-term scheduler • It does context switching • It switches to user mode • It jumps to next executable statement in the user program • The time taken to stop one process and start another is dispatch latency • “interval between stimulation and response”
Scheduling Criteria • CPU utilization • Throughput - # processes completed per time unit • Turnaround time - time from submission to completion • Waiting time - in the ready queue • Response time - time from submission to first response
Scheduling Criteria • Goals: • Maximize: CPU Utilization and Throughput • Minimize: Turnaround, Waiting and Response Times • May also want to minimize variance for response time for more predictability
Scheduling Algorithms • FCFS • SJF • Priority Scheduling • Round-Robin • Multilevel Queue • Multilevel Feedback Queue