Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Scheduling II: priority scheduling.

Slides:



Advertisements
Similar presentations
Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.
Advertisements

Linux Scheduler. Linux is a multitasking OS Deciding what process runs next, given a set of runnable processes, is a fundamental decision a scheduler.
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. .
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 17 Scheduling III.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 16 Scheduling II.
Chapter 5 CPU Scheduling. CPU Scheduling Topics: Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
CPU Scheduling Section 2.5.
CS 311 – Lecture 23 Outline Kernel – Process subsystem Process scheduling Scheduling algorithms User mode and kernel mode Lecture 231CS Operating.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
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, )
 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.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Chapter 6: CPU Scheduling
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.
More Scheduling cs550 Operating Systems David Monismith.
MM Process Management Karrie Karahalios Spring 2007 (based off slides created by Brian Bailey)
Fair Resource Access & Allocation  OS 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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
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.
Real-Time Scheduling CS4730 Fall 2010 Dr. José M. Garrido Department of Computer Science and Information Systems Kennesaw State University.
3.1 : Resource Management Part2 :Processor Management.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
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.
RTOS task scheduling models
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.
ITFN 2601 Introduction to Operating Systems Lecture 4 Scheduling.
1 Real-Time Scheduling. 2Today Operating System task scheduling –Traditional (non-real-time) scheduling –Real-time scheduling.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 5 CPU Scheduling Slide 1 Chapter 5 CPU Scheduling.
Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.
CS333 Intro to Operating Systems Jonathan Walpole.
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 Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
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.
Basic Concepts Maximum CPU utilization obtained with multiprogramming
Scheduling.
1 Chapter 5: CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms.
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.
Copyright ©: Nahrstedt, Angrave, Abdelzaher
Copyright ©: Nahrstedt, Angrave, Abdelzaher
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Operating System Concepts
Chapter 2: The Linux System Part 3
TDC 311 Process Scheduling.
Process Scheduling Decide which process should run and for how long
Chapter 10 Multiprocessor and Real-Time Scheduling
Scheduling 21 May 2019.
Presentation transcript:

Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Scheduling II: priority scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher 2 Priority Scheduling Each process is assigned a priority. Select highest priority job over lower ones. Be aware that: May not give the best AWT  Usually when you use priority scheduling you care more about deadlines, not AWT If not carefully used, you cause starvation of lower priority processes

Copyright ©: Nahrstedt, Angrave, Abdelzaher 3 Priority Scheduling: Example ProcessDurationPriorityArrival Time P1640 P2810 P3730 P P4 (3)P1 (6) 11 P3 (7) 18 P2 waiting time: 0 P4 waiting time: 8 P3 waiting time: 11 P1 waiting time: 18 The average waiting time (AWT): ( )/4 = 9.25 (worse than SJF) P2 (8) 24

Copyright ©: Nahrstedt, Angrave, Abdelzaher 4 Set Priority for time-sharing scheduler Every process has a default priority under Linux time-sharing scheduler (do not confuse it with real-time priorities!) User can also change a process priority The nice command

Copyright ©: Nahrstedt, Angrave, Abdelzaher 5 int getpriority(int which, id_t who); int setpriority(int which, id_t who, int value); Set/Get Priority for time-sharing scheduler

CS 4316 The rest of this lecture is not mandatory… It will not be covered in the MPs and it will not be asked in the exams It is just to satisfy your curiosity about priority scheduling…

CS 4317 Priority and Importance - 1 Example with 2 real-time periodic processes: -A periodic process is periodically reactiveted -A periodic process is composed by a sequence of jobs: one job per period Priority: priority is the order we execute ready jobs. Criticality (Importance): represents the penalty if a process misses a deadline (one of its jobs misses a deadline). Quiz: Which process should have higher priority? Process 1: The most import process in the system: if it does not get done, serious consequences will occur Process 2: A mp3 player: if it does not get done in time, the played song will have a glitch If it is feasible, we would like to meet the real-time deadlines of both processes!

CS 4318 Priority and Importance - 1 Example with 2 real-time periodic processes: -A periodic process is periodically reactiveted -A periodic process has a sequence of jobs: one job per period Quiz: Which process should have higher priority? Answer: the task with higher rate (according to RM) unless the system is overloaded! Process 1: The most import process in the system: if it does not get done, serious consequences will occur Process 2: A mp3 player: if it does not get done in time, the played song will have a glitch

CS 4319 Priority and Importance - 2 If priorities are assigned according to importance, there is no lower bound of processor utilization, below which tasks deadlines can be guaranteed. C 1 /p 1 + C 2 /p 2 = U  Processor utilization U  0, when C 2  0 and p 1   Task  2 will miss its deadline, as long as C 1 > p 2

