Titolo presentazione. Scheduling. sottotitolo A.Y Milano, XX mese 20XX ACSO Tutoring MSc Eng. Michele Zanella

Similar documents
Chapter 5: CPU Scheduling

Chapter 5: CPU Scheduling

CSE 4/521 Introduction to Operating Systems

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

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

Properties of Processes

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

Process- Concept &Process Scheduling OPERATING SYSTEMS

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

Chapter 6: CPU Scheduling

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

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

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Chapter 5: CPU Scheduling

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

CS307: Operating Systems

Chapter 5: Process Scheduling

Chapter 6: CPU Scheduling

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

Ch 4 : CPU scheduling

Operating System Concepts Ch. 5: Scheduling

CHAPTER 2: PROCESS MANAGEMENT

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

Chapter 5: Process Scheduling

Chapter 5 CPU scheduling

CS370 Operating Systems

CPU Scheduling Algorithms

Scheduling of processes

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

CS370 Operating Systems

Practice Exercises 305

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

Operating Systems CS 323 Ms. Ines Abbes

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

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

1.1 CPU I/O Burst Cycle

Lecture 2 Process Management

CPU Scheduling: Objectives

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

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

COSC243 Part 2: Operating Systems

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.

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

Job Scheduling. CS170 Fall 2018

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

CPU scheduling. Alternating sequence of CPU and I/O bursts. P a g e 31

Chapter 6: CPU Scheduling

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

Course Syllabus. Operating Systems

TDIU25: Operating Systems II. Processes, Threads and Scheduling

CPU Scheduling (Part II)

CS3733: Operating Systems

Uniprocessor Scheduling. Aim of Scheduling

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

Chapter 19: Real-Time Systems. Operating System Concepts 8 th Edition,

Chapter 5 Process Scheduling

Chapter 6: CPU Scheduling

8: Scheduling. Scheduling. Mark Handley

CS370 Operating Systems

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

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

Last Class: Processes

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

Chapter 9. Uniprocessor Scheduling

CSE 120 Principles of Operating Systems Spring 2017

Scheduling. Today. Next Time Process interaction & communication

LECTURE 3:CPU SCHEDULING

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

Unit 3 : Process Management

Chap 7, 8: Scheduling. Dongkun Shin, SKKU

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

Supplementary Materials on Multilevel Feedback Queue

Operating Systems Unit 3

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

Process Scheduling. Copyright : University of Illinois CS 241 Staff

CPU Scheduling: Part I ( 5, SGG) Operating Systems. Autumn CS4023

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)

Scheduling. The Basics

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

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

PROCESS SCHEDULING II. CS124 Operating Systems Fall , Lecture 13

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

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

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

CS370 Operating Systems

Scheduling. CSC400 - Operating Systems. 7: Scheduling. J. Sumey. one of the main tasks of an OS. the scheduler / dispatcher

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)

Assignment 3 (Due date: Thursday, 10/15/2009, in class) Part One: Provide brief answers to the following Chapter Exercises questions:

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

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)

Comp 310 Computer Systems and Organization

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Processes and Threads

Operating Systems. Figure: Process States. 1 P a g e

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 5: CPU Scheduling. Operating System Concepts 9 th Edit9on

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

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

Uniprocessor Scheduling

Advanced Operating Systems (CS 202) Scheduling (1)

Transcription:

Titolo presentazione Scheduling sottotitolo A.Y. 2017-18 Milano, XX mese 20XX ACSO Tutoring MSc Eng. Michele Zanella

Process Scheduling Goals: Multiprogramming: having some process running at all times, to maximize CPU utilization Time sharing: switching the CPU among processes so frequently that users can interact with each program while it is running Scheduler: it is in charge of selecting an available process for program execution on the CPU

CPU-I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait. Process execution begins with a CPU burst and is followed by an I/O burst.

Preemptive scheduling Scheduling decision when: A process swtiches from RUNNING to WAIT state A process terminates A process swtiches from RUNNING to READY A process swtiches from WAITING to READY Non-Preemptive: once the CPU has been allocated to a process, the process keeps the CPU until it releases it by terminating or by switching to the WAIT state.

Dispatcher 1. Switching context 2. Switching to user mode 3. Jumping to the propoer location in the user program to restart that program It should be as fast as possible

Scheduling Criteria CPU utilization: keeping the CPU as busy as possible Throughput: number of processes that are completed per time unit Turnaround time: how long it takes to execute the process. Sum of the periods spent waiting to get into memory, waiting in the ready queue, executing on the CPU and doing I/O Waiting time: Amount of time that a process spends waiting in the ready queue Response time: the time from the submission of a request until the first response is produced (it takes to start responding, not to output the response)

Scheduling Techniques: FCFS First-Come, First-Served The process that requests the CPU first is allocated the CPU first FIFO queue Pro Easy to implement Cons Long average waiting Lower CPU and device utilization Non preemptive Troublesome for time-sharing systems

Scheduling Techniques: FCFS Example: Process Burst Time P1 24 P2 3 P3 3 P1 P2 P3 0 24 27 30 P1 W_t = 0ms P2 W_t = 24ms Average W_t = (0+24+27)/3 = 17 P3 W_t = 27ms

Scheduling Techniques: FCFS Example: Process Burst Time P2 3 P3 3 P1 24 P2 P3 P1 0 3 6 30 P2 W_t = 0ms P3 W_t = 3ms Average W_t = (0+3+6)/3 = 3!! P1 W_t = 6ms

Scheduling Techniques: SJF Shortest Job First Associates with each process the length of the process s next CPU burst. The CPU is assigned to the process that has the smallest next CPU burst Pro Optimal (minimum average waiting time) Cons Difficult to know the length of the burst For long-term scheduler Preemptive or Non-preemptive Preemptive version -> Shortest-remaining-time-first Predicting next CPU burst:τ "#$ = αt " + (1 α)τ "

Scheduling Techniques: SJF Example: Process Burst Time P1 6 P2 8 P3 7 P3 3 P4 P1 P3 P2 0 3 9 16 P4 W_t = 0ms P1 W_t = 3ms P3 W_t = 9ms Average W_t = (0+3+9+16)/4 = 7!! P2 W_t =16ms 24

Scheduling Techniques: Priority Priority Scheduling A priority is associated with each process and the CPU is allocated to the process with the highest proprity (low number). Internal or external proprity definition Pro Preemptive or Non-preemptive Cons Starvation Solution for starvation -> aging: gradually increasing the priority of processes that wait in the system for a long time.

Scheduling Techniques: Priority Example: Process Burst Time Priority P1 10 2 P2 1 1 P3 2 3 P4 1 4 P2 P1 P3 P4 0 1 11 13 14 P2 W_t = 0ms P1 W_t = 1ms P3 W_t = 11ms Average W_t = (0+1+11+13)/4 = 6.75ms!! P4 W_t = 13ms

Scheduling Techniques: RR Round-Robin Scheduling A small unit of time (time quantum) is defined. Designed for time-sharing systems. Circular ready queue. The CPU is allocated to each process fro a time interval of up to 1 time quantum Pro Preemptive Known maximum waiting time Cons Long average waiting time Turnaround time depends on the quantum Performance depends on the size of quantum

Scheduling Techniques: RR Two cases: 1. The process may have the CPU burst of less than 1 time quantum -> The process itself releases the CPU 2. The timer goes off and causes an interrupt to the OS -> A context switch is executed and the current process is put in the ready queue The maximum waiting time for a process is: n 1 x q We want the time quantum to be large with respect to the context-switch time

Scheduling Techniques: RR Example: Q=4ms Process Burst Time P1 24 P2 3 P3 3 P1 P2 P3 P1 P1 P1 P1 P1 0 4 7 10 14 18 22 26 30 P1 W_t = (10-4) = 6ms P2 W_t = 4ms Average W_t = (6+4+7)/3 = 5.66ms P3 W_t = 7ms

Scheduling Techniques: Multi-level Multi-level Scheduling Process are classified into different groups The ready queue is partinioned into several separate queues Process are permanently assigned to one queue on some properties (e.g., memory, priority, type ) Scheduling among the queues is required (fixed-priority preemptive) Pro Low overhead Cons Starvation Fixed queue per process

Scheduling Techniques: Multi-level

Scheduling Techniques: Multi-level Feedback Multi-level Feedback Queue Scheduling The process is allowed to move between queues. Separating processes according to the characteristics of their CPU burst It is defined by some parameters: Number of queues Scheduling algorithm for each queue Method used to determine when to upgrade a process to a higher-priority queue Method used to determine when to demote a process to a lower-priority queue Method used to determine which queue a process will enter when that process needs service One of the most complex algorithm

Scheduling Techniques: Thread Scheduling User-level: Managed by the thread library Kernel-level: scheduled by the OS User-level threads must be mapped to an associated kernellevel thread (many-to one, many-to-many) Process Contention Scope (PCS): competition for the CPU takes place among threads belonging to the same process Priority-based, priorities set by the programmer, preemptive System Contention Scope (SCS): competition for the CPU takes place among all threads in the system

Scheduling Techniques: Pthread Scheduling PTHREAD_SCOPE_PROCESS: schedules threads using PCS scheduling PTHREAD_SCOPE_SYSTEM: schedules threads using SCS It creates and bind a Ligthweight Process (LWP) for each user-level thread on many-to-many systems, effectively mapping threads using the one-to-one policy Two functions to get and set the contention scope policy: pthread_attr_setscope(,int scope) pthread_attr_getscope(, int scope)

