From e57f3608b8dd2c92761eb23f30bc164c8ccc1175 Mon Sep 17 00:00:00 2001 From: marting Date: Thu, 27 Jul 2000 13:33:51 +0000 Subject: [PATCH] The handler for the VM schedules now a event that will cause the deliver thread to call the clients of low-interrupt. So the handler is short and save. --- scsh/low-interrupt.scm | 48 ++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/scsh/low-interrupt.scm b/scsh/low-interrupt.scm index 8831aac..09c582c 100644 --- a/scsh/low-interrupt.scm +++ b/scsh/low-interrupt.scm @@ -59,17 +59,41 @@ + (define (init-low-interrupt) - (set-interrupt-handler! - (enum interrupt os-signal) - (lambda (type arg enabled-interrupts) - (call-handlers type enabled-interrupts))) - - (set-interrupt-handler! - (enum interrupt keyboard) - (lambda (enabled-interrupts) - (call-handlers (enum low-interrupt keyboard) enabled-interrupts))) - + (spawn + (lambda () + (let ((I (current-thread))) + (set-interrupt-handler! + (enum interrupt os-signal) + (lambda (type arg enabled-interrupts) + (schedule-event I + (enum event-type interrupt) + (enum interrupt os-signal) + type + enabled-interrupts))) + (set-interrupt-handler! + (enum interrupt keyboard) + (lambda (enabled-interrupts) + (schedule-event I + (enum event-type interrupt) + (enum interrupt keyboard) + enabled-interrupts))) + (let loop () + (wait) + (call-with-values + get-next-event! + (lambda (event . data) + (if (eq? event (enum event-type interrupt)) + (let ((i-nr (car data))) + (if (eq? i-nr (enum interrupt os-signal)) + (call-handlers (cadr data) (caddr data)) + (if (eq? i-nr (enum interrupt keyboard)) + (call-handlers (enum low-interrupt keyboard) + (cadr data)))))))) + (loop)))) + 'low-interrupt-deliver-thread) + (call-after-gc! (lambda () (let ((enabled-interrupts "JMG: enabled interrupts not yet impl")) @@ -83,11 +107,9 @@ (define interrupt-deliver-lock (make-lock)) (define (call-handlers low-interrupt enabled-interrupts) - (obtain-lock interrupt-deliver-lock) (for-each (lambda (handler-lock-pair) ((car handler-lock-pair) enabled-interrupts)) - (low-interrupt-handler-ref low-interrupt)) - (release-lock interrupt-deliver-lock)) + (low-interrupt-handler-ref low-interrupt))) ;;; the vm uses the timer for the scheduler