real real time systems time systems real real time
play

Real- Real -time systems time systems Real- Real -time - PowerPoint PPT Presentation

EDA222/DIT160 Real-Time Systems, Chalmers/GU, 2008/2009 Lecture #2 Updated 2009-01-18 Real- Real -time systems time systems Real- Real -time programming time programming Recommended programming method: Recommended programming method:


  1. EDA222/DIT160 – Real-Time Systems, Chalmers/GU, 2008/2009 Lecture #2 Updated 2009-01-18 Real- Real -time systems time systems Real- Real -time programming time programming Recommended programming method: Recommended programming method: – Parallel programming paradigm Parallel programming paradigm – Specification • Parallel programming • Reduces unnecessary dependencies between tasks • Cooperating tasks • Rendezvous in Ada – Timing Timing- -aware task execution aware task execution – • Enables the identification of timing properties of tasks Implementation – Deterministic task execution with priorities Deterministic task execution with priorities – • Enables the analysis of interference between tasks Verification – Interrupt Interrupt- -based handling of system events based handling of system events – • Enables the analysis of the events’ interference on tasks Real- -time programming time programming Real- -time programming time programming Real Real What programming languages are suitable? What programming languages are suitable? Desired properties of a programming language: Desired properties of a programming language: – C, C++ C, C++ – Suitable schedulable unit Suitable schedulable unit – – • Strong support for low-level programming • tasks with individual memory protection • Parallel programming only via calls to operating system (POSIX) • threads (”lightweight tasks” without individual memory protection) • Priorities and notion of time lacking in language (OS dependent) – Constructs facilitating communication with the environment Constructs facilitating communication with the environment – Java Java – – • Strong support for parallel programming (threads) • access to I/O addresses • Priorities and notion of time lacking (but appears in RT Java) • low-level data types • Memory management (”garbage collection”) unsuited for real-time – Constructs facilitating the analysis of timing correctness Constructs facilitating the analysis of timing correctness – – Ada 95 Ada 95 – • task priorities (enables deterministic conflict resolution) • Strong support for low-level programming • task delays (enables periodic behavior) • Strong support for parallel programming (tasks) • handling of hardware interrupts (model interrupt as a task) • Strong support for priorities and notion of time 1

  2. EDA222/DIT160 – Real-Time Systems, Chalmers/GU, 2008/2009 Lecture #2 Updated 2009-01-18 Why parallel programming? Why parallel programming? Problems with parallel programming Problems with parallel programming Most real- Most real -time applications are inherently parallel time applications are inherently parallel Access to shared resources Access to shared resources – events in the target system’s environment often occur in parallel; – many hardware and software resources can only be used by by viewing the application as consisting of multiple tasks, this one task at a time (e.g., processor, hard disk, display) reality can be reflected. – only pseudo-parallel execution is possible in many cases – while a task is waiting for an event (e.g., I/O or access to a Information exchange Information exchange shared resource) other tasks may execute. – system modeling using parallel tasks also introduces a need System timing properties can be analyzed more easily System timing properties can be analyzed more easily for synchronization and information exchange. – first the local timing properties of each task are derived; then, Parallel programming assumes an advanced run- -time time Parallel programming assumes an advanced run the interference between tasks are analyzed system that takes care of the scheduling of shared system that takes care of the scheduling of shared System can obtain reliability properties System can obtain reliability properties resources and communication between tasks. resources and communication between tasks. – redundant copies of the same task makes system fault-tolerant Support for parallel programming Support for parallel programming Support for parallel programming Support for parallel programming Support in the programming language: Support in the operating system: Support in the programming language: Support in the operating system: – program is easier to read and comprehend, which means – simpler to combine programs written in different languages simpler program maintenance whose parallel programming models are incompatible (e.g., C/C++, Java, Pascal, …) – program code can be easily moved to another operating system – difficult to implement the language’s parallel programming – for some embedded systems, a full-fledged operating system is model on top of the operating system’s model unnecessarily expensive and complicated – Operating systems become more and more standardized, – examples: Ada 95, Java, Modula, Occam, ... which makes program code more portable between OS’s (e.g., POSIX for UNIX, Linux and Windows XT) Example : Example : : Example : Example Ada 95 offers support via task , rendezvous & protected objects C/C++ offer support via fork , semctl & msgctl (UNIX, Linux) Java offers support via threads & synchronized methods 2

  3. EDA222/DIT160 – Real-Time Systems, Chalmers/GU, 2008/2009 Lecture #2 Updated 2009-01-18 Example: a simple control system Example: a simple control system Sequential solution Sequential solution Objective: Keep temperature and Objective: Keep temperature and pressure for a chemical process pressure for a chemical process procedure Controller is Thermometer ADC Thermometer within given bounds. within given bounds. TR : Temp_Reading; PR : Pressure_Reading; Pressure sensor Pressure sensor HS : Heater_Setting; PS : Pressure_Setting; begin loop Switch T P ADC Read(TR); -- read temperature Temp_Convert(TR,HS); -- convert to temperature setting Write(HS); -- to temperature switch Write(TR); -- to screen Heater Heater Read(PR); -- read pressure S Pressure_Convert(PR,PS); -- convert to pressure setting Write(PS); -- to pressure control Write(PR); -- to screen end loop ; end Controller; Screen DAC Pump/valve Pump/valve Sequential solution Improved sequential solution Sequential solution Improved sequential solution The Boolean function Ready_Temp indicates Drawback: whether a sample from ADC is available Drawback: Procedure Controller is ...; – the inherent parallelism of the application is not exploited begin • procedure Read blocks the execution until a new temperature loop if Ready_Temp then or pressure sample is available from the ADC Read(TR); -- read temperature • while waiting to read the temperature, no attention can be given Temp_Convert(TR,HS); -- convert to temperature setting Write(HS); -- to temperature switch to the pressure (and vice versa) Write(TR); -- to screen • if the call for reading the temperature does not return because of end if ; a fault, it is no longer possible to read the pressure if Ready_Pres then Read(PR); -- read pressure – the independence of the control functions are not considered Pressure_Convert(PR,PS); -- convert to pressure setting • temperature and pressure must be read with the same interval Write(PS); -- to pressure control Write(PR); -- to screen • the iteration frequency of the loop is mainly determined by the end if ; blocking time of the calls to Read . end loop ; end Controller; 3

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend