Download GU0102 TSK51x/TSK52x RTOS

Transcript
TSK51x / TSK52x RTOS
C source file
DeclareMessage(sendMsg);
DeclareMessage(recMsg)
ISR(isrSender)
{
int data = GetData();
SendMessage(sendMsg,&data);
...
return;
}
ISR(isrRec)
{
int data;
ReceiveMessage(recMsg,&data);
ProcessData(data);
...
return;
}
9.8
Fast Disable/Enable API Services
The OSEK/VDX standard provides you with a number of fast disable/enable API functions. The implementation hides all the
internal target details for you. These services come always in pairs:
Critical code
API services
Suspended ISRs
very short (no nesting)
DisableAllInterrupts
EnableAllInterrupts
ISR1s and and ISR2s
very short (nesting)
SuspendAllInterrupts
ResumeAllInterrupts
ISR1s and and ISR2s
short (nesting)
SuspendOSInterrupts
ResumeOSInterrupts
ISR2s
long
GetResource
ReleaseResource
Only ISR2s owning the resource
In the next sections these pairs are described into more detail.
9.8.1
Disable/Enable All Interrupts
You can use the following system services to disable/enable all maskable interrupts:
void DisableAllInterrupts(void);
void EnableAllInterrupts(void);
the DisableAllInterrupts() service disables globally all interrupts (by clearing/setting a global enable/disable bit or by
raising the processor priority level above all possible interrupt levels).
The EnableAllInterrupts() service does the opposite, it restores the saved state in the previous routine.
You can call these services from Category 1 ISR and Category 2 ISR and from the task level, but not from hook routines.
These services are intended to encapsulate a critical section of the code (no maskable interrupts means no scheduling which in
its turn means no concurrency). It is a much faster and costless alternative to the GetResource/ReleaseResource routines.
9−6