SE310 Analysis and Design of Software Systems Lecture 10 Event-Driven Architecture Overview March 21, 2016 Sam Siewert
Copyright {c} 2014 by the McGraw-Hill Companies, Inc. All rights Reserved. Four Common Types of Systems a b c a b a/x c/z b/y x y c z (a) Interactive subsystem (b) Event-driven subsystem (c) Transformational subsystem (d) Database subsystem 6-2
Minute Paper Which of the 4 Architecture Patterns is Best Suited to OOA/OOD? 1. Interactive (e.g. GUI) 2. Event-Driven (e.g. Anti-lock Breaking System) 3. Transformational (e.g. Computer Vision) 4. Transactional (e.g. DBMS) 5. All? Discussion Sam Siewert 3
Event-Driven Architectures Introduction Sam Siewert 4
Real-Time Systems CEC450 We Have a Course at ERUA Dedicated to Embedded Real-Time Systems Good Follow-on for SWE Introduction to Event-Driven Architectures We ll Only Study to Level of Understanding Architecture Pattern Analysis and Design for SWE Most Often Consists of State-Machines and Activity Models to Extend Previous UML Models RT Systems Includes Theory Rate Monotonic (Analysis and Verification) Bruce Douglass Real-time UML (Combines Topics) Sam Siewert 5
RTOS, Embedded SW and RMA Many Great Resources for Theory & Practice CEC 450 (Microcontrollers and OS are Pre-requisites) Focus on RTOS, HW/SW Interface, and Predictable Response Highly Specialized and Mission Critical Pattern Sam Siewert 6
Event-Driven Architectures Not All Event-Driven Systems are Embedded, But Many Are Embedded Systems - Predictable Response, Hard Real-Time Integrated Services Definition of Embedded System Not Just Small, but Purposed Provides Specific Services Rather than General Purpose Computing Often No Direct Connection to User Input/Output Contained within a Larger System as a Sub-system Sam Siewert 7
Many Real-Time Embedded Systems Real Time Must Respond to Requests for Service by a Deadline relative to request Failure to Respond Prior to Deadline Results in a System Failure Request Rate for Service Driven by Real-World Events Controls Processes and Delivers Deadline Driven Services Anti-Lock Braking Streaming Media (Video and Audio) Process Control Aircraft Flight Control Robotic Systems Sam Siewert 8
Why are RT Embedded Systems a Challenge? Real-Time Services Correct Results on time Deadlines! Multi-service Concurrency Required, for Software, Multi-threaded Multiple interfaces to service in addition to data processing Multi-threaded compared to Main Loop + ISR Executive Supports RT analysis and design (Rate Monotonic) Function/Service Allocation HW Service Off-load Management of CPU, IO, and Memory Resources CPU Resource Modern architecture high throughput, less deterministic pipelines, super-scalar, branch prediction, VM, split-transaction and burst transfer bus interfaces, multi-level caches I/O Interface Resources Sensors / Actuators (Interaction with Real World) Networks (Latency and QoS) Off-load and Memory Devices (e.g. Flash, FPGAs, DSP) Memory Hierarchy Resources Register file, L1/L2 cache, SRAM, dynamic RAM, Flash Sam Siewert 9
How to Make RT Embedded Systems Easier! RT Service and CPU Resource Management RT Theory, Practice, and Pitfalls (Theory -> System) RMA and DMA Resource Theory Prediction and Measurement of Performance When to Allocate Services/Functions to HW, FW, or SW Multi-threaded RTOS Systems Design Methods (DFD, SDL, EFSM and UML methods) RTOS Mechanisms (e.g. message queue, signal, semaphore) Analysis Tools (e.g. Windview, KernelShark) HW/FW Debug Tools (e.g. ICE / JTAG) I/O Device Interfaces and Drivers Abstracted SW-HW Interfaces Interaction with Memory System (MMIO, DMAs, Plug-n-Play) Memory Hierarchy Analysis and Abstraction Multi-level Cache Performance Models Abstracted Non-Volatile Memory Filesystems Sam Siewert 10
How to Make RT Embedded Systems Easier! RT Service and CPU Resource Management RT Theory, Practice, and Pitfalls (Theory -> System) RMA and DMA Resource Theory Prediction and Measurement of Performance When to Allocate Services/Functions to HW, FW, or SW Multi-threaded RTOS Systems Design Methods (DFD, SDL, EFSM and MSC methods) RTOS Mechanisms (e.g. message queue, signal, semaphore) I/O Device Interfaces and Drivers Abstracted SW-HW Interfaces Interaction with Memory System (MMIO, DMAs, Plug-n-Play) Memory Hierarchy Analysis and Abstraction Multi-level Cache Performance Models Abstracted Non-Volatile Memory Filesystems Sam Siewert 11
Types of Event-Driver Systems Periodic Predictable Load, Polled or Max Interrupt Rate Controlled Sporadic Upper Bound on Request Rate Known/Limited Aperiodic Driver Completely by Interrupt Rate, No Masking, All Events are Queued in a Backlog Periodic Most Common Sporadic/Aperiodic Typical of Error Handling Sam Siewert 12
Example Event-Driven Application - Voice / Internet Protocol 8 bit Mono 16 bit Mono 16 bit Stereo QoS Transport Buffering Sequencing and Dropouts Point-to-Point Simplex Duplex VOIP Conference Call Audio Buffer Co-Adding Session Control Protocol Mute Feature CU Student Testing VOIP from Chip Up Sam Siewert 13
Example Projects Video Conferencing Combines VOIP and Video QoS Frame Rate Frame Compression Transport Buffering Sequencing and Dropouts CPU Intensive Transport Intensive Session Protocol Sam Siewert 14
Example Projects Mobile Platforms Camera Line Followers Image Processing Steering, Motor Control Collision Avoidance Tethered or Wireless Speed and Curvature Rovers GPS (with compass) GPS + Optical Navigation Sam Siewert 15
Example Projects Robotic Arm 5 DOF Robotic Arm Dead-Reckoning with Limits Monitoring Full-feedback Pick and Place Tasks Find Target and Grapple Object Move to New Location and Place Stack Blocks Embedded Camera in Grappler Sam Siewert 16
Example Projects Tilt/Pan Video Tracking Camera Peak-Up Camera tilts and pans to track object Target Tracker fixed camera, laser pointer tilts and pans to track Stereo Vision Tracker Tracking Speed Intensive Image Processing Scanners Etch n Sketch Scans Image Redraws with Servos Sam Siewert 17
Brief Workbench / VxWorks Demo Basic Host - Target IDE API Guide Programmer s Guide Sam Siewert 18
RTOS vs. OS RTOS Facilitates Predictable Response Priority Preemptive, Run-to-completion Tasks Low Latency, Low Overhead ISRs Direct Translation of RMA (Rate Monotonic Analysis) into Scheduling Priorities OS Facilitates Fairness and Prevents Starvation Linux CFS Completely Fair Scheduler Linux CFQ Completely Fair Queue for I/O Different Objectives Embedded Linux? Not All Event-Driven Systems are HRT (Hard Real-Time) or Even Predictable Response Sam Siewert 19
CPU Scheduling Taxonomy Many Methods Execution Scheduling Most Often Used Round Robin SMP (Linux, Windows, Mac OS-X) Others, Less Often Used Global-MP Local-Uniprocessor Dynamic Static Preemptive Non-Preemptive Symmetric (SMP OS) SMT (Micro-Paralell) Asymmetric (AMP ) Distributed Fixed-Priority Batch (Preemptive, Non-Preemptive Subtree Under Each Global-MP Leaf) Hybrid Rate Monotonic Deadline Monotonic FCFS SJN Dynamic-Priority Cooperative Dataflow Heuristic EDF/LLF RR Timeslice (desktop) Multi-Frequency Executives Co-Routine Continuation Function Sam Siewert 20
Current Trends Use of Linux for Interactive and Embedded Special Linux Kernel Builds and Patches (Compared to Server Transaction Oriented) Use of POSIX Real-Time Extensions Best Effort to Predictable Response (not HRT) RTOS Proprietary (VxWorks), Open (FreeRTOS) Support for Rate Monotonic Analysis and Theory (Proofs) Tools for Event Analysis and Timing Verification Embedded (Hidden) Hybrid Architectures Hardware State-Machines Handle HRT Software is For Configuration, Interaction, and Management Only Sam Siewert 21
Activity Diagrams Concurrency Objects with Active Threads (Tasks) Next State-Machines Deterministic Response Model for a Task (Thread) Task Awaits and Activating Event and Transitions to a New Statet Sam Siewert 22