Concurrent activities in daily life. Real world exposed programs. Scheduling of programs. Tasks in engine system. Engine system

Similar documents
OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

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

Reference Model and Scheduling Policies for Real-Time Systems

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

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

CS4514 Real Time Scheduling

Embedded Systems: OS. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Tasks. Task Implementation and management

Real-time operating systems and scheduling

Event-Driven Scheduling. (closely following Jane Liu s Book)

Embedded Systems: OS

1.1 CPU I/O Burst Cycle

OPERATING SYSTEM CONCEPTS UNDERSTAND!!! IMPLEMENT!!! ANALYZE!!!

Implementing Scheduling Algorithms. Real-Time and Embedded Systems (M) Lecture 9

CPU Scheduling Algorithms

Scheduling. The Basics

CSE 4/521 Introduction to Operating Systems

Multimedia Systems 2011/2012

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)

Precedence Graphs Revisited (Again)

Multiprocessor and Real-Time Scheduling. Chapter 10

Scheduling Algorithm and Analysis

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


Chapter 5: CPU Scheduling

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

Last Class: Processes

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

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

CPU Scheduling: Objectives

CS370 Operating Systems

Chapter 5 CPU scheduling

CS370 Operating Systems

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

CS370 Operating Systems

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

Scheduling of processes

8: Scheduling. Scheduling. Mark Handley

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)

Operating Systems Unit 3

Operating System Concepts Ch. 5: Scheduling

Chapter 6: CPU Scheduling

Computer Science 4500 Operating Systems

7. Multimedia Operating System. Contents. 7.3 Resource Management. 7.4 Process Management. 7.2 Real Time Systems. 7.5 Prototype Systems. 7.

(b) External fragmentation can happen in a virtual memory paging system.

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

Multimedia-Systems. Operating Systems. Prof. Dr.-Ing. Ralf Steinmetz Prof. Dr. rer. nat. Max Mühlhäuser Prof. Dr.-Ing. Wolfgang Effelsberg

Learning Outcomes. Scheduling. Is scheduling important? What is Scheduling? Application Behaviour. Is scheduling important?

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

Aperiodic Task Scheduling

