+ Fixed small race condition problem in wait. There are still problems
when lots of processes are forked + Added optional name parameter in run-as-long-as
This commit is contained in:
parent
405512e0db
commit
6671ff0e04
|
@ -178,7 +178,8 @@
|
||||||
(let ((next-event (next-sigevent event interrupt/chld)))
|
(let ((next-event (next-sigevent event interrupt/chld)))
|
||||||
(*sigchld-handler*)
|
(*sigchld-handler*)
|
||||||
(lp next-event))))
|
(lp next-event))))
|
||||||
thunk))
|
thunk
|
||||||
|
'auto-reaping))
|
||||||
|
|
||||||
;;; This list contains pids whose proc-obj were gc'd before they died
|
;;; This list contains pids whose proc-obj were gc'd before they died
|
||||||
;;; We try to reap them after every gc and maybe on every SIGCHLD
|
;;; We try to reap them after every gc and maybe on every SIGCHLD
|
||||||
|
@ -291,9 +292,9 @@
|
||||||
(release-lock wait-lock)
|
(release-lock wait-lock)
|
||||||
; we have to block and hence use the event system
|
; we have to block and hence use the event system
|
||||||
(let lp ((pre-event pre-event))
|
(let lp ((pre-event pre-event))
|
||||||
(let ((event (next-sigevent pre-event interrupt/chld)))
|
(cond ((wait proc (bitwise-ior flags wait/poll)) => win)
|
||||||
(cond ((wait proc (bitwise-ior flags wait/poll)) => win)
|
(else
|
||||||
(else (lp event))))))
|
(lp (next-sigevent pre-event interrupt/chld))))))
|
||||||
|
|
||||||
((eq? wait/poll (bitwise-and flags wait/poll))
|
((eq? wait/poll (bitwise-and flags wait/poll))
|
||||||
(cond ((really-wait (proc:pid proc) flags) => win)
|
(cond ((really-wait (proc:pid proc) flags) => win)
|
||||||
|
|
|
@ -188,7 +188,7 @@
|
||||||
(structure-ref threads-internal event-type)
|
(structure-ref threads-internal event-type)
|
||||||
interrupt)
|
interrupt)
|
||||||
(enum interrupt keyboard))))))
|
(enum interrupt keyboard))))))
|
||||||
(run-as-long-as deliver-interrupts thunk))
|
(run-as-long-as deliver-interrupts thunk 'deliver-interrupts))
|
||||||
|
|
||||||
(define (deliver-interrupts)
|
(define (deliver-interrupts)
|
||||||
(let lp ((last ((structure-ref sigevents most-recent-sigevent))))
|
(let lp ((last ((structure-ref sigevents most-recent-sigevent))))
|
||||||
|
|
|
@ -273,11 +273,12 @@
|
||||||
; This is *extremly* low level
|
; This is *extremly* low level
|
||||||
; Don't use unless you know what you are doing
|
; Don't use unless you know what you are doing
|
||||||
|
|
||||||
(define (run-as-long-as thunk1 thunk2)
|
(define (run-as-long-as thunk1 thunk2 . name)
|
||||||
(let ((thread (make-placeholder)))
|
(let ((thread (make-placeholder)))
|
||||||
(spawn (lambda ()
|
(apply spawn (lambda ()
|
||||||
(placeholder-set! thread (current-thread))
|
(placeholder-set! thread (current-thread))
|
||||||
(thunk1)))
|
(thunk1))
|
||||||
|
name)
|
||||||
(dynamic-wind
|
(dynamic-wind
|
||||||
(lambda () #t)
|
(lambda () #t)
|
||||||
thunk2
|
thunk2
|
||||||
|
|
Loading…
Reference in New Issue