20.01.05Lecture 2, CS52701 The Real Time Computing Environment I CS 5270 Lecture 2.

Slides:



Advertisements
Similar presentations
Simulation of Feedback Scheduling Dan Henriksson, Anton Cervin and Karl-Erik Årzén Department of Automatic Control.
Advertisements

EE5900 Advanced Embedded System For Smart Infrastructure
Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.
Priority INHERITANCE PROTOCOLS
© 2004 Wayne Wolf Topics Task-level partitioning. Hardware/software partitioning.  Bus-based systems.
1 EE5900 Advanced Embedded System For Smart Infrastructure RMS and EDF Scheduling.
CS5270 Lecture 31 Uppaal, and Scheduling, and Resource Access Protocols CS 5270 Lecture 3.
CPE555A: Real-Time Embedded Systems
Courseware Scheduling of Distributed Real-Time Systems Jan Madsen Informatics and Mathematical Modelling Technical University of Denmark Richard Petersens.
5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 5: CPU Scheduling.
An Introduction to Real Time Systems
Real-time concepts Lin Zhong ELEC424, Fall Real time Correctness – Logical correctness – Timing Hard vs. Soft – Hard: lateness is intolerable Pass/Fail.
Real-Time Scheduling CIS700 Insup Lee October 3, 2005 CIS 700.
Is It Time Yet? Wing On Chan. Distributed Systems – Chapter 18 - Scheduling Hermann Kopetz.
Tasks Periodic The period is the amount of time between each iteration of a regularly repeated task Time driven The task is automatically activated by.
Module 2 Priority Driven Scheduling of Periodic Task
Review: Chapters 1 – Chapter 1: OS is a layer between user and hardware to make life easier for user and use hardware efficiently Control program.
Scheduling for Embedded Real-Time Systems Amit Mahajan and Haibo.
CS 3013 & CS 502 Summer 2006 Scheduling1 The art and science of allocating the CPU and other resources to processes.
Courseware Basics of Real-Time Scheduling Jan Madsen Informatics and Mathematical Modelling Technical University of Denmark Richard Petersens Plads, Building.
Real-Time Kernels and Operating Systems. Operating System: Software that coordinates multiple tasks in processor, including peripheral interfacing Types.
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
By Group: Ghassan Abdo Rayyashi Anas to’meh Supervised by Dr. Lo’ai Tawalbeh.
CprE 458/558: Real-Time Systems
Real-Time Software Design Yonsei University 2 nd Semester, 2014 Sanghyun Park.
OPERATING SYSTEMS CPU SCHEDULING.  Introduction to CPU scheduling Introduction to CPU scheduling  Dispatcher Dispatcher  Terms used in CPU scheduling.
Real-Time Scheduling CS4730 Fall 2010 Dr. José M. Garrido Department of Computer Science and Information Systems Kennesaw State University.
Scheduling policies for real- time embedded systems.
Reference: Ian Sommerville, Chap 15  Systems which monitor and control their environment.  Sometimes associated with hardware devices ◦ Sensors: Collect.
CS Spring 2011 CS 414 – Multimedia Systems Design Lecture 31 – Multimedia OS (Part 1) Klara Nahrstedt Spring 2011.
Real-Time Scheduling CS4730 Fall 2010 Dr. José M. Garrido Department of Computer Science and Information Systems Kennesaw State University.
CS244-Introduction to Embedded Systems and Ubiquitous Computing Instructor: Eli Bozorgzadeh Computer Science Department UC Irvine Winter 2010.
6. Application mapping 6.1 Problem definition
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
CS244-Introduction to Embedded Systems and Ubiquitous Computing Instructor: Eli Bozorgzadeh Computer Science Department UC Irvine Winter 2010.
Special Class on Real-Time Systems
1 Real-Time Scheduling. 2Today Operating System task scheduling –Traditional (non-real-time) scheduling –Real-time scheduling.
CSCI1600: Embedded and Real Time Software Lecture 24: Real Time Scheduling II Steven Reiss, Fall 2015.
Introduction to Embedded Systems Rabie A. Ramadan 5.
CSCI1600: Embedded and Real Time Software Lecture 23: Real Time Scheduling I Steven Reiss, Fall 2015.
CS Spring 2009 CS 414 – Multimedia Systems Design Lecture 31 – Process Management (Part 1) Klara Nahrstedt Spring 2009.
Introduction to Real-Time Systems
1.  System Characteristics  Features of Real-Time Systems  Implementing Real-Time Operating Systems  Real-Time CPU Scheduling  An Example: VxWorks5.x.
Undergraduate course on Real-time Systems Linköping University TDDD07 Real-time Systems Lecture 2: Scheduling II Simin Nadjm-Tehrani Real-time Systems.
Unit - I Real Time Operating System. Content : Operating System Concepts Real-Time Tasks Real-Time Systems Types of Real-Time Tasks Real-Time Operating.
CS Spring 2010 CS 414 – Multimedia Systems Design Lecture 32 – Multimedia OS Klara Nahrstedt Spring 2010.
Big Picture Lab 4 Operating Systems C Andras Moritz
Distributed Process Scheduling- Real Time Scheduling Csc8320(Fall 2013)
Real-Time Operating Systems RTOS For Embedded systems.
Embedded System Scheduling
REAL-TIME OPERATING SYSTEMS
EEE Embedded Systems Design Process in Operating Systems 서강대학교 전자공학과
Topics Covered What is Real Time Operating System (RTOS)
Scheduling and Resource Access Protocols: Basic Aspects
Wayne Wolf Dept. of EE Princeton University
Unit OS9: Real-Time and Embedded Systems
EEE 6494 Embedded Systems Design
Real-time Software Design
Lecture 24: Process Scheduling Examples and for Real-time Systems
Realtime System Fundamentals : Scheduling and Priority-based scheduling B. Ramamurthy cse321-fall2014 9/20/2018.
Chapter 6: CPU Scheduling
Realtime System Fundamentals : Scheduling and Priority-based scheduling B. Ramamurthy cse321-fall /27/2018.
CSCI1600: Embedded and Real Time Software
CPU SCHEDULING.
Chapter 6: CPU Scheduling
CSCI1600: Embedded and Real Time Software
Operating System , Fall 2000 EA101 W 9:00-10:00 F 9:00-11:00
CSE 153 Design of Operating Systems Winter 19
Real-Time Process Scheduling Concepts, Design and Implementations
Real-Time Process Scheduling Concepts, Design and Implementations
Presentation transcript:

