#: 14743 S12/OS9/68000 (OSK)
31-Mar-92 21:37:35
Sb: Timing Help
Fm: Bob van der Poel 76510,2203
To: all
Has anyone done much work with timed sleeps? I think I've found a bug in the
sleep command--when the high bit of the value is set (as per MW instructions)
it does not time 1/256 seconds accurately. Look at the following test code:
main()
{
register int t;
/* this gives "exactly" 10 seconds delay */
system("date"); for(t=10;t;t--) tsleep(0x80000000 + 256);
/* however, this gives only about 7 sec... */
system("date"); for(t=256;t;t--) tsleep(0x80000000 + 10);
/* and this gives only about 1 second */
system("date"); for(t=2560;t;t--) tsleep(0x80000000 + 1);
system("date");
}
As the comments indicate, the smaller the duration, the greater the error. If
anything, the loops with the short sleep values should give more than 10
seconds delay due to the loop overhead. Or am I doing this all wrong?
Oh, I'm using OSK 2.4 on a mm/1.
|