Example: CPU-bound process that would run for 100 quanta continuously 1, 2, 4, 8, 16, 32, 64 (only 37 required for last run) Needs only 7 swaps

Similar documents
Course Syllabus. Operating Systems

8: Scheduling. Scheduling. Mark Handley

Last Class: Processes

Announcements. Program #1. Program #0. Reading. Is due at 9:00 AM on Thursday. Re-grade requests are due by Monday at 11:59:59 PM.

Operating Systems. Lecture Process Scheduling. Golestan University. Hossein Momeni

Today s class. Scheduling. Informationsteknologi. Tuesday, October 9, 2007 Computer Systems/Operating Systems - Class 14 1

Uniprocessor Scheduling

Process behavior. Categories of scheduling algorithms.

CS 326: Operating Systems. CPU Scheduling. Lecture 6

Uniprocessor Scheduling. Aim of Scheduling

Uniprocessor Scheduling. Aim of Scheduling. Types of Scheduling. Long-Term Scheduling. Chapter 9. Response time Throughput Processor efficiency

Frequently asked questions from the previous class survey

Ch 4 : CPU scheduling

Uniprocessor Scheduling. Basic Concepts Scheduling Criteria Scheduling Algorithms. Three level scheduling

Scheduling II. Today. Next Time. ! Proportional-share scheduling! Multilevel-feedback queue! Multiprocessor scheduling. !

Announcements. Program #1. Reading. Due 2/15 at 5:00 pm. Finish scheduling Process Synchronization: Chapter 6 (8 th Ed) or Chapter 7 (6 th Ed)

Interactive Scheduling

Two Level Scheduling. Interactive Scheduling. Our Earlier Example. Round Robin Scheduling. Round Robin Schedule. Round Robin Schedule

Scheduling. Scheduling. Scheduling. Scheduling Criteria. Priorities. Scheduling

Scheduling. Today. Next Time Process interaction & communication

Announcements/Reminders

OPERATING SYSTEMS. After A.S.Tanenbaum, Modern Operating Systems, 3rd edition. Uses content with permission from Assoc. Prof. Florin Fortis, PhD

Scheduling Bits & Pieces

Scheduling of processes

Operating Systems. Scheduling

Review. Preview. Three Level Scheduler. Scheduler. Process behavior. Effective CPU Scheduler is essential. Process Scheduling

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

CSCE Operating Systems Scheduling. Qiang Zeng, Ph.D. Fall 2018

CPU Scheduling. CSE 2431: Introduction to Operating Systems Reading: Chapter 6, [OSC] (except Sections )

CISC 7310X. C05: CPU Scheduling. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/1/2018 CUNY Brooklyn College

Announcements. Reading. Project #1 due in 1 week at 5:00 pm Scheduling Chapter 6 (6 th ed) or Chapter 5 (8 th ed) CMSC 412 S14 (lect 5)

CPU Scheduling. Operating Systems (Fall/Winter 2018) Yajin Zhou ( Zhejiang University

The different Unix contexts

Preview. Process Scheduler. Process Scheduling Algorithms for Batch System. Process Scheduling Algorithms for Interactive System

Process Scheduling. Copyright : University of Illinois CS 241 Staff

Scheduling in the Supermarket

CPU Scheduling. The scheduling problem: When do we make decision? - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s)

W4118: advanced scheduling

CPU Scheduling. The scheduling problem: When do we make decision? - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s)

Chapter 9. Uniprocessor Scheduling

ò mm_struct represents an address space in kernel ò task represents a thread in the kernel ò A task points to 0 or 1 mm_structs

Scheduling. Don Porter CSE 306

Advanced Operating Systems (CS 202) Scheduling (2)

Multiprocessor and Real-Time Scheduling. Chapter 10

CS370 Operating Systems

Multiprocessor and Real- Time Scheduling. Chapter 10

CSCI-GA Operating Systems Lecture 3: Processes and Threads -Part 2 Scheduling Hubertus Franke

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

LECTURE 3:CPU SCHEDULING

CPU Scheduling. The scheduling problem: When do we make decision? - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s)

CSE120 Principles of Operating Systems. Prof Yuanyuan (YY) Zhou Scheduling

Lecture 5 / Chapter 6 (CPU Scheduling) Basic Concepts. Scheduling Criteria Scheduling Algorithms

Chapter 5: CPU Scheduling

