Page 1 of 1

EE_hal_terminate_task and EE_hal_terminate_savestk

Posted: Mon Sep 06, 2010 1:40 pm
by srl100
Can anyone give me a plain description of what EE_hal_terminate_task() and EE_hal_terminate_savestk() should do?

There are plenty of examples of what the functions do for particular processor architectures, thanks, but what I am missing is an overview of what the requirement for these functions is.

Thanks,

Steve.

Re: EE_hal_terminate_task and EE_hal_terminate_savestk

Posted: Mon Sep 20, 2010 3:34 pm
by srl100
Sorted!

What was misleading me was the name of EE_hal_terminate_savestk() - it's not called at task termination time, but prior to running the task (in preparation for the task's eventual termination).

Once I'd got my head round that it was clearer what the routine should do!

Re: EE_hal_terminate_task and EE_hal_terminate_savestk

Posted: Tue Sep 21, 2010 6:20 pm
by paolo.gai
Hi!

sorry for the delay, I was out of town for a while...

The idea is that the two functions works more or less as a longjump in the C library.

Each task when using OSEK saves all registers which are saved if used by the callee. Then it saves the stack pointer and calls the thread body.

Then the terminatetask is called inside the task, which takes back the data saved unwinding the stack.

the function should be written when possible in a way that if the user forgets to put the TerminateTask, then the thread returns on the unwinding procedure avoiding a system crash. Typically you obtain this by putting the termination part after the save in the assembler file.

Note that FP, EDF, FRSH kernels does not support TerminateTask and these functions...

I hope this helps...

PJ