(and entry (weak-cdr entry))))
(define (signal-gc-events)
- (let ((statistic last-statistic))
- (if (< (gc-statistic/heap-left statistic) 4096)
- (begin
- (for-each
- (lambda (entry)
- (let ((thread (weak-car entry))
- (event (weak-cdr entry)))
- (if (and thread event)
- (signal-event thread abort-heap-low))))
- gc-events)
- (let ((console-thread
- (thread-mutex-owner (port/thread-mutex console-i/o-port))))
- (if (not (weak-assq console-thread gc-events))
- (signal-event console-thread abort-heap-low))))
- (for-each
- (lambda (entry)
- (let ((thread (weak-car entry))
- (event (weak-cdr entry)))
- (if (and thread event)
- (signal-event thread (named-lambda (gc-event)
- (event statistic))))))
- gc-events))))
-
-(define (signal-event thread event)
- (without-interrupts
- (lambda ()
- (if (not (eq? 'DEAD (thread-execution-state thread)))
- (%signal-thread-event thread event)))))
+ (let ((statistic last-statistic)
+ (signaled? #f))
+
+ (define (signal-event thread event)
+ (if (and thread (not (eq? 'DEAD (thread-execution-state thread))))
+ (begin
+ (%signal-thread-event thread event)
+ (set! signaled? #t))))
+
+ (without-interrupts
+ (lambda ()
+ (if (< (gc-statistic/heap-left statistic) 4096)
+ (begin
+ (for-each
+ (lambda (entry)
+ (signal-event (weak-car entry) abort-heap-low))
+ gc-events)
+ (let ((thread (console-thread)))
+ (if (and thread (not (weak-assq thread gc-events)))
+ (signal-event thread abort-heap-low))))
+ (for-each
+ (lambda (entry)
+ (let ((thread (weak-car entry))
+ (event (weak-cdr entry)))
+ (signal-event thread (named-lambda (gc-event)
+ (event statistic)))))
+ gc-events))
+ (if signaled? (%maybe-toggle-thread-timer))))))
(define (weak-assq obj alist)
(let loop ((alist alist))
(clear-interrupts! interrupt-bit/global-3)
(cond ((console-thread)
=> (lambda (thread)
- (without-interrupts
- (lambda ()
- (%signal-thread-event thread
- (lambda ()
- (event-distributor/invoke! event:console-resize)))))))))
+ (signal-thread-event thread
+ (lambda ()
+ (event-distributor/invoke! event:console-resize)))))))
(define ((illegal-interrupt-handler interrupt-bit)
interrupt-code interrupt-enables)
(define (signal-interrupt hook/interrupt hook/clean-input char interrupt)
(let ((thread (thread-mutex-owner (port/thread-mutex console-i/o-port))))
(if thread
- (%signal-thread-event thread
+ (signal-thread-event thread
(lambda ()
(if hook/interrupt
(hook/interrupt))
(vector-set! system-interrupt-vector character-slot
external-interrupt-handler)
(vector-set! interrupt-mask-vector character-slot
- interrupt-mask/gc-ok)
+ interrupt-mask/timer-ok)
(vector-set! system-interrupt-vector after-gc-slot
after-gc-interrupt-handler)
(if (not (eq? status current))
(begin
(%signal-thread-event
- thread (and event (lambda () (event current))))
+ thread (and event
+ (named-lambda (immediate-subprocess-status-event)
+ (event current))))
+ (%maybe-toggle-thread-timer)
(set-subprocess-registration/status! registration current))))))
registration))
(define (%handle-subprocess-status-change)
(if ((ucode-primitive process-status-sync-all 0))
- (begin
+ (let ((signaled? #f))
(for-each (lambda (weak)
(let ((subprocess (weak-car weak)))
(if subprocess
(let ((event (subprocess-registration/event registration)))
(%signal-thread-event
(subprocess-registration/thread registration)
- (and event (lambda () (event status))))
+ (and event
+ (named-lambda (subprocess-status-event)
+ (event status))))
+ (set! signaled? #t)
(set-subprocess-registration/status! registration
status)))))
subprocess-registrations)
(subprocess-registration/status registration)))
(not (or (eq? status 'EXITED)
(eq? status 'SIGNALLED)))))
- subprocess-registrations)))))
+ subprocess-registrations))
+ (if signaled? (%maybe-toggle-thread-timer)))))
(define-integrable subprocess-job-control-available?
(ucode-primitive os-job-control? 0))
(export (runtime thread)
%deregister-gc-event)
(import (runtime thread)
+ %maybe-toggle-thread-timer
%signal-thread-event)
(initialization (initialize-package!)))
generate-suspend-file?)
(export (runtime swank)
keyboard-interrupt-vector)
- (import (runtime thread)
- %signal-thread-event)
(initialization (initialize-package!)))
(define-package (runtime lambda-abstraction)
deregister-subprocess-events
%handle-subprocess-status-change)
(import (runtime thread)
+ %maybe-toggle-thread-timer
%signal-thread-event
subprocess-registrations
subprocess-support-loaded?)