projects
/
ghc-base.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
688c2e1
)
expose the value of +RTS -N as GHC.Conc.numCapabilities (see #1733)
author
Simon Marlow
<simonmar@microsoft.com>
Tue, 9 Oct 2007 13:20:42 +0000
(13:20 +0000)
committer
Simon Marlow
<simonmar@microsoft.com>
Tue, 9 Oct 2007 13:20:42 +0000
(13:20 +0000)
GHC/Conc.lhs
patch
|
blob
|
history
diff --git
a/GHC/Conc.lhs
b/GHC/Conc.lhs
index
55da1ac
..
094ff05
100644
(file)
--- a/
GHC/Conc.lhs
+++ b/
GHC/Conc.lhs
@@
-28,6
+28,7
@@
module GHC.Conc
-- * Forking and suchlike
, forkIO -- :: IO a -> IO ThreadId
, forkOnIO -- :: Int -> IO a -> IO ThreadId
-- * Forking and suchlike
, forkIO -- :: IO a -> IO ThreadId
, forkOnIO -- :: Int -> IO a -> IO ThreadId
+ , numCapabilities -- :: Int
, childHandler -- :: Exception -> IO ()
, myThreadId -- :: IO ThreadId
, killThread -- :: ThreadId -> IO ()
, childHandler -- :: Exception -> IO ()
, myThreadId -- :: IO ThreadId
, killThread -- :: ThreadId -> IO ()
@@
-190,6
+191,17
@@
forkOnIO (I# cpu) action = IO $ \ s ->
where
action_plus = catchException action childHandler
where
action_plus = catchException action childHandler
+-- | the value passed to the @+RTS -N@ flag. This is the number of
+-- Haskell threads that can run truly simultaneously at any given
+-- time, and is typically set to the number of physical CPU cores on
+-- the machine.
+numCapabilities :: Int
+numCapabilities = unsafePerformIO $ do
+ n <- peek n_capabilities
+ return (fromIntegral n)
+
+foreign import ccall "&n_capabilities" n_capabilities :: Ptr CInt
+
childHandler :: Exception -> IO ()
childHandler err = catchException (real_handler err) childHandler
childHandler :: Exception -> IO ()
childHandler err = catchException (real_handler err) childHandler