[Vm-dev] Interrupt checking in HydraVM using event system

Igor Stasenko siguctua at gmail.com
Thu Feb 14 09:02:21 UTC 2008

Hello everyone,

I'd like to discuss a not-very-easy to understand topic, like
interrupt checking mechanism in squeak VM.

I introduced an event system in HydraVM: all external events to
Interpreter can be posted at any time using event queue without much
processor stall (i'm using atomic operations for that).
I really now considering to change interpret() loop to move out and
cleanup code concerning interrupts checking.

How it's currently done (how do i see it - please tell me if i'm wrong
with this):
there is an interruptCheckCounter which initialized to big number, and
in different places of interpret(), there are method, called
quickCheckForInterrupts, which decrements the counter, and if it falls
beyond zero, calls the checkForInterrupts() method which doing all
gory details  by checking many things , like user input events and any
external events like signaling semaphores. In the end, it resets
interruptCheckCounter back to big number.
There's also a functions like forceInterruptCheck, which simply sets
counter to zero, making checkForInterrupts be called as soon as

How i'm suggesting this can be done:
- change a quickCheckForInterrupts() to check if interpreter's event
queue is not empty,
and if so, return from interpret() , and outside there will be a code which will
handle all pending events, and then enter interpret() again.

- for periodical interrupt checking we could use a system timer, which
simply post an events periodically, making calls of
checkForInterrupts() at same time intervals.
This is more better than using an interruptCheckCounter, it will do
checks with more precise/regular intervals.

- for any other external events all you need to do is to post a new
event to interpreter's event queue.
Again, it's better because your event will be handled as soon as
possible, AND!! without calling common checkForInterrupts() procedure,
which is a bit cumbersome, in cases if your only intent was to signal
a semaphore.

Best regards,
Igor Stasenko AKA sig.

More information about the Vm-dev mailing list