handling interrupts added by megane on Tue Oct 23 14:22:41 2012
(use srfi-18 posix) (let* [(time (current-milliseconds)) (slice-used? #f) (c 0) (timer-reason 255) (t (make-thread (lambda () (print "thread started") (let [(old-hook ##sys#interrupt-hook) (ct ##sys#current-thread)] (set! ##sys#interrupt-hook (lambda (reason state) (print "c:" c " " reason " "(current-milliseconds)) (if (fx= reason timer-reason) (if (< (- (current-milliseconds) time) 1000) (begin (set! c (add1 c)) (##core#inline "C_set_initial_timer_interrupt_period" (##sys#slot ct 9)) ;; what does 0 mean? (old-hook 0 state)) (begin (set! slice-used? #t) ;;(set! ##sys#interrupt-hook old-hook) (old-hook reason state) ;;(##sys#schedule) )) (old-hook reason state))))) (let lp [(i 0)] (lp (add1 i))) (print "thread done"))))] (thread-start! t) (thread-yield!) (print "back to pri slice-used?: " slice-used? " num-ints: " c)) ... c:4051 255 1017.0 c:4052 255 1017.0 c:4053 255 1017.0 back to pri slice-used?: #t num-ints: 4053