Process Scheduling in Linux (Chap. 11, Understanding the Linux Kernel) J. H. Wang Sep. 26, 2008.

Slides:



Advertisements
Similar presentations
Operating Systems Process Scheduling (Ch 3.2, )
Advertisements

Linux Scheduling Algorithm -Ashish Singh. Introduction History and Background Linux Scheduling Modification in Linux Scheduling Results Conclusion References.
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.
CPU Scheduling Questions answered in this lecture: What is scheduling vs. allocation? What is preemptive vs. non-preemptive scheduling? What are FCFS,
Process Scheduling in Linux (Chap.7 in Understanding the Linux Kernel) J. H. Wang Oct. 1, 2009.
Operating Systems, fall 2002 SCHEDULING in Linux Lior Amar, David Breitgand (recitation)
Sogang University Advanced Operating Systems (Process Scheduling - Linux) Advanced Operating Systems (Process Scheduling - Linux) Sang Gue Oh, Ph.D. .
CHAPTER 5 Organization of Schedulers Scheduling Methods Priority Inversion Multiprocessor and Distributed Scheduling Process and Thread Scheduling.
Chapter 5 CPU Scheduling. CPU Scheduling Topics: Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
CPU Scheduling Section 2.5.
© Ibrahim Korpeoglu Bilkent University
Operating System Process Scheduling (Ch 4.2, )
Operating System I Process Scheduling. Schedulers F Short-Term –“Which process gets the CPU?” –Fast, since once per 100 ms F Long-Term (batch) –“Which.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Scheduling in Linux COMS W4118 Spring Scheduling Goals O(1) scheduling; 2.4 scheduler iterated through Run queue on each invocation Task queue.
1 Scheduling in Representative Operating Systems.
The Linux Scheduler 2.4 vs 2.6 Michael McCabe Michael McCabe
Job scheduling Queue discipline.
Operating Systems Process Scheduling (Ch 4.2, )
Operating System Process Scheduling (Ch 4.2, )
1Chapter 05, Fall 2008 CPU Scheduling The CPU scheduler (sometimes called the dispatcher or short-term scheduler): Selects a process from the ready queue.
Processes and Threads Case studies: Windows and Linux Lecture 6 ~ Fall, 2007 ~
 Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Cosc 4740 Chapter 5 Process Scheduling. CPU Scheduling Short-term Scheduler –Selects a process from the ready queue when current process releases the.
Scheduling in Linux and Windows 2000
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-3 CPU Scheduling Department of Computer Science and Software Engineering.
Linux Scheduling CS Scheduling Policy ► The scheduling algorithm of traditional Unix systems must fulfill several conflicting objectives  Fast.
Operating System Concepts and Techniques Lecture 5 Scheduling-1 M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques, First.
Chapter 6 CPU SCHEDULING.
Operating System Examples - Scheduling
Chapter 6 Scheduling. Basic concepts Goal is maximum utilization –what does this mean? –cpu pegged at 100% ?? Most programs are I/O bound Thus some other.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
Operating Systems Process Management.
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
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 and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
CPU Scheduling Presentation by Colin McCarthy. Runqueues Foundation of Linux scheduler algorithm Keeps track of all runnable tasks assigned to CPU One.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
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 5: Process Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Basic Concepts Maximum CPU utilization can be obtained.
1 11/29/2015 Chapter 6: CPU Scheduling l Basic Concepts l Scheduling Criteria l Scheduling Algorithms l Multiple-Processor Scheduling l Real-Time Scheduling.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Scheduling II: priority scheduling.
Traditional UNIX Scheduling Scheduling algorithm objectives Provide good response time for interactive users Ensure that low-priority background jobs do.
Scheuduling.
Cpr E 308 Spring 2005 Process Scheduling Basic Question: Which process goes next? Personal Computers –Few processes, interactive, low response time Batch.
6.1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
Operating System Examples - Scheduling. References r Silberschatz et al, Chapter 5.6, Chapter
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 3.
Linux Process Management. Linux Implementation of Threads Threads enable concurrent programming / true parallelism Linux implementation of threads.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
1 Uniprocessor Scheduling Chapter 3. 2 Alternating Sequence of CPU And I/O Bursts.
Chapter 4 CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
Operating Systems Unit 5: – Processor scheduling – Java – Linux – Windows XP Operating Systems.
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.
CPU scheduling.  Single Process  one process at a time  Maximum CPU utilization obtained with multiprogramming  CPU idle :waiting time is wasted 2.
Basic Concepts Maximum CPU utilization obtained with multiprogramming
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.
Linux kernel: Processes, threads and scheduling
A Comparison Study of Process Scheduling in FreeBSD, Linux and Win2k
Chapter 2: The Linux System Part 3
Linux Scheduling CSE 2431: Introduction to Operating Systems
Presentation transcript:

