TIP: Click on subject to list as thread! ANSI
echo: cis.os9.68000.osk
to: all
from: Bob van der Poel 76510,2203
date: 1992-03-31 21:37:35
subject: Timing Help

#: 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.

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.