Chapter 5 Scheduling

Similar documents
Chapter 5 CPU scheduling

Chapter 6: CPU Scheduling

Round Robin (RR) ACSC 271 Operating Systems. RR Example. RR Scheduling. Lecture 9: Scheduling Algorithms

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

Job Scheduling. CS170 Fall 2018

Chapter 5: CPU Scheduling

CS307: Operating Systems

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

Operating Systems CS 323 Ms. Ines Abbes

Properties of Processes

CPU Scheduling. Basic Concepts. Histogram of CPU-burst Times. Dispatcher. CPU Scheduler. Alternating Sequence of CPU and I/O Bursts

Chapter 5: Process Scheduling

Chapter 5: Process Scheduling

Scheduling. Today. Next Time Process interaction & communication

Chapter 5 Process Scheduling

CSE 4/521 Introduction to Operating Systems

Chapter 5: CPU Scheduling

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

Chapter 6: CPU Scheduling

Chapter 6: CPU Scheduling

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

Chapter 6: CPU Scheduling

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

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

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

Chapter 5: CPU Scheduling

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

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

CPU Scheduling Algorithms

Process Concept Process in Memory Process State new running waiting ready terminated Diagram of Process State

LECTURE 3:CPU SCHEDULING

CS370 Operating Systems

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

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Scheduling in the Supermarket

CHAPTER 2: PROCESS MANAGEMENT

CS370 Operating Systems

CPU Scheduling: Objectives

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

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

Lecture 2 Process Management

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Processes and threads

CPU Scheduling (Part II)

CPU Scheduling. Schedulers. CPSC 313: Intro to Computer Systems. Intro to Scheduling. Schedulers in the OS

Scheduling. Today. Next Time. ! Introduction to scheduling! Classical algorithms. ! Process interaction & communication

ALL the assignments (A1, A2, A3) and Projects (P0, P1, P2) we have done so far.

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

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)

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)

CPU Scheduling. Rab Nawaz Jadoon. Assistant Professor DCS. Pakistan. COMSATS, Lahore. Department of Computer Science

Operating System Concepts Ch. 5: Scheduling

Chapter 5: CPU Scheduling. Operating System Concepts 9 th Edit9on

Processes and Threads

Course Syllabus. Operating Systems

Operating Systems. Scheduling

Operating Systems. Process scheduling. Thomas Ropars.

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

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.

Last Class: Processes

Ch 4 : CPU scheduling

CS3733: Operating Systems

Practice Exercises 305

Lecture 17: Threads and Scheduling. Thursday, 05 Nov 2009

CS370 Operating Systems

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

OPERATING SYSTEMS. UNIT II Sections A, B & D. An operating system executes a variety of programs:

So far. Next: scheduling next process from Wait to Run. 1/31/08 CSE 30341: Operating Systems Principles

8: Scheduling. Scheduling. Mark Handley

Multithreaded Programming

3. CPU Scheduling. Operating System Concepts with Java 8th Edition Silberschatz, Galvin and Gagn

Start of Lecture: February 10, Chapter 6: Scheduling

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

COSC243 Part 2: Operating Systems

CS370 Operating Systems

Scheduling of processes

Processes. Overview. Processes. Process Creation. Process Creation fork() Processes. CPU scheduling. Pål Halvorsen 21/9-2005

TDIU25: Operating Systems II. Processes, Threads and Scheduling

CPU Scheduling (1) CPU Scheduling (Topic 3) CPU Scheduling (2) CPU Scheduling (3) Resources fall into two classes:

Comp 310 Computer Systems and Organization

CS Computer Systems. Lecture 6: Process Scheduling

CS370 Operating Systems

Process Scheduling. Copyright : University of Illinois CS 241 Staff

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

CS 318 Principles of Operating Systems

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)

INF1060: Introduction to Operating Systems and Data Communication. Pål Halvorsen. Wednesday, September 29, 2010

Operating Systems Unit 3

Process- Concept &Process Scheduling OPERATING SYSTEMS

Scheduling Mar. 19, 2018

Operating Systems ECE344. Ding Yuan

Scheduling. Multi-processing. Process Characterization. time. ...makes use of idle. COS450-F18-05-Scheduling - October 8, 2018

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

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)

Chap 7, 8: Scheduling. Dongkun Shin, SKKU

Uniprocessor Scheduling. Aim of Scheduling

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

Scheduling. Scheduling 1/51

Operating Systems. CPU Scheduling ENCE 360

Uniprocessor Scheduling. Chapter 9

Scheduling. Scheduling 1/51

Transcription:

Chapter 5 Scheduling Images from Silberschatz Pacific University 1

Life time of a single process CPU usage/io bursts What would an IO bound process look like? What would a CPU bound process look like? Pacific University 2

Single process What would an IO bound process look like? What would a CPU bound process look like? Pacific University 3

Short term scheduler CPU Scheduler Takes process from ready queue and runs it Various algorithms used here... Data structure? Why? puts it on the CPU Takes a process off the CPU and puts it on the ready queue Why? Swapping processes around causes a... Pacific University 4

Scheduling events Processes moved from the CPU when: Switches from running to waiting state Switches from running to ready state Switches from waiting to ready Terminates What if only first and last are implemented? Why would we ever do this? Pacific University 5

