GC daemons need to run when there is no current thread. Try-lock-
thread-mutex was intended for their use. They do not mind
occasionally skipping an opportunity to clean, including the rare
times when a GC interrupt occurs with no current thread -- in the
thread system of a quiescent world.
Try-lock-thread-mutex was signaling spurious deadlocks when GC daemons
ran with no current thread. Free locks appeared to be owned by #F --
the current thread.
(without-interrupts
(lambda ()
(and (not (thread-mutex/owner mutex))
- (let ((thread (current-thread)))
- (set-thread-mutex/owner! mutex thread)
- (add-thread-mutex! thread mutex)
- #t)))))
+ (let ((thread first-running-thread))
+ ;; GC daemons may use this when there is no current thread.
+ (and thread
+ (begin
+ (set-thread-mutex/owner! mutex thread)
+ (add-thread-mutex! thread mutex)
+ #t)))))))
\f
(define (with-thread-mutex-lock mutex thunk)
(guarantee-thread-mutex mutex 'WITH-THREAD-MUTEX-LOCK)