UC Santa Barbara. Operating Systems. Christopher Kruegel Department of Computer Science UC Santa Barbara

Similar documents
Scheduling I. Today Introduction to scheduling Classical algorithms. Next Time Advanced topics on scheduling

Scheduling I. Today. Next Time. ! Introduction to scheduling! Classical algorithms. ! Advanced topics on scheduling

CPU scheduling. CPU Scheduling

CS 550 Operating Systems Spring CPU scheduling I

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

CSE 380 Computer Operating Systems

CPU Scheduling. Heechul Yun

CPU SCHEDULING RONG ZHENG

Module 5: CPU Scheduling

Chapter 6: CPU Scheduling

2/5/07 CSE 30341: Operating Systems Principles

Process Scheduling. Process Scheduling. CPU and I/O Bursts. CPU - I/O Burst Cycle. Variations in Bursts. Histogram of CPU Burst Times

Last class: Today: Threads. CPU Scheduling

Simulation of Process Scheduling Algorithms

CPU Scheduling. CPU Scheduler

LSN 15 Processor Scheduling

TDDB68 Concurrent programming and operating systems. Lecture: CPU Scheduling II

TDDI04, K. Arvidsson, IDA, Linköpings universitet CPU Scheduling. Overview: CPU Scheduling. [SGG7] Chapter 5. Basic Concepts.

Real-time operating systems course. 6 Definitions Non real-time scheduling algorithms Real-time scheduling algorithm

Comp 204: Computer Systems and Their Implementation. Lecture 11: Scheduling cont d

CHAPTER 5 - PROCESS SCHEDULING

CPU Scheduling Exercises

ENHANCING CPU PERFORMANCE USING SUBCONTRARY MEAN DYNAMIC ROUND ROBIN (SMDRR) SCHEDULING ALGORITHM

Revamped Round Robin Scheduling Algorithm

Design and Performance Evaluation of a New Proposed Shortest Remaining Burst Round Robin (SRBRR) Scheduling Algorithm

DETERMINING THE VARIABLE QUANTUM TIME (VQT) IN ROUND ROBIN AND IT S IMPORTANCE OVER AVERAGE QUANTUM TIME METHOD

Scheduling. Uwe R. Zimmer & Alistair Rendell The Australian National University

ODSA: A Novel Ordering Divisional Scheduling Algorithm for Modern Operating Systems

Efficient Dual Nature Round Robin CPU Scheduling Algorithm: A Comparative Analysis

Half Life Variable Quantum Time Round Robin (HLVQTRR)

Dynamic Time Quantum based Round Robin CPU Scheduling Algorithm

Improvising Round Robin Process Scheduling through Dynamic Time Quantum Estimation

CS 370. FCFS, SJF and Round Robin. Yashwanth Virupaksha and Abhishek Yeluri

Journal of Global Research in Computer Science

COMPARATIVE PERFORMANCE ANALYSIS OF MULTI-DYNAMIC TIME QUANTUM ROUND ROBIN (MDTQRR) ALGORITHM WITH ARRIVAL TIME

Season Finale: Which one is better?

Lecture 13. Real-Time Scheduling. Daniel Kästner AbsInt GmbH 2013

Real-Time Scheduling and Resource Management

February 2011 Page 23 of 93 ISSN

Networked Embedded Systems WS 2016/17

A new Hybridized Multilevel Feedback Queue Scheduling with Intelligent Time Slice and its Performance Analysis

Embedded Systems Development

Process Scheduling for RTS. RTS Scheduling Approach. Cyclic Executive Approach

An Improved Round Robin Approach using Dynamic Time Quantum for Improving Average Waiting Time

Improved Deadline Monotonic Scheduling With Dynamic and Intelligent Time Slice for Real-time Systems

A NEW PROPOSED DYNAMIC DUAL PROCESSOR BASED CPU SCHEDULING ALGORITHM

Journal of Global Research in Computer Science

How to deal with uncertainties and dynamicity?

Non-Preemptive and Limited Preemptive Scheduling. LS 12, TU Dortmund

Aperiodic Task Scheduling

CIS 4930/6930: Principles of Cyber-Physical Systems

ENHANCING THE CPU PERFORMANCE USING A MODIFIED MEAN- DEVIATION ROUND ROBIN SCHEDULING ALGORITHM FOR REAL TIME SYSTEMS.

Andrew Morton University of Waterloo Canada

