Sogang University Advanced Operating Systems (Process Scheduling - Linux) Advanced Operating Systems (Process Scheduling - Linux) Sang Gue Oh, Ph.D. Email.

Slides:



Advertisements
Similar presentations
Scheduling Algorithems
Advertisements

Operating Systems Process Scheduling (Ch 3.2, )
Linux Scheduling Algorithm -Ashish Singh. Introduction History and Background Linux Scheduling Modification in Linux Scheduling Results Conclusion References.
CPU Management CT213 – Computing Systems Organization.
Process Scheduling in Linux (Chap.7 in Understanding the Linux Kernel) J. H. Wang Oct. 1, 2009.
CS4315A. Berrached:CMS:UHD1 CPU Scheduling Chapter 7.
Operating Systems, fall 2002 SCHEDULING in Linux Lior Amar, David Breitgand (recitation)
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.
Scheduling in Batch Systems
CS 3013 & CS 502 Summer 2006 Scheduling1 The art and science of allocating the CPU and other resources to processes.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time.
1 Thursday, June 15, 2006 Confucius says: He who play in root, eventually kill tree.
5: CPU-Scheduling1 Jerry Breecher OPERATING SYSTEMS SCHEDULING.
1 Scheduling in Representative Operating Systems.
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
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.
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.
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.
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.
Uniprocessor Scheduling
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.
Chapter 6 CPU SCHEDULING.
More Scheduling cs550 Operating Systems David Monismith.
Operating System Examples - Scheduling
1 Previous lecture review n Out of basic scheduling techniques none is a clear winner: u FCFS - simple but unfair u RR - more overhead than FCFS may not.
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 Basic scheduling policies, for OS schedulers (threads, tasks, processes) or thread library schedulers Review of Context Switching overheads.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
Operating Systems Process Management.
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.
CPU Scheduling Presentation by Colin McCarthy. Runqueues Foundation of Linux scheduler algorithm Keeps track of all runnable tasks assigned to CPU One.
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.
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
Traditional UNIX Scheduling Scheduling algorithm objectives Provide good response time for interactive users Ensure that low-priority background jobs do.
Cpr E 308 Spring 2005 Process Scheduling Basic Question: Which process goes next? Personal Computers –Few processes, interactive, low response time Batch.
ITFN 2601 Introduction to Operating Systems Lecture 4 Scheduling.
CSC 322 Operating Systems Concepts Lecture - 10: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Operating System Examples - Scheduling. References r Silberschatz et al, Chapter 5.6, Chapter
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.
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.
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.
Scheduling.
Process Scheduling 國立中正大學 資訊工程研究所 羅習五 老師 1. Outline OS schedulers Unix scheduling Linux scheduling Linux 2.4 scheduler Linux 2.6 scheduler – O(1) scheduler.
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.
Processes and threads.
Chapter 2 Scheduling.
Lecture 23: Process Scheduling for Interactive Systems
Chapter 2: The Linux System Part 3
CPU SCHEDULING.
CPU scheduling decisions may take place when a process:
Process Scheduling Decide which process should run and for how long
CS703 – Advanced Operating Systems
CPU Scheduling CSE 2431: Introduction to Operating Systems
Linux Scheduling CSE 2431: Introduction to Operating Systems
Presentation transcript:

Sogang University Advanced Operating Systems (Process Scheduling - Linux) Advanced Operating Systems (Process Scheduling - Linux) Sang Gue Oh, Ph.D.

Sogang University Process Scheduling - Linux Page 2 Scheduling Policy (1)  Scheduling Policy  set of rules to determine when and how to select a new process to run  Traditional Scheduling Objectives  fast process response time  good throughput for background jobs  avoidance of process starvation  reconciliation of the needs of low- and high-priority processes  Linux Scheduling  based on time sharing  CPU time divided into slices – one for each runnable process (quantum)  based on timer interrupt and ranking (or priority)  dynamic process priority – by kernel and by users (via system calls)

Sogang University Process Scheduling - Linux Page 3 Scheduling Policy (2)  System Calls Related to Scheduling System CallsDescriptions nice() Change the priority of conventional process getpriority() Get the maximum priority of a group of conventional processes setpriority() Set the priority of a group of conventional processes sched_getscheduler() Get the scheduling policy of a process sched_setscheduler() Set the scheduling policy and priority of a process sched_getparam() Get the priority of a process sched_setparam() Set the priority of a process sched_yield() Relinquish the processor voluntarily without blocking sched_get_priority_min() Get the minimum priority value for a policy sched_get_priority_max() Get the maximum priority value for a policy sched_rr_get_interval() Get the time quantum value for the Round Robin policy

