Open
Description
Consider the pseudo code:
Task Dispatch:
{
sem_wait(&Semaphore); // Wait for event
dispatch_event(State_Machines, 1)
}
Task Generate Events:
{
Machine.Event = SOME_EVENT;
sem_post(&Semaphore);
Sleep(random());
}
Task Generate Other Events:
{
Machine.Event = OTHER_EVENT;
sem_post(&Semaphore);
Sleep(random());
}
Should the set of event be protected from other tasks?
- Since dispatch_event will clear internally Machine.Event,
- Since more than one task can generate events,
- Since there is no queue of events, once an event is created, no other can be created until the previous is cleared.
What is your opinion on this? Could this be improved?