caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Nicolas George <nicolas.george@ens.fr>
To: caml-list@inria.fr
Cc: Nick Name <nick.name@inwind.it>
Subject: Re: [Caml-list] Thread.delay, Unix.select, Unix.gettimeofday, Sys.time together?
Date: Sat, 7 Jun 2003 15:31:34 +0200	[thread overview]
Message-ID: <20030607133134.GA28903@clipper.ens.fr> (raw)
In-Reply-To: <20030607141702.28d583c6.nick.name@inwind.it>

[-- Attachment #1: Type: text/plain, Size: 1092 bytes --]

Le nonidi 19 prairial, an CCXI, Nick Name a écrit :
> If I put the delay into the cycle, I can't get less than 1/100 of second
> delay, on any machine I do this test.

I guess you didn't try with Linux/alpha :) The 1/100 of second is the
time slice of the scheduler of the OS. Anything that sleeps by calling
the OS will sleep at least that.

>					Is there a portable function that
> can do a shorter delay, say 1/1000 of second ad least?

You need to do busy wait: keep running and check the clock until the
delay is over. Please note that busy wait is considered evil.

> Sys.time returns an almost constant value! This also happens if I use
> Unix.select [] [] [] mydelay instead of Thread.delay. I suspect this
> happens because some sort of counter gets reset by a delay, but this
> makes no sense.

The answer is in the manual: Sys.time returns the processor time of your
program. While sleeping, your program does not burn CPU, so Sys.time
does not grow. It will only grow during the phases between the sleeps,
and this will be much slower than whithout sleep.

[-- Attachment #2: Type: application/pgp-signature, Size: 185 bytes --]

  reply	other threads:[~2003-06-07 13:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-07 12:17 Nick Name
2003-06-07 13:31 ` Nicolas George [this message]
2003-06-09 16:19 ` Xavier Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030607133134.GA28903@clipper.ens.fr \
    --to=nicolas.george@ens.fr \
    --cc=caml-list@inria.fr \
    --cc=nick.name@inwind.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).