International Journal of Advanced Research in Computer Science and Software Engineering

Determining the Optimum Time Quantum Value in Round Robin Process Scheduling Method

Clock-driven scheduling

ENHANCED ROUND ROBIN ALGORITHM FOR PROCESS SCHEDULING USING VARYING QUANTUM PRECISION

PBS: A Unified Priority-Based CPU Scheduler

Embedded Systems 14. Overview of embedded systems design

Real-Time Scheduling. Real Time Operating Systems and Middleware. Luca Abeni

Lecture 4: Process Management

Lecture Note #6: More on Task Scheduling EECS 571 Principles of Real-Time Embedded Systems Kang G. Shin EECS Department University of Michigan

Scheduling IoT on to the Cloud : A New Algorithm

process arrival time CPU burst time priority p1 0ms 25ms 3 p2 1ms 9ms 1 p3 20ms 14ms 4 p4 32ms 4ms 2

ENHANCING THE CPU PERFORMANCE USING A MODIFIED MEAN- DEVIATION ROUND ROBIN SCHEDULING ALGORITHM FOR REAL TIME SYSTEMS

Real-Time Systems. Event-Driven Scheduling

Shared resources. Sistemi in tempo reale. Giuseppe Lipari. Scuola Superiore Sant Anna Pisa -Italy

Real Time Operating Systems

CEC 450 Real-Time Systems

Task Models and Scheduling

Computing the Signal Duration to Minimize Average Waiting Time using Round Robin Algorithm

Real Time Operating Systems

Analysis of Software Artifacts

NATCOR: Stochastic Modelling

Embedded Systems 15. REVIEW: Aperiodic scheduling. C i J i 0 a i s i f i d i

EDF Feasibility and Hardware Accelerators

Online Energy-Aware I/O Device Scheduling for Hard Real-Time Systems with Shared Resources

Real-Time Systems. Event-Driven Scheduling

Operational Laws Raj Jain

Real-time Scheduling of Periodic Tasks (1) Advanced Operating Systems Lecture 2

Lab Course: distributed data analytics

Research Article Designing of Vague Logic Based 2-Layered Framework for CPU Scheduler

Scheduling Lecture 1: Scheduling on One Machine

EDF Scheduling. Giuseppe Lipari May 11, Scuola Superiore Sant Anna Pisa

Analysis of Round-Robin Implementations of Processor Sharing, Including Overhead

D Praveen Kumar et al, / (IJCSIT) International Journal of Computer Science and Information Technologies, Vol. 5 (5), 2014,

Real-Time Scheduling

EDF Scheduling. Giuseppe Lipari CRIStAL - Université de Lille 1. October 4, 2015

3. Scheduling issues. Common approaches 3. Common approaches 1. Preemption vs. non preemption. Common approaches 2. Further definitions

Probabilistic Preemption Control using Frequency Scaling for Sporadic Real-time Tasks

Operating Systems. VII. Synchronization

Scheduling Slack Time in Fixed Priority Pre-emptive Systems

Analysis of PFLOTRAN on Jaguar

EXTRA THRESHOLD IN ROUND ROBIN ALGORITHM IN MULTIPROCESSOR SYSTEM

Lecture 6. Real-Time Systems. Dynamic Priority Scheduling

Convolution Algorithm

Real-Time Systems. Lecture #14. Risat Pathan. Department of Computer Science and Engineering Chalmers University of Technology

An Efficient Energy-Optimal Device-Scheduling Algorithm for Hard Real-Time Systems

1 Lamport s Bakery Algorithm

Transcription:

Operating Systems Christopher Kruegel Department of Computer Science http://www.cs.ucsb.edu/~chris/

Many processes to execute, but one CPU OS time-multiplexes the CPU by operating context switching Between user processes Between user processes and the operating system Operation carried out by scheduler following a scheduling algorithm Switching is expensive Switch from user to kernel model Save the state of the current process (including memory map) Select a process for execution (scheduler) Restore the saved state of the new process 2

CPU-bound and I/O-bound Processes Bursts of CPU usage alternate with periods of I/O wait a CPU-bound process (a) an I/O bound process (b) 3

When To Schedule Must schedule a process blocks (I/O, semaphore, etc) a process exits May schedule new process is created (parent and child are both ready) I/O interrupt clock interrupt 4

