www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/15/22:54:19

Date: Sun, 15 Dec 1996 22:44:19 -0500 (EST)
From: Michael Phelps <morphine AT hops DOT cs DOT jhu DOT edu>
To: djgpp AT delorie DOT com
Subject: delay() problem
Message-ID: <Pine.GSO.3.95.961215223809.14931A-100000@hops.cs.jhu.edu>
MIME-Version: 1.0

Someone posted a problem with delay() starting to delay more after around
30 seconds and locking up.  Could you provide a little more information
about your machine and operating system and such?  I am unable to
reproduce the problem on my 5x86 under Win 95 with the following program:

#include <stdio.h>
#include <dos.h>
#include <time.h>

#define	RESOLUTION	100

int	main()
{
	uclock_t	last_time, current_time;
	int	x = 0;

	last_time = uclock(); /* start timing */
	while (1)
	{
		delay(1); /* delay 1 msec */
		x++;
		if (x % RESOLUTION == 0)
		{
			current_time = uclock();
			printf("%d 1 msec delays, actual time:  %f\n",
				RESOLUTION,
				(double)(current_time - last_time) /
				UCLOCKS_PER_SEC);
			last_time = current_time;
		}
	}

	return 0;
}

I get an average of around 120 msec for each 100 1 msec delay interations,
regardless of how long I let the program run.  (The range is from 110 msec
to 170 msec, and remember, this is under a multitasking environment.)

						---Michael Phelps
						   morphine AT cs DOT jhu DOT edu


                               CH3
                               |
                               N
                             / |
                     ______/   |
                    /      \   CH2
             _____/         \__|__      
           //     \\        /  |  \\     
         //        \\______/___CH2 \\  
          \        /       \       /
           \______/         \_____/
          / ------ \       /      \
        OH           \   /         OH
                       O
 
                   Morphine

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019