File tree Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Original file line number Diff line number Diff line change @@ -98,22 +98,17 @@ void *_dispatch_wait_for_enqueuer(void **ptr);
9898#define _dispatch_contention_spins () \
9999 ((DISPATCH_CONTENTION_SPINS_MIN) + ((DISPATCH_CONTENTION_SPINS_MAX) - \
100100 (DISPATCH_CONTENTION_SPINS_MIN)) / 2)
101- #elif defined( _WIN32 )
101+ #else
102102// Use randomness to prevent threads from resonating at the same frequency and
103103// permanently contending. Windows doesn't provide rand_r(), so use a simple
104104// LCG. (msvcrt has rand_s(), but its security guarantees aren't optimal here.)
105+ // The implementation of rand() can contain a lock (known with glibc at least).
105106#define _dispatch_contention_spins () ({ \
106107 static os_atomic(unsigned int) _seed = 1; \
107108 unsigned int _next = os_atomic_load(&_seed, relaxed); \
108109 os_atomic_store(&_seed, _next * 1103515245 + 12345, relaxed); \
109110 ((_next >> 24) & (DISPATCH_CONTENTION_SPINS_MAX)) | \
110111 (DISPATCH_CONTENTION_SPINS_MIN); })
111- #else
112- // Use randomness to prevent threads from resonating at the same
113- // frequency and permanently contending.
114- #define _dispatch_contention_spins () ({ \
115- ((unsigned int)rand() & (DISPATCH_CONTENTION_SPINS_MAX)) | \
116- (DISPATCH_CONTENTION_SPINS_MIN); })
117112#endif
118113#define _dispatch_contention_wait_until (c ) ({ \
119114 bool _out = false; \
You can’t perform that action at this time.
0 commit comments