Escolar Documentos
Profissional Documentos
Cultura Documentos
Agenda
You can potentially handle more You are to execute these activities within
advanced functionality. the one program?
How can you do all these things concurrently
(at the same time)?
Yet, the program internal structure is
How can you change the same LEDs based on
simply a single sequence of actions: both (1) the push buttons, (2) as well as the
While (1) { photoresistor?
1. Sample How can you print different information on the
2. Compute
same display?
3. Actuate
4. State update
} Requirement1: Concurrency / Multitasking
Requirement2: Resource sharing
1
Machine Design Machine Design
How you might have dealt with How you might have dealt with real-
concurrency? time requirements?
2
Machine Design Machine Design
ECU connectors
Medical on top of the ECU
Tough Environment
Tight integration
Robot Real-time
Dependability
Cowbot
Combustion Engine ECU tasks: control of engine, fan, alternator, engine brake,
engine turbo, and the EGR valve + CAN communication, + diagnostics, …
Mechatronics Lab 15 Mechatronics Lab 16
Activity examples:
Human-machine interface
Controllers
Communication
3
Machine Design Machine Design
Context
Switch
4
Machine Design Machine Design
Definition of real-time
Advanced ES software:
Real-Time Systems Common definitions:
A computer system is a real-time one if it
explicitly manages resources in order to meet
timing constraints
(Douglas Jensen, 1992)
Examples of real-time
Real-Time Computing Basics
activities/tasks
Hard real-time activities/tasks: Time: the correctness of the system
– Sensory data acquisition depends on both time and logic
– Detection of critical conditions
– Control output to actuator Real: the internal time scale must
– Control of safety critical systems match the external time scale
Real-time: ( real fast) predictable in
Soft real-time activities/tasks: deterministic or probabilistic timing
– HMI requirements, i.e., the deadline
– Handling input data from the keyboard
– Displaying messages on the screen – Hard: missing deadline may cause
– GUI catastrophic or critical consequence
– Logging – Soft: meeting deadline is desirable, but not
critical
5
Machine Design Machine Design
6
Machine Design Machine Design
Code
PC
Global variable
OS
Mechatronics Lab 39 Mechatronics Lab 40
A Thread Has
Final solution: Real-time operating
Execution context SP(T2)
systems
Stack (T2)
– Program counter
(PC) Stack (T1)
SP(T1)
– Stack pointer (SP)
– Data registers Heap
1 process has at least
1 thread
Static Data
1 thread must belong PC(T2)
to 1 process Code (T2)
Code (T1)
PC(T1)
7
Machine Design Machine Design
8
Machine Design Machine Design
A A X
B B
0 2 0 2
Mechatronics Lab 53 Mechatronics Lab 54
9
Machine Design Machine Design
B
0 2
Mechatronics Lab 55 Mechatronics Lab 56
10
Machine Design Machine Design
11
Machine Design Machine Design
A different thread
Waiting
Lock(s) when s is
called Unlock(s) already locked by
another thread
Mechatronics Lab 67 Mechatronics Lab 68
12