Skip to content

Commit 0d601cc

Browse files
authored
Merge pull request #1093 from esrlabs/cr-131286
Adding rationale for fixed assignment of activities to threads.
2 parents c245bc5 + 11dbaf2 commit 0d601cc

File tree

5 files changed

+54
-2
lines changed

5 files changed

+54
-2
lines changed
21 KB
Loading
42.1 KB
Loading
9.14 KB
Loading
12.6 KB
Loading

docs/features/frameworks/feo/index.rst

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ Queuing of topics:
184184
* Queue enable and queue length are "runtime static" configuration settings
185185

186186

187-
Process/Thread Mapping
188-
======================
187+
Process/Thread/Activity Mapping
188+
===============================
189189

190190
* An application consists of one or more processes
191191
* One of the processes is the primary process
@@ -208,6 +208,50 @@ Process/Thread Mapping
208208
achieve Freedom From Interference for safety relevant applications
209209

210210

211+
Static mapping of activities to threads
212+
'''''''''''''''''''''''''''''''''''''''
213+
214+
As pointed out above, FEO activities are required to be mapped to threads in a static way.
215+
The rationale behind this requirement is:
216+
217+
* Calling activity functions init(), step() and shutdown() from a single pre-defined thread
218+
allows implementations to make use of thread-local optimizations such as thread-local variables.
219+
* Calling an activity's step() function from different threads in different iterations of the
220+
task chain may cause execution time jitter e.g. from unpredictable cache misses or different
221+
properties of the processor cores the respective threads may be assigned to.
222+
* Most importantly, a dynamic assignment of activities to threads may result in non-deterministic
223+
variations of the task-chain execution time.
224+
225+
To understand how a dynamic thread assignment can cause execution time variations, consider
226+
the following example (sub-) task chain.
227+
228+
|example_task_chain|
229+
230+
Here, activity 6 depends on, i.e. must be executed after activities 1 to 5. The length of the bars
231+
is intended to indicate the relative computation time needed by the respective activity on a
232+
single processor core. It is assumed that all of these activities will be executed in the same process.
233+
234+
In a simple approach, each of the activities 1 to 5 could be assigned to its own thread and
235+
activity 6 could be executed subsequently in one of these threads as shown in the figure below.
236+
Each blue "lane" indicates one thread.
237+
238+
|example_task_chain_5_threads|
239+
240+
If each thread runs on a separate core and execution is not interrupted by other tasks, the length of
241+
the blue box is related to the total execution time of the task chain.
242+
243+
Approximately the same total execution time can be achieved with only 3 threads (on three cores), if the
244+
tasks are assigned in an optimized way:
245+
246+
|example_task_chain_3_threads_optimized|
247+
248+
If, on the other hand, activities are assigned to the same 3 threads in a dynamic way, the execution
249+
time may vary unpredictably, because of the possibly varying execution sequence of activities,
250+
as can be seen below.
251+
252+
|example_task_chain_3_threads_dynamic|
253+
254+
211255
Lifecycle
212256
=========
213257

@@ -383,3 +427,11 @@ timing of activities, supporting safety-critical applications
383427
in the automotive domain. In this domain the footprint of the framework is curcial especially
384428
w.r.t impact of computation load and latency.
385429

430+
431+
.. |example_task_chain| image:: _assets/example_task_chain.png
432+
433+
.. |example_task_chain_5_threads| image:: _assets/example_task_chain_5_threads.png
434+
435+
.. |example_task_chain_3_threads_optimized| image:: _assets/example_task_chain_3_threads_optimized.png
436+
437+
.. |example_task_chain_3_threads_dynamic| image:: _assets/example_task_chain_3_threads_dynamic.png

0 commit comments

Comments
 (0)