Hi!

Here is an experimental approach:

(import (scheme base))

(declare (disable-interrupts) (uses scheduler))

(define disable-timer-interrupts
  (let ((old ##sys#interrupt-hook))
    (lambda ()
      (set! ##sys#interrupt-hook
        (lambda (reason state)
          (let loop ((reason reason))
            (if (eq? 255 reason)
                (loop (##core#inline "C_i_pending_interrupt" #f))
                (old reason state))))))))

If you compile this file, like this:

  csc dti.scm -s -o dti.so

You get a loadable file that installs a new interrupt-hook,
which filters out timer-interrupts. We still need interrupt
processing for handling signals, therefore we can't just disable
them completely. This must be a separate file, so we can compile
it without interrupt checks (interrupts in the interrupt handler
would be a problem, naturally).

Now you can load this into your file:

(load "dti.so")
(disable-timer-interrupts)

And from there on context-switches should only happen on 
thread-yield! and I/O blocking. I only did some basic tests,
perhaps you can try this and tell me whether it works for you.

Once we make sure this works, we can think of a better packaging
(as an egg, for example)


cheers,
felix


Reply via email to