Periodic scheduler for Linux OS

Slides:



Advertisements
Similar presentations
Scheduling Algorithems
Advertisements

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.
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.
Sogang University Advanced Operating Systems (Process Scheduling - Linux) Advanced Operating Systems (Process Scheduling - Linux) Sang Gue Oh, Ph.D. .
Completely Fair Scheduler Alireza Heidari. Introduction The Completely Fair Scheduler (CFS) is a process scheduler. Merged into the release of.
BFS: Brain F*ck Scheduler Jacob Chan. Objectives  Brain F*ck Scheduling  What it is  How it works  Features  Scalability  Limitations  Definition.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 6: CPU Scheduling.
Operating Systems 1 K. Salah Module 2.1: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation.
Processes CSCI 444/544 Operating Systems Fall 2008.
Scheduling in Linux COMS W4118 Spring Scheduling Goals O(1) scheduling; 2.4 scheduler iterated through Run queue on each invocation Task queue.
The Linux Scheduler 2.4 vs 2.6 Michael McCabe Michael McCabe
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
The Linux “Completely Fair Scheduler”
 Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.
Scheduling in Linux and Windows 2000
Linux Scheduling CS Scheduling Policy ► The scheduling algorithm of traditional Unix systems must fulfill several conflicting objectives  Fast.
Chapter 4 Processor Management
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.
More Scheduling cs550 Operating Systems David Monismith.
Adding a Scheduling Policy to the Linux Kernel By Juan M. Banda CS518 Advanced Operating Systems.
Seminar on Linux Process Management Presentation by Manoj Dhage MTech 1 st Year, SIT, IIT Kharagpur.
CPU Scheduling Presentation by Colin McCarthy. Runqueues Foundation of Linux scheduler algorithm Keeps track of all runnable tasks assigned to CPU One.
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.
Lec 3aOperating Systems1 Operating Systems Lecture 3a: Linux Schedulers William M. Mongan Material drawn in part from
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
LINUX SCHEDULING Evolution in the 2.6 Kernel Kevin Lambert Maulik Mistry Cesar Davila Jeremy Taylor.
Linux Processes Travis Willey Jeff Mihalik. What is a process? A process is a program in execution A process includes: –program counter –stack –data section.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Scheduling II: priority scheduling.
4300 Lines Added 1800 Lines Removed 1500 Lines Modified PER DAY DURING SUSE Lab.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
MP2: RATE-MONOTONIC CPU SCHEDULING Based on slides by Gourav Khaneja, Raoul Rivas and Keun Yim University of Illinois at Urbana-Champaign Department of.
CSC 660: Advanced Operating Systems
Operating System Examples - Scheduling. References r Silberschatz et al, Chapter 5.6, Chapter
MP2: Rate-Monotonic CPU Scheduling
1 Akira Tsukamoto System Platform Laboratory NEC Corporation.
Linux Process Management. Linux Implementation of Threads Threads enable concurrent programming / true parallelism Linux implementation of threads.
Scheduling Classes and Real-Time Scheduling in Linux David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St.
Operating System Examples - Scheduling. References r er/ch10.html r bangalore.org/blug/meetings/200401/scheduler-
Process Scheduling. Scheduling Strategies Scheduling strategies can broadly fall into two categories  Co-operative scheduling is where the currently.
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
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.
Process Scheduling II 3/6/13COMS W4118. Spring 2013, Columbia University. Instructor: Dr. Kaustubh Joshi, AT&T Labs. 1 COMS W4118 Prof. Kaustubh R. Joshi.
Lecture 6 The Rest of Scheduling Algorithms and The Beginning of Memory Management.
Virtual-Time Round-Robin: An O(1) Proportional Share Scheduler Jason Nieh, Chris Vaill, Hua Zhong Columbia University Presented by Adam Binford.
Guy Martin, OSLab, GNU Fall-09
Scheduling and Fairness
Processes.
Process Scheduling 國立中正大學 資訊工程研究所 羅習五 老師.
The Linux “Completely Fair Scheduler”
Lecture 23: Process Scheduling for Interactive Systems
CS 3204 Operating Systems Lecture 14 Godmar Back.
Linux kernel: Processes, threads and scheduling
TDC 311 Process Scheduling.
Operating systems Process scheduling.
Enforcing Real-Time Behavior I
CPU scheduling decisions may take place when a process:
Midterm Review Brian Kocoloski
Process Scheduling B.Ramamurthy 4/11/2019.
Process Scheduling B.Ramamurthy 4/7/2019.
Scheduling.
Scheduling Classes and Real-Time Scheduling in Linux
Linux Process State Scheduling information Identifiers
Outline Chapter 2 (cont) Chapter 3: Processes Virtual machines
Scheduling of Regular Tasks in Linux
CPU Scheduling David Ferry CSCI 3500 – Operating Systems
Presentation transcript:

