1 Multilevel Feedback Queue Scheduling Another way to put a preference on short-lived processes –Penalize processes that have been running longer. Preemptive.

Slides:



Advertisements
Similar presentations
1 First Come, First Served (FCFS) The simplest algorithm –When a process becomes ready, it enters the FIFO queue. –When the currently-running process ceases.
Advertisements

CS 149: Operating Systems February 3 Class Meeting
Operating Systems Process Scheduling (Ch 3.2, )
1 Uniprocessor Scheduling Types of scheduling –The aim of processor scheduling is to assign processes to be executed by the processor so as to optimize.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 17 Scheduling III.
A. Frank - P. Weisberg Operating Systems Advanced CPU Scheduling.
 Basic Concepts  Scheduling Criteria  Scheduling Algorithms.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 16 Scheduling II.
A. Frank - P. Weisberg Operating Systems Process Scheduling and Switching.
Chapter 3: CPU Scheduling
Operating Systems 1 K. Salah Module 2.1: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation.
1 Traditional Unix Scheduling “Traditional” means –No consideration on realtime processes. –Typically 4.3BSD and SVR3 MFQ-based –Preemptive (time quantum.
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.
CS 311 – Lecture 23 Outline Kernel – Process subsystem Process scheduling Scheduling algorithms User mode and kernel mode Lecture 231CS Operating.
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.
CS 104 Introduction to Computer Science and Graphics Problems Operating Systems (2) Process Management 10/03/2008 Yang Song (Prepared by Yang Song and.
Processes and Resources
1 Uniprocessor Scheduling Chapter 9. 2 Aims of Scheduling Assign processes to be executed by the processor(s) Response time Throughput Processor efficiency.
Job scheduling Queue discipline.
Operating Systems Process Scheduling (Ch 4.2, )
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Scheduling. Model of Process Execution Ready List Ready List Scheduler CPU Resource Manager Resource Manager Resources Preemption or voluntary yield AllocateRequest.
Process Description and Control A process is sometimes called a task, it is a program in execution.
1 Lecture 10: Uniprocessor Scheduling. 2 CPU Scheduling n The problem: scheduling the usage of a single processor among all the existing processes in.
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.
Introduction to Embedded Systems Traditional OS Processes and Scheduling Lecture 15hb.
Uniprocessor Scheduling
Chapter 6: CPU Scheduling
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-3 CPU Scheduling Department of Computer Science and Software Engineering.
Lecture 5: Uniprocessor Scheduling
Chapter 9 Uniprocessor Scheduling Spring, 2011 School of Computer Science & Engineering Chung-Ang University.
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
Chapter 6 CPU SCHEDULING.
Fair Resource Access & Allocation  OS Scheduling
Operating System Examples - Scheduling
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 System Chapter 9. Uniprocessor Scheduling
Operating Systems Process Management.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling To improve: Response time: time it takes a system to react to a given input Turnaround Time (TAT)
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
Scheduling Example 3 (1) Assume: FIFO Job Scheduling 100 K Main Memory Processor Sharing Process Scheduling (Cont…)
1 Our focus  scheduling a single CPU among all the processes in the system  Key Criteria: Maximize CPU utilization Maximize throughput Minimize waiting.
CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor Scheduling Operating Systems Examples Algorithm.
Process A program in execution. But, What does it mean to be “in execution”?
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
1 Uniprocessor Scheduling Chapter 9. 2 Aim of Scheduling Response time Throughput Processor efficiency.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling Response time Throughput Processor efficiency.
Uniprocessor Scheduling
Uniprocessor Scheduling Chapter 9. Processor Scheduling Processor scheduling determines the assignment of processes to be executed by the processor over.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling Assign processes to be executed by the processor or processors: –Response time –Throughput –Processor.
Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
1 Uniprocessor Scheduling Chapter 3. 2 Alternating Sequence of CPU And I/O Bursts.
1 Lecture 5: CPU Scheduling Operating System Fall 2006.
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
Uniprocessor Scheduling Chapter 9 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
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.
Uniprocessor Scheduling
Uniprocessor Scheduling
Introduction What is an operating system bootstrap
Uniprocessor Scheduling
Presentation transcript:

1 Multilevel Feedback Queue Scheduling Another way to put a preference on short-lived processes –Penalize processes that have been running longer. Preemptive CPU Ready Queue 0 dispatched Timeout admitted CPU Ready Queue 1 dispatched CPU Ready Queue 2 dispatched Timeout (RR) Processes in RQ1 are scheduled only when no processes exist in RQ0. Processes in RQ2 are scheduled only when no processes exist in RQ1. Longer processes gradually drift downward. Timeout

P1 P2 P3 P4 P5 MFQ tq=1 ProcessArrival TimeProcess Exec Time 103 msec 226 msec 344 msec 465 msec 582 msec Assume 3 ready queues

P1 P2 P3 P4 P5 MFQ tq=1 ProcessArrival TimeProcess Exec Time 103 msec 226 msec 344 msec 465 msec 582 msec Assume 3 ready queues TNT 4-0 = 44/3=1… 20-2=1818/6=3 16-4=1212/4=3 19-6=1313/5=2… 11-8=33/2=1.5 Avg TAvg NT

P1 P2 P3 P4 P5 MFQ tq=1 TNT 4-0 = 44/3=1… 20-2=1818/6=3 16-4=1212/4=3 19-6=1313/5=2… 11-8=33/2=1.5 Avg TAvg NT P1 P2 P3 P4 P5 RR tq=1 TNT 4-0 = 44/3=1… 18-2=1616/6=2… 17-4=1313/4=3… 20-6=1414/5=2… 15-8=77/2=3… Avg TAvg NT ProcessArrival TimeProcess Exec Time 103 msec 226 msec 344 msec 465 msec 582 msec 17 context switches 18 context switches

5 Favors newer, shorter processes over older, longer processes. Leaves I/O-bound processes at higher queues An issue: possible starvation for long processes –If new short processes continuously enters the OS. Different time quantum (time slice) values in different ready queues. –2 i msec, where i indicates the ID of ready queue 1 msec for RQ0 2 msec for RQ1 4 msec for RQ2

P1 P2 P3 P4 P5 MFQ tq=2 i ProcessArrival TimeProcess Exec Time 103 msec 226 msec 344 msec 465 msec 582 msec Assume 3 ready queues

P1 P2 P3 P4 P5 MFQ tq=2 i ProcessArrival TimeProcess Exec Time 103 msec 226 msec 344 msec 465 msec 582 msec Assume 3 ready queues TNT 3-0 = 33/3=1 17-2=1515/6=2… 18-4=1414/4=3… 20-6=1414/5=2… 14-8=66/2=3 Avg TAvg NT

P1 P2 P3 P4 P5 MFQ tq=2 i TNT 4-0 = 44/3=1… 17-2=1515/6=2… 18-4=1414/4=3… 20-6=1414/5=2… 14-8=66/2=3 Avg TAvg NT P1 P2 P3 P4 P5 MFQ tq=1 4-0 = 44/3=1… 20-2=1818/6=3 16-4=1212/4=3 19-6=1313/5=2… 11-8=33/2=1.5 Avg TAvg NT P1 P2 P3 P4 P5 RR tq=1 4-0 = 44/3=1… 18-2=1616/6=2… 17-4=1313/4=3… 20-6=1414/5=2… 15-8=77/2=3… Avg TAvg NT P1 P2 P3 P4 P5 RR tq=4 3-0 = 33/3=1 17-2=1515/6=2… 11-4=77/4=1… 20-6=1414/5=2… 19-8=1111/2=5.5 Avg TAvg NT context switches 17 context switches 6 context switches 18 context switches

9 Variants of MFQ CPU Ready Queue 0 dispatched timeout admitted CPU Ready Queue 1 dispatched CPU Ready Queue 2 FCFS timeout Using FCFS at the lowest queue to avoid the starvation for long-lived processes –Rather than RR

10 Using aging promotion to avoid starvation for long- lived processes –Promote a process to a higher queue after it spends a certain amount of time waiting in the current RQ. CPU Ready Queue 0 dispatched Timeout admitted CPU Ready Queue 1 dispatched CPU Ready Queue 2 dispatched Timeout (RR) Timeout Promotion based on aging

11 Priority Scheduling Previous scheduling algorithms consider the concept of priority. –Short-lived or long-lived? –CPU-bound or I/O-bound? i.e., Priorities are determined with internal measurable characteristics of a process. External characteristics of a process –Time-sharing, batch (SVR3, 4.3BSD) –Real-time, system, time-sharing (SVR4, 4.4BSD) –Real-time, system, time-sharing, interactive (Solaris 9) –Real-time, system, time-sharing, interactive, batch

12 CPU Ready Queue 0 admitted dispatched exit interrupted I/O type 1 wait I/O 1 completed I/O 1 Blocked Queue I/O N Blocked Queue I/O type N wait I/O N completed Design choices: Preemptive or non-preemptive? Same or different time slices to different ready queue? Fixed or dynamic priorities? Potential issue: Lower-priority processes may suffer starvation. Workaround: promotion with aging Ready Queue 1 Ready Queue N

13 Traditional Unix Scheduling “Traditional” means –No consideration on realtime processes. –Typically 4.3BSD and SVR3 MFQ-based –Preemptive (time quantum based) –Round robin in the same priority queue –Same time quantum to different priority queues –Dynamic priority assignment Priority –Integer value between 0 and 127 Numerically lower values correspond to higher priorities. Priorities between 0 and 49 are reserved for the kernel Priorities between 50 and 127 are for user-level programs

14 PCB: the most important data structure in an OS –Process identification PID –CPU state information The contents of CPU registers Program counter –Indicates the address of the next instruction to be executed. –Process control information Event that a process is waiting on. I/O status (e.g., open files) Scheduling info Process Control Block User Program User Data/Stack Kernel Stack Process Image

15 PCB contains, as process scheduling info, –Current scheduling priority (pri) –User mode priority (usrpri) –Measure of recent CPU utilization (cpu) –Nice value (user-controllable adjustment factor; nice) Current scheduling priority (pri) –Used to decide which process to schedule. –Same as user mode priority (usrpri), when a process is in user mode. –Goes down to place higher priority to kernel mode processing upon I/O completion. Down to a predefined priority (0 =< sleep priority =< 49). –20 for disk I/O This enables a prompt I/O completion (a prompt completion of system call). –Replaced with the current user mode priority (usrpri) when it is back in use mode.

16 7-State Process Behavior Model Ready: The process is in main memory and available for execution. Blocked: The process is in main memory and blocked on an event. Blocked, suspended: The process is in virtual memory and blocked on an event. Ready, suspended: The process is in virtual memory but is available for execution as soon as it is loaded to main memory. Ready, Suspended ReadyRunningTerminated Blocked activated Dispatched to a CPU interrupted I/O or event wait Event completion exit Blocked, Suspended Suspended New admitted activated

17 User mode priority (usrpri) –Depends two factors: Recent CPU utilization (cpu) Nice value (nice) CPU utilization –Initialized to 0 when a process is created. –Incremented (for the currently-running process) at every clock interrupt. 10 msec Nice value –An integer value between 0 and 39 The default value is 20. –Increasing this value decreases the priority. Only OS administrators can decrease it. –The nice command is used to change the nice value for each process. Accepts -20 to 19 as an increment to the current value.

18 cpu j (i) –CPU utilization by process j through interval i. –Unit time for i: 10 msec. DR: decay rate –cpu j is reduced by a decay factor. –1/2 in SVR3. PUSER (baseline priority): 50 –used to divide processes into fixed bands of priority levels. Every second, user mode priority (usrpri) is updated as follows:

19 An Example DR: 1/2 PUSER: 50 nice: 0 3 processes in the same priority band Process 1 usrpri cpu Process 2 usrpri cpu Process 3 usrpri cpu Time