diff options
Diffstat (limited to 'rts/posix/OSThreads.c')
-rw-r--r-- | rts/posix/OSThreads.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c index 42d72c2e0d..6347e8ce7a 100644 --- a/rts/posix/OSThreads.c +++ b/rts/posix/OSThreads.c @@ -240,13 +240,14 @@ forkOS_createThread ( HsStablePtr entry ) void freeThreadingResources (void) { /* nothing */ } +static uint32_t nproc_cache = 0; + // Get the number of logical CPU cores available to us. Note that this is // different from the number of physical cores (see #14781). uint32_t getNumberOfProcessors (void) { - static uint32_t nproc = 0; - + uint32_t nproc = RELAXED_LOAD(&nproc_cache); if (nproc == 0) { #if defined(HAVE_SCHED_GETAFFINITY) cpu_set_t mask; @@ -287,6 +288,7 @@ getNumberOfProcessors (void) #else nproc = 1; #endif + RELAXED_STORE(&nproc_cache, nproc); } return nproc; @@ -396,6 +398,14 @@ interruptOSThread (OSThreadId id) pthread_kill(id, SIGPIPE); } +void +joinOSThread (OSThreadId id) +{ + if (pthread_join(id, NULL) != 0) { + sysErrorBelch("joinOSThread: error %d", errno); + } +} + KernelThreadId kernelThreadId (void) { #if defined(linux_HOST_OS) |