ICS 143 Principles of Operating Systems

Slides:



Advertisements
Similar presentations
CPU Scheduling.
Advertisements

 Basic Concepts  Scheduling Criteria  Scheduling Algorithms.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
Chapter 5 CPU Scheduling. CPU Scheduling Topics: Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 5: CPU Scheduling.
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.
Chapter 5-CPU Scheduling
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.
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
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
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 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.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
6.1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
Chapter 4 CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
1 Module 5: Scheduling CPU Scheduling Scheduling Algorithms Reading: Chapter
Basic Concepts Maximum CPU utilization obtained with multiprogramming
1 Lecture 5: CPU Scheduling Operating System Fall 2006.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
lecture 5: CPU Scheduling
Chapter 6: CPU Scheduling
Dan C. Marinescu Office: HEC 439 B. Office hours: M, Wd 3 – 4:30 PM.
Chapter 5a: CPU Scheduling
Operating Systems Processes Scheduling.
CPU scheduling 6. Schedulers, CPU Scheduling 6.1. Schedulers
Scheduling (Priority Based)
CPU Scheduling.
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
CS 143A - Principles of Operating Systems
CPU Scheduling Basic Concepts Scheduling Criteria
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Operating System Concepts
So far…. Firmware identifies hardware devices present
3: CPU Scheduling Basic Concepts Scheduling Criteria
Chapter5: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Outline Scheduling algorithms Multi-processor scheduling
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Lecture 2 Part 3 CPU Scheduling
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 4/11/2019.
Process Scheduling B.Ramamurthy 4/7/2019.
Operating System , Fall 2000 EA101 W 9:00-10:00 F 9:00-11:00
Process Scheduling B.Ramamurthy 4/19/2019.
Process Scheduling B.Ramamurthy 4/24/2019.
Shortest-Job-First (SJR) Scheduling
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Module 5: CPU Scheduling
Process Scheduling B.Ramamurthy 5/7/2019.
CPU SCHEDULING CPU SCHEDULING.
CPU Scheduling: Basic Concepts
Chapter 6: CPU Scheduling
CPU Scheduling.
CPU Scheduling: Basic Concepts
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Presentation transcript:

ICS 143 Principles of Operating Systems Discussion Section Week 4

Today Announcements Programming Assignment Preview Lifetime of a Process Schedulers Pop Quiz #1 11/15/2018

Announcements Homework #2 Mid-term exam New office hours Due Thu, 30 April 2015, 11:55pm via EEE DropBox Mid-term exam Fri, 8 May 2015, 11:00-11:50am in EH 1200 New office hours Ekin: Mons 2:00-3:00pm in ICS 468A Michael: Tues 1:00-2:00pm in SBSG 2236 Prof V: Thus 10:00-11:00am in DBH 2086 11/15/2018

Programming Assignment Preview Individual submission – everyone gets to code! It’s ok to discuss ideas, but everyone must submit their own code Implement several schedulers Simulator will provide template / skeleton (Java) Preemptive / non-preemptive Short report (1 page max.) Black-box testing Public tests and expected output provided Will test on public / private tests to make sure your code works More details will be announced next week… 11/15/2018

Schedulers Overview Long Term Short Term Medium Term Creation Terminated Short Term Ready Running Blocked Medium Term Suspended 11/15/2018

Lifetime of a Process 11/15/2018

Lifetime of a Process No PCB yet Must go through scheduler dispatch 11/15/2018

Levels of Scheduling 11/15/2018

CPU Scheduler CPU scheduler selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them. Non-preemptive Scheduling Once CPU has been allocated to a process, the process keeps the CPU until Process exits OR Process switches to waiting state Preemptive Scheduling Process can be interrupted and must release the CPU. Need to coordinate access to shared data 11/15/2018

Dispatch Module Dispatcher module gives control of the CPU to the process selected by the short-term scheduler. This involves: switching context switching to user mode jumping to the proper location in the user program to restart that program Dispatch Latency: time it takes for the dispatcher to stop one process and start another running. Dispatcher must be fast. 11/15/2018

Scheduling Criteria CPU Utilization Throughput Turnaround time Keep the CPU and other resources as busy as possible Throughput # of processes that complete their execution per time unit. Turnaround time amount of time to execute a particular process from its entry time. Waiting time amount of time a process has been waiting in the ready queue. Response Time (in a time-sharing environment) amount of time it takes from when a request was submitted until the first response is produced, NOT output. MAX MAX MIN MIN MIN 11/15/2018

CPU Burst Distribution 11/15/2018

Determining Length of Next CPU Burst One can only estimate the length of burst. Use the length of previous CPU bursts and perform exponential averaging. tn = actual length of nth burst n+1 =predicted value for the next CPU burst  = 0, 0    1 Define: n+1 =  tn + (1- ) n 11/15/2018

