Preemptive Scheduling Vivek Pai / Kai Li Princeton University.

Slides:



Advertisements
Similar presentations
© 2004, D. J. Foreman 1 Scheduling & Dispatching.
Advertisements

Operating Systems ECE344 Midterm review Ding Yuan
Mutual Exclusion.
WHAT IS AN OPERATING SYSTEM? An interface between users and hardware - an environment "architecture ” Allows convenient usage; hides the tedious stuff.
Process Description and Control
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CS-334: Computer.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
1: Operating Systems Overview
1/27/2010CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying an earlier version.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
Forking & Process Scheduling Vivek Pai / Kai Li Princeton University.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
Chapter 8 Operating System Support
1HW1 Explain the transition “interrupted” and “event wait.” Describe how they are different. NewReadyRunningTerminated Waiting (Blocked) admitted Dispatched.
1/23/2008CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
CSE451 Processes Spring 2001 Gary Kimura Lecture #4 April 2, 2001.
CPS110: Implementing threads/locks on a uni-processor Landon Cox.
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
Preemptive Scheduling Vivek Pai / Kai Li Princeton University.
Threads and Critical Sections Vivek Pai / Kai Li Princeton University.
CE Operating Systems Lecture 5 Processes. Overview of lecture In this lecture we will be looking at What is a process? Structure of a process Process.
LOGO OPERATING SYSTEM Dalia AL-Dabbagh
Operating System Review September 10, 2012Introduction to Computer Security ©2004 Matt Bishop Slide #1-1.
1 Previous lecture review n Out of basic scheduling techniques none is a clear winner: u FCFS - simple but unfair u RR - more overhead than FCFS may not.
CSC 501 Lecture 2: Processes. Process Process is a running program a program in execution an “instantiation” of a program Program is a bunch of instructions.
Object Oriented Analysis & Design SDL Threads. Contents 2  Processes  Thread Concepts  Creating threads  Critical sections  Synchronizing threads.
Implementing Processes and Process Management Brian Bershad.
Chapter 41 Processes Chapter 4. 2 Processes  Multiprogramming operating systems are built around the concept of process (also called task).  A process.
Chapter 3 Process Description and Control
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Mutual Exclusion.
Mutual Exclusion. Readings r Silbershatz: Chapter 6.
Operating Systems CSE 411 Multi-processor Operating Systems Multi-processor Operating Systems Dec Lecture 30 Instructor: Bhuvan Urgaonkar.
1: Operating Systems Overview 1 Jerry Breecher Fall, 2004 CLARK UNIVERSITY CS215 OPERATING SYSTEMS OVERVIEW.
Concurrency & Context Switching Process Control Block What's in it and why? How is it used? Who sees it? 5 State Process Model State Labels. Causes of.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
CSE 153 Design of Operating Systems Winter 2015 Midterm Review.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
Managing Processors Jeff Chase Duke University. The story so far: protected CPU mode user mode kernel mode kernel “top half” kernel “bottom half” (interrupt.
CPU Scheduling Operating Systems CS 550. Last Time Deadlock Detection and Recovery Methods to handle deadlock – Ignore it! – Detect and Recover – Avoidance.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Overview: Using Hardware.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
Scheduler activations Landon Cox March 23, What is a process? Informal A program in execution Running code + things it can read/write Process ≠
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.
SLC/VER1.0/OS CONCEPTS/OCT'99 1Processes Process Concept Process Scheduling Operation On Processes Cooperating Processes Threads Interprocess Communication.
Tutorial 2: Homework 1 and Project 1
Multiprogramming. Readings r Chapter 2.1 of the textbook.
Processes and threads.
Operating Systems CMPSC 473
Copyright ©: Nahrstedt, Angrave, Abdelzaher
Sujata Ray Dey Maheshtala College Computer Science Department
OPERATING SYSTEMS CS3502 Fall 2017
Scheduler activations
2P13 Week 2.
Process & its States Lecture 5.
Operating Systems.
Process Description and Control
Processes Hank Levy 1.
Sujata Ray Dey Maheshtala College Computer Science Department
Process Description and Control
Process Description and Control
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Processes Hank Levy 1.
Chapter 3: Processes Process Concept Process Scheduling
CSE 153 Design of Operating Systems Winter 2019
Chapter 3: Process Management
Presentation transcript:

Preemptive Scheduling Vivek Pai / Kai Li Princeton University

2 Errata while loop example from last time Going from randVal = 9 to randVal = 0 may take loop overhead So, it’s not really guaranteed to be random

3 Mechanics Lamport’s paper added to readings Project 4 stripped down from last year People are hiring – good news

4 Overview for Today Wrap up swapping Move on to pre-emptive scheduling

5 Job Swapping Partially executed swapped-out processes Ready Queue CPU I/O Waiting queues I/O Terminate Swap out Swap in

6 Add Job Swapping to State Transition Diagram Running Blocked Ready Resource becomes available (move to ready queue) Create a process Terminate (call scheduler) Yield (call scheduler) Block for resource (call scheduler) Scheduler dispatch Swap out Swap in Swap

7 Think About Swapping Is swapping Necessary Desirable Good Ideal Things to consider Performance Complexity Efficiency

8 The Hello/Goodbye Server Server: Hello User: Hello Server: Drink Slurm! (ka-ching!) User: Goodbye Server: Goodbye

9 Life is Simple Until… Hello, My name is Bill Gates. Please try out my new “Hello/Goodbye Server” and I’ll give you a million dollars and a new cat. Tell your friends. I wuv you, Bill Gates

10 You Have to Fix It accept new connection; say hello wait for hello; print advertising message wait for goodbye, say goodbye close connection

11 What’s the Simplest Option? While (1) accept new connection fork new process let process handle connection Drawback: lots of process creation/deletion

12 Can We Reduce Forks? At program launch, fork some number While (1) accept wait for hello wait for goodbye close Note: wait = implicit yield

13 But What If We Do More While (1) accept wait for hello perform possibly unbounded calculation wait for goodbye close Problem: when do we yield?

14 Signals and Interrupts Both are asynchronous Used to notify system of event occurrence Signal – delivered by OS to process Interrupt – delivered by hardware to OS Some overlap/interaction? Definitely Examples? Code tries executing divide-by-zero User disconnects (hangs up)

15 I/O and Timer Interrupts Why Timer interrupt to do CPU management Asynchronous I/O to overlap with computation Interrupt Between instructions Within an instruction Enable and disable CPU Memory Interrupt

16 Using Interrupts For Scheduling Timer interrupt Generated by hardware Assume changing requires privilege Delivered to the OS Main idea Before moving process to running, set timer If process yields/blocks, clear timer Timer expires? Go to scheduler

17 Scheduling Considerations Timer granularity Finer timers = more responsive Coarse timers = more efficient Accounting Cheap Accurate Fair – consider I/O versus CPU applications

18 Preemptive Scheduling Running Blocked Ready I/O completion interrupt (move to ready queue) Create Terminate (call scheduler) Yield, Timer Interrupt (call scheduler) Block for resource (call scheduler) Scheduler dispatch

19 No Control Over Yielding Reasons for yielding Timer goes off Higher-priority interrupt occurs Higher-priority process becomes ready Some unintentional block (e.g. page fault)

20 “Atomic” Pieces of Code Example: bank transaction Read account balance Add/subtract money Write account balance Problem: what happens when two transactions are being posted to the same account?

21 Next Time Atomic pieces known as critical sections Very common in concurrent/parallel programming Must share memory Possible via forked processes Default via threads Cover some scheduling policies