The Linux Scheduler 2.4 vs 2.6 Michael McCabe Michael McCabe

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.
CS 149: Operating Systems February 3 Class Meeting
Abdulrahman Idlbi COE, KFUPM Jan. 17, Past Schedulers: 1.2 & : circular queue with round-robin policy. Simple and minimal. Not focused on.
Linux Scheduler. Linux is a multitasking OS Deciding what process runs next, given a set of runnable processes, is a fundamental decision a scheduler.
Process Scheduling in Linux (Chap.7 in Understanding the Linux Kernel) J. H. Wang Oct. 1, 2009.
Sogang University Advanced Operating Systems (Process Scheduling - Linux) Advanced Operating Systems (Process Scheduling - Linux) Sang Gue Oh, Ph.D. .
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 6: CPU Scheduling.
1 Friday, June 16, 2006 "In order to maintain secrecy, this posting will self-destruct in five seconds. Memorize it, then eat your computer." - Anonymous.
Chapter 3: CPU Scheduling
Cs238 CPU Scheduling Dr. Alan R. Davis. CPU Scheduling The objective of multiprogramming is to have some process running at all times, to maximize CPU.
Scheduling in Linux COMS W4118 Spring Scheduling Goals O(1) scheduling; 2.4 scheduler iterated through Run queue on each invocation Task queue.
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.
Linux Kernel 2.6 Scheduler O(1) from O(n) A B.Sc Seminar in Software Engineering Student: Maxim Raskin Lecturer: Dr. Itzhak Aviv Tel Aviv Afeka College.
The Linux “Completely Fair Scheduler”
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Scheduling in Linux and Windows 2000
Linux Scheduling CS Scheduling Policy ► The scheduling algorithm of traditional Unix systems must fulfill several conflicting objectives  Fast.
Operating System Examples - Scheduling
Lecture 2 Process Concepts, Performance Measures and Evaluation Techniques.
Operating Systems. Definition An operating system is a collection of programs that manage the resources of the system, and provides a interface between.
Scheduling Example 3 (1) Assume: FIFO Job Scheduling 100 K Main Memory Processor Sharing Process Scheduling (Cont…)
CPU Scheduling Presentation by Colin McCarthy. Runqueues Foundation of Linux scheduler algorithm Keeps track of all runnable tasks assigned to CPU One.
Linux Scheduler © DJ Foreman 3/8/ Objectives Response time Throughput for batch No starvation Accommodate high AND low priority © DJ Foreman 3/8/2009.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
Process Scheduling in Linux (Chap. 11, Understanding the Linux Kernel) J. H. Wang Sep. 26, 2008.
What Every Developer Should Know about the Kernel Dr. Michael L. Collard 1.
Lec 3aOperating Systems1 Operating Systems Lecture 3a: Linux Schedulers William M. Mongan Material drawn in part from
CSC 660: Advanced Operating SystemsSlide #1 CSC 660: Advanced OS Scheduling.
BFSBFS by Con KolivasCon Kolivas Guruprasad Aphale. Real Time Lunch, 10/21/ Guruprasad Aphale.
LINUX SCHEDULING Evolution in the 2.6 Kernel Kevin Lambert Maulik Mistry Cesar Davila Jeremy Taylor.
1 Review of Process Mechanisms. 2 Scheduling: Policy and Mechanism Scheduling policy answers the question: Which process/thread, among all those ready.
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.
ITFN 2601 Introduction to Operating Systems Lecture 4 Scheduling.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 3.
1.  System Characteristics  Features of Real-Time Systems  Implementing Real-Time Operating Systems  Real-Time CPU Scheduling  An Example: VxWorks5.x.
Operating System Examples - Scheduling. References r er/ch10.html r bangalore.org/blug/meetings/200401/scheduler-
W4118 Operating Systems Instructor: Junfeng Yang.
Process Scheduling 國立中正大學 資訊工程研究所 羅習五 老師 1. Outline OS schedulers Unix scheduling Linux scheduling Linux 2.4 scheduler Linux 2.6 scheduler – O(1) scheduler.
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.
UNIT–II: Process Management
Processes and threads.
Linux Scheduler.
Chapter 5a: CPU Scheduling
Process Scheduling 國立中正大學 資訊工程研究所 羅習五 老師.
Chapter 2 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
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 2: The Linux System Part 3
Scheduling Adapted from:
TDC 311 Process Scheduling.
CPU SCHEDULING.
Lecture Topics: 11/1 General Operating System Concepts Processes
Outline Scheduling algorithms Multi-processor scheduling
Chapter 6: CPU Scheduling
Lesson Objectives Aims Key Words
Chapter 3: Processes.
Scheduling.
Operating System , Fall 2000 EA101 W 9:00-10:00 F 9:00-11:00
Shortest-Job-First (SJR) Scheduling
Linux Scheduler © DJ Foreman 3/8/2009.
Chapter 6: Scheduling Algorithms Dr. Amjad Ali
Linux Scheduling CSE 2431: Introduction to Operating Systems
Presentation transcript:

