Re: nanosleep (Ashley Sanders)
Re: nanosleep (Ashley Sanders)
- Subject: Re: nanosleep (Ashley Sanders)
- From: Dave Butenhof <email@hidden>
- Date: Wed, 10 Mar 2004 18:01:46 -0500
On Fri, Mar 05, 2004 at 09:25:36AM -0800, Dean N. Williams wrote:
Has anyone had success in using the nanosleep function? I would
like
to gradually increase the tv_nsec to 5 sec. I don't want to use the
tv_sec at all. I can get the tv_sec to work, but the tv_nsec doesn't
seem to be working.
My Mac is at home, but the Solaris man page for nanosleep says it can
return the the following error:
EINVAL
The rqtp argument specified a nanosecond value less
than zero or greater than or equal to 1000 million.
Ie, you can't use nanosleep to sleep for more than 1 second.
You can't use the tv_nsec field of 'struct timespec' to wait more than
a second. If the OP really wants to cycle a time up from 0 to 5
seconds, it will be necessary to count tv_nsec up to 999,999,999, then
reset it to 0 and increment tv_sec.
Generally, this is pointless, though. No general purpose commercial
system can actually wait for a nanosecond -- or even microseconds.
(Though Solaris and Tru64 UNIX, at least, can EMULATE microsecond
granularity, roughly, using processor cycle counting in addition to the
actual OS timer interrupt mechanism.) Generally, the real timer
granularity is in the range of milliseconds, or even 10s of
milliseconds.
_______________________________________________
x11-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/x11-users
Do not post admin requests to the list. They will be ignored.