Algorithms Non-preemptive CPU is switched when process has finished executes a yield() blocks Preemptive CPU is switched independently of the process behavior A clock interrupt is required Scheduling algorithms should enforce Fairness Policy Balance 5

in Batch Systems Goals Throughput: maximize jobs per hour Turnaround time: minimize time between submission and termination CPU utilization keep processor busy Examples First-come first-served Shortest job first Shortest remaining time next 6

First-Come First-Served Processes are inserted in a queue The scheduler picks up the first process, executes it to termination or until it blocks, and then picks the next one Very simple Disadvantage I/O-bound processes could be slowed down by CPU-bound ones 7

Shortest Job First This algorithm assumes that running time for all the processes to be run is known in advance Scheduler picks the shortest job first Optimizes turnaround time a) Turnaround is A=8, B=12, C=16, D=20 (avg. 14) b) Turnaround is B=4, C=8, D=12, A=20 (avg. 11) Problem: what if new jobs arrive? 8

Shortest Remaining Time Next This algorithm also assumes that running time for all the processes to be run is known in advance The algorithm chooses the process whose remaining run time is the shortest When a new job arrive, its remaining run time is compared to the one of the process running If current process has more remaining time than the run time of new process, the current process is preempted and the new one is run 9

in Interactive Systems Goals Response time: minimize time needed to react to requests Proportionality: meet user expectations Examples Round robin Priority scheduling Lottery scheduling 10

Round Robin Scheduling Each is process is assigned a quantum The process Suspends before the end of the quantum or Is preempted at the end of the quantum Scheduler maintains a list of ready processes 11

Round Robin Scheduling Parameters: Context switch (e.g., 1 msec) Quantum length (e.g., 25 msec) If quantum is too small, a notable percentage of the CPU time is spent in switching contexts If quantum is too big, response time can be very bad 12

Priority Scheduling Each process is assigned a priority The process with the highest priority is allowed to run I/O bound processes should be given higher priorities Problem: low priority processes may end up starving... First solution: As the process uses CPU, the corresponding priority is decreased Second solution: Set priority as the inverse of the fraction of quantum used Third solution: Used priority classes (starvation is still possible) 13

Priority Scheduling 14

Lottery Scheduling OS gives lottery tickets to processes Scheduler picks a ticket randomly and gives CPU to the winner Higher-priority processes get more tickets Advantage: processes may exchange tickets it is possible to fine tune the share of CPU that a process receives easy to implement 15

Example non-preemtive priority scheduling Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 16

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 17

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 18

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 19

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 20

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 21

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 22

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 23

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 24

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 25

A B C D E 0 2 4 6 8 10 12 14 16 18 20 t Process A C B D E Time (RUNNING) 0 5 8 9 16 26

Example preemtive priority scheduling Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 27

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 28

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 29

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 30

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 31

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 32

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 33

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 34

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 35

Process Start Runtime Priority A 0 5 2 B 3 1 1 C 4 3 4 D 8 7 0 E 12 2 3 A B C D E 0 2 4 6 8 10 12 14 16 18 20 t 36

A B C D E 0 2 4 6 8 10 12 14 16 18 20 t Process A C A B D E D Time (RUNNING) 0 4 7 8 9 12 14 37

Thread Scheduling If threads are implemented in user space, only one process threads are run inside a quantum Possible scheduling of user-level threads 48-msec process quantum Threads run 8 msec/cpu burst 38

If threads are implemented in the kernel, threads can be interleaved Thread Scheduling Kernel may decide to switch to a thread belonging to the same process for efficiency reasons (memory map does not change) 39

Policy versus Mechanism Sometimes an application may want to influence the scheduling of cooperating processes (same user, or children processes) to achieve better overall performance Separate what is allowed to be done with how it is done process knows which of its children threads are important and need priority Scheduling algorithm parameterized Mechanism in the kernel Parameters filled in by user processes Policy set by user process 40

Linux - CFS Completely fair scheduler (CFS)!Ingo Molnar:!!80% of CFS's design can be summed up in a single sentence: CFS basically models an "ideal, precise multi-tasking CPU" on real hardware.!!on real hardware, we can run only a single task at once, so while that one task runs, the other tasks that are waiting for the CPU are at a disadvantage - the current task gets an unfair amount of CPU time. In CFS this fairness imbalance is expressed and tracked via the per-task p->wait_runtime (nanosec-unit) value. "wait_runtime" is the amount of time the task should now run on the CPU for it to become completely fair and balanced. 41