Has anyone see this problem?
I have a BCC task that has to make a run-time decision to perform a ChainTask (on itself) or a TerminateTask:
... SuspendAllInterrupts(); x = global_var; ResumeAllInterrupts();
if ( x ) { ChainTask (this_task); } else { TerminateTask(); }
The problem is that there is a window of vulnerability between the ResumeAllInterrupts and the TerminateTask where an interrupt or task can preempt and write global_var (to non-zero). In which case, the task would really have wanted to ChainTask and not TerminateTask. Is there a way to make this thread-safe?
Can't use ECC tasks because they use too much stack. Can't use PostTaskHook because this is called every time this task is preempted. Can't remove ResumeAllInterrupts call because OSEK doesn't allow API calls within a critical section.