Periodic scheduler for Linux OS Mike Athanasakis – michath@csd.uoc.gr Operating System TA – Winter 2015-2016

History Linux v1.2 – Round Robin Linux v2.2 – Scheduling Classes & Policies Linux v2.4 – Division in epochs, goodness of function Linux v2.6 – Runqueue O(1) Linux v2.6.21 – Completely Fair Scheduler (CFS) Virtual time concept Time-ordered red-black tree instead of queue Maintains balance in providing processor time to tasks

Scheduling classes Linux scheduler at kernel/sched.c It is modular, depending the type of task it changes scheduling algorithm. It uses the idea of scheduling class. Each task belongs to a scheduling class, that changes the way it gets scheduled. sched.c calls an “overloaded” function that depending the scheduling class it calls different code

Task hierarchy in CFS Red-black tree to hold tasks struct task_struct { … struct sched_entity se; … } Red-black tree to hold tasks struct ofs_rq struct sched_entity { … struct rb_node run_node; … } rb_root rb rb struct rb_node { … rb_node *right, left; … } rb rb rb rb

Scheduler and policies Scheduling policy is set by sched_setscheduler() Available scheduling policies SCHED_FIFO – Special time-critical tasks SCHED_RR – Round robin scheduling SCHED_IDLE – Low priority tasks SCHED_OTHER – Default linux task (normal) SCHED_BATCH – CPU intensive tasks

Scheduling policies and their files Completely fair scheduler (SCHED_OTHER) kernel/sched_fair.c Real time processes (SCHED_FIFO & SCHED_RR) kernel/sched_rt.c Idle tasks (SCHED_IDLE) kernel/sched_idle.c

Scheduling state of task Defined at /include/linux/sched.h TASK_RUNNING 0 TASK_INTERRUPTIBLE 1 TASK_UNINTERRUPTIBLE 2 TASK_ZOMBIE 3 TASK_STOPPED 4 Maybe you can add a new task state? Maybe TASK_PERIODIC?

Runqueue the magic starts here Defined at kernel/sched.c is the main scheduling struct of Linux. struct runqueue { … struct task_struct *curr; currently running task struct prio_array *active; active priority array struct prio_array *expired; expired priority array struct prio_array arrays[2]; actual priority arrays }

Runqueue functions Called inside main schedule at kernel/sched.c cpu_rq(processor) – returns CPU’s runqueue this_rq() – returns runqueue of current CPU task_rq(task) – returns the runqueue where the task is in

void schedule(void); 1/2 Located at kernel/sched.c it is the main scheduling function. void asmlinkage __sched schedule (void) { struct task_struct *prev, *next; previous & next task struct rq *rq; ... rq = cpu_rq(cpu); prev = rq->curr; current task will become the previous after the context switch pre_schedule (rq, prev); depending the scheduling class the code to run changes

void schedule(void); 2/2 put_prev_task(rq, prev); scheduling class dependent code next = pick_next_task(rq); the function that chooses the next task ... context_switch(rq, prev, next); the actual context switch … post_schedule(rq); depending the scheduling class the code to run changes

pick_next_task(rq) if (likely(rq->nr_running == rq->cfs.nr_running)) { p = fair_sched_class.pick_next_task(rq); if (likely(p)) return p; } for_each_class(class) { p = class->pick_next_task(rq); if (p) return p; }

struct sched_class Located at include/linux/sched.h How to handle enqueue/dequeue of a specific sched_class void (*enqueue_task) (struct rq, struct task_struct, int flags); void (*dequeue_task) (struct rq, struct task_struct, int flags); During the context switch how to handle the sched_class struct task_struct * (*pick_next_task) (struct rq *rq); void (*put_prev_task) (struct rq *rq, struct task_struct *p);

Assignment 4 A periodic scheduler with a short period first Each process has a period_time (p_i) and a computation time (c_i) in milliseconds. Each task has to run exactly c_i time every p_i time. If a task doesn’t run c_i time every p_i then we say it missed a deadline. We choose what periodic process to run first by choosing the one with the smallest period time (shortest period first). Remember that normal Linux schedule quantum is 100ms.

Periodic tasks example Process 1: p_i: 40 seconds c_i: 12 seconds Process 2: p_i: 10 seconds c_i: 3 seconds

How to test Create a simple test program that takes as argument the p_i and c_i Run a 1st task test instance with p_i/c_i: 1000 / 200 Run a 2nd task test instance with p_i/c_i: 2000 / 500 Run a 3rd task test instance with p_i/c_i: 1500 / 400 And so on… the tasks should start miss deadlines! Get creative on how to test it, it will score you points!

More help? Info? Deliverables? Just check the assignment pdf. It has much more text than it shows. If you need more help read the links, they have a lot of info that can make this assignment much easier. This task is like a real problem out there Study the problem and design the solution. Implement your solution and test it as much as you can. Submit even the smallest piece of code to show your effort!