parser.
#| -*-Scheme-*-
-$Id: conpar.scm,v 14.37 1999/02/24 05:59:01 cph Exp $
+$Id: conpar.scm,v 14.38 1999/02/24 21:23:46 cph Exp $
Copyright (c) 1988-1999 Massachusetts Institute of Technology
(parse/standard-next type elements state #f #f))
((fix:= code code/special-compiled/restore-interrupt-mask)
(parser/%stack-marker (parser-state/dynamic-state state)
+ (parser-state/block-thread-events? state)
(vector-ref elements 2)
type elements state))
((fix:= code code/special-compiled/stack-marker)
(values (vector-ref elements 2) (vector-ref elements 3))))
(lambda (marker-type marker-instance)
(let ((continue
- (lambda (dynamic-state interrupt-mask)
- (parser/%stack-marker dynamic-state interrupt-mask
- type elements state))))
+ (lambda (dynamic-state block-thread-events? interrupt-mask)
+ (parser/%stack-marker dynamic-state block-thread-events?
+ interrupt-mask type elements state))))
(cond ((eq? marker-type %translate-to-state-point)
(continue (merge-dynamic-state
(parser-state/dynamic-state state)
marker-instance)
+ (parser-state/block-thread-events? state)
(parser-state/interrupt-mask state)))
((eq? marker-type set-interrupt-enables!)
(continue (parser-state/dynamic-state state)
+ (parser-state/block-thread-events? state)
marker-instance))
+ ((eq? marker-type with-thread-events-blocked)
+ (continue (parser-state/dynamic-state state)
+ marker-instance
+ (parser-state/interrupt-mask state)))
(else
(continue (parser-state/dynamic-state state)
+ (parser-state/block-thread-events? state)
(parser-state/interrupt-mask state))))))))
-(define (parser/%stack-marker dynamic-state interrupt-mask
+(define (parser/%stack-marker dynamic-state block-thread-events? interrupt-mask
type elements state)
(parser/standard
type
elements
- (make-parser-state
- dynamic-state
- (parser-state/block-thread-events? state)
- interrupt-mask
- (parser-state/history state)
- (parser-state/previous-history-offset state)
- (parser-state/previous-history-control-point state)
- (parser-state/element-stream state)
- (parser-state/n-elements state)
- (parser-state/next-control-point state)
- (parser-state/previous-type state))))
+ (make-parser-state dynamic-state
+ block-thread-events?
+ interrupt-mask
+ (parser-state/history state)
+ (parser-state/previous-history-offset state)
+ (parser-state/previous-history-control-point state)
+ (parser-state/element-stream state)
+ (parser-state/n-elements state)
+ (parser-state/next-control-point state)
+ (parser-state/previous-type state))))
(define (stack-frame/stack-marker? stack-frame)
(or (%stack-frame/stack-marker? stack-frame)
#| -*-Scheme-*-
-$Id: runtime.pkg,v 14.318 1999/02/24 05:59:18 cph Exp $
+$Id: runtime.pkg,v 14.319 1999/02/24 21:23:58 cph Exp $
Copyright (c) 1988-1999 Massachusetts Institute of Technology
unblock-thread-events
unlock-thread-mutex
with-create-thread-continuation
+ with-thread-events-blocked
with-thread-mutex-locked
with-thread-timer-stopped
yield-current-thread)
#| -*-Scheme-*-
-$Id: thread.scm,v 1.30 1999/02/24 05:18:12 cph Exp $
+$Id: thread.scm,v 1.31 1999/02/24 21:23:27 cph Exp $
Copyright (c) 1991-1999 Massachusetts Institute of Technology
(handle-thread-events thread)
(set-thread/block-events?! thread #f))))))
+(define (with-thread-events-blocked thunk)
+ (let ((interrupt-mask (set-interrupt-enables! interrupt-mask/gc-ok)))
+ (let ((thread first-running-thread))
+ (if thread
+ (let ((block-events? (thread/block-events? thread)))
+ (set-thread/block-events?! thread #t)
+ (let ((value
+ ((ucode-primitive with-stack-marker 3)
+ (lambda ()
+ (set-interrupt-enables! interrupt-mask)
+ (let ((value (thunk)))
+ (set-interrupt-enables! interrupt-mask/gc-ok)
+ value))
+ with-thread-events-blocked
+ block-events?)))
+ (let ((thread first-running-thread))
+ (if thread
+ (set-thread/block-events?! thread block-events?)))
+ (set-interrupt-enables! interrupt-mask)
+ value))
+ (begin
+ (set-interrupt-enables! interrupt-mask)
+ (thunk))))))
+
(define (get-thread-event-block)
(without-interrupts
(lambda ()
(let ((thread first-running-thread))
(if thread
(set-thread/block-events?! thread block?))))))
-
+\f
(define (signal-thread-event thread event)
(guarantee-thread thread signal-thread-event)
(let ((self first-running-thread))
(if (and (not (thread/block-events? thread))
(eq? 'WAITING (thread/execution-state thread)))
(%thread-running thread)))
-\f
+
(define (handle-thread-events thread)
(let loop ((any-events? #f))
(let ((event (ring/dequeue (thread/pending-events thread) #t)))
#| -*-Scheme-*-
-$Id: conpar.scm,v 14.40 1999/02/24 05:59:09 cph Exp $
+$Id: conpar.scm,v 14.41 1999/02/24 21:23:31 cph Exp $
Copyright (c) 1988-1999 Massachusetts Institute of Technology
(parse/standard-next type elements state #f #f))
((fix:= code code/special-compiled/restore-interrupt-mask)
(parser/%stack-marker (parser-state/dynamic-state state)
+ (parser-state/block-thread-events? state)
(vector-ref elements 2)
type elements state))
((fix:= code code/special-compiled/stack-marker)
(values (vector-ref elements 2) (vector-ref elements 3))))
(lambda (marker-type marker-instance)
(let ((continue
- (lambda (dynamic-state interrupt-mask)
- (parser/%stack-marker dynamic-state interrupt-mask
- type elements state))))
+ (lambda (dynamic-state block-thread-events? interrupt-mask)
+ (parser/%stack-marker dynamic-state block-thread-events?
+ interrupt-mask type elements state))))
(cond ((eq? marker-type %translate-to-state-point)
(continue (merge-dynamic-state
(parser-state/dynamic-state state)
marker-instance)
+ (parser-state/block-thread-events? state)
(parser-state/interrupt-mask state)))
((eq? marker-type set-interrupt-enables!)
(continue (parser-state/dynamic-state state)
+ (parser-state/block-thread-events? state)
marker-instance))
+ ((eq? marker-type with-thread-events-blocked)
+ (continue (parser-state/dynamic-state state)
+ marker-instance
+ (parser-state/interrupt-mask state)))
(else
(continue (parser-state/dynamic-state state)
+ (parser-state/block-thread-events? state)
(parser-state/interrupt-mask state))))))))
-(define (parser/%stack-marker dynamic-state interrupt-mask
+(define (parser/%stack-marker dynamic-state block-thread-events? interrupt-mask
type elements state)
(parser/standard
type
elements
- (make-parser-state
- dynamic-state
- (parser-state/block-thread-events? state)
- interrupt-mask
- (parser-state/history state)
- (parser-state/previous-history-offset state)
- (parser-state/previous-history-control-point state)
- (parser-state/element-stream state)
- (parser-state/n-elements state)
- (parser-state/next-control-point state)
- (parser-state/previous-type state))))
+ (make-parser-state dynamic-state
+ block-thread-events?
+ interrupt-mask
+ (parser-state/history state)
+ (parser-state/previous-history-offset state)
+ (parser-state/previous-history-control-point state)
+ (parser-state/element-stream state)
+ (parser-state/n-elements state)
+ (parser-state/next-control-point state)
+ (parser-state/previous-type state))))
(define (stack-frame/stack-marker? stack-frame)
(or (%stack-frame/stack-marker? stack-frame)
#| -*-Scheme-*-
-$Id: runtime.pkg,v 14.323 1999/02/24 05:59:23 cph Exp $
+$Id: runtime.pkg,v 14.324 1999/02/24 21:23:53 cph Exp $
Copyright (c) 1988-1999 Massachusetts Institute of Technology
unblock-thread-events
unlock-thread-mutex
with-create-thread-continuation
+ with-thread-events-blocked
with-thread-mutex-locked
with-thread-timer-stopped
yield-current-thread)