Linux Scheduling Algorithm -Ashish Singh. Introduction History and Background Linux Scheduling Modification in Linux Scheduling Results Conclusion References.

Slides:



Advertisements
Similar presentations
CPU Scheduling Tanenbaum Ch 2.4 Silberchatz and Galvin Ch 5.
Advertisements

CS 149: Operating Systems February 3 Class Meeting
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.
CPU Management CT213 – Computing Systems Organization.
Sogang University Advanced Operating Systems (Process Scheduling - Linux) Advanced Operating Systems (Process Scheduling - Linux) Sang Gue Oh, Ph.D. .
Ceng Operating Systems Chapter 2.2 : Process Scheduling Process concept  Process scheduling Interprocess communication Deadlocks Threads.
CPU Scheduling Section 2.5.
Chapter 3: CPU Scheduling
CS 3013 & CS 502 Summer 2006 Scheduling1 The art and science of allocating the CPU and other resources to processes.
Chapter 6: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Chapter 6: CPU Scheduling Basic.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
5: CPU-Scheduling1 Jerry Breecher OPERATING SYSTEMS SCHEDULING.
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
Operating Systems Process Scheduling (Ch 4.2, )
Operating System Process Scheduling (Ch 4.2, )
Process Scheduling in Windows XP, Linux, and UNIX By Sarah G. Levinson CSC 4320.
 Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.
Chapter 5: CPU Scheduling (Continuation). 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Determining Length.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Scheduling in Linux and Windows 2000
CPU Scheduling Chapter 6 Chapter 6.
Linux Scheduling CS Scheduling Policy ► The scheduling algorithm of traditional Unix systems must fulfill several conflicting objectives  Fast.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 5 Operating Systems.
Operating System Concepts and Techniques Lecture 5 Scheduling-1 M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques, First.
OPERATING SYSTEMS CPU SCHEDULING.  Introduction to CPU scheduling Introduction to CPU scheduling  Dispatcher Dispatcher  Terms used in CPU scheduling.
Operating System Examples - Scheduling
Introduction to Processes CS Intoduction to Operating Systems.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Seminar on Linux Process Management Presentation by Manoj Dhage MTech 1 st Year, SIT, IIT Kharagpur.
1 Scheduling The part of the OS that makes the choice of which process to run next is called the scheduler and the algorithm it uses is called the scheduling.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 5: CPU Scheduling.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Process Scheduling in Linux (Chap. 11, Understanding the Linux Kernel) J. H. Wang Sep. 26, 2008.
CE Operating Systems Lecture 10 Processes and process management in Linux.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 7: CPU Scheduling Chapter 5.
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
Chapter 5: Process Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Basic Concepts Maximum CPU utilization can be obtained.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 3.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Types of shedulars Process.
Chapter 4 CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
Process Scheduling. Scheduling Strategies Scheduling strategies can broadly fall into two categories  Co-operative scheduling is where the currently.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
OPERATING SYSTEMS CS 3502 Fall 2017
Processes and threads.
Process Management Process Concept Why only the global variables?
Copyright ©: Nahrstedt, Angrave, Abdelzaher
OPERATING SYSTEMS CS3502 Fall 2017
Process Management with OS
Chapter 6: CPU Scheduling
Introduction What is an operating system bootstrap
Operating System Concepts
Chapter 5: CPU Scheduling
Chapter 2: The Linux System Part 3
Chapter5: CPU Scheduling
TDC 311 Process Scheduling.
CPU SCHEDULING.
Outline Scheduling algorithms Multi-processor scheduling
Process Scheduling Decide which process should run and for how long
Shortest-Job-First (SJR) Scheduling
Chapter 6: Scheduling Algorithms Dr. Amjad Ali
Presentation transcript:

Linux Scheduling Algorithm -Ashish Singh

Introduction History and Background Linux Scheduling Modification in Linux Scheduling Results Conclusion References Questions

History and Background In 1991 Linus Torvalds took a college computer science course that used the Minix operating system Minix is a “toy” UNIX-like OS written by Andrew Tanenbaum as a learning workbench Linus went in his own direction and began working on Linux In October 1991 he announced Linux v0.02 In March 1994 he released Linux v1.0

Scheduling in Linux Time Sharing System-magical effect by switching from one process to the other in short time frame. Question – when to switch and what process?

Linux Approach Process run concurrently – CPU time divided into slices, one for each process. If current process is not terminated when its time quantum expires – switch process.

Linux Approach General Systems – algorithms to derive priority of process, end result – process assigned a value Linux – process priority is dynamic. Scheduler increases/decreases the priority.

Process Scheduling Linux uses two process-scheduling algorithms: A time-sharing algorithm for fair preemptive scheduling between multiple processes A real-time algorithm for tasks where absolute priorities are more important than fairness A process’s scheduling class defines which algorithm to apply For time-sharing processes, Linux uses a prioritized, credit based algorithm The crediting rule factors in both the process’s history and its priority

Process Scheduling Linux implements the FIFO and round-robin real-time scheduling classes; in both cases, each process has a priority in addition to its scheduling class The scheduler runs the process with the highest priority; for equal- priority processes, it runs the process waiting the longest FIFO processes continue to run until they either exit or block

