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

Sleep equivalent in VxWorks

3,421 views
Skip to first unread message

A. Earl Jackson

unread,
Mar 18, 1998, 3:00:00 AM3/18/98
to

I am looking for the VxWorks equivalent for sleep found in UNIX. We are
using a Hyper SPARC system. I've tried sleep command from the command line
and I get an error. The suggested reference manual for version 5.3 suggests
nanosleep. However, I used the function within a c program. I compiles
correctly; but again VxWorks rejects the command nanosleep. Has anyone ever
invoked a sleep equivalent in VxWorks?

Thanks to all that respond.

Earl Jackson

ale...@fls.infi.net

Fred Zwarts

unread,
Mar 19, 1998, 3:00:00 AM3/19/98
to

"A. Earl Jackson" writes:

VxWorks 3.2 for the AXPvme has the taskDelay function. Is that what you are
looking for?

Fred Zwarts Kernfysisch Versneller Instituut (KVI)
Zernikelaan 25 Phone: (+31/0)50 363 3619
9747 AA Groningen Fax: (+31/0)50 363 4003
The Netherlands E-mail: F.Zw...@KVI.nl


Joseph Durusau

unread,
Mar 19, 1998, 3:00:00 AM3/19/98
to

"A. Earl Jackson" <ale...@fls.infi.net> writes:

>I am looking for the VxWorks equivalent for sleep found in UNIX. We are
>using a Hyper SPARC system. I've tried sleep command from the command line
>and I get an error. The suggested reference manual for version 5.3 suggests
>nanosleep. However, I used the function within a c program. I compiles
>correctly; but again VxWorks rejects the command nanosleep. Has anyone ever
>invoked a sleep equivalent in VxWorks?

look up the man page on taskDelay. Most BSPs support it.
Note that you may have to include a system prefix to get the page.

Speaking only for myself,

Joe Durusau

Donald McLachlan

unread,
Mar 19, 1998, 3:00:00 AM3/19/98
to

#define sleep(x) taskDelay(x * sysClkRateGet())

--
Donald McLachlan e-mail Donald.M...@crc.ca
Communications Research Centre / DRX office 613-998-2845
3701 Carling Ave., fax 613-998-9648
Ottawa, Ontario
K2H 8S2
Canada

Kevin Bradley

unread,
Mar 19, 1998, 3:00:00 AM3/19/98
to

Excerpts from netnews.comp.os.vxworks: 18-Mar-98 Sleep equivalent in
VxWorks by "A. Earl Jackson"@fls.in
> nanosleep. However, I used the function within a c program. I compiles
> correctly; but again VxWorks rejects the command nanosleep. Has anyone ever
> invoked a sleep equivalent in VxWorks?

I presume that when you says "VxWorks rejects the command nanosleep"
you mean that it says something about nanosleep being an undefined
symbol on download.

Your target system has to have the "nanosleep" compiled in to the kernel.
I believe this is a part of the ANSI routines; check your kernel config
to make sure you have

#define INCLUDE_ANSI_TIME
or
#define INCLUDE_ANSI_ALL

somewhere in config.h or configdb.h. Check the manual about timerLib.

I'm pretty sure that's the one, as I don't have "#include POSIX"
in my system, but I can do nanosleep.

One other option, which I'm not entirely certain about, is to
strip out the .o file containing nanosleep from the system libraries
and link directly with that. I believe it lives in timerLib.o,
which is in your lib<sys>gnuvx.a archive. However, it requires
the rest of the functions in timerLib (timer_cancel, etc.),
so it's probably not a good idea.

If you've got your system up, try doing a "lkup timer_connect"
on the target and see if the symbol comes back, or look through
the symbol table on the host. If it's not there, then timerLib
isn't on your target system, so you can't use nanosleep unless
you rebuild the kernel to include it.

If you can't, then the suggestions about taskDelay() are necessary,
as taskDelay is always on the system.

Keep in mind that the accuracy of taskDelay is with regards to the
system clock, so if you're running at something fairly slow, e.g.
60 Hz, you can't do taskDelay() on the order of 1 ms; you're limited
to integer clock ticks.

-- Kevin


0 new messages