Scheduling of Non-Real-Time Tasks in Linux (SCHED_NORMAL/SCHED_OTHER)

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

CPU Scheduling Tanenbaum Ch 2.4 Silberchatz and Galvin Ch 5.
Operating Systems Process Scheduling (Ch 3.2, )
Abdulrahman Idlbi COE, KFUPM Jan. 17, Past Schedulers: 1.2 & : circular queue with round-robin policy. Simple and minimal. Not focused on.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 6: CPU Scheduling.
CPU Scheduling Basic Concepts Scheduling Criteria
CS 3013 & CS 502 Summer 2006 Scheduling1 The art and science of allocating the CPU and other resources to processes.
1 Thursday, June 15, 2006 Confucius says: He who play in root, eventually kill tree.
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
Process Scheduling in Windows XP, Linux, and UNIX By Sarah G. Levinson CSC 4320.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Linux Scheduling CS Scheduling Policy ► The scheduling algorithm of traditional Unix systems must fulfill several conflicting objectives  Fast.
Windows 2000 Scheduling Computing Department, Lancaster University, UK.
Operating System Concepts and Techniques Lecture 5 Scheduling-1 M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques, First.
Operating System Examples - Scheduling
1 Previous lecture review n Out of basic scheduling techniques none is a clear winner: u FCFS - simple but unfair u RR - more overhead than FCFS may not.
1 Scheduling Processes. 2 Processes Each process has state, that includes its text and data, procedure call stack, etc. This state resides in memory.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
1 Process Scheduling in Multiprocessor and Multithreaded Systems Matt Davis CS5354/7/2003.
LINUX SCHEDULING Evolution in the 2.6 Kernel Kevin Lambert Maulik Mistry Cesar Davila Jeremy Taylor.
Cpr E 308 Spring 2005 Process Scheduling Basic Question: Which process goes next? Personal Computers –Few processes, interactive, low response time Batch.
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.
2.5 Scheduling. Given a multiprogramming system, there are many times when more than 1 process is waiting for the CPU (in the ready queue). Given a multiprogramming.
Martin Kruliš by Martin Kruliš (v1.1)1.
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.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
Lecture 4 CPU scheduling. Basic Concepts Single Process  one process at a time Maximum CPU utilization obtained with multiprogramming CPU idle :waiting.
Operating System Examples - Scheduling. References r er/ch10.html r bangalore.org/blug/meetings/200401/scheduler-
CPU scheduling.  Single Process  one process at a time  Maximum CPU utilization obtained with multiprogramming  CPU idle :waiting time is wasted 2.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 6: CPU Scheduling.
CPU Scheduling Scheduling processes (or kernel-level threads) onto the cpu is one of the most important OS functions. The cpu is an expensive resource.
Guy Martin, OSLab, GNU Fall-09
Chapter 6: CPU Scheduling (Cont’d)
Linux Scheduler.
Midterm Review Chris Gill CSE 422S - Operating Systems Organization
Chapter 5a: CPU Scheduling
Time Sources and Timing
Linux Scheduling.
Midterm Review David Ferry, Chris Gill
Task Scheduling for Multicore CPUs and NUMA Systems
The Linux “Completely Fair Scheduler”
Time Sources and Timing
Semester Review Chris Gill CSE 422S - Operating Systems Organization
Operating Systems Processes Scheduling.
Chapter 2.2 : Process Scheduling
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
CS 3204 Operating Systems Lecture 14 Godmar Back.
A Comparison Study of Process Scheduling in FreeBSD, Linux and Win2k
CPU Scheduling G.Anuradha
Module 5: CPU Scheduling
Lecture 21: Introduction to Process Scheduling
Scheduling Adapted from:
Scheduling.
Chapter 5: CPU Scheduling
Process scheduling Chapter 5.
CPU SCHEDULING.
Process Scheduling Decide which process should run and for how long
Top Half / Bottom Half Processing
Midterm Review Brian Kocoloski
Lecture 21: Introduction to Process Scheduling
Scheduling of Regular Tasks in Linux
Time Sources and Timing
CPU Scheduling David Ferry CSCI 3500 – Operating Systems
Linux Block I/O Layer Chris Gill, Brian Kocoloski
Scheduling Classes and Real-Time Scheduling in Linux
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 of Non-Real-Time Tasks in Linux (SCHED_NORMAL/SCHED_OTHER) David Ferry, Chris Gill CSE 422S - Operating Systems Organization Washington University in St. Louis St. Louis, MO 63143

