Operating Systems Part III: Process Management (CPU Scheduling)

Slides:



Advertisements
Similar presentations
CPU Scheduling.
Advertisements

CH 5. CPU Scheduling Basic Concepts F CPU Scheduling  context switching u CPU switching for another process u saving old PCB and loading.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 6a: CPU Scheduling.
 Basic Concepts  Scheduling Criteria  Scheduling Algorithms.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
Chap 5 Process Scheduling. Basic Concepts Maximum CPU utilization obtained with multiprogramming CPU–I/O Burst Cycle – Process execution consists of a.
Chapter 5 CPU Scheduling. CPU Scheduling Topics: Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
CPU Scheduling CS 3100 CPU Scheduling1. Objectives To introduce CPU scheduling, which is the basis for multiprogrammed operating systems To describe various.
Chapter 3: CPU Scheduling
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Cs238 CPU Scheduling Dr. Alan R. Davis.
CS 311 – Lecture 23 Outline Kernel – Process subsystem Process scheduling Scheduling algorithms User mode and kernel mode Lecture 231CS Operating.
Chapter 6: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Chapter 6: CPU Scheduling Basic.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
What we will cover…  CPU Scheduling  Basic Concepts  Scheduling Criteria  Scheduling Algorithms  Evaluations 1-1 Lecture 4.
Chapter 5-CPU Scheduling
02/11/2004CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
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 – 7 th Edition, Feb 2, 2005 Basic Concepts Maximum CPU utilization.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: Process Scheduling.
CS212: OPERATING SYSTEM Lecture 3: Process Scheduling 1.
OPERATING SYSTEMS CPU SCHEDULING.  Introduction to CPU scheduling Introduction to CPU scheduling  Dispatcher Dispatcher  Terms used in CPU scheduling.
Operating Systems (CS 340 D)
CPU S CHEDULING Lecture: Operating System Concepts Lecturer: Pooja Sharma Computer Science Department, Punjabi University, Patiala.
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
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor Scheduling Operating Systems Examples Algorithm.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 5: CPU 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.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Chapter 5: CPU Scheduling Basic.
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.
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.
CPU scheduling.  Single Process  one process at a time  Maximum CPU utilization obtained with multiprogramming  CPU idle :waiting time is wasted 2.
1 Module 5: Scheduling CPU Scheduling Scheduling Algorithms Reading: Chapter
Basic Concepts Maximum CPU utilization obtained with multiprogramming
 In a single-processor system, only one process can run at a time; any others must wait until the CPU is free and can be rescheduled.  The objective.
1 Chapter 5: CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms.
CPU SCHEDULING.
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
3: CPU Scheduling Basic Concepts Scheduling Criteria
Chapter5: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Operating System , Fall 2000 EA101 W 9:00-10:00 F 9:00-11:00
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Presentation transcript:

Operating Systems Part III: Process Management (CPU Scheduling)

CPU-I/O Burst Cycle CPU burst - CPU executes process I/O burst - process does I/O Processes go back & forth between 2 states Frequency curve of CPU bursts is inverse exponential: – Large number of short CPU bursts, small number of long CPU bursts CPU-bound: few but long CPU bursts I/O-bound: many very short CPU bursts

Preemptive & Non-preemptive Scheduling CPU decisions needed in: – switching from running to waiting (i/o request) – switching from running to ready (timer interrupt) – switching from waiting to ready (i/o done) – process termination 1 st and 4 th : no choice in terms of scheduling: new process must be selected for execution 2 nd and 3 rd : scheduling is pre-empted

Preemptive & Non-preemptive Scheduling Non-preemptive scheduling – Once CPU is allocated to a process, it is released only by termination or waiting – Does not need special hardware (timer)

Preemptive & Non-preemptive Scheduling Preemptive scheduling – Processes may be interrupted any time – Costly because: shared data update by a process may be preempted kernel process may be preempted (e.g. medium-term scheduler) solution: wait for system call to finish -> not good for real- time computing

Dispatcher Gives control to process selected by short-term scheduler Does: – Context-switching – Switching to user-mode – Jumping to program location to start it Dispatch latency - time it takes the dispatcher to stop one process and start another running

Scheduling Criteria CPU utilization - keep CPU busy (40% - 100%) Throughput - number of processes completed per unit time Maximize these.

Scheduling Criteria Waiting time - sum of time spent in ready queue Turnaround time - time it takes to execute process (from submission to completion) Response time - time it takes to start responding (from submission to first response); does not include time to output response Minimize the above.

Scheduling Algorithms Scheduling: which process in the ready queue is to be run (allocated to the CPU)? First Come First Served (FCFS) – Easily managed by a FIFO queue – Simple to write and understand – Long waiting time depending on order of process – Non-preemptive

Scheduling Algorithms Shortest Job First (SJF) – CPU assigned to process that has shortest next CPU burst – FCFS used for processes that have same length – Can be proved to be optimal (minimum waiting time) – Difficulty is determining length or time duration of next CPU burst.