Process Scheduling in Linux (Chap. 11, Understanding the Linux Kernel) J. H. Wang Sep. 26, 2008

Outline Scheduling Policy Scheduling Algorithm System Calls related to Scheduling

Scheduling Policy Based on time-sharing –Time slice Based on priority ranking –Dynamic Classification of processes –Interactive processes –Batch processes –Real-time processes

System Calls related to Scheduling System calldescription 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() change the priority get the maximum group priority set the group priority get the scheduling policy set the scheduling policy and priority get the priority set the priority relinquish the processor voluntarily get the minimum priority value get the maximum priority value get the time quantum for Round-Robin

Linux (user) processes are preemptive –When a new process has higher priority than the current –When its time quantum expires, need_resched will be set A preempted process is not suspended since it remains in the TASK_RUNNING state Linux kernel is nonpreemptive –Simpler

How Long Must a Quantum Last? Neither too long nor too short –Too short: overhead for process switch –Too long: processes no longer appear to be executed concurrently Always a compromise –The rule of thumb: to choose a duration as long as possible, while keeping good system response time

The Scheduling Algorithm Dividing CPU time into epochs –In a single epoch, every process has a specified time quantum whose duration is computed when the epoch begins Each process has a base time quantum, which is the time-quantum assigned by the scheduler if it has exhausted its quantum in the previous epoch –Can be changed by nice(), setpriority() INIT_TASK macro sets the value of initial time quantum of process 0 to DEF_COUNTER –#define DEF_COUNTER (10*HZ/100) (~105ms)

Two kinds of priorities –Static priority Real-time: 1-99, never changed –Dynamic priority Conventional processes Base time quantum+# of ticks left before its quantum expires

Data Structures used by the Scheduler Fields related to scheduling in process descriptor –need_resched: a flag checked by ret_from_sys_call() –policy: the scheduling class SCHED_FIFO: First-In First-Out real-time SCHED_RR: Round-Robin real-time SCHED_OTHER: conventional time-shared processes

–rt_priority: static priority for real-time process (1-99) –counter: # of ticks left before its quantum expires –nice: determines length of time quantum (-20-19) –cpus_allowed: a bit mask specifying the CPUs on which the process is allowed to run –cpus_runnable: a bit mask specifying the CPU that is executing the process –processor: the index of CPU that is executing the process

When a new process is created, do_fork() sets the counter field of both current (the parent) and p (the child): –p->counter = (current->counter+1) >> 1; current->counter >>= 1; if (!current->counter) current->need_resched= 1;

CPU’s Data Structures aligned_data array of NR_CPUS structures of type schedule_data –curr: a pointer to the process descriptor of the process running on that CPU cpu_curr(n) –last_schedule: the value of the 64-bit Time Stamp Counter when the last process switch was performed on the CPU last_schedule(n)

The schedule() Function Direct invocation –When the process must be blocked to wait for resource –When long iterative tasks are executed in device drivers Lazy invocation: by setting the need_resched –When current has used up its quantum, by update_process_times() –When a process is woken up, by reschedule_idle() –When a sched_setscheduler() or sched_yield() system call is issued

Actions performed by schedule() before and after a process switch –Details in pp How good is a runnable process? –weight returned by goodness() measures the “goodness” of a process weight = -1: will be selected only if no other runnable processes weight = 0: conventional process that has exhausted its quantum weight= 2-77: a conventional process that has not exhausted its quantum Weight>=1000: a real-time process

Scheduling on multiprocessor systems –reschedule_idle(): checks whether the just replaced process should be executed on some other CPU running a lower priority process Is the CPU that was last running p currently idle? Does an idle processor exist that can execute p? Does there exist a processor that can execute p and whose current process has lower dynamic priority than p? –Details on pp

Performance of Scheduling Algorithm (kernel 2.4) The algorithm does not scale well The predefined quantum is too large for high system loads I/O-bound process boosting strategy is not optimal Support for real-time applications is weak (These should have been fixed in new kernel versions…)

System Calls Related to Scheduling nice() –Allows processed to change their base priority –Replaced by setpriority() getpriority() and setpriority() –Act on the base priorities of all processes in a given group –which: PRIO_PROCESS, PRIO_PGRP, PRIO_USER –who: the value of pid, pgrp, or uid field to be used for selecting the processes –niceval: the new base priority value

System Calls Related to Real-Time Processes sched_getscheduler(), sched_setscheduler() –Queries/sets the scheduling policy sched_getparam(), sched_setparam() –Retrieves/sets the scheduling parameters sched_yield() –To relinquish the CPI volutarily without being suspended sched_get_priority_min(), sched_get_priority_max() –To return the minimum/maximum real-time static priority sched_rr_get_interval() –To write the round-robin time quantum for real-time process

Thanks for Your Attention!