Operating System Process Scheduling (Ch 4.2, 5.1 - 5.3)

Slides:



Advertisements
Similar presentations
CH 5. CPU Scheduling Basic Concepts F CPU Scheduling  context switching u CPU switching for another process u saving old PCB and loading.
Advertisements

Operating Systems Process Scheduling (Ch 3.2, )
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 6a: CPU Scheduling.
A. Frank - P. Weisberg Operating Systems Advanced CPU Scheduling.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
CPU Scheduling Section 2.5.
Chapter 3: CPU Scheduling
Operating Systems 1 K. Salah Module 2.1: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation.
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
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Cs238 CPU Scheduling Dr. Alan R. Davis. CPU Scheduling The objective of multiprogramming is to have some process running at all times, to maximize CPU.
5: CPU-Scheduling1 Jerry Breecher OPERATING SYSTEMS SCHEDULING.
Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Silberschatz, Galvin and Gagne ©2007 Chapter 5: CPU Scheduling.
Job scheduling Queue discipline.
Operating Systems Process Scheduling (Ch 4.2, )
02/11/2004CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
1 Lecture 10: Uniprocessor Scheduling. 2 CPU Scheduling n The problem: scheduling the usage of a single processor among all the existing processes in.
1 Inside the Windows NT Scheduler, Part 1 Assigning CPU time in a uniprocessor environment by Mark Russinovich Windows NT Magazine - July 1997 Inside the.
1Chapter 05, Fall 2008 CPU Scheduling The CPU scheduler (sometimes called the dispatcher or short-term scheduler): Selects a process from the ready queue.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Scheduling Dave Eckhardt Outline ● Chapter 6: Scheduling.
Operating Systems Part III: Process Management (CPU 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.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 5 Operating Systems.
Uniprocessor Scheduling
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Scheduler What is the job of.
CPU Scheduling Introduction to Operating Systems: Module 13.
Chapter 6 CPU SCHEDULING.
Fair Resource Access & Allocation  OS Scheduling
1 Scheduling Processes. 2 Processes Each process has state, that includes its text and data, procedure call stack, etc. This state resides in memory.
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.
Operating Systems Lecture Notes CPU Scheduling Matthew Dailey Some material © Silberschatz, Galvin, and Gagne, 2002.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
ICS Principles of Operating Systems Lecture 5 - CPU Scheduling Prof. Nalini Venkatasubramanian
Scheduling. Alternating Sequence of CPU And I/O Bursts.
CPU Scheduling G.Anuradha References : Galvin and William Stallings Problems taken from Principles of OS by Naresh Chauhan.
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
1 Our focus  scheduling a single CPU among all the processes in the system  Key Criteria: Maximize CPU utilization Maximize throughput Minimize waiting.
Alternating Sequence of CPU And I/O Bursts. Histogram of CPU-burst Times.
CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor Scheduling Operating Systems Examples Algorithm.
Peng Lu. CPU Scheduling 1. Basic Concepts 2. Scheduling Criteria 3. Scheduling Algorithms 4. Multiple-Processor Scheduling 5. Real-Time Scheduling 2.
Process A program in execution. But, What does it mean to be “in execution”?
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
1 Uniprocessor Scheduling Chapter 9. 2 Aim of Scheduling Response time Throughput Processor efficiency.
Chapter 5: Process Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Basic Concepts Maximum CPU utilization can be obtained.
Operating Systems 1 K. Salah Module 2.2: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation.
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.
CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling Assign processes to be executed by the processor or processors: –Response time –Throughput –Processor.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 5 CPU Scheduling Slide 1 Chapter 5 CPU Scheduling.
6.1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
Processor Scheduling Hank Levy. 22/4/2016 Goals for Multiprogramming In a multiprogramming system, we try to increase utilization and thruput by overlapping.
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.
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.
Lecture 4 CPU scheduling. Basic Concepts Single Process  one process at a time Maximum CPU utilization obtained with multiprogramming CPU idle :waiting.
CPU Scheduling G.Anuradha Reference : Galvin. CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time.
1 Module 5: Scheduling CPU Scheduling Scheduling Algorithms Reading: Chapter
Basic Concepts Maximum CPU utilization obtained with multiprogramming
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
UNIT–II: Process Management
Chapter 6: CPU Scheduling
Process Scheduling Decide which process should run and for how long
Presentation transcript:

Operating System Process Scheduling (Ch 4.2, )

Schedulers F Short-Term –“Which process gets the CPU?” –Fast, since once per 100 ms F Long-Term (batch) –“Which process gets the Ready Queue?” F Medium-Term (Unix) –“Which Ready Queue process to memory?” –Swapping

CPU-IO Burst Cycle add read (I/O Wait) store increment write (I/O Wait) Burst Duration Frequency

Preemptive Scheduling F Four times to re-schedule 1Running to Waiting (I/O wait) 2Running to Ready (time slice) 3Waiting to Ready (I/O completion) 4Termination F #2 optional ==> “Preemptive” F Timing may cause unexpected results –updating shared variable –kernel saving state

Question F What Performance Criteria Should the Scheduler Seek to Optimize? –Ex: CPU minimize time spent in queue –Others?

Scheduling Criteria 1 CPU utilization (40 to 90) 2 Throughput (processes / hour) 3 Turn-around time 4 Waiting time (in queue) F Maximize #1, #2 Minimize #3, #4 F Response time –Self-regulated by users (go home) –Bounded ==> Variance!

First-Come, First-Served Process A B C Burst Time ABC F Avg Wait Time ( ) / 3 = 5.7 Gantt Chart

Shortest Job First ABC F Avg Wait Time ( ) / 3 = 1 F Optimal Avg Wait F Prediction tough … Ideas? Process A B C Burst Time 8 1

Priority Scheduling F SJF is a special case Process A B C Burst Time 8 1 Priority ABC F Avg Wait Time ( ) / 3 = 3.3

Priority Scheduling Criteria? F Internal –open files –memory requirements –CPU time used- time slice expired (RR) –process age- I/O wait completed F External –$ –department sponsoring work –process importance –super-user (root)- nice

Round Robin F Fixed time-slice and Preemption Process A B C Burst Time 5 3 BCABCABCAA F Avg = ( ) / 3 = 9.3 F FCFS? SJF? 8911

Round Robin Fun Process A B C Burst Time 10 F Turn-around time? –q = 10 –q = 1 –q --> 0

More Round Robin Fun Process A B C D Burst Time Time Quantum Avg. Turn-around Time Rule: 80% within one quantum

Fun with Scheduling Process A B C Burst Time Priority F Gantt Charts: –FCFS –SJF –Priority –RR (q=1) F Performance: –Throughput –Waiting time –Turnaround time

More Fun with Scheduling Process A B C Arrival Time Burst Time F Turn around time: –FCFS –SJF –q=1 CPU idle –q=0.5 CPU idle

Multi-Level Queues System Priority 1 Priority 2 Priority 3 Interactive Batch F Categories of processes F Run all in 1 first, then 2 … F Starvation! F Divide between queues: 70% 1, 15% 2 …...

Multi-Level Feedback Queues Queue Priority 1 Priority 2 Priority 3 Queue 1 Quantum 2 Quanta 4 Quanta F Time slice expensive but want interactive F Consider process needing 100 quanta –1, 4, 8, 16, 32, 64 = 7 swaps! F Favor interactive users...

Evaluating Scheduling Algorithms F With all these possible scheduling algorithms, how to choose one? –Ease of implementation –Efficiency of implementation / low overhead –Performance evaluation (next slide)

Performance Evaluation Methods F Deterministic methods / Gantt charts –Use more realistic workloads F Queueing theory –Mathematical techniques –Uses probablistic models of jobs / CPU utilization F Simulation –Probabilistic or trace-driven

Linux Process Scheduling F Two classes of processes: –Real-Time –Normal F Real-Time: –Always run Real-Time above Normal –Round-Robin or FIFO –“Soft” not “Hard”

Linux Process Scheduling F Normal: Credit-Based –process with most credits is selected –time-slice then lose a credit (0, then suspend) –no runnable process (all suspended), add to every process: credits = credits/2 + priority F Automatically favors I/O bound processes

Questions F What is a PCB? F List steps that occur during interrupt F Explain how SJF works F True or False: –FCFS is optimal in terms of avg waiting time –Most processes are CPU bound –The shorter the time quantum, the better  micro-shell.c ?

Interrupt Handling F Stores program counter (hardware) F Loads new program counter (hardware) –jump to interrupt service procedure F Save PCB information (assembly) F Set up new stack (assembly) F Set “waiting” process to “ready” (C) F Re-schedule (probably awakened process) (C) –“ dispatcher ” in SOS, “ schedule ” in Linux F If new process, called a context-switch

Outline F Processes  –PCB  –Interrupt Handlers  F Scheduling –Algorithms  –Linux –WinNT 

Windows NT Scheduling F Basic scheduling unit is a thread F Priority based scheduling per thread F Preemptive operating system F No shortest job first, no quotas

Priority Assignment F NT kernel uses 31 priority levels –31 is the highest; 0 is system idle thread –Realtime priorities: –Dynamic priorities: F Users specify a priority class: u realtime (24), high (13), normal (8) and idle (4) –and a relative priority: u highest (+2), above normal (+1), normal (0), below normal (-1), and lowest (-2) –to establish the starting priority F Threads also have a current priority

Quantum F Determines how long a Thread runs once selected F Varies based on: –NT Workstation or NT Server –Intel or Alpha hardware –Foreground/Background application threads F How do you think it varies with each?

Dispatcher Ready List F Keeps track of all Ready-to-execute threads F Queue of threads assigned to each level Dispatcher Ready List Ready Threads

FindReadyThread F Locates the highest priority thread that is ready to execute F Scans dispatcher ready list F Picks front thread in highest priority nonempty queue F When is this like round robin?

Boosting and Decay F Boost priority –Event that “wakes” blocked thread –Boosts never exceed priority 15 for dynamic –Realtime priorities are not boosted F Decay priority –by one for each quantum –decays only to starting priority (no lower)

Starvation Prevention F Low priority threads may never execute F “Anti-CPU starvation policy” –thread that has not executed for 3 seconds –boost priority to 15 –double quantum F Decay is swift not gradual after this boost