TrampolineRTOS / trampoline

Trampoline is a static RTOS for small embedded systems. Its API is aligned with OSEK/VDX OS and AUTOSAR OS 4.2 standards.
GNU General Public License v2.0
615 stars 268 forks source link

Adding TerminateTask(); in the examples provided #114

Closed chowned closed 1 year ago

chowned commented 1 year ago

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.

mbriday commented 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

jlbirccyn commented 1 year ago

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