Traditional Scheduling Concerns Throughput: Maximize tasks finished per time Latency: Minimize time between creation and completion Response time: Minimize time between wakeup and execution Starvation: All tasks guaranteed some processor time Fairness: All tasks given equal processor time Overhead: Multicore scalability, efficiency A scheduler must compromise! CSE 422S – Operating Systems Organization

Important Scheduling Scenarios Pure Compute Bound (e.g. while(1) ) Wants to keep cache hot Pure I/O Bound (e.g. always waits for keyboard) Wants fast response Server Minimize outstanding requests (throughput & latency) Desktop Maximize interactivity Heterogeneous workload Real-time Minimize response time Guarantee timeliness of high priority tasks CSE 422S – Operating Systems Organization

Big Two Scheduling Operations Which task should run next? How long should it run (timeslice)? CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization O(1) Scheduler Per-CPU runqueue, contains two priority arrays Active array feeds processor When tasks exhaust their timeslice they move to expired array, if blocking they stay active When active array is empty we pointer swap Priority arrays give highest priority task in constant time Timeslice is scaled to (priority / priority_range) which results in inconsistent timeslices Active RQ Expired CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization O(1) Scheduler Per-CPU runqueue, contains two priority arrays Active array feeds processor When tasks exhaust their timeslice they move to expired array, if blocking they stay active When active array is empty we pointer swap Priority arrays give highest priority task in constant time Timeslice is scaled to (priority / priority_range) which results in inconsistent timeslices Active RQ Expired CSE 422S – Operating Systems Organization

Normal Task Priorities Based on niceness levels Levels range from [-20, 19], default is 0 “More nice” => “Lower Priority” (higher) “Less nice” => “Higher priority” (lower) Can be adjusted heuristically for interactive and CPU bound tasks CSE 422S – Operating Systems Organization

Problems with O(1) Scheduler Inconsistent timeslices: Nice priorities determine fixed timeslice length Equal priority tasks equally share a processor Two tasks of 0 priority might switch every 100ms Two tasks of 19 priority might switch every 5ms Fixed timeslices cause problems: Large numbers of high priority interactive tasks starve CPU bound tasks Large numbers of CPU bound background tasks cause large latencies for interactive tasks CSE 422S – Operating Systems Organization

Completely Fair Scheduler (CFS) Goal: All tasks receive a weighted proportion of processor time. On a system with N tasks, each task should be promised 1/N processor time I.e. “completely fair” Allows interactive tasks to run at high priority while sharing CPU equally between CPU bound tasks. Abandons notion of fixed timeslice (and varying fairness), for fixed fairness (and varying timeslice) CSE 422S – Operating Systems Organization

CFS Example Consider a video encoder and a text editor Video encoder Entitled proportion: 50% Text editor Entitled proportion:50% Used Unused Over-use Actual proportion: 95% Has low priority. Actual proportion: 5% Has high priority when it wants to run. CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization Virtual Runtime Virtual runtime: the actual running time of a process weighted by its priority, stored as nanoseconds value If all tasks have nice priority 0, their virtual runtime is equal to their actual runtime If some task has nonzero priority, then: where weights are determined by nice priority. Updated in update_curr() in fair.c CSE 422S – Operating Systems Organization

CFS Scheduling Operations Which task? Pick task with lowest virtual runtime How long to run? Keeps virtual runtime as fair as possible, so tasks get swapped out each tick Uses minimum tick length to avoid thrashing CSE 422S – Operating Systems Organization

CFS Run Queue Implementation Needs to pick the task with shortest virtual runtime in constant time. Per-CPU run queues stored as red-black trees (self-balancing binary search tree) Task with least virtual runtime is leftmost node Tasks are charged for a whole timeslice even if its not used 6 3 8 7 9 1 5 CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization Processor Affinity A process (thread) can be bound to a specific sub-set of the available cores (cores numbered 0 to 3 on RPi 3) In user space programs, this can be done via the sched_setaffinity() syscall along with some helpful macros (e.g., CPU_ZERO, CPU_SET) In kernel modules this is done via kthread_bind() Calls will fail if an invalid core is given (or the CPU set isn’t initialized properly before it’s used :-) CSE 422S – Operating Systems Organization