The Linux Scheduler 2.4 vs 2.6 Michael McCabe Michael McCabe

Scheduling Basics  Tasks are divided into three groups, real time processes, IO bound, and CPU bound  Real Time - Extremely high scheduling requirements, needs a guarantee on how often they will run, usually the highest priority process in a system  IO bound - processes that spend most of their time waiting for data going to or coming from the disk  Tasks are divided into three groups, real time processes, IO bound, and CPU bound  Real Time - Extremely high scheduling requirements, needs a guarantee on how often they will run, usually the highest priority process in a system  IO bound - processes that spend most of their time waiting for data going to or coming from the disk

Scheduling Basics cont.  CPU bound - Processes that consume large amounts of cpu  Time slice - amount of time that a process can run on the CPU  Preemption - When the execution of the currently running process is interrupted in order to run a different, higher priority process  CPU bound - Processes that consume large amounts of cpu  Time slice - amount of time that a process can run on the CPU  Preemption - When the execution of the currently running process is interrupted in order to run a different, higher priority process

The schedule function  Schedule() is the function in the linux kernel that does the actual scheduling  Has multiple ways of being run  Runs when a new process needs to be selected for scheduling  Is called when the currently running process is blocked, waiting for a resource  Each processor can call schedule on its own  Many device drivers will call schedule  Schedule() is the function in the linux kernel that does the actual scheduling  Has multiple ways of being run  Runs when a new process needs to be selected for scheduling  Is called when the currently running process is blocked, waiting for a resource  Each processor can call schedule on its own  Many device drivers will call schedule

2.4 Basics  1400 Lines of code  Three basic data structures  Basic data structure is schedule_data. This data structure contains a pointer to the currently running process and the timestamp of the last time the schedule function ran  There is one run queue, and it’s a linked list  1400 Lines of code  Three basic data structures  Basic data structure is schedule_data. This data structure contains a pointer to the currently running process and the timestamp of the last time the schedule function ran  There is one run queue, and it’s a linked list

Schedule_data struct schedule_data { struct task_struct * curr; cycles_t last_schedule; } schedule_data; char __pad [SMP_CACHE_BYTES];

Schedule_data explained  Remarkably simple data structure  Defined in sched.c  Contains a time stamp of the last process switch  Also contains a pointer to the process that is currently running  Remarkably simple data structure  Defined in sched.c  Contains a time stamp of the last process switch  Also contains a pointer to the process that is currently running

2.4 SMP  Reschedule_idle checks to see if the process that just moved out of the running state should be moved to a different cpu  It doesn’t use the counter and nice values directly, it uses the goodness function to check priorities  Goodness takes into account the cost of moving a process across cpus  Reschedule_idle checks to see if the process that just moved out of the running state should be moved to a different cpu  It doesn’t use the counter and nice values directly, it uses the goodness function to check priorities  Goodness takes into account the cost of moving a process across cpus

