Re: semi-timely interrupt




I'm building a virtual machine for a scripting engine and I want to
check the flag on every RTS, LOOP, BREAK instruction. If I lock
there's the challenge of doing the check infrequently enough to not
slow things down and then the question is how infrequently relative to
the speed at which an "instr" executes, such as RTS.

In other words, you don't yet know whether you need this optimization.
Platform-specific optimizations should be one of your last resorts to
solve a proven performance problem.

The optimization sounds perfectly sensible in this situation. Taking
and releasing a lock on every RTS, LOOP and BREAK would indeed have a
measurable performance impact on code with tight loops (unless the
interpreter is very slow!) Many language implementations use exactly
this technique to implement interrupts.

Well put. And I forgot to mention that this language is targeted for
processing complex regexes against very large streams. Not only do I
want to insinuate an interrupt flag check into RTS, LOOP, and BREAK
instrs to be able to interrupt long running functions written in the
scripting language, but I also want my automata engine (after every
new char buffer read, 32 chars) to look at the flag. The reason is
that commonly scripts would be executing automata for several seconds
at a time (large streams). Conclusion: in all of the important long
running tasks that a script can do, we need to check an interrupt
flag, but it would be a disaster to take and release a lock in this
check. Or at the very least, it would be much harder to design the
code to check frequently enough to satisfy the intent of the
interrupt, but infrequently enough not to have a performance impact on
the interpreter and the automata engine.

.



Relevant Pages

  • Re: semi-timely interrupt
    ... Many language implementations use exactly ... want to insinuate an interrupt flag check into RTS, LOOP, and BREAK ...
    (comp.programming.threads)
  • Re: semi-timely interrupt
    ... the task makes periodic checks of the flag. ... interrupt a long running task. ... Lock, test, ... check the flag on every RTS, LOOP, BREAK instruction. ...
    (comp.programming.threads)
  • need_resched flag in C
    ... Is this flag 'need_resched' in linux is per process or global? ... If so, when kernel returns after processing an interrupt, it will go ... for loop for all the processes and select one with this flag set which ...
    (comp.os.linux.development.system)
  • Re: Replace polling with interrupt
    ... I am trying for the first time to write an interrupt driven routine. ... Here I want to transmit n*8 bytes of data over a serial interface ... // I will be polling the registers to check which flag is set ... easily for the inner for loop(). ...
    (alt.lang.asm)
  • Re: Any raw data specs for the Apple IIgs BRAM?
    ... original set of example data with the original assembly code and with ... the AppleScript, and they don't match. ... ' current value of the carry flag and then change the carry flag ... ' end of the loop ...
    (comp.sys.apple2.programmer)

Loading