Tuesday, March 17, 2015 Sam Siewert
SE300
SWE Practices
Lecture 10 – Introduction to Event-
Driven Architectures
Copyright {c} 2014 by the McGraw-Hill Companies, Inc. All rights Reserved.
6-2
Four Common Types of Systems
(a) Interactive subsystem
a
b
c
c
z
y x
a
a/x
b/y c/z
b
(b) Event-driven subsystem
(c) Transformational subsystem (d) Database subsystem
Sam Siewert 3
Minute Paper
Software Services – What Are They?
– Periodic Requests for Service
– Peer-to-Peer Requests vs. Client and Server?
– Describe Services and What Might Differentiate a Server from an
Event-Driven Service
– Concurrency?
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 4
Sam Siewert 5
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 6
Why are RT Embedded Systems a Challenge?
– Real-Time Services – Correct Results on time – Deadlines!
Multi-service Concurrency Required, for Software, Multi-threaded
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) - Latency
Networks (Latency and QoS) - Lag
– Memory Hierarchy Resources
Register file, L1/L2 cache, SRAM, dynamic RAM, Flash
Sam Siewert 7
How to Make RT Embedded Systems Easier!
RT Service and CPU Resource Management
– RT Theory, Practice, and Pitfalls (Theory -> System)
RMA Theory (Real-Time Systems Class)
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)
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 8
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
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 9
Sam Siewert 10
Example Event-Driven Application -
VOIP Voice / Internet Protocol
– 8 bit Mono
– 16 bit Mono
– 16 bit Stereo
QoS
– Transport
– Buffering
– Sequencing and Dropouts
Point-to-Point
– Simplex
– Duplex
Conference Call
– Audio Buffer Co-Adding
– Session Control Protocol
– Mute Feature
CU Student – Testing VOIP from “Chip Up”
Sam Siewert 11
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 12
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 13
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 14
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 15
Brief Workbench / VxWorks Demo
Basic Host - Target IDE
– API Guide
– Programmer’s Guide
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 16
Sam Siewert 17
CPU Scheduling Taxonomy –
Many Methods Execution Scheduling
Global-MP Local-Uniprocessor
Distributed Asymmetric
(AMP )
Symmetric
(SMP OS)
Preemptive Non-Preemptive
Fixed-Priority
Hybrid
Dynamic-Priority Cooperative
Batch
FCFS SJN
Co-Routine Continuation
Function
Heuristic EDF/LLF RR Timeslice
(desktop)
Multi-Frequency
Executives
Static Dynamic
Rate
Monotonic
Deadline
Monotonic
Dataflow
(Preemptive, Non-Preemptive Subtree
Under Each Global-MP Leaf)
SMT
(Micro-Paralell)
Most Often Used –
Round Robin SMP
(Linux, Windows, Mac OS-X)
Others, Less Often Used
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 18
Next …
Activity Diagrams
– Concurrency
– Objects with Active Threads
(Tasks)
State-Machines
– Deterministic Response
– Model for a Task (Thread)
– Task Awaits and Activating
Event and Transitions to a New
Statet
Sam Siewert 19
Next from Text …
SEPA (Pressman) – Chapter 14, 15 & 16
Goals for Software System Re-use and Maintenance
Legacy Systems
Refactoring
…
Sam Siewert 20