Processes. Criteria for Comparing Scheduling Algorithms

Similar documents
Cyber-Physical Systems Scheduling

CS 5523: Operating Systems

Final Review. Chenyang Lu. CSE 467S Embedded Compu5ng Systems

Operating Systems. Chenyang Lu

File Systems: Fundamentals

Concurrent Programing: Why you should care, deeply. Don Porter Portions courtesy Emmett Witchel

Real-Time Scheduling Single Processor. Chenyang Lu

Last Time. Bit banged SPI I2C LIN Ethernet. u Embedded networks. Ø Characteristics Ø Requirements Ø Simple embedded LANs

CS 2461: Computer Architecture I

Adaptive QoS Control for Real-Time Systems

Batch binary Edwards. D. J. Bernstein University of Illinois at Chicago NSF ITR

HPCG on Tianhe2. Yutong Lu 1,Chao Yang 2, Yunfei Du 1

Quality of Service in Optical Telecommunication Networks

Effect of Voting Machine Shortages in Franklin County, Ohio General Election

Civil Justice Improvements (CJI) Committee. Update #2

IBM Cognos Open Mic Cognos Analytics 11 Part nd June, IBM Corporation

CS 5523 Operating Systems: Synchronization in Distributed Systems

Lesson Title: Redistricting in Pennsylvania

Key Considerations for Implementing Bodies and Oversight Actors

Critiques. Ø Critique #1

Product Description

TinyOS and nesc. Ø TinyOS: OS for wireless sensor networks. Ø nesc: programming language for TinyOS.

Whose case is it? Calendar and Trial Management 10/18/2011. NACM Core Competencies BEDROCK PRINCIPLE

Overview. Ø Neural Networks are considered black-box models Ø They are complex and do not provide much insight into variable relationships

Recommendations For Reddit Users Avideh Taalimanesh and Mohammad Aleagha Stanford University, December 2012

College Voting in the 2018 Midterms: A Survey of US College Students. (Medium)

Servilla: Service Provisioning in Wireless Sensor Networks. Chenyang Lu

Congressional samples Juho Lamminmäki

Report No. UCB/CSD November Computer Science Division (EECS) University of California. Berkeley, California 94720

Fall Detection for Older Adults with Wearables. Chenyang Lu

SMS based Voting System

The EPO approach to Computer Implemented Inventions (CII) Yannis Skulikaris Director Operations, Information and Communications Technology

SIERRA LEONE 2012 ELECTIONS PROJECT PRE-ANALYSIS PLAN: POLLING CENTERCONSTITUENCY LEVEL INTERVENTIONS

COLORADO LOTTERY 2014 IMAGE STUDY

Ø Project Description. Ø Design Criteria. Ø Design Overview. Ø Design Components. Ø Schedule. Ø Testing Criteria. Background Design Implementation

FM Legacy Converter User Guide

JD Edwards EnterpriseOne Applications

Real-Time CORBA. Chenyang Lu CSE 520S

Probabilistic earthquake early warning in complex earth models using prior sampling

CSE 520S Real-Time Systems

A comparative analysis of subreddit recommenders for Reddit

Software License Agreement for Beckhoff Software Products

Board Chairman's Guide

Estonian National Electoral Committee. E-Voting System. General Overview

Cluster Analysis. (see also: Segmentation)

A procedure to compute a probabilistic bound for the maximum tardiness using stochastic simulation

Local differential privacy

A Micro-Benchmark Evaluation of Catamount and Cray Linux Environment (CLE) Performance

ALEX4.2 A program for the simulation and the evaluation of electoral systems

Inviscid TotalABA Help

Data Processing Development

Peregian Springs State School mlearning P 3 BYO ipad Program 2018 Frequently Asked Questions Updated 10 October 2017

SMALL STATES FIRST; LARGE STATES LAST; WITH A SPORTS PLAYOFF SYSTEM

My Health Online 2017 Website Update Online Appointments User Guide

Implementing Domain Specific Languages using Dependent Types and Partial Evaluation

UNITED STATES OF AMERICA BEFORE THE FEDERAL ENERGY REGULATORY COMMISSION. NORTH AMERICAN ELECTRIC ) Docket No. RR RELIABILITY CORPORATION )

Performance & Energy

Random Forests. Gradient Boosting. and. Bagging and Boosting

COULD SIMULATION OPTIMIZATION HAVE PREVENTED 2012 CENTRAL FLORIDA ELECTION LINES?

CS 4407 Algorithms Greedy Algorithms and Minimum Spanning Trees

11/7/2011. Section 1: Answering the Three Economic Questions. Section 2: The Free Market

A New Method of the Single Transferable Vote and its Axiomatic Justification

A secure environment for trading

Procedural Justice: Fair Treatment Matters

1.2 Efficiency and Social Justice

HOUSE OF REPRESENTATIVES COMMITTEE ON BUSINESS REGULATION ANALYSIS

National Christian Forensics and Communications Association. Judging Team Policy Debate Manual

An Algorithmic and Computational Approach to Optimizing Gerrymandering

A Calculus for End-to-end Statistical Service Guarantees

Stakeholder Governance Guide

An Electronic Voting System for a Legislative Assembly

Supreme Court of Florida

OFFICIAL BOROUGH OF CONWAY: RESOLUTION No

Key Considerations for Oversight Actors

Exploring QR Factorization on GPU for Quantum Monte Carlo Simulation

POLITICAL NEUTRALITY POLICY

Digital research data in the Sigma2 prospective

Genetic Algorithms with Elitism-Based Immigrants for Changing Optimization Problems

Case 1:18-cv TWP-MPB Document 1 Filed 01/04/18 Page 1 of 17 PageID #: 1

Chapter 2: Economic Systems Section 3

ROOMSKETCHER GENERAL COMMERCIAL TERMS AND CONDITIONS

Summary The Beginnings of Industrialization KEY IDEA The Industrial Revolution started in Great Britain and soon spread elsewhere.

WORKGROUP S CONSENSUS PROCESS AND GUIDING PRINCIPLES CONSENSUS

CASE WEIGHTING STUDY PROPOSAL FOR THE UKRAINE COURT SYSTEM

Political Economics II Spring Lectures 4-5 Part II Partisan Politics and Political Agency. Torsten Persson, IIES

European Law Moot Court The Rules

In Elections, Irrelevant Alternatives Provide Relevant Data

INTRODUCTION THE MEANING OF PARTY

City of Bellingham Residential Survey 2013

CENTRAL CATALOGUE OF OFFICIAL DOCUMENTS OF THE REPUBLIC OF CROATIA

Subreddit Recommendations within Reddit Communities

One View Watchlists Implementation Guide Release 9.2

Deadlock. deadlock analysis - primitive processes, parallel composition, avoidance

Simulating Electoral College Results using Ranked Choice Voting if a Strong Third Party Candidate were in the Election Race

HANDBOOK FOR JURORS: A Concise Summary

Voting Criteria April

General Framework of Electronic Voting and Implementation thereof at National Elections in Estonia

Learning Systems. Research at the Intersection of Machine Learning & Data Systems. Joseph E. Gonzalez

1 Electoral Competition under Certainty

Legal Deposit Copy Act

Transcription:

1 Processes Scheduling Processes Scheduling Processes Don Porter Portions courtesy Emmett Witchel Each process has state, that includes its text and data, procedure call stack, etc. This state resides in memory. The OS also stores process metadata for each process. This state is called the Process Control Block (PCB), and it includes the PC, SP, register states, execution state, etc. All of the processes that the OS is currently managing reside in one and only one of these states. Multiprocessing (concurrency) - one process on the CPU running, and one or more doing I/O enables the OS to increase system utilization and throughput by overlapping I/O and CPU activities. Long Term Scheduling: How does the OS determine the degree of multiprogramming, i.e., the number of jobs executing at once in the primary memory? Short Term Scheduling: How does (or should) the OS select a process from the ready queue to execute? Ø Policy Goals Ø Policy Options Ø Implementation considerations 2 3 Short Term Scheduling Criteria for Comparing Scheduling Algorithms The kernel runs the scheduler at least when Ø a process switches from running to waiting (blocks) Ø a process is created or terminated. Ø an interrupt occurs (e.g., timer chip) Non-preemptive system Ø Scheduler runs when process blocks or is created, not on hardware interrupts Preemptive system Ø OS makes scheduling decisions during interrupts, mostly timer, but also system calls and other hardware device interrupts CPU Utilization The percentage of time that the CPU is busy. Throughput The number of processes completing in a unit of time. Turnaround time The length of time it takes to run a process from initialization to termination, including all the waiting time. Waiting time The total amount of time that a process is in the ready queue. Response time The time between when a process is ready to run and its next I/O request. Ideal CPU scheduler Ø Maximizes CPU utilization and throughput Ø Minimizes turnaround time, waiting time, and response time Real CPU schedulers implement particular policy Ø Minimize response time - provide output to the user as quickly as possible and process their input as soon as it is received. Ø Minimize variance of average response time - in an interactive system, predictability may be more important than a low average with a high variance. Ø Maximize throughput - two components 1. minimize overhead (OS overhead, context switching) 2. efficient use of system resources (CPU, I/O devices) Ø Minimize waiting time - be fair by ensuring each process waits the same amount of time. This goal often increases average response time. Will a fair scheduling algorithm maximize throughput? A) Yes B) No 4 5 6

7 Process activity patterns CPU bound Ø mp3 encoding Ø Scientific applications (matrix multiplication) Ø Compile a program or document I/O bound Ø Index a file system Ø Browse small web pages Balanced Ø Playing video Ø Moving windows around/fast window updates Scheduling algorithms reward I/O bound and penalize CPU bound Ø Why? Simplifying Assumptions Ø One process per user Ø One thread per process (more on this topic next week) Ø Processes are independent Researchers developed these algorithms in the 70 s when these assumptions were more realistic, and it is still an open problem how to relax these assumptions. Scheduling Algorithms: Ø FCFS: First Come, First Served Ø Round Robin: Use a time slice and preemption to alternate jobs. Ø SJF: Shortest Job First Ø Multilevel Feedback Queues: Round robin on priority queue. Ø : Jobs get tickets and scheduler randomly picks winning ticket. FCFS: First-Come-First-Served (or FIFO: First-In-First-Out) The scheduler executes jobs to completion in arrival order. In early FCFS schedulers, the job did not relinquish the CPU even when it was doing I/O. We will assume a FCFS scheduler that runs when processes are blocked on I/O, but that is nonpreemptive, i.e., the job keeps the CPU until it blocks (say on an I/O device). 8 9 FCFS Scheduling Policy In a non-preemptive system, the scheduler must wait for one of these events, but in a preemptive system the scheduler can interrupt a running process. If the processes arrive one time unit apart, what is the average wait time in these three cases? Advantages: Disadvantages Round Robin: very common base policy. Run each process for its time slice (scheduling quantum) After each time slice, move the running thread to the back of the queue. Selecting a time slice: Ø Too large - waiting time suffers, degenerates to FCFS if processes are never preempted. Ø Too small - throughput suffers because too much time is spent context switching. Ø Balance the two by selecting a time slice where context switching is roughly 1% of the time slice. A typical time slice today is between 10-100 milliseconds, with a context switch time of 0.1 to 1 millisecond. Ø Max Linux time slice is 3,200ms, Why? Is round robin more fair than FCFS? A)Yes B)No 5 jobs, 100 seconds each, time slice 1 second, context switch time of 0, jobs arrive at time 0,1,2,3,4 1 100 2 100 3 100 4 100 5 100 10 11 12

13 5 jobs, 100 seconds each, time slice 1 second, context switch time of 0, jobs arrive at time 0,1,2,3,4 1 100 100 0 2 100 200 99 3 100 300 198 4 100 400 297 5 100 500 396 250 495 5 jobs, 100 seconds each, time slice 1 second, context switch time of 0, jobs arrive at time 0,1,2,3,4 1 100 100 496 0 400 2 100 200 497 99 400 Why is this 3 100 300 498 198 400 better? 4 100 400 499 297 400 5 100 500 500 396 400 250 498 198 400 4 20 5 10 14 15 50 0 90 50 120 90 4 20 140 120 5 10 150 140 110 80 50 0 90 50 120 90 4 20 140 120 110 80 50 0 90 50 120 90 4 20 140 90 120 70 110 80 16 17 18

19 50 0 90 50 120 120 90 90 4 20 140 90 120 70 110 80 50 0 90 140 50 100 120 120 90 90 4 20 140 90 120 70 110 80 50 150 0 100 90 140 50 100 Seriously, aren t these 120 120 90 90 the 4 same? 20 140 90 120 70 110 110 80 80 20 21 Fairness Was the average wait time or completion time really the right metric? Ø No! What should we consider for the example with equal job lengths? Ø Variance! What should we consider for the example with varying job lengths? Ø Is completion time proportional to length? 22 slice 4 20 5 10 23 slice 4 20 24

25 slice slice slice 100 60 60 30 60 30 26 27 slice slice Works for preemptive and non-preemptive schedulers. Preemptive SJF is called SRTF - shortest remaining time first. 150 100 100 60 60 30 50 150 150 0 100 100 Now that s 90 140 100 50 100 60 what I m 3 talking 30 about! 120 120 60 90 90 30 4 20 140 90 30 120 70 10 Advantages? Ø Free up system resources more quickly Disadvantages? Ø How do you know how long something will run? 5 10 150 50 10 140 40 0 70 40 110 110 70 80 80 40 28 29 30

31 Multilevel Feedback Queues Approximating SJF: Multilevel Feedback Queues Approximating SJF: Multilevel Feedback Queues Using the Past to Predict the Future: Multilevel feedback queues attempt to overcome the prediction problem in SJF by using the past I/O and CPU behavior to assign process priorities. Ø If a process is I/O bound in the past, it is also likely to be I/O bound in the future (programs turn out not to be random.) Ø To exploit this behavior, the scheduler can favor jobs (schedule them sooner) when they use very little CPU time (absolutely or relatively), thus approximating SJF. Ø This policy is adaptive because it relies on past behavior and changes in behavior result in changes to scheduling decisions. We write a program in e.g., Java. Multiple queues with different priorities. OS uses Round Robin scheduling at each priority level, running the jobs in the highest priority queue first. Once those finish, OS runs jobs out of the next highest priority queue, etc. (Can lead to starvation.) Round robin time slice increases exponentially at lower priorities. Adjust priorities as follows (details can vary): 1. Job starts in the highest priority queue 2. If job s time slices expire, drop its priority one level. 3. If job s time slices do not expire (the context switch comes from an I/O request instead), then increase its priority one level, up to the top priority level. ==> In practice, CPU bounds drop like a rock in priority and I/O bound jobs stay at high priority 32 33 Improving Fairness Since SJF is optimal, but unfair, any increase in fairness by giving long jobs a fraction of the CPU when shorter jobs are available will degrade average waiting time. Possible solutions: Ø Give each queue a fraction of the CPU time. This solution is only fair if there is an even distribution of jobs among queues. Ø Adjust the priority of jobs as they do not get serviced (Unix originally did this.) This ad hoc solution avoids starvation but average waiting time suffers when the system is overloaded because all the jobs end up with a high priority. Give every job some number of lottery tickets. On each time slice, randomly pick a winning ticket. On average, CPU time is proportional to the number of tickets given to each job. Assign tickets by giving the most to short running jobs, and fewer to long running jobs (approximating SJF). To avoid starvation, every job gets at least one ticket. Degrades gracefully as load changes. Adding or deleting a job affects all jobs proportionately, independent of the number of tickets a job has. 0/2 2/0 10/1 34 35 36

37 2/0 10/1 2/0 50% 0% 10/1 2/0 50% 0% 10/1 9/91=~9.8% 1/91=~1% 38 39 Summary of Scheduling Algorithms 2/0 50% 0% 10/1 9/91=~9.8% 1/91=~1% FCFS: Not fair, and average waiting time is poor. Round Robin: Fair, but average waiting time is poor. SJF: Not fair, but average waiting time is minimized assuming we can accurately predict the length of the next CPU burst. Starvation is possible. Multilevel Queuing: An implementation (approximation) of SJF. : Fairer with a low average waiting time, but less predictable. Our modeling assumed that context switches took no time, which is unrealistic. 9/19=~47% 1/19=~5.3% 40 41