[plt-scheme] High precision timing and MrEd/OSX

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Dec 21 09:13:59 EST 2004

At Tue, 21 Dec 2004 16:00:46 +1100, "Rohan Drape" wrote:
> Under MrEd/OSX the timer has a resolution of about one second, under 
> mzscheme/OSX the resolution is actually very good (excepting GC jitter).

Just to make sure I understand, this is as measured by semaphore posts
through `high-precision-time:set-timer' callbacks?

Now that I look, I see lots of problems with posting a semaphore from a
signal handler. MzScheme doesn't expect calls to scheme_sema_post()
from other thread or from signal handlers. In other words, MzScheme's
semaphores are only thread-safe with respect to MzScheme threads. Also,
posting the semaphore won't necessarily wake up the thread scheduler
(though because the scheduler sleeps with select() under Linux and for
MzScheme under OS X, then a signal will often wake up the scheduler).

I think that `current-inexact-milliseconds' returns the same value as
`high-precision-time:get-time', and `sleep' effectively uses
`current-inexact-milliseconds'. Could you get the result you want with
a background thread that calls `sleep' and `semaphore-post', instead of
a timer signal and signal handler that calls `semaphore-post'?


Posted on the users mailing list.