Download GU0102 TSK51x/TSK52x RTOS

Transcript
Interprocess Communication
C source file
#include "flag.h"
#include "mytypes.h"
DeclareMessage(recCommand);
DeclareEvent(event);
TASK (commandHandler)
{
myStruct st;
while(1)
{
if (COM_TRUE == ReadFlag_FlgComm())
{
ReceiveMessage(recCommand,&st);
processMsg(&st);
}
else
{
SetRelAlarm(alarm,
(POLLMSCS)/(OSTICKDURATIONINMSCS),0);
WaitEvent(event);
ClearEvent(event);
}
}
TerminateTask();
return;
}
You must always include the file flag.h when using Flag Notification Mechanisms. Otherwise your
application will not compile.
This solution is even less safe. It assumes that the minimum average interarrival time between two
consecutive commands is at least greater than POLLMSCS plus the code execution overhead in the
while loop.
10-19