Exponential Averaging(cont.)  = 0 n+1 = n; Recent history does not count = 1 n+1 = tn; Only the actual last CPU burst counts. Similarly, expanding the formula: n+1 = tn + (1-) tn-1 + …+ (1-)^j tn-j + … (1-)^(n+1) 0 Each successive term has less weight than its predecessor. j 11/15/2018

First Come First Serve (FCFS) Scheduling Policy: Process that requests the CPU FIRST is allocated the CPU FIRST. Commonly preemptive or non-preemptive? Non-preemptive Implementation - using FIFO queues incoming process is added to the tail of the queue. Process selected for execution is taken from head of queue. Performance metric? Average waiting time in queue. Advantage? Simple, no starvation Disadvantages? Convoy effect: Short processes at the back of the queue may have to wait a long time 11/15/2018

First-Come, First-Served(FCFS) Scheduling Example Suppose the arrival order for the processes is P1, P2, P3 Waiting time P1 = 0; P2 = 24; P3 = 27; Average waiting time (0+24+27)/3 = 17 Gantt Chart for Schedule 24 P1 P2 P3 27 30 11/15/2018

Shortest-Job-First(SJF) Scheduling Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time. Two Schemes: Scheme 1: Non-preemptive Once CPU is given to the process it cannot be preempted until it completes its CPU burst. Scheme 2: Preemptive If a new CPU process arrives with CPU burst length less than remaining time of current executing process, preempt. Also called Shortest-Remaining-Time- First (SRTF). Advantage? SJF is optimal - gives minimum average waiting time for a given set of processes. Disadvantage? May lead to starvation 11/15/2018

Non-Preemptive SJF Scheduling Example Gantt Chart for Schedule P1 7 P3 P2 P4 Average waiting time = (0+6+3+7)/4 = 4 8 12 16 11/15/2018

Preemptive SJF Scheduling(SRTF) Example Waiting time: P1 = 9 Waited from t=2 to t=11 P2 = 1 Waited from t=4 until t=5 P3 = 0 P4 = 2 Waited from t=5 until t=7 Gantt Chart for Schedule P1 2 P2 4 P3 5 7 P2 P4 11 16 P1 11/15/2018

Priority Scheduling A priority value (integer) is associated with each process. Can be based on Cost to user Importance to user Aging %CPU time used in last X hours. CPU is allocated to process with the highest priority. Preemptive Non-preemptive Advantage? Prioritize important jobs Disadvantage? May result in starvation 11/15/2018

Priority Scheduling Example (non-preemptive) Highest priority = 1 Waiting time: P1 = 0 Came in at t=0, processed right away P2 = 6.8 Came in at t=0.2, had to wait until t=7 P3 = 11 Came in at t=4, had to wait until t=15 P4 = 6 Came in at t=5, had to wait until t=11 Gantt Chart for Schedule P1 7 P2 11 15 P4 16 P3 11/15/2018

Round Robin (RR) Each process gets a small unit of CPU time Time quantum usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. n processes, time quantum = q Each process gets 1/n CPU time in chunks of at most q time units at a time. No process waits more than (n-1)q time units (plus context swtich time). Advantages? No starvation, fair time-sharing, good response time. Disadvantages? Typically higher average turnaround time than SRTF, might be complicated to implement 11/15/2018

Round Robin Example Waiting time: Time Quantum = 20 Assume arrival time = 0 for all processes Neglect context switch time for simplicity Waiting time: P1 = 57+24 = 81 from t=20 to t=77, from t=97 to t=121 P2 = 20 from t=0 to t=20 P3 = 37+40+17 = 94 From t=0 to t=37, from t=57 to t=97, from t=117 to t=134 P4 = 57 + 40 = 97 From t=0 to t=57, from t=77 to t=117 Gantt Chart for Schedule P1 20 P2 37 P3 57 P4 77 P1 97 P3 117 P4 121 P1 134 P3 154 P3 162 11/15/2018

Real-Time Scheduling Hard Real-time Computing - required to complete a critical task within a guaranteed amount of time. Soft Real-time Computing - requires that critical processes receive priority over less fortunate ones. Types of real-time Schedulers Periodic Schedulers - Fixed Arrival Rate Demand-Driven Schedulers - Variable Arrival Rate Deadline Schedulers - Priority determined by deadline ….. 11/15/2018

Issues in Real-time Scheduling Dispatch Latency Problem - Need to keep dispatch latency small, OS may enforce process to wait for system call or I/O to complete. Solution - Make system calls preemptible, determine safe criteria such that kernel can be interrupted. Priority Inversion and Inheritance Problem: Priority Inversion Higher Priority process needs kernel resource currently being used by another lower priority process... higher priority process must wait. Solution: Priority Inheritance Low priority process now inherits high priority until it has completed use of the resource in question. 11/15/2018

Pop Quiz #1 11/15/2018