diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-11-09 12:39:47 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-12-16 16:12:44 -0500 |
commit | 70999283156f527c5aea6dee57a3d14989a9903a (patch) | |
tree | 50a7d056523d831e4df2202911b78ebb5c92a9af /rts/include | |
parent | 99269b9fd817262a686867383bf0fe88fdc64fb0 (diff) | |
download | haskell-70999283156f527c5aea6dee57a3d14989a9903a.tar.gz |
rts: Introduce getNumCapabilities
And ensure accesses to n_capabilities are atomic (although with relaxed
ordering). This is necessary as RTS API callers may concurrently call
into the RTS without holding a capability.
Diffstat (limited to 'rts/include')
-rw-r--r-- | rts/include/rts/Threads.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/rts/include/rts/Threads.h b/rts/include/rts/Threads.h index 9303a9e80d..035e0d0315 100644 --- a/rts/include/rts/Threads.h +++ b/rts/include/rts/Threads.h @@ -67,10 +67,13 @@ pid_t forkProcess (HsStablePtr *entry) HsBool rtsSupportsBoundThreads (void); // The number of Capabilities. -// ToDo: I would like this to be private to the RTS and instead expose a -// function getNumCapabilities(), but it is used in compiler/cbits/genSym.c +// TODO: Ideally we would only provide getNumCapabilities +// but this is used in compiler/cbits/genSym.c extern unsigned int n_capabilities; +INLINE_HEADER unsigned int getNumCapabilities(void) +{ return RELAXED_LOAD(&n_capabilities); } + // The number of Capabilities that are not disabled extern uint32_t enabled_capabilities; |