cs & thread: fix problem with place initialization
The `current-place` place-local variable was initialized relatively late in the set of place-creation steps. It was possible for the thread scheduler to get involved before `current-place` was set --- and in that case, it was possible for semaphores and Racket threads to end up being used in the wrong place.
This commit is contained in:
parent
c0cfd32bcb
commit
a484cd76e5
|
@ -13860,14 +13860,14 @@
|
|||
(let ((host-thread_0
|
||||
(|#%app|
|
||||
host:fork-place
|
||||
(lambda ()
|
||||
(call-in-another-main-thread
|
||||
orig-cust_0
|
||||
(lambda ()
|
||||
(begin
|
||||
(unsafe-place-local-set!
|
||||
cell.1$2
|
||||
new-place_0)
|
||||
(call-in-another-main-thread
|
||||
orig-cust_0
|
||||
(lambda ()
|
||||
(begin
|
||||
(set-place-id!
|
||||
new-place_0
|
||||
|
@ -14448,7 +14448,7 @@
|
|||
(define make-message-queue
|
||||
(lambda ()
|
||||
(let ((app_0 (|#%app| host:make-mutex)))
|
||||
(message-queue4.1 app_0 '() '() (box #f) hash2725 (box #f)))))
|
||||
(message-queue4.1 app_0 '() '() (box #f) hash2610 (box #f)))))
|
||||
(define enqueue!
|
||||
(lambda (mq_0 msg_0 wk_0)
|
||||
(let ((lock_0 (message-queue-lock mq_0)))
|
||||
|
@ -14463,7 +14463,7 @@
|
|||
(cons msg_0 (message-queue-rev-q mq_0)))
|
||||
(let ((waiters_0 (message-queue-waiters mq_0)))
|
||||
(begin
|
||||
(set-message-queue-waiters! mq_0 hash2725)
|
||||
(set-message-queue-waiters! mq_0 hash2610)
|
||||
(set-box! (message-queue-out-key-box mq_0) wk_0)
|
||||
(set-box! (message-queue-in-key-box mq_0) #f)
|
||||
(|#%app| host:mutex-release lock_0)
|
||||
|
|
|
@ -90,11 +90,11 @@
|
|||
(define host-thread
|
||||
(host:fork-place
|
||||
(lambda ()
|
||||
(set! current-place new-place)
|
||||
(start-implicit-atomic-mode)
|
||||
(call-in-another-main-thread
|
||||
orig-cust
|
||||
(lambda ()
|
||||
(set! current-place new-place)
|
||||
(set-place-id! new-place (get-pthread-id))
|
||||
(set-place-host-roots! new-place (host:current-place-roots))
|
||||
(current-thread-group root-thread-group)
|
||||
|
@ -155,6 +155,7 @@
|
|||
(place-has-activity! p))
|
||||
(host:mutex-release (place-lock p))))
|
||||
|
||||
;; called with place's lock held or for the current place
|
||||
(define (place-has-activity! p)
|
||||
(set-box! (place-activity-canary p) #t)
|
||||
(sandman-wakeup (place-wakeup-handle p)))
|
||||
|
@ -277,7 +278,7 @@
|
|||
'()
|
||||
'()
|
||||
(box #f)
|
||||
#hash()
|
||||
#hasheq()
|
||||
(box #f)))
|
||||
|
||||
(define (enqueue! mq msg wk)
|
||||
|
@ -286,7 +287,7 @@
|
|||
(host:mutex-acquire lock)
|
||||
(set-message-queue-rev-q! mq (cons msg (message-queue-rev-q mq)))
|
||||
(define waiters (message-queue-waiters mq))
|
||||
(set-message-queue-waiters! mq '#hash())
|
||||
(set-message-queue-waiters! mq '#hasheq())
|
||||
(set-box! (message-queue-out-key-box mq) wk)
|
||||
(set-box! (message-queue-in-key-box mq) #f)
|
||||
(host:mutex-release lock)
|
||||
|
|
|
@ -97,6 +97,7 @@
|
|||
|
||||
;; In atomic mode
|
||||
(define (semaphore-post-all/atomic s)
|
||||
(assert-atomic-mode)
|
||||
(set-semaphore-count! s +inf.0)
|
||||
(queue-remove-all!
|
||||
s
|
||||
|
|
Loading…
Reference in New Issue
Block a user