CS Priority and Importance - 3 An important find in real-time computing theory is that importance may or may not correspond to scheduling priority. In the previous example, giving the less important task higher priority results in both tasks meeting their deadlines. Importance matters only when tasks cannot be scheduled (overload condition) without missing deadlines. Important job Less important job

CS Posix.4 scheduling interfaces Each process can run with a particular scheduling policy and associated scheduling attributes. Both the policy and the attributes can be changed independently. POSIX.4 defines three policies (available on Linux kernel): SCHED_FIFO: preemptive, priority-based scheduling. SCHED_RR: Preemptive, priority-based scheduling with quanta. SCHED_OTHER: an implementation-defined scheduler

CS Posix.4 scheduling interfaces SCHED_FIFO: preemptive, priority-based scheduling. The available priority range can be identified by calling: sched_get_priority_min(SCHED_FIFO)  Linux 2.6 kernel: 1 sched_get_priority_max(SCHED_FIFO);  Linux 2.6 kernel: 99 SCHED_FIFO can only be used with static priorities higher than 0, which means that when a SCHED_FIFO process becomes runnable, it will always preempt immediately any currently running normal SCHED_OTHER process. SCHED_FIFO is a simple scheduling algorithm without time slicing. A process calling sched_yield will be put at the end of its priority list. No other events will move a process scheduled under the SCHED_FIFO policy in the wait list of runnable processes with equal static priority. A SCHED_FIFO process runs until either it is blocked by an I/O request, it is preempted by a higher priority process, it calls sched_yield, or it finishes.

CS Posix.4 scheduling interfaces SCHED_RR: preemptive, priority-based scheduling with quanta. The available priority range can be identified by calling: sched_get_priority_min(SCHED_RR)  Linux 2.6 kernel: 1 sched_get_priority_max(SCHED_RR);  Linux 2.6 kernel: 99 SCHED_RR is a simple enhancement of SCHED_FIFO. Everything described above for SCHED_FIFO also applies to SCHED_RR, except that each process is only allowed to run for a maximum time quantum. If a SCHED_RR process has been running for a time period equal to or longer than the time quantum, it will be put at the end of the list for its priority. A SCHED_RR process that has been preempted by a higher priority process and subsequently resumes execution as a running process will complete the unexpired portion of its round robin time quantum. The length of the time quantum can be retrieved by sched_rr_get_interval.

CS Posix.4 scheduling interfaces SCHED_OTHER: an implementation-defined scheduler Default Linux time-sharing scheduler SCHED_OTHER can only be used at static priority 0. SCHED_OTHER is the standard Linux time-sharing scheduler that is intended for all processes that do not require special static priority real-time mechanisms. The process to run is chosen from the static priority 0 list based on a dynamic priority that is determined only inside this list. The dynamic priority is based on the nice level (set by the nice or setpriority system call) and increased for each time quantum the process is ready to run, but denied to run by the scheduler. This ensures fair progress among all SCHED_OTHER processes.

CS Posix.4 scheduling interfaces Child processes inherit the scheduling algorithm and parameters across a fork. Do not forget!!!!  a non-blocking end-less loop in a process scheduled under SCHED_FIFO or SCHED_RR will block all processes with lower priority forever; a software developer should always keep available on the console a shell scheduled under a higher static priority than the tested application. This will allow an emergency kill of tested real-time applications that do not block or terminate as expected. Since SCHED_FIFO and SCHED_RR processes can preempt other processes forever, only root processes are allowed to activate these policies under Linux.

CS Posix.4 scheduling interfaces #include int fifo_min, fifo_max; int sched, prio, i; pid_t pid; struct sched_param attr; main() { fifo_min = sched_get_priority_min(SCHED_FIFO); fifo_max = sched_get_priority_max(SCHED_FIFO); sched_getparam(pid, &attr); printf("process %d uses scheduler %d with priority %d \n", pid, sched_getscheduler(pid), attr.sched_priority); printf("\n Let’s modify a process sched parameters: Input the PID, scheduler type, and priority \n"); scanf("%d %d %d", &pid, &sched, &prio); attr.sched_priority = prio; i = sched_setscheduler(pid, sched, &attr); }

CS Posix.4 scheduling interfaces Now you know how to assign real-time priorities to Linux processes. The next question is: how do we assign priorities? One of the most popular real-time scheduling algorithms is Rate Monotonic scheduling (RM) If you are curious about it, check following tutorial at: