Konzepte von Betriebssystem-Komponenten. Linux Scheduler. Valderine Kom Kenmegne Valderinek@hotmail.com. Proseminar KVBK Linux Scheduler Valderine Kom



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

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

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

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

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

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

CPU Scheduling Outline

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

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

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

OPERATING SYSTEMS SCHEDULING

Linux Process Scheduling Policy

Operating Systems Lecture #6: Process Management

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

Operating System: Scheduling

Operating Systems. III. Scheduling.

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

Chapter 5 Process Scheduling

ICS Principles of Operating Systems

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Processor Scheduling. Queues Recall OS maintains various queues

Overview of Presentation. (Greek to English dictionary) Different systems have different goals. What should CPU scheduling optimize?

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

Scheduling Algorithms

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

W4118 Operating Systems. Instructor: Junfeng Yang

CPU Scheduling. CPU Scheduling

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

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

Job Scheduling Model

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

Threads Scheduling on Linux Operating Systems

CPU Scheduling. Core Definitions

Process Scheduling in Linux

Real-Time Scheduling 1 / 39

Overview of the Linux Scheduler Framework

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

Exercises : Real-time Scheduling analysis

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

Linux process scheduling

Process Scheduling II

W4118 Operating Systems. Instructor: Junfeng Yang

Introduction. Scheduling. Types of scheduling. The basics

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

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

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

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

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

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

Process Scheduling. Process Scheduler. Chapter 7. Context Switch. Scheduler. Selection Strategies

CS Fall 2008 Homework 2 Solution Due September 23, 11:59PM

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

Process Scheduling in Linux

PROCESS SCHEDULING ALGORITHMS: A REVIEW

Linux Scheduler. Linux Scheduler

OS OBJECTIVE QUESTIONS

Operating Systems, 6 th ed. Test Bank Chapter 7

Lecture Outline Overview of real-time scheduling algorithms Outline relative strengths, weaknesses

A Review on Load Balancing In Cloud Computing 1

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

A Priority based Round Robin CPU Scheduling Algorithm for Real Time Systems

Completely Fair Scheduler and its tuning 1

A Group based Time Quantum Round Robin Algorithm using Min-Max Spread Measure

Improvement of Scheduling Granularity for Deadline Scheduler

A LECTURE NOTE ON CSC 322 OPERATING SYSTEM I DR. S. A. SODIYA

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

CPU Scheduling 101. The CPU scheduler makes a sequence of moves that determines the interleaving of threads.

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

Predictable response times in event-driven real-time systems

Analysis of Job Scheduling Algorithms in Cloud Computing

EECS 750: Advanced Operating Systems. 01/28 /2015 Heechul Yun

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

Priority-Driven Scheduling

Hard Real-Time Linux

Task Scheduling for Multicore Embedded Devices

Operating System Tutorial

Technical Properties. Mobile Operating Systems. Overview Concepts of Mobile. Functions Processes. Lecture 11. Memory Management.

UNIVERSITY OF WISCONSIN-MADISON Computer Sciences Department A. Arpaci-Dusseau

Lecture 3 Theoretical Foundations of RTOS

Chapter 1: Introduction. What is an Operating System?

Chapter 2: OS Overview

A Comparative Study of CPU Scheduling Algorithms

REAL TIME OPERATING SYSTEMS. Lesson-10:

First-class User Level Threads

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

Load Balancing Scheduling with Shortest Load First

Efficient Scheduling Of On-line Services in Cloud Computing Based on Task Migration

3. Scheduling issues. Common approaches /1. Common approaches /2. Common approaches / /13 UniPD / T. Vardanega 23/01/2013. Real-Time Systems 1

STORM. Simulation TOol for Real-time Multiprocessor scheduling. Designer Guide V3.3.1 September 2009

4. Fixed-Priority Scheduling

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

Tasks Schedule Analysis in RTAI/Linux-GPL

Scheduling. Monday, November 22, 2004

Chapter 3. Operating Systems

EE8205: Embedded Computer System Electrical and Computer Engineering, Ryerson University. Multitasking ARM-Applications with uvision and RTX

Example of Standard API

Load-Balancing for a Real-Time System Based on Asymmetric Multi-Processing

Synchronization. Todd C. Mowry CS 740 November 24, Topics. Locks Barriers

Final Report. Cluster Scheduling. Submitted by: Priti Lohani

Syllabus MCA-404 Operating System - II

Transcription:

Konzepte von Betriebssystem-Komponenten Linux Scheduler Kenmegne Valderinek@hotmail.com 1

