Scheduling Classes and Real-Time Scheduling in Linux

Slides:



Advertisements
Similar presentations
1 Always want to have CPU (or CPU’s) working Usually many processes in ready queue –Ready to run on CPU –Focus on a single CPU here Need strategies for.
Advertisements

Operating Systems Process Scheduling (Ch 3.2, )
Linux Scheduler. Linux is a multitasking OS Deciding what process runs next, given a set of runnable processes, is a fundamental decision a scheduler.
Sogang University Advanced Operating Systems (Process Scheduling - Linux) Advanced Operating Systems (Process Scheduling - Linux) Sang Gue Oh, Ph.D. .
Tasks Periodic The period is the amount of time between each iteration of a regularly repeated task Time driven The task is automatically activated by.
CS 3013 & CS 502 Summer 2006 Scheduling1 The art and science of allocating the CPU and other resources to processes.
 Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.
Operating System Examples - Scheduling
Scheduling Basic scheduling policies, for OS schedulers (threads, tasks, processes) or thread library schedulers Review of Context Switching overheads.
CPU Scheduling Presentation by Colin McCarthy. Runqueues Foundation of Linux scheduler algorithm Keeps track of all runnable tasks assigned to CPU One.
BFSBFS by Con KolivasCon Kolivas Guruprasad Aphale. Real Time Lunch, 10/21/ Guruprasad Aphale.
CHAPTER 2 PROCESSOR SCHEDULING PART V by U ğ ur HALICI.
LINUX SCHEDULING Evolution in the 2.6 Kernel Kevin Lambert Maulik Mistry Cesar Davila Jeremy Taylor.
RTOS task scheduling models
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Scheduling II: priority scheduling.
Traditional UNIX Scheduling Scheduling algorithm objectives Provide good response time for interactive users Ensure that low-priority background jobs do.
Lecture 6 Page 1 CS 111 Online Preemptive Scheduling Again in the context of CPU scheduling A thread or process is chosen to run It runs until either it.
Periodic scheduler for Linux OS
Real Time System with MVL. © 2007 MontaVista Confidential | Overview of MontaVista Agenda Why Linux Real Time? Linux Kernel Scheduler Linux RT technology.
Operating System Examples - Scheduling. References r Silberschatz et al, Chapter 5.6, Chapter
Linux Process Management. Linux Implementation of Threads Threads enable concurrent programming / true parallelism Linux implementation of threads.
Scheduling Classes and Real-Time Scheduling in Linux David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St.
Operating Systems Unit 5: – Processor scheduling – Java – Linux – Windows XP Operating Systems.
REAL-TIME OPERATING SYSTEMS
Chapter 19: Real-Time Systems
Scheduling of Non-Real-Time Tasks in Linux (SCHED_NORMAL/SCHED_OTHER)
Lecture 12: Real-Time Scheduling
Operating Systems Design (CS 423)
Midterm Review Chris Gill CSE 422S - Operating Systems Organization
Chapter 5a: CPU Scheduling
Time Sources and Timing
Midterm Review David Ferry, Chris Gill
Networks and Operating Systems: Exercise Session 2
April 6, 2001 Gary Kimura Lecture #6 April 6, 2001
Kernel Tracing David Ferry, Chris Gill
Chapter 2 Scheduling.
Chapter 8 – Processor Scheduling
Time Sources and Timing
Semester Review Chris Gill CSE 422S - Operating Systems Organization
Lecture 4 Schedulability and Tasks
Chapter 6: CPU Scheduling
CS 3204 Operating Systems Lecture 14 Godmar Back.
Linux kernel: Processes, threads and scheduling
CPU Scheduling Basic Concepts Scheduling Criteria
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 2: The Linux System Part 3
TDC 311 Process Scheduling.
Scheduling.
Enforcing Real-Time Behavior I
Multiprocessor and Real-Time Scheduling
Chapter 6: CPU Scheduling
Process Scheduling Decide which process should run and for how long
Top Half / Bottom Half Processing
Kernel Synchronization I
Overview of the Lab 2 Assignment: Multicore Real-Time Tasks
CS703 – Advanced Operating Systems
Midterm Review Brian Kocoloski
Scheduling of Regular Tasks in Linux
Chapter 10 Multiprocessor and Real-Time Scheduling
Time Sources and Timing
Scheduling.
Kernel Tracing David Ferry, Chris Gill, Brian Kocoloski
Linux Process State Scheduling information Identifiers
Real-Time Process Scheduling Concepts, Design and Implementations
Interrupts and Interrupt Handling
Real-Time Process Scheduling Concepts, Design and Implementations
Linux Scheduling CSE 2431: Introduction to Operating Systems
Scheduling of Regular Tasks in Linux
CPU Scheduling David Ferry CSCI 3500 – Operating Systems
Presentation transcript:

