On 8/18/2025 11:51 AM, Rob Arthan wrote:
I realised that I was completely misunderstanding the use of the term “synchronous” in the description of the type InterruptState. I now believe that synchronous interrupts require co-operation from the thread being interrupted while asynchronous interrupts are pre-emptive (not the other way round). Have I got it right now?
The documentation says that asynchronous interrupts occur "at a suitable point soon after they are triggered”. Is iit possible to state what the suitable points are.
I can't speak for polyml specifically, but as a virtual machine designer / implementer I can say that designs are simpler and more robust if one uses vm-inserted checks for interrupts, done at places where the low level vm state is relative "clean". The goal is to limit the number of kinds of places while still keeping interrupt latency bounded and relatively low. A typical design would check at calls and/or returns and at loops (backward branches). The latter may manifest as tail calls in a number languages.
Exactly what the places are is a VM design choice, not a language design choice, so it is appropriate that it be a bit vague while perhaps stating the semantic guarantee (bounded time) and performance hope (generally short).
Note that bounded time pretty much requires a check in any loop whose number of iterations cannot be statically bounded. And since the stack is bounded, it is not absolutely necessary to check on ordinary (not tail) calls and returns, though doing so can reduce latency.
HTH -- Eliot Moss