Problems What happens if a process is preempted while in a system call? Possible bad outcomes? How to fix this? Pacific University 6

Dispatcher Module/code that puts the process on the CPU Switch context Switch to user mode Restart at correct program counter (PC) Dispatch Latency: Pacific University 7

Goals CPU Utilization Throughput Turnaround time Waiting time Response time Usually optimize average Sometimes optimize the minimum or maximum Sometimes minimize the variance Why? Which values? Pacific University 8

Scheduling Algorithms First-Come, First-Served (FCFS) Non-preemptive (cooperative!) Data structure? P 1 P 2 P 3 0 2 4 2 7 3 0 Pacific University 9

FCFS, cont P 2 P 3 P 1 0 3 6 3 0 Advantages? Pacific University 10

Shortest Job First (SJR) Choose process who's next CPU burst is the shortest Not really shortest JOB first May be preemptive (or not) Preemptive (Shortest-Remaining-Time-First (SRTF)) Gives minimum average waiting time Provably optimal Preemptive With perfect knowledge Pacific University 11

Example (cooperative!) P 1 P 3 P 2 P 4 0 3 7 8 1 2 1 6 Pacific University 12

Preemptive P 1 P 2 P 3 P 2 P 4 P 1 0 2 4 5 7 1 1 1 6 Pacific University 13

Length of next CPU burst is? Why is this hard? + Why? What does this mean? What does this look like? Pacific University 14

Prediction of next CPU Burst Pacific University 15

Priority Scheduling Give each process a priority (an integer) Schedule process with highest priority May be the lowest integer (to make things more confusing) Preemptive or not SJF is a special case of this What is the priority? Where might a problem arise? Pacific University 16

Round Robin Each process gets some amount of time (10-100 milliseconds) Time quantum/slice Put at the end of the queue when done P 1 P 2 P 3 P 4 P 1 P 3 P 4 P 1 P 3 P 3 0 2 0 3 7 5 7 7 7 9 7 1 1 7 1 2 1 1 3 4 1 5 4 1 6 2 Pacific University 17

Time quanta & context switches Pacific University 18

Turnaround time Pacific University 19

Multilevel Queue Scheduling Different Queues, different algorithms Process stays in one queue forever Foreground Background Other categories Pacific University 20

Absolute vs Time slicing Pacific University 21

Multilevel Feedback-Queue Scheduling Processes move between queues Use CPU burst information to move processes Aging may play a role Defining characteristics number of queues scheduling algorithms for each queue method used to determine when to upgrade a process method used to determine when to demote a process method used to determine which queue a process will enter when that process needs service Pacific University 22

Example (p168) Three queues Q0 RR with time quantum 8 milliseconds Q1 RR with time quantum 16 milliseconds Q2 FCFS Pacific University 23

Multiple-Processor Scheduling Asymmetric Multiprocessor Symmetric Multiprocessor Processor Affinity Soft vs hard Pacific University 24

Cont. Load Balancing Push migration Pull migration Hyperthreading Pacific University 25

Process-contention-scope Thread Scheduling System-contention-scope Pacific University 26

#include <pthread.h> #include <stdio.h> #define NUM THREADS 5 Pthreads int main(int argc, char *argv[]) { int i; pthread t tid[num THREADS]; Note the coding pthread attr t attr; standards violations! /* get the default attributes */ pthread attr init(&attr); /* set the scheduling algorithm to PROCESS or SYSTEM */ pthread attr setscope(&attr, PTHREAD SCOPE SYSTEM); /* set the scheduling policy - FIFO, RR, or OTHER */ pthread attr setschedpolicy(&attr, SCHED OTHER); /* create the threads */ for (i = 0; i < NUM THREADS; i++) pthread create(&tid[i],&attr,runner,null); /* now join on each thread */ for (i = 0; i < NUM THREADS; i++) pthread join(tid[i], NULL); } /* Each thread will begin control in this function */ void *runner(void *param) { printf("i am a thread\n"); pthread exit(0); } Pacific University 27

Linux O(1) Scheduler: no longer used Preemptive, priority based Two priority ranges (lower is better): Real-time: 0-99 Nice: 100-140 Pacific University 30

Linux: Complete Fair Scheduler (CFS) Current scheduler kernel/sched/fair.c merged 2.6.23 (October 2007) give each process a fair share of the CPU virtual runtime - amount of time provided to a given task (process/thread) priorities cause the virtual runtime to increase more quickly or more slowly each process has its own timeslice metric. Red-Black tree is used to hold tasks (indexed by virtual runtime) always choose the left most node to run insert a task into the right and slowly migrate to the left. http://www.diit.unict.it/users/llobello/linuxscheduling20122013_p2.pdf https://www.ibm.com/developerworks/linux/library/l-completely-fair-scheduler/l-completely-fair-scheduler-pdf.pdf Pacific University 31

Algorithm Evaluation How to choose a scheduling algorithm? Define goals Minimize wait time? Minimize response time? Maximize CPU utilization? Deterministic modeling Queuing modeling (queuing network analysis) Little's formula Simulations Build it Pacific University 32