Chap 7, 8: Scheduling. Dongkun Shin, SKKU

1.1 CPU I/O Burst Cycle

Chapter 9 Uniprocessor Scheduling

Multi-Level Feedback Queues

CHAPTER III SCHEDULING. Jehan-François Pâris

Uniprocessor Scheduling. Chapter 9

Operating Systems. Process scheduling. Thomas Ropars.

SIMULATION-BASED COMPARISON OF SCHEDULING TECHNIQUES IN MULTIPROGRAMMING OPERATING SYSTEMS ON SINGLE AND MULTI-CORE PROCESSORS *

Last Class: CPU Scheduling! Adjusting Priorities in MLFQ!

Operating System Review Part

CPU Scheduling. Daniel Mosse. (Most slides are from Sherif Khattab and Silberschatz, Galvin and Gagne 2013)

CS3733: Operating Systems

Advanced Operating Systems (CS 202) Scheduling (1)

COSC243 Part 2: Operating Systems

Scheduling Mar. 19, 2018

Start of Lecture: February 10, Chapter 6: Scheduling

Lecture Topics. Announcements. Today: Advanced Scheduling (Stallings, chapter ) Next: Deadlock (Stallings, chapter

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Properties of Processes

Midterm Exam Amy Murphy 6 March 2002

238P: Operating Systems. Lecture 14: Process scheduling

CSL373: Lecture 6 CPU Scheduling

Unit 3 : Process Management

Scheduling. The Basics

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

Practice Exercises 305

Midterm Exam Amy Murphy 19 March 2003

Last class: Today: CPU Scheduling. CPU Scheduling Algorithms and Systems

Scheduling. Scheduling 1/51

CPU Scheduling Algorithms

CS370 Operating Systems

Subject Name: OPERATING SYSTEMS. Subject Code: 10EC65. Prepared By: Kala H S and Remya R. Department: ECE. Date:

CS418 Operating Systems

CS 318 Principles of Operating Systems

Scheduling II. q q q q. Proportional-share scheduling Multilevel-feedback queue Multiprocessor scheduling Next Time: Memory management

Chapter 5: Process Scheduling

Chapter 5 CPU scheduling

2. The shared resource(s) in the dining philosophers problem is(are) a. forks. b. food. c. seats at a circular table.

1 Textbook scheduling. 2 Priority scheduling. 3 Advanced scheduling topics. - What goals should we have for a scheduling algorithm?

Chapter 5: CPU Scheduling

Chapter 5: CPU Scheduling

Chapter 5: CPU Scheduling. Operating System Concepts Essentials 8 th Edition

Chap 7, 8: Scheduling. Dongkun Shin, SKKU

CPU Scheduling: Objectives

Chapter 5 Scheduling

Lecture Topics. Announcements. Today: Uniprocessor Scheduling (Stallings, chapter ) Next: Advanced Scheduling (Stallings, chapter

Transcription:

Interactive Scheduling Algorithms Continued o Priority Scheduling Introduction Round-robin assumes all processes are equal often not the case Assign a priority to each process, and always choose the process with the highest priority Problem highest priority process could run indefinitely Possible solution: decrease priority at each clock interrupt until it has lower priority Can be used to achieve system goals Example I/O bound processes o Spend most time waiting for I/O to finish o Should get CPU quickly to make the next I/O request Assign priority of 1/f to each process o f = fraction of the last quantum used 1msec of 50msec quantum = 50 25msec of 50msec = 2 50msec of 50msec = 1 Priority classes can also be used Use priority scheduling among classes Use round-robin within each class Priorities must be adjusted so the lower priority classes won t be starved o Multiple Queues Attempt to reduce context switches without hurting response time Set up a cascade of priority classes Highest priority runs for one quantum Second highest runs for 2 Third highest runs for 4 Etc. Processes that use up their quanta are moved down a priority class Result: CPU-bound processes run longer, but less often

Example: CPU-bound process that would run for 100 quanta continuously 1, 2, 4, 8, 16, 32, 64 (only 37 required for last run) Needs only 7 swaps (including initial load) as opposed to 100 for round robin Negative long-running processes could be punished and not get the CPU often if there are a lot of new interactive processes o Shortest Process Next Use shortest job first for interactive processes Estimate the completion time of jobs based on past history Aging o Guaranteed Scheduling make quantifiable promises to processes Example: If there are n users, each will get 1/n of the CPU power Example: If there are n processes, each will get 1/n of the power Requirements Keep track of the amount of time the CPU has been run on the process Keep track of the time the process has been active Algorithm Compute amount of time the process should have on the CPU (time since creation/n) Divide actual time on CPU by entitled time Example: 0.5 means process has had half as much as entitled Always run the process with the lowest ratio until another process has a small ratio Problem more complicated guarantees are difficult to implement o Lottery scheduling simpler implementation but predictable results Introduction Give processes lottery tickets for CPU time When scheduling, a lottery ticket is chosen at random and that process is given the CPU for a quantum. Lottery tickets can be allocated in any way we want Uniform allocation will result in guaranteed scheduling like above (on average) o Processes with f fraction of the tickets will get f fraction of the CPU New processes that are assigned tickets will immediately have a chance to run Highly responsive Example video server streaming content to clients at different frame rates 10, 20, and 25 frames/sec required Allocated that number of lottery tickets to each process o CPU will be divided up into that proportion automatically

o Fair-Share Scheduling We ve only considered cases where processes are independent (not based on owner) Example: User 1 starts 9 processes and 2 starts 1 process o User 1 will get 90% of the CPU Fair-share scheduling allocates a certain percentage of the CPU to each user instead User 1: Processes A, B, C, D User 2: Process E Fair-share: A E B E C E D E A E Other definitions of fairness can also be used here Multiprocessor scheduling o Introduction Many new processors have multiple cores Always share main memory, sometimes share cache as well Scheduling before: which thread to run to Scheduling after: which threads to run which CPU should each run on Threads can either be unrelated or related Timesharing system: all threads are independent More common: multi-threaded process where the threads communicate frequently Assumptions Multiple cores or CPUs that do not share cache Individual threads are the scheduled elements (related and unrelated) o Timesharing scheduling independent threads Simple approach Maintain single system-wide structure of ready threads When a CPU becomes available, pick the next highest priority thread

Advantages o Single structure time-shares the CPUs o Automatic load balancing (no CPU stays idle with work left to do) Disadvantages o Contention for scheduling structure as # CPUs grow o Context switching overhead (same as uniprocessor) o Ignores any benefits of running a thread on the same CPU, which might have a significant number of cache entries remaining Two-level scheduling let threads run on the same CPU if possible Algorithm o Each CPU maintains its own scheduling structure o When thread is created, assign it to the CPU with the lowest load at the moment (top level) o Scheduling is done at the CPU level, according to priority or some other metric o If a CPU becomes idle, it takes a thread from another CPU Advantages o Threads will often stay on the same CPU (cache benefits) o Load is still roughly evenly distributed o Contention for scheduling data structure is reduced Disadvantages o More complicated to implement o Doesn t take advantage of relationships between threads Example Two threads belong to A and two threads belong to B The threads of A need to communicate frequently, but get scheduled not at the same time

o Message + Reply takes 200ms (very slow) o Space Sharing scheduling related threads at the same time Examples: parallel make, web crawler, most any multi-threaded application where threads communicate with each other Simple approach Algorithm o Assume all related threads are created at once o Scheduler assigns each thread its own dedicated CPU Nonmultiprogrammed Thread holds onto CPU until it terminates I/O blocking doesn t cause thread to lose CPU o If enough CPUs aren t available, threads must wait o First-come, first-served used on the group level Result threads are statically partitioned, each one running a thread Advantages Eliminates context switching overhead Cache benefits are guaranteed Communicating threads can easily cooperate Simple to implement Disadvantages I/O bound threads will waste huge portions of CPU cycles o Gang Scheduling combining timesharing and space sharing Algorithm Divide time into discrete quanta and schedule CPUs synchronously o When a quantum expires, schedule all CPUs again o No scheduling is done in the quantum (CPU idles if blocked) Groups (gangs) of related threads are scheduled as a group o All members run simultaneously on a different timeshared CPU

o Gang members start and end their time slices together Example 6 CPUs and 5 processes (A through E) with 24 ready threads Advantages Reduces possibility of threads getting out of sync and communication being delayed Less CPU cycles are wasted on idle threads because the CPUs are multiprogrammed Disadvantages Requires scheduling synchronization between CPUs Context switching overhead Again requires thread affinity to take advantage of cache contents