From a319b7e0736cba2c7d7013ed4b8c66e67c05184a Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 9 Dec 2019 07:15:20 -0700 Subject: [PATCH] cs: wake up main thread blocked on fsemaphore If a future posts to an fsemaphore that the main thread is waiting on but went to sleep, then be sure to wake up the main thread. Relevant to #2957 --- racket/src/thread/fsemaphore.rkt | 5 +++-- racket/src/thread/future.rkt | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/racket/src/thread/fsemaphore.rkt b/racket/src/thread/fsemaphore.rkt index 32de30d23f..463bd5aa20 100644 --- a/racket/src/thread/fsemaphore.rkt +++ b/racket/src/thread/fsemaphore.rkt @@ -53,12 +53,13 @@ (set-fsemaphore-dependents! fs (hash-remove deps f)) (future-notify-dependent f)] [else + (set-fsemaphore-c! fs 1) (when b ;; This is a kind of broadcast wakeup, and then the ;; awakened threads will compete for the fsemaphore: (set-fsemaphore-dep-box! fs #f) - (set-box! b #t)) - (set-fsemaphore-c! fs 1)])] + (set-box! b #t) + (wakeup-this-place))])] [else (set-fsemaphore-c! fs (add1 c))]))) diff --git a/racket/src/thread/future.rkt b/racket/src/thread/future.rkt index 9439eeb75c..35c2453885 100644 --- a/racket/src/thread/future.rkt +++ b/racket/src/thread/future.rkt @@ -43,7 +43,8 @@ (provide future*-lock set-future*-state! future-suspend - future-notify-dependent)) + future-notify-dependent + wakeup-this-place)) (define (init-future-place!) (init-future-logging-place!))