Process Scheduling in Linux



Similar documents
Linux Process Scheduling Policy

Linux scheduler history. We will be talking about the O(1) scheduler

Scheduling policy. ULK3e 7.1. Operating Systems: Scheduling in Linux p. 1

W4118 Operating Systems. Instructor: Junfeng Yang

Project No. 2: Process Scheduling in Linux Submission due: April 28, 2014, 11:59pm

Process Scheduling II

Scheduling 0 : Levels. High level scheduling: Medium level scheduling: Low level scheduling

Process Scheduling in Linux

Linux Process Scheduling. sched.c. schedule() scheduler_tick() hooks. try_to_wake_up() ... CFS CPU 0 CPU 1 CPU 2 CPU 3

The Linux Kernel: Process Management. CS591 (Spring 2001)

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

Konzepte von Betriebssystem-Komponenten. Linux Scheduler. Valderine Kom Kenmegne Proseminar KVBK Linux Scheduler Valderine Kom

Scheduling. Yücel Saygın. These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum

CPU Scheduling Outline

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Linux O(1) CPU Scheduler. Amit Gud amit (dot) gud (at) veritas (dot) com

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

2. is the number of processes that are completed per time unit. A) CPU utilization B) Response time C) Turnaround time D) Throughput

Linux Scheduler. Linux Scheduler

Chapter 5 Linux Load Balancing Mechanisms

Linux Load Balancing

Thomas Fahrig Senior Developer Hypervisor Team. Hypervisor Architecture Terminology Goals Basics Details

Chapter 5 Process Scheduling

Scheduling. Scheduling. Scheduling levels. Decision to switch the running process can take place under the following circumstances:

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

Chapter 5: CPU Scheduling. Operating System Concepts 8 th Edition

Process Scheduling CS 241. February 24, Copyright University of Illinois CS 241 Staff

Real-Time Scheduling 1 / 39

Operating System: Scheduling

ò Paper reading assigned for next Thursday ò Lab 2 due next Friday ò What is cooperative multitasking? ò What is preemptive multitasking?

Objectives. Chapter 5: Process Scheduling. Chapter 5: Process Scheduling. 5.1 Basic Concepts. To introduce CPU scheduling

Modular Real-Time Linux

A Survey of Parallel Processing in Linux

OPERATING SYSTEMS SCHEDULING

W4118 Operating Systems. Instructor: Junfeng Yang

Exercises : Real-time Scheduling analysis

Jorix kernel: real-time scheduling

CPU Scheduling. Core Definitions

Objectives. Chapter 5: CPU Scheduling. CPU Scheduler. Non-preemptive and preemptive. Dispatcher. Alternating Sequence of CPU And I/O Bursts

Overview of the Linux Scheduler Framework

Deciding which process to run. (Deciding which thread to run) Deciding how long the chosen process can run

Operatin g Systems: Internals and Design Principle s. Chapter 10 Multiprocessor and Real-Time Scheduling Seventh Edition By William Stallings

Threads Scheduling on Linux Operating Systems

Operating Systems. III. Scheduling.

ICS Principles of Operating Systems

Linux process scheduling

CPU Scheduling. CSC 256/456 - Operating Systems Fall TA: Mohammad Hedayati

Readings for this topic: Silberschatz/Galvin/Gagne Chapter 5

ò Scheduling overview, key trade-offs, etc. ò O(1) scheduler older Linux scheduler ò Today: Completely Fair Scheduler (CFS) new hotness

CPU Scheduling. Multitasking operating systems come in two flavours: cooperative multitasking and preemptive multitasking.

CPU Scheduling. CPU Scheduling

An Implementation Of Multiprocessor Linux

CPU Scheduling. Basic Concepts. Basic Concepts (2) Basic Concepts Scheduling Criteria Scheduling Algorithms Batch systems Interactive systems

Why Relative Share Does Not Work

Understanding the Linux CPU Scheduler

Chapter 3. Operating Systems

Process Scheduling in Linux

Completely Fair Scheduler and its tuning 1

Understanding the Linux CPU Scheduler

Road Map. Scheduling. Types of Scheduling. Scheduling. CPU Scheduling. Job Scheduling. Dickinson College Computer Science 354 Spring 2010.

A complete guide to Linux process scheduling. Nikita Ishkov

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Operating System Engineering: Fall 2005

Announcements. Basic Concepts. Histogram of Typical CPU- Burst Times. Dispatcher. CPU Scheduler. Burst Cycle. Reading

TOP(1) Linux User s Manual TOP(1)

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

/ Operating Systems I. Process Scheduling. Warren R. Carithers Rob Duncan

SYSTEM ecos Embedded Configurable Operating System

Mitigating Starvation of Linux CPU-bound Processes in the Presence of Network I/O

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

ELEC 377. Operating Systems. Week 1 Class 3

Processor Scheduling. Queues Recall OS maintains various queues

Scheduling Algorithms

Improvement of Scheduling Granularity for Deadline Scheduler

Intel DPDK Boosts Server Appliance Performance White Paper

Lecture 3 Theoretical Foundations of RTOS

Multi-core architectures. Jernej Barbic , Spring 2007 May 3, 2007

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

Linux Scheduler Analysis and Tuning for Parallel Processing on the Raspberry PI Platform. Ed Spetka Mike Kohler

