Download GU0102 TSK51x/TSK52x RTOS

Transcript
Interrupts
The critical area should be extremely short though, since the system as a whole is on hold (even
Category 1 ISRs are disabled!). DisableAllInterrupts() must always precede the critical section
and immediately after the section, EnableAllInterrupts() must follow.
Avoid situations situations like below:
ISR(isr)
{
DisableAllInterrupts();
if (A)
{
EnableAllInterrupts();
doSth();
}
else
{
...
}
return;
}
This causes the system to be outbalanced when returning from isr if A is zero.
Also, no API service calls are allowed within this critical section. You must avoid code like below:
TASK(myTask)
{
...
DisableAllInterrupts();
/* critical code section */
SetEvent(task,event);
/* not allowed */
EnableAllInterrupts();
...
}
You should be careful when building library functions which are potential users of of these services,
since nested calls are never allowed. Avoid situations like below:
static void f(void)
{
DisableAllInterrupts();
otherThings();
EnableAllInterrupts();
return;
}
9-11