delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/01/18:14:20

Date: Sun, 1 Aug 1999 12:06:18 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Pierre-André Mudry <pyrrhus AT tvs2net DOT ch>
cc: djgpp AT delorie DOT com
Subject: Re: usleep function problem....
In-Reply-To: <7o0261$3ci$1@news.interpoint.ch>
Message-ID: <Pine.SUN.3.91.990801120558.20304d-100000@is>
MIME-Version: 1.0
X-MIME-Autoconverted: from QUOTED-PRINTABLE to 8bit by delorie.com id HAA24224
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sun, 1 Aug 1999, Pierre-André Mudry wrote:

> the function usleep() doesn't seem to work on the two computers I have. It
> produces stranges results (e.g. when I convert delay(x) in usleep(x * 1000)
> the result should be the same but they aren't).

`usleep' and `delay' should certainly NOT produce the same effect.
`delay' has a 1-millisecond granularity, while `usleep' has the basic
54-millisecond granularity of the system clock.

> When the argument of usleep
> is bigger than 10000 the delays are always the same and when under 10000
> there is no delay at all...

This is expected behavior.  Any argument less than 55000 will cause
such strange effects.

> What should I do ? I really need a better resolution than 1 ms....

Write your own loop using the function `uclock'.  It has 800-nanosecond
granularity.

- Raw text -


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