+ 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:
mainzelm 2001-11-08 08:14:37 +00:00
parent 405512e0db
commit 6671ff0e04
3 changed files with 12 additions and 10 deletions

View File

@ -178,7 +178,8 @@
(let ((next-event (next-sigevent event interrupt/chld)))
(*sigchld-handler*)
(lp next-event))))
thunk))
thunk
'auto-reaping))
;;; 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
@ -290,10 +291,10 @@
((zero? (bitwise-and flags wait/poll))
(release-lock wait-lock)
; we have to block and hence use the event system
(let lp ((pre-event pre-event))
(let ((event (next-sigevent pre-event interrupt/chld)))
(cond ((wait proc (bitwise-ior flags wait/poll)) => win)
(else (lp event))))))
(let lp ((pre-event pre-event))
(cond ((wait proc (bitwise-ior flags wait/poll)) => win)
(else
(lp (next-sigevent pre-event interrupt/chld))))))
((eq? wait/poll (bitwise-and flags wait/poll))
(cond ((really-wait (proc:pid proc) flags) => win)

View File

@ -188,7 +188,7 @@
(structure-ref threads-internal event-type)
interrupt)
(enum interrupt keyboard))))))
(run-as-long-as deliver-interrupts thunk))
(run-as-long-as deliver-interrupts thunk 'deliver-interrupts))
(define (deliver-interrupts)
(let lp ((last ((structure-ref sigevents most-recent-sigevent))))

View File

@ -273,11 +273,12 @@
; This is *extremly* low level
; 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)))
(spawn (lambda ()
(placeholder-set! thread (current-thread))
(thunk1)))
(apply spawn (lambda ()
(placeholder-set! thread (current-thread))
(thunk1))
name)
(dynamic-wind
(lambda () #t)
thunk2