Title: Introduction to 5143
1Introduction to 5143
- Key Concepts and Terms
- def. of embedded system
- def. of real-time system
- how the 2 are related
- controlled system
- open/closed-loop control
- hard vs soft real-time
- Class Structure
- topics covered
- schedule
- reading
- assignments
- grading
- lab work
2Distinctions of Embedded Software Development
- Hardware knowledge
- Efficient code
- Peripheral interfaces
- Robust code
- Minimal resources
- Reusable software
- Development tools
3What is a real-time system?
- A computer system with strict timing constraints.
- It must provide
- the right answer
- at the right time
- or suffer
- death and destruction!
- (well, at least serious system malfunction)
4The Real-Time Blanket
- Real-Time is an added constraint
- placed on top of every component of a system
- from the hardware to the application.
5Overall Class Objective
- Good high-level understanding
- of real-time, embedded systems.
- What are the critical issues during
- design, implementation, and testing?
-
- Low-level Hardware Control
- Concurrent Programming
- Real-Time Scheduling
- System Modeling
- Worst-Case Execution Time Analysis (WCET)
- Hands-on Experience
6More specifically .
7Embedded Systems and UM003
Key Concepts and Terms
- controlled system
- closed and open loop control basic system
elements - variations of RAM and ROM
- basics of schematics
- datasheets
- firmware
- cross-compilation
- host machine
- target platform
- ports
- in-circuit emulator
- debug monitor
- on-chip debug
8Hello World!
- Compiling
- Linking
- Locating
- Downloading
- Executing
- Debugging
- User Interface
9Debugging Techniques
in-circuit emulator
meta- code
HOST
logic analyzer
TARGET
on-chip debugger
code
Simulator
Registers ALU
code
oscilloscope
UI with comm
Debug Monitor
LEDs
Hello World
10I/O and Peripherals
Key Concepts and Terms
- control and status registers
- ports
- bitmasking
- bit manipulation
- device drivers
- memory mapped I/O
- bandwidth
- synchronization
- polling
- busy waiting
- serial and parallel interfaces
- analog and digital signals
- analog to digital conversion
- sampling frequency
- active high, active low
- edge-triggered
- level triggered
- timing diagram
11I/O and UM003
- I/O
- Ports
- Device Drivers and Interfaces
- Control and Status Registers
- Synchronization Techniques
- Signal Processing
- Signal Types
- Sampling
- A/D Conversion
12Read / Write to Ports
- Memory-Mapped I/O
- Port-Mapped I/O
- DMA
out(PORTA, 0x33) or PORTA 0x33
13Bit Manipulation
14Control Status Register Pins/Ports
iom128.h / Port B Data Register - PORTB
/ define PB7 7 define PB6
6 set bit7, bit6, bit0 hi (equivalent to
0xC2) DDRB (1ltltPB7) (1ltltPB6) (1ltltPB0)
read 4 most significant bits data PINA 0xF0
15Relating to the outside world
- 4 categories of interfaces
- parallel (digital, multiple bits at a time)
- serial (digital, one bit at a time)
- analog (voltage, continuum)
- time (analog period, frequency, )
- Types of Signals (signal processing world)
- continuous-time (analog)
- discrete-time (sampled analog signal or
inherently discrete signal) - continuous-value
- discrete-value
- random (noise)
16Synchronization Techniques(Im just waiting on a
friend)
- blind cycle open door at precisely 204 pm
- busy wait (gadfly) stand at the door
- interrupt keep busy until doorbell rings
- periodic polling doorbell broke, check every 5
minutes - DMA friend lets herself in
17Peripherals and I/O
- Ports
- Device Drivers and Interfaces
- Control and Status Registers
- Synchronization
18Signal
- a time varying physical phenomenon which is
intended to convey information.
Nigel Others only go to 10. We can go to 11 1
louder. Interviewer Why dont you just make 10
louder and make 10 be the top number. Nigel
Long pause. These go to 11.
19Sampling a Sinusoid(How often, is often enough?)
- Shannons Sampling Theorem
- If sampled at a rate more than twice the highest
frequency (of the component sinusoids) - it can be exactly reconstructed.
- fm Nyquist Frequency highest frequency
- 2fm Nyquist Rate
20Sampling a Sinusoid(How often, is often enough?)
21Sampling a Sinusoid(How often, is often enough?)
RTS Fig. 1.2 p. 4
22Concurrency, Tasks, and Intertask Communication
Key Concepts and Terms
- semaphore
- context switching
- atomicity
- tasks
- task control block
- threads
- scheduler
- scheduling point
- preemptive scheduler
- nonpreemptive scheduler
- blocked
- synchronization
- intertask communication semaphore
- counting semaphore
- message queue
- event
- signal
- producer-consumer problem
- critical section
- double buffer
- ring buffer
23Concurrency, Tasks, and Intertask Communication
- Introduction
- Interrupts and Concurrency
- Sharing CPU
- Scheduling
- Role of Scheduler
- Task Control Block
- Preemptive Scheduler
- Scheduling Points
- Tasks
- Defining
- Task dependencies
- Communication and Synchronization
- Semaphores
- Buffers and Queues
- Events
- Signals
- Examples and Constructs in C
24TCB Task Control Block Data Structure OS uses
to keep track of threads
ReadyQ BlockedQ SpawnedQ
25Task Dependencies
- data dependencies
- shared data
- computational intensity
- functional dependencies
- sequential cohesion
- functional cohesion
- time dependencies
- critical and urgent activities
- varying periodicity
- temporal cohesion
26Communication and Synchronization
- Communication (Data Sharing)
- Message Queues
- Mailboxes
- Buffers (semaphores for access control)
- Double Buffer
- Ring Buffer
- Synchronization (Sequencing)
- Semaphores
- Events
- Signals
27Real-Time Scheduling
Key Concepts and Terms
- round robin
- weighted round robin
- cyclic executive
- job
- task
- periodic task
- sporadic task
- aperiodic task
- periodic task model
- table-driven
- clock-driven
- time slice
- static scheduling
- dynamic scheduling
- frame-based scheduling
- WCET
- jitter
- execution time
- release time
- phase
- period
- deadline
- relative deadline
- feasability
- utilization
- response time
- hyperperiod
- harmonic task set
- optimality
- priority-driven schedule
- state-driven
- polled loop
- slack
28Not quite a RTS Kernel
- Pseudokernel
- Polled Loop
- Cyclic Executive
- State-Driven Code
- Typical nonRT approaches
- Round Robin
- Weighted Round Robin
- Foreground / Background
- Self-Scheduling
29Table-Driven Scheduling
- Assumptions
- Known, fixed tasks.
- Known periods and execution times (hard
real-time). - Job available at start of period.
- Aperiodic executed during idle times.
- Approach
- Define hyperperiod.
- Define schedule.
- Create table with release times relative to start
of hyperperiod. - No error checking.
30Frame-Based Scheduling
- Scheduler for frame-based is periodic.
- Scheduling decisions made at set intervals (start
of a frame). - Schedule table is made up of blocks (all jobs to
run in a given frame). - Attempt to simplify and standardize scheduling.
- Error checking performed at start of frame.
- Frame size carefully selected to meet criteria.
31Aperiodic and Sporadic Jobs
- Aperiodic (soft deadline)
- Scheduled when processor idle as FIFO (no
acceptance test). - Slack Stealing (scheduled before periodic tasks).
- Can calculate average response time.
- Sporadic (hard deadline)
- Consider EDF (Earliest Deadline First) Scheduling
- Job with earliest absolute deadline has highest
priority. - Acceptance Test
- Enough slack?
32Priority-Driven Scheduling
- Key Concepts and Terms
- EDF
- RM
- DM
- LST
- schedulability test
- schedulable utilization
- optimality
- critical instant
- time-demand analysis
- busy interval
- general schedulability test
33Priority Schemes
- Rate Monotonic Assignment (RM)
- Rate 1/p.
- Higher rate Higher priority.
- Deadline Monotonic Assignment (DM)
- Relative deadline.
- Shorter deadline Higher priority
- DM RM when D p.
- Earliest Deadline First (EDF)
- Absolute deadline.
- Closer deadline Higher priority
- Least Slack Time First (LST)
- Slack d t x.
- Smaller slack Higher priority.
34Schedulability (Breakdown) Utilization
- Schedulability tests when D p
- EDF
- necessary and sufficient condition.
- RM
- sufficient condition
35Time-Demand Function
36General Time-Demand Analysis
- Can all jobs in Ti meet their deadline?
- for each task Tk in ?i
- compute wk1(t)
- if all wk1(t) ? pk
- check wi1(t) ? t ? Di
- if ji1 meets deadline
- feasible
- else
- not feasible
- else
- compute length (tl) of in-phase level-?i busy
interval - compute max response of ALL ceil(tl/pi) jobs of
Ti if all meet deadlines - feasible
37Scheduling of Aperiodic and Sporadic Tasks
- Key Concepts and Terms
- Periodic Server
- Bandwidth-Preserving Servers
- Deferrable Server
- Consumption Rules
- Replenishment Rules
- Sporadic Server
- Constant Utilization
- Total Bandwidth Server
- Weighted Fair-Queueing Server
- Slack Stealing
38Objectives of Scheduling Algorithm
- Correct Schedule
- Response Time is minimal
- Scheduling of sporadic is optimal
- Validation is relatively easy
39Scheduling of Aperiodic ONLY
- Aperiodic Scheduling Schemes
- Background (non-optimal)
- Interrupt-Driven (not correct)
- Slack Stealing Algorithm (high overhead)
- Polling Server (non-optimal)
- Bandwidth Preserving Server
40Scheduling Aperiodic Sporadic Jobs
- Aperiodic Jobs
- Polling
- Bandwidth Preserving Server
- Deferrable Server
- Sporadic Server
- Constant Utilization and Total Bandwidth Servers
- Weighted Fair-Queueing Server (will not be
covered) - Slack-Stealing Algorithms (will not be covered)
- Sporadic Jobs
- EDF
- acceptance based on density
- Fixed Priority Scheduled by Bandwidth Preserving
Server - acceptance based on slack
41Acceptance for Sporadic Tasks in Deadline-Driven
System
- Density of periodic jobs
- Density of sporadic job
- Acceptance of first sporadic job
42Acceptance for Sporadic Tasks with Fixed-Priority
- Acceptance Test for first sporadic task
S1(t,d1,e1) - Acceptance Test for any sporadic task Si(t,di,ei)
- enough slack ?
- make any lower priority sporadic tasks miss
deadline?
43Two-Level Scheme for Integrated Scheduling
- Application Servers (level)
- Schedule subset of all tasks
- May use any priority scheme
- Runs on slower virtual processor
- OS Scheduler (level)
- replenishes budgets of application servers
- sets deadlines of application servers
- schedules application servers using EDF
44Priority Scheduling
- Assigning Priority
- task-level fixed (RM, DM)
- task-level dynamic, job-level fixed (EDF)
- Schedulability Test
- Schedulable (Breakdown) Utilization
- Time-Demand Analysis
- Assumptions
- Preemptable at any time.
- No self-suspension.
- Independence.
45Consequences of Blocking
- Job waits (self-suspends) until resource
available, - thus it is blocked by another job.
- If you use self-suspension exclusively
- to control access to resources
- BAD THINGS CAN HAPPEN
- Unbounded priority inversion wait is
potentially infinite. - Deadlock job A waits for job B, job B waits for
job A.
46Sharing Resources Control Protocols
- Resource Access Control Protocols
- Nonpreemptive Critical Section (NPCS)
- Basic Priority-Inheritance Protocol
- Basic Priority-Ceiling Protocol
- Stack-Based, Priority-Ceiling (Ceiling-Priority)
Protocol - Distinguished by
- Scheduling Rule
- Allocation Rule
- Priority Rule
- Implementation
- Priority Algorithm (fixed or dynamic)
- Simplicity of implementation (a priori
information) - Addresses concerns
- Unbounded Priority Inversion
- Deadlock
- Blocking Time
47Assigning Tasks (Subtasks)
- How many of each processor type?
- What is the function of each processor?
- How are tasks and jobs defined?
- How do you synchronize tasks (precedence
constraints)? - How do you control shared resources across
processors? - What scheduling algorithm should you use?
- How do you optimally assign tasks to processors?
(NP-Hard) - Frame as bin-packing (Ignore communication and
resources). - Frame as integer linear-programming problem
(Ignore resources). - Frame as graph-partitioning.
48Local and Remote Resources
49Scheduling the Tasks
- How do you control shared resources across
processors?
50Power Management and Embedded Systems
- Importance of power
- Power Estimation
- Power Management
- Hardware
- Software
- Power Aware Computing, MF Jacome and A
Ramachandran in Embedded Systems Handbook - Power Management Techniques for Real-Time
Embedded Systems, S. Gary. Texas Instruments
White Paper
51Why save power?
- Effects of power usage
- Dynamic and Static power
- Power usage
52WCET
- definition
- upper and lower bounds
- safe and tight
53Methods and Goals
- Static Analysis
- Measurement-Based
- Goals
- affordable
- sufficiently precise
- tractable
- easy
54Problems in WCET Analysis
- Path Problem
- infeasible paths
- halting problem
- longest path
55Problems in WCET Analysis
- State Problem
- intractability
- local vs global analysis
- divide-and-conquer
- context (TRPS timing-relevant processor state)
- control-flow interference
- data memory interference
- timing anomolies
56References
- Formal Methods
- Ten commandments of formal methods... Ten years
later (Bowen, Jonathan P. and Hinchey, Michael
G.) Computer, v 39(1), January, 2006, p 40-48. - Statecharts
- Describing Behaviors Using Statecharts
(Jonathan M. Kaye and David Castillo) Flash MX
for Interactive Simulation (Ch. 7).
www.flashsim.com, 2003, p. 75-101 - STATECHARTS A Visual Formalism for Complex
Systems (Harel, David) Science of Computer
Programming, v 8(3), 1987, p 231-274.
57Formal Methods
- A formal specification language provides
- a notation (its syntactic domain),
- a universe of objects (its semantic domain)
- a rule defining which objects satisfy each
specification. - It provides the means of proving
- a specification is realizable
- a system is correct
- properties (behavior) of a system without running
it
58Statecharts
- Statecharts state-diagrams depth
orthogonality broadcast communication - state-diagrams
- depth
- orthogonality
- broadcast communication
- AND
- permits rapid and robust coding
- provides excellent documentation and validation
tools
59Petri Nets
- Graphical and Mathematical Model of Processes
- places, transitions, tokens, markings
- coverability tree
- colored petri nets
- timed petri nets