Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!adm!C03601DM%WUVMD.BITNET@cunyvm.cuny.EDU From: C03601DM%WUVMD.BITNET@cunyvm.cuny.EDU (Derek Morgan) Newsgroups: comp.lang.c Subject: Using MSC 5.0 time functions Message-ID: <11679@brl-adm.ARPA> Date: 7 Feb 88 17:54:16 GMT Sender: news@brl-adm.ARPA Lines: 36 I have a routine titled delay(), which uses the system clock to create a timed pause which is theoretically independent of CPU speed. The problem is that the delay is never constant, and rarely of the length that it should be. Even accepting the ~120 ms error margin, the function is relatively random with respect to how long the delay is. Any ideas on why this is so? I am sending the code. Please forgive any lack of C eloquence, but I am still learning the ins and outs of the language. Direct responses are preferred, because I receive the C net in digest format, and it may take a week or more to get your reply :-) #include #include void delay(len) long len; { struct timeb xtime; long t0, t2; ftime(&xtime); t0 = (long)xtime.millitm+xtime.time*100L; do { ftime(&xtime); t2 = (long)xtime.millitm+xtime.time*100L; } while(t2-t0