Sogang University Process Scheduling - Linux Page 4 Scheduling Policy (3)  Process Classification  CPU usage: I/O-bound vs. CPU-bound processes  IO type : interactive vs. batch processes  timing : real-time (1~99) vs. normal processes (0)  I/O-bound processes favored by Linux (or other Unix kernels as well)  Process Preemption  preemptive user processes  current user process interrupted by a new process with higher priority  current user process switched over with quantum expired (need_resched)  non-preemptive kernel processes (schedule( ), interruptable_sleep_on ( ))  no actual real-time support guaranteed

Sogang University Process Scheduling - Linux Page 5 Scheduling Policy (4)  Process Quantum  a time slice during which a process can run on CPU  too short quantum: too much switching overhead  too long quantum: too slow system response time  Linux policy: make it as long as possible while keeping good response time  different from process to process – more or less 60ms in general  example: Linux process 0 – swapper in INIT-TASK macro #define DEF_COUNTER (10 * HZ / 100) // 10 ticks ≈ 105ms where HZ = 100 for IBM compatible PCs

Sogang University Process Scheduling - Linux Page 6 Scheduling Algorithm (1)  Epoch  basic time unit on which Linux scheduling is based  a duration during which each process keeps its time quantum  Scheduling Basics  scheduling based on epoch  a specific time quantum per process within a single epoch  CPU assigned to each process (maybe several times) for the given quantum  the given epoch ends when all runnable processes exhaust their quanta  a new quantum computed and assigned to each runnable process again  base time quantum per process – can be changed via nice() and setpriority()  base time quantum inherited to child processes 

Sogang University Process Scheduling - Linux Page 7 Scheduling Algorithm (2)  Linux Priority Used for Scheduling  static priority assigned by the users for RT processes (1~99) can not be changed by the scheduler  dynamic priority applied to conventional processes base priority + number of ticks left within the given epoch can be changed via system calls such as nice()  static priority > dynamic priority  Scheduling Policy  SCHED_FIFO: for RT processes, FIFO among same priorities  SCHED_RR: for RT processes, RR among same priorities  SCHED_OTHER: for conventional time-shared processes

Sogang University Process Scheduling - Linux Page 8 Scheduling Algorithm (3)  Scheduler  find a process in the runqueue and assign the CPU  invoked directly or lazy (deferred) way  Direct Scheduler Invocation  when a process to relinquish the CPU voluntarily  when the current process must be blocked  by many device drivers  Lazy Scheduler Invocation  when a process needs to be scheduled involuntarily (via setting need_reched field of the current process descriptor)  when the current process’s quantum expires  when a process with the higher priority than the current wakes up  when sched_setscheduler() or sched_yield() is called

Sogang University Process Scheduling - Linux Page 9  Main Goal – Determine Which Process to Run Next  via goodness() function call  input to goodness() p: descriptor pointer of candidate process this_cpu: logical CPU number this_mm: memory descriptor of the process being replaced  return value and meaning weight = -1: SCHED_YIELD flag is set weight = 0: conventional process and quantum expired 2  weight  77 : conventional process and quantum not expired (+15, +1 for kernel thread or memory shared) weight  1000: real-time process p->counter Scheduling Algorithm (4)

Sogang University Process Scheduling - Linux Page 10 Scheduling Algorithm (5)  Scheduling on Multiprocessor Systems  each processor runs its own schedule() function  processors communicate with each other  process can migrate from one processor to another – global priority  reschedule_idle() – sends RESCHEDULE_VECTOR first checks the processor on which the last process ran for availability if not, then tries to find a least recently active idle processor (why?) if not, finds processors running lower priority processor than the one just suspended then, reschedule  Hyper-threading Technology  two threads executed at once by one hyper-threaded microprocessor  multiple copies of the internal registers and switching between register sets

Sogang University Process Scheduling - Linux Page 11 Scheduling Algorithm (6)  Performance of Scheduling Algorithm  very straightforward and easy in Linux  a lot of room for improvement – but no significant success  one good for some cases and another good for other cases  performs good for small and medium scale systems  performs relatively poor for large scale systems  too large time quantum for high-end machines with a very high load  less optimal I/O bound process boosting strategy  weak RT support due to non-preemptive kernel feature  Unscalable – inefficient when the number of processes is large  long time taken to recompute priorities (in every second in Unix)  use long interval between priority recomputations (What happens?)