Scheduling Algorithms Shortest Job First (continued) – Determining length or time duration of next CPU burst: approximate by using the exponential average of the job's previous CPU bursts. – t n is the length of the nth CPU burst (previous), ξ n+1 the predicted value for the next CPU burst: ξ n+1 = α t n + (1 – α ) ξ n

Scheduling Algorithms Shortest Job First (continued) – Long-term scheduling (batch system): length of process time limit specified by user – Short-term scheduling: SJF cannot be implemented since there’s no way to know length of next CPU burst Implementation relies on predicting length of next CPU burst, using the previous formula

Scheduling Algorithms Shortest Job First (continued) – May be: Preemptive - also called shortest-remaining-time-first Non-preemptive - allows current process to finish

Scheduling Algorithms Priority Scheduling – A priority is associated with each process. CPU is allocated to process with the highest priority. Equal priority processes are scheduled in FCFS order or SJF order. – SJF special case of priority scheduling algorithm. CPU is allocated to process with shortest next burst (highest priority), and longest next burst has lowest priority.

Scheduling Algorithms Priority Scheduling (continued) – Priority defined either Internally - measurable quantities to compute priority (memory requirements, time limits, number of open files, etc.) Externally - set by criteria outside the O/S (importance of process, funded projects, etc.) – Scheduling is also preemptive or non-preemptive

Scheduling Algorithms Priority Scheduling (continued) – Indefinite blocking or starvation - can leave low priority processes starving for CPU allocation – Solution: Aging - low priority process gradually increases priority until it is finally allocated to the CPU

Scheduling Algorithms Round-Robin Scheduling – Designed specifically for time-sharing systems – Similar to FCFS but with preemption – Time quantum or time slice is defined (typically between 10 and 100 milliseconds) – CPU goes around ready queue allocating 1 time quantum to each process

Scheduling Algorithms Round-Robin Scheduling (continued) – Two things can happen: Process takes up 1 time quantum, or Process gives CPU up voluntarily

Scheduling Algorithms Round-Robin Scheduling (continued) – Performance depends heavily on size of time quantum, n n is very small - called processor sharing (virtual processor runs at 1/n the speed) -> smaller time quantum increases context-switching -> make time-quantum >> context switch (10%) n is large - scheduling degenerates to FCFS policy Rule of thumb: 80% of CPU bursts should be shorter than time quantum

Scheduling Algorithms Multilevel Queue Scheduling – Ready queue classified into several groups – Processes are permanently assigned to a queue depending on priority, memory size, etc. (e.g. separate queues used for foreground and background processes) – Examples: Absolute priority: System -> Interactive -> Batch -> Low- priority Time-slice: 80% foreground, 20% background

Scheduling Algorithms Multilevel Feedback Queue Scheduling – Allows processes to move between queues – Separate processes w/ different CPU burst characteristics Too much CPU time -> move to low-priority queue I/O-bound and interactive -> high-priority queue Use aging : if process waits too long in low-priority queue - > move to high-priority queue to prevent starvation

Scheduling Algorithms Multilevel Feedback Queue (continued) – General parameters: Number of queues Scheduling algorithm for each queue Method to upgrade process to high-priority queue Method to demote process to low-priority queue Method to determine what queue a process will enter – Considered the most general (can be configured to fit a system), but also the most complex

Multiprocessor Scheduling Scheduling process becomes more complex Many possibilities tried, no one best solution Heterogeneous system – Processors are different (e.g. distributed system) – Process can only run on processor it was compiled in

Multiprocessor Scheduling Homogenous system – Identical CPUs within a multiprocessor system – Process can run in any CPU – Can have load sharing Separate queue for each processor May have one processor busy while another is idle (empty queue) Remedied with a common ready queue

Multiprocessor Scheduling Homogeneous system (continued) – Load sharing - 2 possibilities Self-scheduling (symmetric scheduling) SMP - each processor examines queue and selects process to execute -> careful programming to ensure no two processors choose the same process Master-slave (asymmetric scheduling) - one processor is appointed as scheduler -> in some systems, other system activities are performed by the master, slaves only execute user code

Real-Time Scheduling Hard real-time – Resource reservation -> scheduler either admits a process w/ guaranteed response time, or rejects it – Guarantee impossible for systems with virtual memory or secondary storage – Composed of special software running hardware dedicated to critical processes Soft real-time -> less restrictive – Requires only that critical processes receive priority – Can support multimedia & high speed graphics

Algorithm Analysis Analytic Evaluation – Uses an algorithm and the system workload to produce a formula to evaluate performance – Deterministic Modeling Takes a particular predetermined workload and defines performance of each algorithm for that (sample) workload Simple, fast, and gives exact numbers (input/output) Requires too specific and too much exact knowledge to be useful -> processes that run daily vary greatly

Algorithm Analysis Queueing Models – CPU burst distribution is used instead of predetermined workload Simulations – Uses software to simulate major system components – Expensive -> requires hours of computer time – Design, coding, and debugging of simulator is complex

Algorithm Analysis Implementation – Simulations have limited accuracy – Only way to find out is to implement – Puts algorithm to test in real environment – Disadvantages: Cost Reaction of users to constantly changing O/S