4/6/2011. Informally, scheduling is. Informally, scheduling is. More precisely, Periodic and Aperiodic. Periodic Task. Periodic Task (Contd.

Exam Review TexPoint fonts used in EMF.

Real-Time and Concurrent Programming Lecture 6 (F6): Scheduling and bounded response times

Operating Systems. Scheduling

MARUTHI SCHOOL OF BANKING (MSB)

PROCESS SCHEDULING II. CS124 Operating Systems Fall , Lecture 13

Introduction to Embedded Systems

Chapter -5 QUALITY OF SERVICE (QOS) PLATFORM DESIGN FOR REAL TIME MULTIMEDIA APPLICATIONS

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

Systemy RT i embedded Wykład 11 Systemy RTOS

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

6.1 Motivation. Fixed Priorities. 6.2 Context Switch. Real-time is about predictability, i.e. guarantees. Real-Time Systems

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

Chap 7, 8: Scheduling. Dongkun Shin, SKKU

SMD149 - Operating Systems

Multiprocessor and Real- Time Scheduling. Chapter 10

Operating Systems: Quiz2 December 15, Class: No. Name:

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

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

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

Problems Kernel Scheduler User Level Scheduler Universität Karlsruhe (TU), System Architecture Group

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University

An application-based EDF scheduler for OSEK/VDX

UNIT:2. Process Management

COMP 3361: Operating Systems 1 Final Exam Winter 2009

(MCQZ-CS604 Operating Systems)

LAST LECTURE ROUND-ROBIN 1 PRIORITIES. Performance of round-robin scheduling: Scheduling Algorithms: Slide 3. Slide 1. quantum=1:

2. Introduction to Software for Embedded Systems

Process- Concept &Process Scheduling OPERATING SYSTEMS

Comparison of scheduling in RTLinux and QNX. Andreas Lindqvist, Tommy Persson,

Multitasking and scheduling

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

Practice Exercises 305

Embedded Systems Dr. Santanu Chaudhury Department of Electrical Engineering Indian Institution of Technology, IIT Delhi

Properties of Processes

Fault tolerant scheduling in real time systems

But this will not be complete (no book covers 100%) So consider it a rough approximation Last lecture OSPP Sections 3.1 and 4.1

Computer Systems Assignment 4: Scheduling and I/O

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

LECTURE 3:CPU SCHEDULING

What s an Operating System? Real-Time Operating Systems. Cyclic Executive. Do I Need One? Handling an Interrupt. Interrupts

Unit 3 : Process Management

Operating system concepts. Task scheduling

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

CSCI-GA Operating Systems Lecture 3: Processes and Threads -Part 2 Scheduling Hubertus Franke

Scheduling in the Supermarket

Verification of Real-Time Systems Resource Sharing

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

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

Analyzing Real-Time Systems

Transcription:

Real world exposed programs Programs written to interact with the real world, outside the computer Programs handle input and output of data in pace matching the real world processes Necessitates ability to handle periodic, sporadic and aperiodic events and actions onstraints defined by real world objects and processes monitored and/or controlled oncurrent activities in daily life In daily life we are doing many things repeatedly and concurrently, for example: ooking food Making the dish icycling to work Listening to radio Talking with friends Sleeping Etc. We switch our attention between many such tasks and give them varying priority Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 1 Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 2 Simple monolith approach to control Periodic cycle once a day (e.g. in your daily life routines) Large program loop controlling the overall task 1 2 3 4 5 6 7 Part 1, 3 and 5 are task instances of the same type activated three times in a main period (LM). Part 2 and 4 is the same task preempted by task 3. Part 6 may depend on the result from task 4. Program and part state info may be kept in global variables Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 3 Scheduling of programs program aimed to perform an overall task can be partitioned into smaller parts The parts can be executed in an order and period defined by the overall program Such a program written as a control loop is a simple method to describe a schedule The program parts ordered in this way (scheduled) are subtasks State information of subtasks and loop iterations may be exchanged via global variables Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 4 Engine system Tasks in engine system Engine system Processing and Memory Subsystem (consisting of one or more computers) Fuel volume Ignition time ir volume Gas temperature Gas pressure ngle of crankshaft Sensor and ctuator Subsystem ontrolled subsystem TSKS: 1. Measure temperature 2. Measure angle of the crankshaft 3. Measure air volume 4. alculate rotation speed 5. Measure pressure 6. alculate fuel volume 7. alculate ignition time 8. Order fuel volume 9. Order ignition time (and pressure adjustment, if possible) What do you think are suitable periods for each task? Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 5 Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 6 1

Task (execution) period 4 7 1 8 3 Different physical properties or requirements often imply that different task periods are needed 2 6 7 8 2 5 4 3 9 2 1 7 8 5 Give comments on drawbacks on the monolith approach 6 2 9 5 omments on the monolith Seemingly simple but difficult to handle timing properly Limited flexibility change in one task can influence the timing of other tasks Related program parts are difficult to keep together as a task with a common goal Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 7 Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 8 oncurrent programs Many programs can be executed faster than required by the external real world processes If a program has to wait for an event or a resource the processor can be better utilized (if it can be used for execution of some other program) program have its own thread of control if it can stop to wait for a time point or an event to occur and then be resumed (and continue where it was) The type of job or work that such a program describes is called a task How follow a schedule? schedule can be handled and executed: directly by a simple main program or by an OS guided by timing constraints and static or dynamic priority information Scheduling is more feasible if tasks can be assumed to be independent of each other Some theoretical scheduling results are based on such assumptions Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 9 Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 10 ircular calendar scheduler ircular table of jobs and release times lock timer gives time to next interrupt Easy to update via user interface J n T m % Scheduling Preemptive or Non preemptive lthough non preemptive schedulers often allow to preemption by short interrupt service routines (ISR) Priority Rate Monotonic, Deadline Monotonic Value ased Dynamic (e.g., earliest deadline first) Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 11 Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 12 2

Scheduling, cont. First-ome-First-Served (FFS) also called First-In-First-Out (FIFO) Last-ome-First-Served (LFS) also called Last-In-First-Out (LIFO) Shortest Job First (SJF) Round-Robin (RR) Time Slicing Random Service Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 13 Scheduling cont. schedule is feasible if it fulfills all constraints (e.g. all task always meet their deadlines) for the given set of tasks set of tasks is schedulable if there exists an algorithm that can produce a feasible schedule scheduling algorithm is optimal if it minimizes a cost function (reflecting real-time requirements) defined over the set of tasks Tasks can be: periodic with arrival interval T sporadic (or rare) with arrival interval > T aperiodic with no minimal interval between arrivals (sometimes assumed triggered by independent random arrivals (Poisson) allowing estimation of required arrival queues and delays). Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 14 Scheduling cont. non preemptive, a running task is not interrupted by a higher priority task that has become ready (often with exception for ISRs) preemptive, a high priority task can be interrupted and suspend a lower priority task static, schedule based on fixed priority decided in advance (during design time) dynamic, schedule with tasks execution priority decided dynamically during execution (e.g. based on time remaining to deadline) Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 15 Periodic jobs (services) Hard real-time systems often deals with control processes handled in periodic intervals (based on standard control theory) Many hard real-time systems also handles sporadic and aperiodic jobs triggered by external events To handle sporadic and aperiodic jobs without disturbance of the hard periodic jobs sufficient processing spare capacity must be available and allocated for this purpose Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 16 Periodic task Task parameters = {, T, O} = omputation (execution) time, in worst case T = Time period, usually same as deadline O = Offset or phase, often zero D = T (Deadline assumed equal to end of period) O T Preemption Suspension of a task when it has used its allocated upper time limit (or slot) Interrupt of a task when an external event, message or job (task instance) with higher priority has arrived The ability to preempt ongoing tasks: can increase processor utilization simplifies static and dynamic scheduling may shorten the response time to urgent events Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 17 Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 18 3

Preemption Preemptive scheduling H = higher priority task (instance) L = lower priority task (instance) H is scheduled (activated and ready) or an event that H is waiting on arrives Task Priority H L L is preempted and temporary blocked to give free way for H Task : {T = 60, = 20} Task : {T = 30, = 10} Task : {T = 15, = 5} Priority is preempted LM = Least ommon Multiple Utilisation = 100% Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 19 Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 20 Preemptive scheduling, cont. Preemptive scheduling, cont. Job n is preempted Job n+1 is preempted Task : T = 60, = 15, D = 40 Task : T = 30, = 10, D = 20 Task : T = 20, = 05, D = 10 Utilization = Σ /T = 15/60 + 10/30 + 5/20 = 1/4 + 1/3 +1/4 = 0,8333 Priority LM period n LM period n+1 Utilisation = 83.333 % LM Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 21 Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 22 Non preemptive scheduling The utilization of a shared resource can be increased by not allowing preemption of tasks while they use the shared resource This is a good strategy provided that the resources only are used for a short while In some applications the resources are more expensive and must be shared with more care than the processor controlling its use. This is a reason why functional distribution and dedicated processors sometimes are preferred for control of expensive resources. Locking of resources by marking of the corresponding program code as a critical section is easier to use than semaphores Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 23 Non preemptive scheduling H is ready (some event that it waited on has occurred) Task Priority H is blocked waiting on L to finish H L Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 24 4

Non preemptive scheduling Synchronization conflicts, blocking and deadlock are easier to avoid if preemption is not allowed In soft real-time systems, where good throughput and robustness to overload is important, nonpreemptive FFS scheduling is often preferred Non preemptive scheduling often assumes that tasks are cooperative and do not use the processor for too long intervals. This means that a large task is supposed to take a break, by itself, at suitable places in its execution. periodic jobs Soft real-time systems deals mainly with non-deterministic jobs triggered by external aperiodic events occurring randomly Such random events (e.g. phone calls) are: independent, memory less, and can arrive in bursts Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 25 Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 26 periodic jobs, cont. To handle bursts, job arrival queuing (and often priority based queuing) is used To handle overload a job rejection and cancelling strategy is also needed Many real-time systems run hard periodic jobs as basic load and use remaining spare capacity to handle bounded aperiodic jobs with softer requirements Sporadic or aperiodic (job) arrivals ounded by a minimal inter-arrival time or maximal arrival rate (also called sporadic tasks) Independent random (Poisson) distributed arrivals where average response time delays can be calculated using queuing theory (e.g., Little's Theorem) ursty bounded by max event density limit Not only arrival rates but also the size of jobs (e.g. if data dependent) may be modeled as random Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 27 Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 28 periodic tasks Task parameters = {, D,, O} = omputation (execution) time, in worst case D = Deadline, relative to start O = Offset, in this case the delay from the external triggering event to the task activation (usually assumed zero) = verage arrival rate (in queuing theory denoted by λ) Sporadic tasks Task parameters = {, D, M, O} = omputation (execution) time, in worst case D = Deadline, relative to start O = Offset, in this case the delay from the external triggering event to the task activation (usually assumed zero) M = Minimum inter arrival time O D O D M Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 29 Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 30 5

Scheduling notation = rrival Rate = locking Time = omputation Time (Worst ase Execution Time, WET) D = Deadline, relative I = Interference Time (I = R - ) (time a job is hindered by other jobs) J = Jitter M = Minimum Inter rrival Rate O = Offset or phase, absolute P = Priority R = Response Time (time to finish a job from its arrival) S = Slack (S = D - R) is also called laxity T = Time period for task U = Utilization Value based scheduling The priority of a task is valued based on a relationship such as: p Priority = ------- r p r where: p = omputation time performed r = omputation time remaining to deadline Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 31 Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 32 Value based scheduling, cont. Static (off-line) scheduling p r Rate-Monotonic (RM) Tasks with shorter periods are given higher priorities. Deadline-Monotonic (DM) Tasks with shorter relative deadlines are given higher priorities. r p Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 33 Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 34 Dynamic scheduling Earliest-Deadline-First (EDF) When put in the ready queue the task that has the closest deadline is given the highest priority. variation of EDF called LSF (or MLF) takes the task with the least slack (or minimum laxity) first, i.e. gives it highest priority. Dynamic scheduling cont. Estimation of the remaining time to deadline (shortest slack) is used to set task priority dynamically, i.e. during run time The setting of priority require that each task block contains information about computation time (WET) and deadline The task block can contain data about resource types needed and the priority can be set based on the current resource usage dynamic scheduler can reach 100% utilisation but then also create an avalanche effect as soon as a deadline is missed Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 35 Distributed Real-Time Systems 2008, Tony Larsson, Halmstad University 36 6