2.6 Basics  5700 Lines of code  Run queue and priority arrays are the basic data structures  One run queue per processor  Two priority arrays per run queue  5700 Lines of code  Run queue and priority arrays are the basic data structures  One run queue per processor  Two priority arrays per run queue

Run Queue spinlock_t lock; unsigned long nr_running; #ifdef CONFIG_SMP unsigned long prio_bias; unsigned long cpu_load[3]; #endif unsigned long long nr_switches; unsigned long nr_uninterruptible; unsigned long expired_timestamp; unsigned long long timestamp_last_tick; task_t *curr, *idle; struct mm_struct *prev_mm; prio_array_t *active, *expired, arrays[2]; int best_expired_prio; atomic_t nr_iowait; #ifdef CONFIG_SMP struct sched_domain *sd; int active_balance; int push_cpu; task_t *migration_thread; struct list_head migration_queue; #endif

Run queue explained  Primary scheduling data structure  Defined in sched.c  Needs to be locked before its modified  Locks are obtained on multiple run queues in ascending order  Primary scheduling data structure  Defined in sched.c  Needs to be locked before its modified  Locks are obtained on multiple run queues in ascending order

Priority Array struct prio_array { unsigned int nr_active; unsigned long bitmap[BITMAP_SIZE]; struct list_head queue[MAX_PRIO]; };

Priority Arrays explained  Defined in sched.c  Provides constant running time for the scheduling algorithm  Contains lists of runnable processes at each priority level  A bitmap is used to efficiently discover the highest priority process  When a task with priority 10 becomes runnable bit 10 in the bitmap gets set to 1  Defined in sched.c  Provides constant running time for the scheduling algorithm  Contains lists of runnable processes at each priority level  A bitmap is used to efficiently discover the highest priority process  When a task with priority 10 becomes runnable bit 10 in the bitmap gets set to 1

2.6 SMP  Load_balance is the function that makes sure each processor has a relatively equal number of processes on it  Only is run on multi processor systems  Runs every millisecond when the system is idle or every 200 milliseconds  Only tasks that are not running are moved  Load_balance is the function that makes sure each processor has a relatively equal number of processes on it  Only is run on multi processor systems  Runs every millisecond when the system is idle or every 200 milliseconds  Only tasks that are not running are moved

Big O running times  The 2.6 kernel has a constant running time  O(1)  Leads to better scalability than the 2.4 kernel  Also has a much more complex implementation  Time slices are calculated when a process’s timeslice is used, before it moves to the expired array  The 2.6 kernel has a constant running time  O(1)  Leads to better scalability than the 2.4 kernel  Also has a much more complex implementation  Time slices are calculated when a process’s timeslice is used, before it moves to the expired array  2.4 kernel has a linear running time in the worst case  Loops over the process list at the end of each time quantum  Recalculates each processes’s time slice

Real time differences  2.6 provides soft real time support  Real time processes will preempt regular processes  Real time priorities are set statically  2.6 provides soft real time support  Real time processes will preempt regular processes  Real time priorities are set statically  Not all versions of the 2.4 kernel can offer any real time guarantees  Not all versions of the 2.4 kernel offer preemption  Priority inversion occurs frequently in the 2.4 kernel

References  Understanding the Linux Kernel 2nd Edition Understanding the Linux Kernel 2nd Edition  Kernel newbies Kernel newbies  Linux Kernel Cross Reference Linux Kernel Cross Reference  Linux Kernel Development Linux Kernel Development  Linux Device Drivers 3rd Edition Linux Device Drivers 3rd Edition  Understanding the Linux Kernel 2nd Edition Understanding the Linux Kernel 2nd Edition  Kernel newbies Kernel newbies  Linux Kernel Cross Reference Linux Kernel Cross Reference  Linux Kernel Development Linux Kernel Development  Linux Device Drivers 3rd Edition Linux Device Drivers 3rd Edition