CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of...

17
CIS250 OPERATING SYSTEMS

Transcript of CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of...

Page 1: CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.

CIS250

OPERATING SYSTEMS

Page 2: CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.

Chapter 6 - CPU SchedulingBasic Concepts

• The objective of multi-programming is have a program running at all times

• Maximize CPU utilization

• A process executes until it has to wait for something: O/S takes the CPU away and gives it to another process

• CPU scheduler is central to O/S design

Page 3: CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.

CPU-I/O Burst Cycle

• Process CPU, wait…

• Last instruction, terminate, CPU

• > short CPU bursts

• < long CPU bursts

Page 4: CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.

CPU Scheduler

• Short-term scheduler - when the CPU is idle, a process is selected

Page 5: CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.

Preemptive Scheduling

• The process scheduler interrupts a process and transfers the CPU to another process– switch from run to ready– switch from wait to ready

Page 6: CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.

Non-Preemptive

• No interrupts; once a process has the CPU, it runs until there is an I/O interrupt or the process terminates

• No choice; the process keeps CPU until it releases it– process switches from running to wait– process terminates

• No timer is required

Page 7: CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.

Dispatcher

• Gives the control of the CPU to a selected process:– switch context– switch to user mode– jump to a location in the user program and

restart

• Should be fast; the time to stop one process and start another is called dispatch latency

Page 8: CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.

Scheduling Criteria

• Algorithms are used to schedule the CPU time

• Consider the properties for each algorithm– CPU utilization– throughput– turnaround time– waiting time– response time

Page 9: CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.

Scheduling Criteria

• CPU Utilization - keep the CPU busy as much as possible; utilize as close to 100%; realistic - 40-90%

• Throughput - the number of processes that complete in a given time; a measurement of the amount of work being done– 10 processes per second

Page 10: CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.

Scheduling Criteria

• Turnaround Time - how long it takes for a process to run; subtract time of completion from submission start time– wait states are included in this time

• Waiting Time - total amount of time a process spends in the ready queue

• Response Time - amount of time it takes to get a response

Page 11: CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.

• Maximize CPU and throughput

• Minimize turnaround, wait and response time

Page 12: CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.

Scheduling Algorithms

• A method for deciding which process in the ready queue should be allocated the CPU

Page 13: CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.

Scheduling Algorithms

• First-Come, First-Served - non-preemptive; the first process to request the CPU, gets it– uses FIFO queue: PCB is linked to the tail of

the queue; the head gets allocated CPU

• Shortest-Job-First - shortest CPU burst first; if there is a tie, uses FIFO

Page 14: CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.

Scheduling Algorithms

• Priority

• Round-Robin

Page 15: CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.

Scheduling Algorithms

• Multilevel Queue

• Multilevel Feedback Queue

Page 16: CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.

Other Scheduling Models

• Multi-Processor Scheduling

• Real-Time Scheduling

Page 17: CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.

Algorithm Evaluation

• Deterministic modeling

• Queuing models

• Simulations

• Implementation