Download GU0102 TSK51x/TSK52x RTOS

Transcript
Events
if (E_OK != WaitEvent(myEvent3))
{
/* 'myEvent' is not owned by 'myTask' */
LogError(WAITEVENT);
TerminateTask();
}
...
TerminateTask();
return;
}
When the scheduler moves the task from the ready to the running state, the task resumes
execution at the following immediate instruction.
3. A task can wait for several events at a time:
WaitEvent(myEvent1 | myEvent2 | ...);
The task does not undergo the transition if just one of the events has occurred. In this case the
service immediately returns and the task remains in the running state. Only when all the events are
cleared for the calling task, the invoking task is put into the waiting state.
4. WaitEvent() can only be invoked from the task level of an extended task, never from interrupt
level or a hook routine.
5. You can set an event (equivalent to an event occurs") to a specific task directly with the system
service:
StatusType SetEvent(TaskType,EventMaskType);
6. If you need to trigger an event for more than one task you need to call SetEvent() for each
combination of task and event.
7. An event can be set indirectly by the RTOS code upon expiration of an alarm (provided that its
ACTION attribute is set to SETEVENT in the OIL file) or when a message is transmitted (provided
that its NOTIFICATION attribute is set to SETEVENT).
8. An event can be triggered from interrupt level (common situation).
9. You cannot set events to suspended tasks.
10. You can set several events at a time for a waiting task or ready task:
SetEvent( myTask, myEvent1 | myEvent2 | ...)
If myTask is waiting for any of the triggered events it will enter the ready state. If the task is ready,
the events shall remain set waiting for evaluation in the next call to WaitEvent().
11. You can check which events have been set for a given task with the system service:
StatusType GetEvent(TaskType,EventMaskRefType);
You can call this service to distinguish which event triggered the task and then take the
corresponding action. This service can be called from a hook routine or from interrupt level.
6-3