Real-Time CPU Scheduling Soft real-time system: it provides no guarantee as to when a critical real-time process will be scheduled. It guarantees only that the process will be given preference over non-critical processses. Hard real-time system: a task must be serviced by its deadline; service after the deadline has expired is the same as no service at all

Real-Time CPU Scheduling: minimizing latency RT system is typically waiting for an event in real-time to occur Event -> the system must respond to and service it as quickly as possible Goal -> Minimizing the latency Event latency: the amount of time that elapses from when an event occurs to when it is serviced Interrupt latency: period of time from the arrival of an interrupt at the CPU to the start of the routine that services the interrupt (Interrupt Service Routine, ISR) -> must be bounded Dispatch latency: the amount of time required for the scheduling dispatcher to stop one process and start another -> preemptive kernels

Real-Time CPU Scheduling: minimizing latency

Real-Time CPU Scheduling: Priority-based Priority-based Scheduling Providing a preemptive, priority-based scheduler only guarantees soft real-time functionality Notion of periodic processes They require the CPU at constant intervals (periods). It has fixed processing time t, a deadline d by which it must be serviced by the CPU, a period p Rate is 1/p Admission control: the scheduler can admit the process, guaranteeing that it will complete on time, or reject the request as impossible

Real-Time CPU Scheduling: Rate-Monotonic Rate-Monotonic Scheduling It schedules periodic tasks using a static priority policy Preemptive Priority is the inverse of the period We assume that the processing time of a periodic process is the same for each CPU burst. Optimal: if a set of processes cannot be scheduled by this algorithm, it cannot be scheduled by any other that assigns static priorities It is not possible fully to maximize CPU resources. The worst-case CPU utilization for scheduling N processes is: N(2 $ 3 1)

Scheduling Techniques: Rate-Monotonic Example: Deadline: next period Process Period Process Time P1 50 20 P2 100 35 P1 P1,P2 P1 P1 P2 P1 P2 P1 P2 P1 P2 0 20 50 70 75 100 120 150 170 175

Real-Time CPU Scheduling: EDF Earlier-Deadline-First Scheduling Dynamically assigns proprities according to deadline The earlier the deadline, the higher the priority It does not require periodic processes nor processes with a costant amount of CPU time per burst. Requirement: a process announces its deadline to the scheduler when it becomes runable Theoretical optimality -> In practice we have context switching cost!

Scheduling Techniques: EDF Example: Deadline: next period Process Period Process Time P1 50 25 P2 80 35 P1 P2 P1 P1 P2 P1 P2 P1 P2 P1 P2 0 25 50 60 80 85 100 125 145 150 160

Real-Time CPU Scheduling: Proportional Share Proportional Share Scheduling It allocates T shares among all applications. It ensures that the application will have N/T of the total processor time It must work in conjunction with an admission-control policy A request is admitted only if sufficient shares are available.

Real-Time CPU Scheduling: POSIX Extensions for real-time computing SCHED_FIFO: it schedules threads accoring to FCFS policy SCHED_RR: it uses a round-robin policy

Exercise 2 (Thread & Parallelism) 27/02/2014 Condition loc in TH_1 loc in TH_2 After stat. A EXISTS CAN EXIST After stat. C CAN EXIST EXISTS After stat. D After stat. E EXISTS EXISTS CAN EXIST DOESN T EXIST Condition ONE {0,1} TWO {0,1,2} global After stat. A After stat. B After stat. C After stat. D 0 0 0 / 1 0 / 1 0 / 1 / 2 0 / 1 0 / 1 / 2 0 {0,1} 0 / 1 0 0 / 1 0

Exercise 2 (Thread & Parallelism) 27/02/2014 Situation TH_1 TH_2 TH_3 global 1 2 wait(two) 0 / 1 Second wait(two) 0

Exercise 4 (Process State) 22/02/2017 Task name IDLE P S Q PID 1 2 3 4 TGID 1 2 3 4 S sem_init 0 READY READY EXEC WAIT (read) TH1 5 3 TH2 6 3 S pthread_create 10 READY READY EXEC WAIT (read) READY Interrupt from RT_clock Interrupt from DMA, allblocks transferred Interrupt from ck TH_1 sem_wait S pthread_create S exit P waitpid Q - exit 20 30 40 50 60 70 80 90 READY READY EXEC READY WAIT (read) READY READY READY EXEC READY READY READY READY READY EXEC N.E. READY READY READY READY READY READY READY EXEC WAIT (waitpid) EXEC EXEC READY WAIT (wait S) EXEC WAIT (wait S) READY NOT EXIST NOT EXIST NOT EXIST READY EXEC NOT EXIST NOT EXIST NOT EXIST NOT EXIST READY NOT EXIST NOT EXIST NOT EXIST