Priorities: Linux 2.4 Scheduling Static priority The maximum size of the time slice a process should be allowed before being forced to allow other processes to compete for the CPU. Dynamic priority The amount of time remaining in this time slice; declines with time as long as the process has the CPU. When its dynamic priority falls to 0, the process is marked for rescheduling. Real-time priority Only real-time processes have the real-time priority. Higher real-time values always beat lower values

Linux Scheduling Process Selection most deserving process is selected by the scheduler real time processes are given higher priority than ordinary processes when several processes have the same priority, the one nearest the front of the run queue is chosen when a new process is created the number of ticks left to the parent is split in two halves, one for the parent and one for the child priority and counter fields are used both to implement time-sharing and to compute the process dynamic priority

Linux Scheduling Actions performed by schedule( ) Before actually scheduling a process, the schedule( ) function starts by running the functions left by other kernel control paths in various queues The function then executes all active unmasked bottom halves  Scheduling value of current is saved in the prev local variable and the need_resched field of prev is set to 0 a check is made to determine whether prev is a Round Robin real-time process. If so, schedule( ) assigns a new quantum to prev and puts it at the bottom of the runqueue list if state is TASK_INTERRUPTIBLE, the function wakes up the process schedule( ) repeatedly invokes the goodness( ) function on the runnable processes to determine the best candidate when counter field becomes zero, schedule( ) assigns to all existing processes a fresh quantum, whose duration is the sum of the priority value plus half the counter value

Goodness Function in Scheduling Algorithm goodness( ) function  identify the best candidate among all processes in the runqueue list.  It receives as input parameters prev (the descriptor pointer of the previously running process) and p (the descriptor pointer of the process to evaluate)  The integer value c returned by goodness( ) measures the "goodness" of p and has the following meanings: c = -1000, p must never be selected; this value is returned when the runqueue list contains only init_task c =0, p has exhausted its quantum. Unless p is the first process in the runqueue list and all runnable processes have also exhausted their quantum, it will not be selected for execution. 0 < c < 1000, p is a conventional process that has not exhausted its quantum; a higher value of c denotes a higher level of goodness. c >= 1000, p is a real-time process; a higher value of c denotes a higher level of goodness.

Selecting the next Process

Two Level Implementation The first level scheduler selects a set of processes, a batch, to be scheduled for a specified amount of time. Rather than selecting a constant number of processes for each batch, the processes selected are based on the system load to avoid any subsystem (PE or I/O) to be idle. The first level scheduler keeps processes in two lists: a ready queue and an expired queue. These queues are used to guarantee fairness. All new processes are placed on the ready queue and processes to be scheduled are selected from this queue. When a process has been scheduled for a defined period of time, Crq, the process is removed from the run queue, in the second level scheduler, and placed on the expired queue.

Two Level Implementation When the ready queue becomes empty, all processes from the expired queue are moved to the ready queue. This is repeated indefinitely. While processes are executed, the system keeps track of time spent in the running state and blocked state for each process. UPE += Trunning(p)/Tblocked(p) and UIO += 1 - (Trunning(p)/Tblocked(p))

Linux Vs Two Level

Limitations It has not been possible to improve the Linux scheduler through modifications like this, while maintaining all of the advantages in the existing Linux scheduler. It is hypothesized that if knowledge of the type of jobs which would be executed on the system exists, this could be used to compile-time select the scheduler, which is the most efficient for the specific job-mix and usage.

Advantages Linux scheduler: Suitable for standard workstation use where few processes is in the running or ready state at a time, as this proves very good response times. Two-level Scheduler: Suitable for systems in where a very high load can exist, and resources are scarce compared to the load of the system.

Conclusion Two-level scheduling is implemented by suspending a set of processes for longer periods of time. While the load is low, this algorithm performs exactly as the Linux scheduler though a slightly administrative overhead is introduced in the first-level scheduling. Hypothesized that if used it reduces thrashing.

References [1] Silberschatz, A., P.B. Galvin, and G. Gagne, "Chapter 6 CPU Scheduling, Operating System Concepts, Sixth Ed.," John Wiley & Son, [1] Silberschatz, A., P.B. Galvin, and G. Gagne, "Chapter 6 CPU Scheduling, Operating System Concepts, Sixth Ed.," John Wiley & Son, [2] Daniel P. Bovet & Marco Cesati, "Chapter 10, Processing Scheduling, Understanding the Linux Kernel," [2] Daniel P. Bovet & Marco Cesati, "Chapter 10, Processing Scheduling, Understanding the Linux Kernel," [3] Sivarama P. Dandamudi and Samir Ayachi. Performance of hierarchical processor scheduling in shared-memory multiprocessor systems". IEEE Transactions on Computers, 48(11):1202–1213, DA99 [3] Sivarama P. Dandamudi and Samir Ayachi. Performance of hierarchical processor scheduling in shared-memory multiprocessor systems". IEEE Transactions on Computers, 48(11):1202–1213, DA99 [4] S. Haldar and D. K. Subramanian. Fairness in processor scheduling in time sharing systems. Operating Systems Review, Vol 25. Issue 1.:4–18, HS91 [4] S. Haldar and D. K. Subramanian. Fairness in processor scheduling in time sharing systems. Operating Systems Review, Vol 25. Issue 1.:4–18, HS91 [5] [5] [6] [6] [7]John O'Gorman, Chapter 7, Scheduling, The Linux Process Manager, [7]John O'Gorman, Chapter 7, Scheduling, The Linux Process Manager, 2003.