Lecture 2, CS52701 The Real Time Computing Environment I CS 5270 Lecture 2

Lecture 2, CS52702 A Conceptual Framework The outside view: –Closed system :  verification –Open system :  Synthesis, schdulability analysis, … The inside view –Architecture –Interrupts –Task scheduling….. –Embedded software Modeling, analysis, verification are important at all layers!

Lecture 2, CS52703 The Closed System View Computing system Plant Sense Actuate Extract a model (Timed Automaton) ; Verify if this closed system meets a given specification.

Lecture 2, CS52704 The Open System View Plant Sense Actuate For this open system, synthesize a controller (real time computing system) such that the closed system meets a given specification.

Lecture 2, CS52705 The Open System View Actuate For this open system, synthesize a controller (real time computing system) such that the closed system meets a given specification. Plant Sense Computing system

Lecture 2, CS52706 The Outside View Timed Automata : – outside view  closed system  Verification Model extraction Specification of properties Verification methods/tools.

Lecture 2, CS52707 The Inside View Plant Sense Computing system Actuate What is inside the black box?

Lecture 2, CS52708 Sense Computing system Actuate Sense Actuate

Lecture 2, CS52709 Distributed Architecture

Lecture 2, CS A Node

Lecture 2, CS A Node Often, multiple instances of the above for fault tolerance!

Lecture 2, CS A Node

Lecture 2, CS The Host Computer DSPProcessor ASIC Timer Memory Bus

Lecture 2, CS The Host Computer DSPProcessor ASIC Timer Memory

Lecture 2, CS Tasks DATA SETS TASK1 TASK2 TASK3 TASK4 RT !mages!

Lecture 2, CS RT Images RT entity: – Some item of interest whose value changes over time. –Pressure, temperature, valve position … Continuous RT entity: –Can be observed at any point in time  pressure Discrete RT entity –Can be observed only between specified occurrences of interesting events

Lecture 2, CS RT Images RT Image: –Current picture of an RT entity. – Accuracy: –Value –Temporal is  -accurate if the value of N was v at some time in the interval (t- , t).

Lecture 2, CS RT Images Suppose is observed at time t and used at time t’. Then the maximum error (v’ – v) depends on the temporal accuracy (  ) and the maximum gradient of N during this interval. If the gradient is high then  must be small and tasks using N must be scheduled often! (this is a fair but crude statement)

Lecture 2, CS Accuracy RT ImageMax.ChangeV-AccuracyT-accuracy Piston Position 6000 RPM0.1 degrees 3  secs Acc. pedal100%/sec1%10 msecs Eng. Load50%/sec1%20 msecs Oil temp10%/min1%6 seconds

Lecture 2, CS The Design Challenge Derive a model of the closed system (external). –Specification/requirements –Timing –Notion of physical time Design and implement –a distributed, fault-tolerant, optimal- real time computing system so that the closed system meets the specification/requirements.

Lecture 2, CS The Structural Elements Each computing node will be assigned a set of tasks to perform the intended functions. Task : – Execution of a (simple) sequential program.  Read the input data  The internal state of the task (include RT profiles)  Terminate with production of results and updating internal state of the task.

Lecture 2, CS Tasks The (real time) operating system provides the control signal for each initiation of the task. Stateless task: no internal state at the time of initiation. Task with state

Lecture 2, CS Tasks Simple task: –No synchronization point within the task. –Does not block due to lack of progress by other tasks in the system. –But can get interrupted (preempted) by the operating system. –Total execution time can be computed in isolation. –The Worst Case Execution Time of task over all possible relevant inputs.  Correct estimate of WCET is crucial for guaranteeing real time constraints will be met.

Lecture 2, CS Complex Tasks Contains blocking synchronization statement: –“wait” semaphore operation. –“receive” message operation. Must wait till another task has updated a common data structure: –Data dependency –Sharing Must wait for input to arrive. WCET of a complex task can not be computed in isolation..

Lecture 2, CS Interfaces Interfaces: –Common boundary between two subsystems. –Design is essentially interface design. –Designing and implementing the interface “glue logic” consumes the major portion of the design cycle.

Lecture 2, CS527026

Lecture 2, CS Interfaces Interface Parameters: –Control signals flowing across the interface and the associated task invocations. –Temporal properties to be satisfied by the control signals and data values flowing across. – Functional relationships between input and output data.

Lecture 2, CS The Host Computer DSP Processor ASIC Timer Memory

Lecture 2, CS Tasks DATA SETS TASK1 TASK2 TASK3 TASK4

Lecture 2, CS Tasks There will be tasks that are triggered by exceptions, interrupts and alarms. There will be tasks that need to be executed periodically. These tasks may have precedence relationships. These tasks may have deadlines. These tasks may share data structures. They may have to execute on the same processor. We must schedule!

Lecture 2, CS Scheduling: Basic Concepts Scheduling Policy: –CPU has to execute –sequentially- a set of concurrent tasks.  If T1 and T2 are both executable at t we must choose between T! and T2 Scheduling Algorithm: –The recipe (algorithm) which determines at each time t which task to execute. Dispatching:  Allocating the CPU to the task selected by the scheduling algorithm.

Lecture 2, CS Scheduling: Basic Concepts Active Task: – A task which can potentially execute on the CPU (which may or may not be available). Ready Task: – An active task which is waiting for the CPU Running Task: –An active task in execution. Ready Queue: –The queue in which ready tasks are kept.

Lecture 2, CS Scheduling : Basic Concepts Preemption: –Tasks may be activated dynamically  time of activation not determined. –If the task activated at time is more important (has higher priority) than the running task:  running task is interrupted and inserted in the running queue. Preemption is needed for : –Exception-handling tasks. –Tasks may have different levels of criticality. –Improve system responsiveness, throughput, utilization etc.

Lecture 2, CS The Ready Queue

Lecture 2, CS Schedules Task set J = { J 1, J 2, …, J n } A schedule assigns at each t one task to the processor so that each task is eventually completed. A schedule can be preemptive. Schedules will have to perform context switching. A schedule is feasible if all tasks can be completed while satisfying the given constraints. A task set is schedulable If there is at least one scheduling algorithm which produces a feasible schedule.

Lecture 2, CS Schedule

Lecture 2, CS Schedule ? 7?

Lecture 2, CS Schedule with Preemption

39 Schedule with Preemption ? 5? Context switch?

Lecture 2, CS Task Constraints Timing Constraints Precedence Constraints Resource Constraints

Lecture 2, CS Timing Constraints Timing Constraints: –A task should meet its deadline.  Hard  Soft Relevant Parameters for the task J i : –arrival time a i  Request time, release time –computation time C i  time needed to execute J i (without interruption).

Lecture 2, CS Timing Parameters deadline d i – time before which J i must be completed. start time s i finishing time f i value (priority?) v i : –The relative importance of J i.

Lecture 2, CS Basic Timing Parameters

Lecture 2, CS Basic Timing Parameters D i = d i – a i Relative deadline

Lecture 2, CS Timing Parameters Pattern of activation: – Periodic task  regularly activated at a constant rate.  instances or jobs corresponding to the same task.   i the phase of  I :  The activation time of the first instance of the periodic task  i.  T i the period of the task.  D i the relative deadline  Often, one assumes D i = T i –Aperiodic task:  Same as periodic tasks but the activation times are NOT periodic.

Lecture 2, CS Periodic/Aperiodic Task

Lecture 2, CS Task Constraints Timing Constraints Precedence Constraints Resource Constraints

Lecture 2, CS Precedence Constraints Precedence Constraints: – Tasks can not be executed in any arbitrary order.  Data dependencies.  Control strategy Task Graphs: –Instead of Task sets. –Nodes are tasks –Edges capture precedence.

Lecture 2, CS Task Graph

Lecture 2, CS The Task Graph

Lecture 2, CS Task Constraints Timing Constraints Precedence Constraints Resource Constraints

Lecture 2, CS Resource Constraints resource: –software structure used by a task during its execution. –A data structure, variables, an area of main memory, a file, a piece of code, a set of registers of a peripheral device. Shared resource: –Used by more than one task. Exclusive resource: –No simultaneous access. –Require mutual exclusion. –Operating must provide a synchronization mechanism to ensure sequential access..

Lecture 2, CS Critical Section Critical section: –A piece of code belonging to task executed under mutual exclusion constraints. Mutual exclusion enforced by semaphores. –wait(s)  Blocked if s = 0. – signal(s)  s is set to 1 when signal(s) executes.

Lecture 2, CS Structure of Critical Sections.

Lecture 2, CS Wait State A task waiting for an exclusive resource is blocked on that resource. Tasks blocked on the same resource are kept in a wait queue associated with the semaphore protecting the resource. A task in the running state executing wait(s) on a locked semaphore (s = 0) enters the waiting state. When a task currently using the resource executes signal(s), the semaphore is released. When a task leaves its waiting state (because the semaphore has been released) it goes into the ready state: –Why not enter the running state?

Lecture 2, CS Waiting State

Blocking via Exclusive Resource J 1 has higher priority than J 2. Preemption is in play. Only one processor available.

Lecture 2, CS Multiprocessor Settings a1 e1 d H a2 e2 s rec

