Page 1 of 1

What is more effective

PostPosted: Tue Nov 05, 2002 9:10 am
by luben
Hello,

Just for curiousity what is more effective (takes less time from the OSSched and/or less memory) for slowly process tracking of variable or event:

1. To use OS_Delay and after the task wakes up to check the event or variable
2. to use OS_WaitXYZ

As I know every time I call OSSched the kernel checks the events and if something occures it makes the waiting for this event task eligible. That means - every call to OSSched brings some time and attention to check the events.

When the task is delayed it waits several calls of OSTimer (that are processed after that in OSSched).

Regards
Luben


Re: What is more effective

PostPosted: Tue Nov 05, 2002 9:25 am
by aek
Hi Luben.
quote:
As I know every time I call OSSched the kernel checks the events and if something occures it makes the waiting for this event task eligible.
Actually, that's not what happens in an event-driven system like Salvo. OSSched() does not "check the events". In fact, OSSched() really knows nothing of events -- it just knows about tasks in queues.

What happens is when an event is signaled, the task(s) that successfully wait the event are placed in a special queue in the order that the events were signaled. When OSSched() is finally called, those now-eligible tasks are moved to the eligible queue, delayed tasks are checked for timeouts, and finally the most eligible task runs.

quote:
That means - every call to OSSched brings some time and attention to check the events.
All OSSched() does is check queues -- if they're empty, it does nothing.

This is a subtle but very important distinction -- events are never "polled" in Salvo.

So, to your question -- in terms of performance, using OS_WaitXyz() is always better. That's because on average, fewer cycles will be spent in Salvo code. But the code will be larger (has to handle events), and it will cost some extra RAM (e.g. 4 bytes per event). Using OS_Delay() will be smaller, RAM- and ROM-wise, but less efficient because you will spend time in Salvo code regardless of whether your event has happened, since you will be polling ...

Regards,

------------------