Hacker News new | ask | show | jobs
by moring 107 days ago
> Obviously it is true in a single threaded system.

But only if you disable interrupts, right? Of course, if you are working that close to the hardware, it makes sense to include "no interrupts" in your definition of "single threaded".

> Note that garbage collection itself can have a switch, not involving disabling interrupts.

I don't understand this. If you get thrashed with interrupts then no switch will remove the overhead of the interrupt handler, so you'd need an upper bound on the time for that handler AND the frequency of hardware interrupts to achieve hard real-time.

1 comments

The only reason you'd need to disable interrupts to be sure that GC is not called over some block of code is if interrupt service routines are allowed to invoke GC.

For that to work, thread-like concurrency issues already have to be solved in the run-time.

Separately from that, we can have a system in which interrupts are allowed to call into the garbage collection module in order to allocate objects from an atomic free list, but a garbage collection pass is not allowed in interrupt context. (Allowing garbage collection passes, even if ephemeral, in interrupt context strikes as a bad idea because you generally want interrupt context to do as little work as possible.)

Now if we care about some block of instructions executing with absolute minimal delay then we do have to disable interrupts (at least local interrupts on the processor where that block is executed). We don't want the code to be interrupted to service any interrupts. No timer interrupts, no network interrupts, nothing. It is not related to GC.