Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[VxWorks] Timer and TaskDelay

729 views
Skip to first unread message

Yao Yong

unread,
Sep 15, 2003, 2:13:59 AM9/15/03
to
Hi,all
Now, there's an application model like the following:
A task is waiting for a semphore, and then do a job. And again,
waiting for the semphore. A timer gives the semphore once a second.
The code maybe like the following:
void Daemon()
{
FOREVER ()
{
semTake(sem); (1)
...;
}
}

void TimeHandler()
{
semGive();
}

I want to know, if I change sentence (1) into
taskDelay(sysClkRateGet()), and get rid of the TimerHandler. It seems
that the two solution both can handle the problem, but if there's any
difference?

Best regards

free

unread,
Sep 15, 2003, 7:28:15 AM9/15/03
to
For me,
VxWorks is not very accurate with taskDelay, particulary with small value
(1,2).
Example for 1 ms
Case 1: your code time executed each 1 ms. No time shift

Case 2: TaskDelay(1 ms) + your code time + taskDelay(1ms) + ...
There is a time shift.

Charly

Michael Lawnick

unread,
Sep 15, 2003, 7:44:52 AM9/15/03
to
Hi Yao Yong,

the difference is:
- with TimeHandler() you'll stay synchronized. Even if the job execution
time has a jitter that might exceed 1s sometimes, two rounds will be taken
within 2 seconds. If you use a counting semaphore, multiple jobs exceeding
1s in sequence are allowed and still the whole system will synchronize after
some turns.

- with taskDelay(sysClkRateGet()) you will get out of 1s sync if jobExecTime
> tickTime (i.e.. not 1s!). This 'out of sync' will accumulate for evey job
that executes longer than one system tick.

You should not assume that your job is always guaranteed to finish within
one tick, as there might be an higher priority task or an interrupt
occupying the CPU outside your control. Assumptions like 'time will be
enough' are sometimes the first step to trouble ;-)

The second version is simpler, the first is more accurate. You'll have to
decide yourself which one serves your needs.

--

Regards,
Michael

21 is only half the truth.

FAQ - "http://www.xs4all.nl/~borkhuis/vxworks/vxworks.html"
Wiki -
"http://www.bluedonkey.org/cgi-bin/twiki/bin/view/Books/VxWorksCookBook"
"Yao Yong" <yy_un...@hotmail.com> schrieb im Newsbeitrag
news:cfe430d0.03091...@posting.google.com...

Yao Yong

unread,
Sep 18, 2003, 4:46:50 AM9/18/03
to
"Michael Lawnick" <michael.lawnick@no_spam_pls.kontron.com> wrote in message news:<3f65a...@news.arcor-ip.de>...

Thanks a lot&#65281;

0 new messages