Closed chowned closed 1 year ago
Hi,
Thanks.
In fact, the TerminateTask() is not required in Trampoline, as the tpl_init_context
function inserts the TerminateTask() call in the stack (in machine/avd/tpl_machine.c
)
regards,
Mik
Thanks a lot @chowned.
I correct my colleague a bit. 🙂
Not calling TerminateTask() is an error according to AUTOSAR requirement SWS_Os_00069 and section 4.7 of OSEK/VDX Operating System.
Trampoline complies with the AUTOSAR standard. Therefore it meets the following requirements:
This explains why Trampoline supports omitting TerminateTask(). The purpose of these AUTOSAR requirements is to avoid unpredictable behavior.
From the implementation point of view, the return address of a task is the CallTerminateTask function (this is the case for the AVR port). CallTerminateTask performs the following operations:
Best regards.
Jean-Luc
This is a minor thing, but I added at the end of each task in the examples provided for Arduinos a simple "TerminateTask();". Arduino manages to still run without this code even if it is not beautiful, but this is enforcing a bad programming habit.
This is something similar as "fclose" for files.
Codes were tested and were running like expected. Just it drives better new programmers.