POSIX. RTOSes Part I. POSIX Versions. POSIX Versions (2)

A Study of Performance Monitoring Unit, perf and perf_events subsystem

Operating Systems 4 th Class

Task Scheduling for Multicore Embedded Devices

Types Of Operating Systems

Hard Real-Time Linux

Job Scheduling Model

HyperThreading Support in VMware ESX Server 2.1

Chapter 19: Real-Time Systems. Overview of Real-Time Systems. Objectives. System Characteristics. Features of Real-Time Systems

Virtual Servers. Virtual machines. Virtualization. Design of IBM s VM. Virtual machine systems can give everyone the OS (and hardware) that they want.

Multilevel Load Balancing in NUMA Computers

Operating Systems Lecture #6: Process Management

Safe Kernel Scheduler Development with Bossa

Configuring CoreNet Platform Cache (CPC) as SRAM For Use by Linux Applications

Main Points. Scheduling policy: what to do next, when there are multiple threads ready to run. Definitions. Uniprocessor policies

Transcription:

Process Scheduling in Linux Scheduling Mechanism: how to switch. Scheduling Policy: when to switch and what process to choose. Some scheduling objectives: fast process response time avoidance of process starvation good throughput for background jobs support for soft real time processes Linux uses dynamically assigned process priorities for non real-time processes. Processes running for a long time have their priorities decreased while processes that are waiting have their priorities increased dynamically.

Classification of Processes Compute-bound versus I/O bound. Linux implicitly favors I/O bound processes over compute bound processes (why?). Another classification: Interactive processes. Examples: shells, text editors, GUI applications. Batch processes. Examples: compilers, database search engine, web server, number-crunching. Real-time processes. audio/video applications, data-collection from physical sensors, robot controllers.

Process States in Linux There are five process states defined in /usr/include/linux/sched.h. #define TASK_RUNNING 0 #define TASK_INTERRUPTIBLE 1 #define TASK_UNINTERRUPTIBLE 2 #define TASK_ZOMBIE 4 #define TASK_STOPPED 8

Scheduling Parameters Processes are preemptible in user mode but not in kernel mode. How long is a quantum? Examine INIT TASK macro in include/linux/sched.h header file. All processes inherit the default quantum value via fork from the init task. #define DEF_COUNTER (10*HZ/100) /* 100 ms time slice */ #define MAX_COUNTER (20*HZ/100) #define DEF_NICE (0) Processes have two types of priorities: Static priority. Between 1 and 99. Used by real-time processes. Dynamic priority. For non real-time processes. Sum of the base time quantum and of the number of ticks of CPU time left to the process before its quantum expiers in the current epoch.

Data Structures Used by Scheduler From the task struct in include/linux/sched.h. struct task_struct {... volatile long need_resched;... long counter; long nice; // replaces the priority variable in earlier kernel unsigned long policy; //SCHED_OTHER, SCHED_FIFO, SCHED_RR... int has_cpu, processor; unsigned long cpus_allowed;... unsigned long rt_priority;... }

Passing quantums after fork() From the do fork(...) function in kernel/fork.c. // from do_fork in kernel/fork.c (different from the textbook) p->counter = (current->counter + 1) >> 1; current->counter >>= 1; if (!current->counter) current->need_resched = 1; The number of ticks left to the parent is split in two halves, one for the parent, one for the child. This prevents processes from getting an unlimited amount of CPU time.

Invoking the scheduler The scheduler proper is the function schedule() in kernel/sched.c. Direct Invocation. Examples: A process must be blocked because a resource is not available, a device driver can invoke schedule() directly if it will be executing a long iterative task. Lazy Invocation. By setting the need resched flag field of current to 1. Examples: When current has use up its quantum of CPU time (done by update process times function in kernel/timer.c) When a process is woken up and its priority is higher than that of the current process. When a setscheduler() or sched yield() system call is issued.

Goodness of a Process This is the function that decides how desirable a process is.. You can weigh different processes against each other depending on what CPU they ve run on lately etc to try to handle cache and TLB miss penalties. Return values: -1000: never select this 0: out of time, recalculate counters (but it might still be selected) +ve: goodness value (the larger, the better) +1000: realtime process, select this.

Actions performed by schedule() treat current process select process switch process

Linux SMP scheduler Each cpu runs the schdule function on its own and communicate via shared data structures. /* * We align per-cpu scheduling data on cacheline boundaries, * to prevent cacheline ping-pong. */ static union { struct schedule_data { struct task_struct * curr; cycles_t last_schedule; } schedule_data; char pad [SMP_CACHE_BYTES]; } aligned_data [NR_CPUS] cacheline_aligned = { {{&init_task,0}}}; Processor affinity is implemented through extra goodness for staying on the same cpu.

Performance of Linux Scheduler The scheduling algorithm does not scale well. The predefined quantum is too large for high system loads. I/O bound process priority boosting is not optimal. Support for real-time applications is weak. Several attempts have been made to provide alternate schedulers. An interesting tool called Lockmeter is available to study performance of SMP scheduling.

System Calls Related to Scheduling Name nice() getpriority() setpriority() sched getscheduler() sched setscheduler() sched getparam() sched setparam() sched yield() sched get priority min() sched get priority max() sched rr get interval()