From: Markus Mottl <markus@mail4.ai.univie.ac.at>
To: caml-list@inria.fr
Subject: Re: [Caml-list] How to make a delay ?
Date: Fri, 17 Aug 2001 12:00:04 +0200 [thread overview]
Message-ID: <20010817120003.A19392@fichte.ai.univie.ac.at> (raw)
In-Reply-To: <20010817061534.A14359@darling.home.br>; from romildo@uber.com.br on Fri, Aug 17, 2001 at 06:15:34 -0300
On Fri, 17 Aug 2001, Jos? Romildo Malaquias wrote:
> I am need to control the time under a program I am writing, in order
> to simulate a real-time situation. I just need a function that suspends
> the program execution for a given time, in miliseconds precision.
You can use timers and signals to do this, e.g.:
---------------------------------------------------------------------------
open Sys
open Unix
open Printf
let _ =
set_signal sigalrm (Signal_handle (fun _ -> ()));
let timer = 3.14159 in
let expected_time = gettimeofday () +. timer in
ignore (setitimer ITIMER_REAL { it_interval = 0.0; it_value = timer });
pause ();
printf "Precision: %f\n" (abs_float (gettimeofday () -. expected_time))
---------------------------------------------------------------------------
Depending on the type and load of your system, you can achieve precision
in the range of milliseconds.
Regards,
Markus Mottl
--
Markus Mottl markus@oefai.at
Austrian Research Institute
for Artificial Intelligence http://www.oefai.at/~markus
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
prev parent reply other threads:[~2001-08-17 10:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-17 9:15 José Romildo Malaquias
2001-08-17 9:39 ` Daniel de Rauglaudre
2001-08-17 10:00 ` Markus Mottl [this message]
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=20010817120003.A19392@fichte.ai.univie.ac.at \
--to=markus@mail4.ai.univie.ac.at \
--cc=caml-list@inria.fr \
/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