(without-interrupts %suspend-current-thread))
(define (%suspend-current-thread)
+ (%trace ";%suspend-current-thread: "first-running-thread"\n")
(call-with-current-thread #f
(lambda (thread)
(let ((fp-env (flo:environment))
;; Preserve the floating-point environment here to guarantee that the
;; thread timer won't raise or clear exceptions (particularly the
;; inexact result exception) that the interrupted thread cares about.
- (%trace ";Thread timer: interrupt in "first-running-thread"\n")
+ (%trace ";thread-timer: interrupt in "first-running-thread"\n")
(let ((fp-env (flo:environment)))
(flo:set-environment! (flo:default-environment))
(set! next-scheduled-timeout #f)
(deliver-timer-events)
(maybe-signal-io-thread-events)
(let ((thread first-running-thread))
- (%trace ";Thread timer: first runnable: "thread".\n")
(cond ((not thread)
(%maybe-toggle-thread-timer)
- (%trace ";Thread timer: continuing with timer set for "
- next-scheduled-timeout".\n"))
+ (%trace ";thread-timer: continuing with timer set for "
+ next-scheduled-timeout"\n"))
((thread/continuation thread)
- (%trace ";Thread timer: switching to "thread".\n")
+ (%trace ";thread-timer: switching to "thread"\n")
(run-thread thread))
((not (eq? 'RUNNING-WITHOUT-PREEMPTION
(thread/execution-state thread)))
- (%trace ";Thread timer: yielding to "(thread/next thread)".\n")
+ (%trace ";thread-timer: yielding "thread" to "(thread/next thread)"\n")
(yield-thread thread fp-env))
(else
- (%trace ";Thread timer: continuing with "thread".\n")
+ (%trace ";thread-timer: continuing with "thread"\n")
(flo:set-environment! fp-env)
(%resume-current-thread thread))))))
(define (yield-thread thread #!optional fp-env)
(let ((next (thread/next thread)))
+ (%trace ";yield-thread: "thread" yields to "next"\n")
(if (not next)
(begin
(if (not (default-object? fp-env))
(set-thread/next! last-running-thread thread)
(set! last-running-thread thread)
(set! first-running-thread next)
- (%trace ";yield-thread: "thread" yields to "next"\n")
(run-thread next))))))
\f
(define (exit-current-thread value)
(let ((thread (current-thread)))
+ (%trace ";exit-current-thread: "thread" with "value"\n")
(set-interrupt-enables! interrupt-mask/gc-ok)
(set-thread/block-events?! thread #t)
(ring/discard-all (thread/pending-events thread))
'#(READ)))))
(define (maybe-signal-io-thread-events)
+ (%trace ";maybe-signal-io-thread-events")
(if io-registrations
(let ((result (test-select-registry io-registry #f)))
- (%trace "maybe-signal-io-thread-events: "result" "io-registry"\n")
- (signal-select-result result))))
+ (%trace " => "(and result (vector-ref result 0))"\n")
+ (signal-select-result result))
+ (%trace " => 0\n")))
(define (block-on-io-descriptor descriptor mode)
(without-interrupts
(dynamic-wind %stop-thread-timer thunk %maybe-toggle-thread-timer))
(define (%maybe-toggle-thread-timer #!optional consider-non-timers?)
+ (%trace ";%maybe-toggle-thread-timer "consider-non-timers?"\n")
(let ((now (real-time-clock)))
(let ((start
(lambda (time)