Scheduling Classes and Real-Time Scheduling in Linux David Ferry, Chris Gill, Brian Kocoloski CSE 422S - Operating Systems Organization Washington University in St. Louis

Real-Time Applications Have repeating functions that must execute within a precise period of time Within the next 10 ms, do something, or else bad things could happen Examples Air traffic control systems Video/audio communication systems Web serving Stock Trading CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization Real-Time Scheduling Real-time tasks execute repeatedly (usually are periodic) under some time constraint Task Time 0ms 5ms 10ms E.g., a task is released to execute every 5 msec, and each invocation has a deadline of 5 msec Separate priority range from the nice priorities for CFS: Priorities are from 1 (low) to 99 (high), highest ones need root CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization Real-Time OS Support Why might supporting such applications be challenging, given our understanding of Linux’ CFS scheduler? For example, if a user accessed the kernel: ”can you guarantee my task will run for 1 second at every 5 second interval?” Challenges: CFS uses proportional sharing – so the answer is highly dependent on other system activity What if another process boosts its priority? What if another process is starved? vruntime is designed to achieve proportionality – not to give guarantees on deadlines or speak in terms of fixed time quantities CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization Real-Time OS Support Goal is to achieve predictable execution: Other sources of uncertainty (and solutions): Interrupts (can mask some interrupts) Migrations (can pin tasks to cores) OS latency, jitter, and kernel non-preemptibility (real-time scheduling) Ideal: Real world: Preempt Migrate CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization Kernel Preemption Before the 2.6 kernel (2003), Linux did not have a pre-emptible kernel If a process was executing in the kernel, it could hog the CPU indefinitely User-level process in a system-call Kernel threads Major issue for interactive/latency-sensitive + real-time applications Starting in 2.6, the kernel became fully1 preemptible 1 there are ways to selectively disable preemption, for example, during interrupt handlers, or when taking special locks; more on this in a few weeks CSE 422S – Operating Systems Organization

Three real-time scheduling classes SCHED_FIFO First-in, First-out scheduling SCHED_RT Round robin scheduling SCHED_DEADLINE Earliest deadline first CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization SCHED_FIFO First-in, First-out scheduling The first enqueued task of highest priority executes to completion A task will only relinquish a processor when it completes, yields, or blocks Only a higher priority SCHED_FIFO or SCHED_RR task can preempt a SCHED_FIFO task – all others will be starved as it runs Task 1 Task 2 Task 3 Time CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization SCHED_RR Round-robin scheduling Same as SCHED_FIFO but with timeslices Among tasks of equal priority: Rotate through all tasks Each task gets a fixed time slice Only a higher priority SCHED_FIFO or SCHED_RR task can preempt a SCHED_FIFO Tasks of equal priority preempt each other after timeslice expiration Task 1 Task 2 Task 3 Time CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization SCHED_DEADLINE Earliest Deadline First (EDF) scheduling (only available with rt-preempt patch) Whichever task has next deadline gets to run Theory exists to analyze such systems Linux implements bandwidth reservation to prevent deadline abuse Task 3 Deadline: 12 Exec time: 2 Task 2 Deadline: 8 Exec time: 3 Task 1 Deadline: 5 Exec time: 4 Time 0 Task 1 Task 2 Task 3 5 8 12 CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization Scheduling Classes Multiple schedulers are implemented as different scheduling classes. Normal: SCHED_NORMAL: regular, interactive CFS tasks SCHED_BATCH: low priority, non-interactive CFS tasks SCHED_IDLE: very low priority tasks Real-time: SCHED_RR: round-robin SCHED_FIFO: first-in, first-out SCHED_DEADLINE: earliest deadline first (rt-preempt) CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization struct sched_class A few major functions: Other functions: Task migration Task state queries Task yielding Other utilities CSE 422S – Operating Systems Organization

Current Scheduling Classes and Ordering stop_sched_class //for halting processors dl_sched_class // (rt-preempt patch only) rt_sched_class // SCHED_RR, SCHED_FIFO fair_sched_class // SCHED_OTHER idle_sched_class Declared in /kernel/sched/sched.h CSE 422S – Operating Systems Organization

Example sched_class Definition From: /kernel/sched/rt.c CSE 422S – Operating Systems Organization

How the Next Runnable Task is Picked Function pick_next_task() from /kernel/sched/core.c Have all scheduling classes try to pick a new task The last class, SCHED_IDLE, should always return some idle task CSE 422S – Operating Systems Organization