Contents: 1. Introduction 2. Scheduler Policy in Operating System 2.1 Scheduling Objectives 2.2 Some Scheduling Algorithms 3. Linux scheduler 3.1 Different process type in Linux 3.2 Process states 3.3 Process Preemption 3.4 case study: Linux 2.6 scheduling policy 3.4.1 Real-time processes 3.4.2 Conventional processes 3.4.3 Goodness computation 3.4.4.Linux 2.4 disadvantages 4 Summary 5 References 2

1. Introduction In our daily life we have a lot of tasks for example in our family, at work, at school therefore we have to think about how we can manage our time so that we won t be overloaded. To resolve this problem we can use an agenda. But it remains some situation where we cannot execute all our tasks or there are many tasks at time, in this cases we try to order our tasks in priorities depending on our interests and goals. Our operating system (OS) knows also about this problem, the tasks to be executed will be called this time processes. Like a man does not have more than 24 hours per days to execute his task, an OS has only a limited number of processors for many processes. To manage this situation, our OS has to choose a scheduling algorithm. In the first part of our study we will focus on the goals of scheduling and scheduling algorithms in OS in general, later we will define our OS as Linux and base our study on Linux 2.4. 2. Scheduler policy in Operating Systems In this section we will get some knowledge about the objectives of scheduling in OS and about some scheduling strategies. 2.1 Scheduling Objectives During the design of the scheduler, the designer has to consider several factors like the application area of the OS and the need of potential users. Depending on these aspects the scheduler can have as purpose: - Maximize the number of interactive processes receiving acceptable response time. - Maximize resource utilization. The scheduling mechanism should keep the resources of the system busy. - Avoid indefinite postponement. A process should not experience an unbounded wait time before or while receiving service. - Minimize overhead. Interestingly, this is not generally considered to be one of the most important objectives. Overhead often results in wasted resources. But a certain portion of system resources effectively invested as overhead can greatly improve overall system performance. - Ensure predictability. By minimizing the statistical variance in process response time, a system can guarantee that processes will receive predictable service levels. Despite the differences in the goals amount systems, many scheduling algorithm exhibit similar properties: 3

Fairness. A scheduling algorithm is fair if all similar processes are treated the same and no process can suffer indefinite postponement due to scheduling issues Predictability. See above. Scalability. System performance should degrade gracefully it should not immediately collapse under heavy loads. [1] To reach these objectives, an OS has to choose a corresponding algorithm. Therefore we will introduce some scheduling algorithm in this part. 2.2 Some Scheduling Strategies There are two classes of scheduling algorithms: Non-preemptive: a process cannot be removed from the processor while computing. Preemptive: It is the opposite: A process can be removed from the processor while computing. Depending on these classes we have different scheduling strategies: - First-comes-first-served (FCFS): The processes are dispatched according to their arrival time at the ready queues. Once a process has been assigned to a processor, the process runs until completion. This is a non-preemptive scheduling algorithms. The disadvantage of FCFS is that short processes can starve while waiting for the processor. - Round-Robin (RR): RR is similar to FCFS but the processes are given a limited amount of processor time called a time slice or a quantum. If a process does not complete before its quantum expires, the system preempts it and gives the processor to the next waiting process. The system places the preempted process at the end of the ready queue. - Shortest-process-first (SPF): Is a non preemptive scheduling algorithm in which the scheduler selects the waiting process with the smallest estimated run-time-to-completion. SPF reduces average waiting time over FCFS. The great problem is to predict the process duration. - Shortest-Remaining-Time (SRT): Is the preemptive counterpart of SPF. In SPF, once a process begins executing, it runs until its completion. In SRT a newly arriving process with a shorter estimated run-time-to-completion, preempts a running process with a longer run-time-to-completion. Like SPF this scheduling requires also a knowledge about the process duration. 4

3. Linux Scheduler In Linux each process has a priority, used by the scheduler to determine the process execution. The process with the greatest priority will receive the processor at first. This priority can be static: once a process is given a priority it won t be changed, or dynamic: the scheduler adjusts the process priority periodically. In this third part, let us get some information about Linux processes in general, before focusing on Linux 2.4. 3.1 Different process type in Linux Linux has three process types: Interactive, batch and real-time. In the following part, we will describe each process type. - Interactive processes: These processes communicate with the user, therefore, they spend much time waiting on key presses and mouse clicks. They also have to react quickly to an input in average 50-150 ms, otherwise the user will find that the system is too slow or unresponsive. The typical interactive processes are: command shells, text editor and graphical application. - Batch processes: They do not need to interact with the user and normally run in the background. These processes are often penalized by the scheduler because they don t need to be very responsive. Typical batch processes are programming language compilers, database search machines and scientific computations. - Real-time processes: These have very strong scheduling of scheduling. Such processes would never be blocked by processes of lower priority, they should have a short response time, such a time of answer should have a minimal discord. Typical real-time programs are video and sound applications, robot controllers, and programs that collect data from physical sensor. [6] 5

