diff --git a/LOG b/LOG index 39a263f9b6..b3b1dfaa5b 100644 --- a/LOG +++ b/LOG @@ -248,3 +248,8 @@ io.ms - fixed typo: VC/bin/vcvars64.bat => VC/bin/amd64/vcvars64.bat c/Mf-a6nt, c/Mf-ta6nt +- scheme_mutex_t now uses volatile keyword for owner and count fields + because these fields can be accessed from multiple threads + concurrently. Updated $yield and $thread-check in mats/thread.ms to + be more tolerant of timing variability. + c/types.h, mats/thread.ms, release_notes.stex diff --git a/c/types.h b/c/types.h index 698acff3de..8273478a34 100644 --- a/c/types.h +++ b/c/types.h @@ -277,8 +277,8 @@ typedef struct _bucket_pointer_list { #ifdef PTHREADS typedef struct { - s_thread_t owner; - uptr count; + volatile s_thread_t owner; + volatile uptr count; s_thread_mutex_t pmutex; } scheme_mutex_t; diff --git a/mats/thread.ms b/mats/thread.ms index 991dff4386..ecf5a98b7f 100644 --- a/mats/thread.ms +++ b/mats/thread.ms @@ -94,11 +94,11 @@ (define $fib (lambda (x) (if (< x 2) 1 (+ ($fib (- x 1)) ($fib (- x 2)))))) (define $nthreads 1) (define $yield - (let ([t (make-time 'time-duration 1000 0)]) + (let ([t (make-time 'time-duration 1000000 0)]) (lambda () (sleep t)))) (define $thread-check (lambda () - (let loop ([n 10] [nt (length ($threads))]) + (let loop ([n 100] [nt (length ($threads))]) (cond [(<= nt $nthreads) (set! $nthreads nt) diff --git a/release_notes/release_notes.stex b/release_notes/release_notes.stex index db3d811953..43f153e859 100644 --- a/release_notes/release_notes.stex +++ b/release_notes/release_notes.stex @@ -1474,6 +1474,12 @@ On Windows, the inliner has been fixed to handle \scheme{wchar} and On Windows, the path-related procedures now raise an appropriate exception when the path argument is not a string. +\subsection{Internal mutex structure not always thread safe (9.4)} + +The internal mutex structure now has its fields marked +\scheme{volatile} so that the C compiler does not reorder assignments +to these fields. + \subsection{\protect\scheme{dynamic-wind} mistakenly enabling interrupts (9.3.3)} A bug causing \scheme{dynamic-wind} to unconditionally enable