Lecture 2, CS Scheduling Problem. Task set {J 1, J 2,..,J n } Processors {P 1, P 2,…, P m } Resources {R 1, R 2, …,R s } Timing constraints Precedence constraints Resource constraints Problem: Assign processors and resources to tasks so that all the tasks can be finished under the imposed constraints.

Lecture 2, CS Scheduling Problem The general problem (in fact various simpler versions of it) is NP-complete.

Lecture 2, CS Scheduling Problem The general problem (in fact various simpler versions of it) is NP-complete. There is a non-deterministic Turing Machine TM and a polynomial in one variable p(n) (egs. 8n 3 + 5n + 6) such for each problem instance of size n (in binary representation!), TM determines if there exists a schedule and if so outputs one in atmost p(n) steps. Any non-deterministic polynomial time problem can be transformed in deterministic polynomial time to the general scheduling problem. Only exponential time deterministic algorithms are known.

Lecture 2, CS Scheduling Problem Algorithm1 O(n) Algorithm2 O(5 n ) Each computation step 1  sec. n = 30 Algorithm1 : 30  seconds. Algorithm2 : 30, 000, 000 years!

Lecture 2, CS Scheduling Problems Must find imperfect but efficient solutions to scheduling problems. Great variety of algorithms exist: – various assumptions –Different complexities – Different pragmatic contents. Optimal scheduling algorithm: – Minimizes a given cost function. –If no cost function, then no algorithm in the same class can produce a feasible schedule if the optimal one can not.

Lecture 2, CS A Classic Example Rate Monotonic Scheduling. –Task set : {J 1, J 2, …, J n } –Each task is periodic. T 1, T 2,.., T n –  i = 0 for each i. –D i = T i for each i. –Pre-emption allowed. –Only one processor –No precedence constraints –No shared resources.

Lecture 2, CS RMS The RMS algorithm: –Assign a static priority to the tasks according to their periods.  Tasks with shorter periods have higher priorities. –Preemption policy:  If T i is executing and T j arrives which has higher priority (shorter period), then preempt T i and start executing T j.

Lecture 2, CS RMS Results RMS is optimal. – If a set of of periodic tasks (satisfying the assumptions set out previously) is not schedulable under RMS then no static priority algorithm can schedule this set of tasks. RMS requires very little run time processing. Static scheduling policy.

Lecture 2, CS Process Utilization Factor Task set = {T 1, T 2, …, T n } Process Utilization Factor –  C i / T i –C 1 / T 1 + C 2 / T 2 + … C n / T n If this factor is GREATER than 1 then the task set can not be scheduled. –Why? If UF ≤ 1 it may be schedulable. If UF  U lub then it is guaranteed to be schedulable.

Lecture 2, CS Process Utilization Factor Task set = {T 1, T 2, …, T n } If UF  U lub then it is guaranteed to be schedulable. U lub = n( 2 1/n – 1) For large n this is approximately But if UF is greater than U lub and not greater than 1, we must check explicitly whether the task set is schedulable (under RM).

Lecture 2, CS EDF Earliest Deadline First. – Tasks with earlier deadlines will have higher priorities. –Applies to both periodic and aperiodic tasks. –EDF is optimal for dynamic priority algorithms. – A set of periodic tasks is schedulable with EDF iff the utilization factor is not greater than 1.

Lecture 2, CS An Example {T1, T2} T1 –Period = 5 –Computation time = 2

Lecture 2, CS An Example {T1, T2} T2 –Period = 7 –Computation time = 4

Lecture 2, CS An RMS Schedule ?

Lecture 2, CS An RMS Schedule Time-Overflow

Lecture 2, CS The Example UF = 2 / / 7 = = 0.97 Guaranteed to be schedulable under EDF!

Lecture 2, CS Resource Access Protocols Multiple tasks. Uniprocessor Shared resources. –Need proper protocols for accessing shared resources. –Resource access protocols. Avoid priority inversion!