3.2 Process States running exited User Mode Kernel Mode running ready blocked Process States in Linux. Ready state: These processes are waiting to receive the processor. Blocked state: When a process blocks because it cannot be continued for example when the process waits for user input. Running state: The process is executed at the moment. Linux makes a difference between the running process in Kernel Mode (these can directly access the hardware) and running in User Mode (for normal user processes). Exited state: The process has terminated its execution. 3.3 Process Preemption After looking at these process states we can easily find out when a process preemption can occur, for example when one of the following event happens: - The birth of a new process caused by the system call fork(): The scheduler has to choose between the father and the son process. If the return value of fork() is 0 the son is the running process, if greater than 0 the running process is the father process. - The running process blocks. - The reserved time expires. - The running process terminates. 6

Now that we have enough basic knowledge about the goal of scheduling, scheduling strategies, process types, process states and process preemption. We can focus our attention on scheduling policy on Linux 2.4. 3.4 Case study: Linux 2.4 scheduling policy. Every new process receive a priority and goodness value at the beginning and enter if runnable in the run-queue. We will explain later how this goodness is computed. We can already affirm at this stage that Linux 2.4 differentiates realtime processes from conventional processes. Depending on the process type Linux has to choose a strategy. Scheduler/ Load Balanced Globale Run-Queue Process 1 / Priority x1 Process 2 / priority x2 Process 3 /priority x3 Process n / priority xn CPU 1 CPU 2 CPU m. Kernel 2.4 7

3.4.1 Real-time processes Every process of this type receives a goodness value equal or greater than 1000 and the scheduler uses one of the following scheduling classes: SHED_FIFO or SCHED_OTHER. - SCHED_FIFO: This class implements the FCFS algorithm the processes receive a static priority between 0-99. When a Process has the processor it will run as long as it wishes even if other real-time processes having the same priority are runnable. The process will only free the CPU if it blocks, exits or there is another real-time process with a greater priority. - SCHED_ RR: Is similar to SCHED_FIFO, but each process receives a time slice. See Round Robin strategy in the section 2.2. 3.4.2 Conventional processes For all other processes SCHED_OTHER is used. A process will start to run if there is no real-time process runnable. These processes can be preempted, their priority is dynamic and can be influenced by calling nice( ) the negative value can only be given by the super user because if the priority value is higher the priority is smaller. Their goodness value ranges between 1 and 999. 3.4.3 Goodness computation When choosing the new process to be executed, the scheduler computes for each runnable candidate the goodness value, the one with the greatest goodness value will be chosen. The following table explains this computation. Scheduling - Strategy Remaining quantum Goodness SCHED_FIFO, RR - 1000 + priority SCHED_OTHER >0 Quantum + priority(+1) SCHED_OTHER 0 0 By this table, one can already figure out that interactive processes attain a higher goodness value in Linux. They block often while waiting for user input and therefore they consume only a part of their time slice. 8

3.4.4 Linux 2.4 Disadvantages -Linux 2.4 has a great overhead due to the run-queue. For each process preemption the scheduler has to compare and compute the goodness of all processes in the queue. -The kernel has a global run-queue for all runnable processes. It can also happen that a CPU is locked because it waits for another CPU to release this list. 5. Summary At the beginning we wanted to know how an Operating System in general and Linux in particular determines the process to be executed. To reach this objectives we studied the scheduling algorithms. In Linux the scheduler differentiates between real-time processes and conventional processes. According to this difference it chooses between SCHED_FIFO, SCHED_RR, SCHED_OTHER. In Linux 2.4 the scheduler computes for each process in the run-queue the goodness value, depending on this value, it chooses the process to be executed. However we also saw that this method has a great overhead due to this computation. 6 References [1] Operating System, Deitel Deitel Choffnes Third edition, Pearson Education, 2004 [2] Betriebsystem, Casten Vogt 1.Auflage Spektrum, Akademischer verlag, 2001 [3] Moderne Betriebsystem, Andrew s.tanenbaum 2.Auflage Pearson Studium [4] Übung zu Softwaresystem I, Jürgen Kleinöder, 2005 [5] IX, 2/2005 (Zeitschrift) [6] Understanding the Linux Kernel, Daniel P. Bovet, Marco Cesati O Reilly, 2001 9