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

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Dec 21 19:54:17 EST 2004

At Wed, 22 Dec 2004 11:13:58 +1100, "Rohan Drape" wrote:
> The module is used to implement a scheduler.  When a new item is 
> added to the front of the schedule, high-precision-time:set-timer 
> is called with the interval to the new entry.  The setitimer 
> semantics allow the timer to be reset by subsequent calls.  (The 
> scheduler has an epsilon value to avoid rescheduling below the 
> timing threshold of the system.)
> I don't see how sleep by itself can be made to work efficiently
> in this scenario?

I see that `sleep' doesn't work, but maybe `sync' (formerly known as
`object-wait-multiple') with either a timeout or an alarm event,
combined with a channel to receive a revised timeout?

In any case, it occurs to me that your signal handler could just call
scheme_signal_received() to solve the main problem. As the function
name suggests, I've had to deal with this problem before, so I should
have remembered the solution earlier. I should also remember to
document it in _Inside MzScheme_.

I still worry that it's not safe to post a MzScheme semaphore from a
signal handler, though. You could avoid this problem by defining
something that is simpler than a semaphore (from the MzScheme
scheduler's perspective). You would have to define a constructor and a
`wait' function, where the latter blocks using scheme_block_until().
The scheduler will poll a function that you provide to


Posted on the users mailing list.