DVA455 Exercises
DVA455 Exercises
1. RTS development
a) Explain why the following probably is not a good idea, and suggest another development
approach:
“We will use an agile development method with short sprints. Each sprint we will pick one
function, define detailed functional- and timing requirements for that function, implement it
and ensure that those requirements are met.”
b) Give two reasons why real-time embedded systems are difficult to test compared to other
types of software, and explain why.
a) Explain why the following is probably not a good system-level timing requirement, and
suggest a reasonable reformulation:
“After detecting that a collision has occurred, the fuel valve must be closed within 100 ms.”
b) Consider the description: The motor should be adjusted based on the water level at least
every 50 ms. If the pause button is pushed, the motor must stop within 200 ms and remain off
for 10 s.
Explain why the following is not a suitable design (what specific problem will it cause), and
suggest an improvement (numbers indicate task periods):
3. RTS design (cont.)
c) Consider the description: If the average temperature reaches 120 degrees, the fan must
start within 200 ms and the valve must be opened within 50 ms.
Explain why the following is not a suitable design (what specific problem will it cause), and
suggest an improvement (numbers indicate task periods):
4. RTS implementation
a) Let A and B be two tasks with a precedence relation from task A to task B.
Explain how task parameters can be selected to ensure this precedence when the system
is based on i) Fixed Priority Scheduling (FPS); or ii) Earliest Deadline First (EDF).
b) Consider the design below, with this explanation: The periods are defined in a way that we
can use rate monotonic priority assignment and ensure that tasks are executed in the right
order. Explain why this is not a suitable design (what specific problem will it cause) and
suggest an improvement (numbers indicate task periods).
c) Give an example of a task set that is not suitable to implement as a cyclic executive, and
explain why.
5. RTS design and analysis
Consider the following requirements for a real-time system controlling a part of a water distribution network:
1. The main valve should be adjusted every 100 ms based on the pressure before and after the valve.
2. If the pressure after the valve ever reaches max_level, the two emergency valves must be opened
within 50 ms, and no more than 10 ms apart.
3. The current pressure values should be sent to a remote operator station every second.
In addition, you know that the code for sending information to the operator station is fairly complex, with a
WCET of 150 ms. Each sensor reading takes 10 ms, but computations and controlling the valves takes very
little time (around 1 ms).
a) Design the system and depict the design graphically, including the tasks, what data is communicated
between tasks, and which tasks are communicating with which peripheral devices (sensors/actuators).
b) Select a suitable scheduling approach (offline/online, preemptive/nonpreemptive, etc.), and assign periods
and other relevant task parameters.
c) Argue that all three system-level timing requirements are met (including that the system is schedulable).
Note: Consistency between the three sub-assignments (a, b and c) is crucial.
6. RTOS
Assume the following tasks:
sleep(42); sleep(24);
} } }
b) Give an example of a priority ordering that prevents at least one task from
executing.
b) Give a schedulability test that is both sufficient and necessary for a task
set where all tasks have the same period, i.e.., T1=T2=T3=…=Tn
8. Rate Monotonic
Assuming the taskset:
Task T C
A 10 1
B 4 1
C 2 1
If not, how much do you need to reduce the execution time of the lowest
priority task such that the system is schedulable?
10. Response time analysis
Task Period = deadline C
L 50 10
H ? 3
L = low priority
H = high priority
a) What is the shortest possible period for H such that the system is schedulable?
11. Response time analysis with shared resources
Length of the
critical section (cs)
Priority assignment = Rate Monotonic.
Synchronisation protocol = Priority Ceiling Protocol
Task Period D C
A 3 2 1
B 4 2 1
C 5 4 2
æ ê L - Di ú ö
n
"L Î D : L ³ å çç ê + ÷
ú ÷Ci
1
i =1 è ë Ti û ø
15. Offline scheduling
Use preemption and EDF heuristics to schedule the precedence graphs below:
Period: 15
Task C Release time (RT) Deadline (D)
A
A 4 0 7
C
PG 1: B 3 0 12
B C 5 0 15
D 1 3 4
Period: 5
PG 2:
D
16. Offline scheduling
Construct an offline schedule for the control of an electric motor.
MOTOR
Period=12
sampling actuating
Computer
Sampling
– It takes at most one clock tick
– Must be done latest 3 clock ticks after its activation
Computation of an actuation value
– Takes at most 5 clock ticks
Actuation
– Takes at most 1 clock tick
– The time between actuation and the next sampling may not be longer than 3 clock
ticks
Additionally, we have a taks that calculates the engine torque
– Period= 2T=24
– Takes at most 1 clock tick
– Must be done latest 3 clock ticks after its activation
17. CAN communication
Assume the following messages sent on a CAN bus from 3
nodes (N1 sends m1, etc.)
message Deadline (D) Period (P) Data bytes (n)
m1 4 10 1
m2 6 20 5
m3 10 15 6
Assume:
• all values represent milliseconds
• Priority assignment: deadline monotonic
• nr of control bits in every frame: 47
• Buss spped: 50 Kbit/s
• no incoming jitter