X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fdocs%2Fcomm%2Frts-libs%2Fmulti-thread.html;fp=ghc%2Fdocs%2Fcomm%2Frts-libs%2Fmulti-thread.html;h=67a544be85983ef77469775538bd8a02fafe8155;hb=e199c200be63a0efcc8ac8fc63d69d96c5fc65bf;hp=d31a1d6d032f571f166b4d1d73bb03d3bbc1b24f;hpb=d8a9b534050f62f65d9db0d69aad9733f687ef8b;p=ghc-hetmet.git diff --git a/ghc/docs/comm/rts-libs/multi-thread.html b/ghc/docs/comm/rts-libs/multi-thread.html index d31a1d6..67a544b 100644 --- a/ghc/docs/comm/rts-libs/multi-thread.html +++ b/ghc/docs/comm/rts-libs/multi-thread.html @@ -28,7 +28,7 @@ OS threads may safely call Haskell functions concurrently. Section -
When a Concurrent Haskell(CH) thread calls a 'foreign import'ed function, the runtime system(RTS) has to handle this in a manner @@ -48,25 +48,45 @@ threads (pthreads) and one for the Win32 threads.
-From an RTS perspective, a simple and efficient way to implement this -is to retain the property that only one OS thread is allowed to +A simple and efficient way to implement non-blocking foreign calls is like this: +
+The Current Haskell Worker Thread repeatedly grabs a Haskell thread, executes it until its +time-slice expires or it blocks on an MVar, then grabs another, and executes +that, and so on.
+-When this OS thread comes to execute a potentially blocking 'foreign -import', it leaves the RTS, but before doing so it makes certain that -another OS worker thread is available to take over its RTS executing -priviledges. Consequently, the external call will be handled -concurrently to the execution of the other Concurrent Haskell threads. +When the Current Haskell Worker comes to execute a potentially blocking 'foreign +import', it leaves the RTS and ceases being the Current Haskell Worker, but before doing so it makes certain that +another OS worker thread is available to become the Current Haskell Worker. +Consequently, even if the external call blocks, the new Current Haskell Worker +continues execution of the other Concurrent Haskell threads. When the external call eventually completes, the Concurrent Haskell thread that made the call is passed the result and made runnable again.
--The rest of this section describes the mechanics of implementing -this. There's two parts to it, one that describes how a native thread +
+The rest of this section describes the mechanics of implementing all +this. There's two parts to it, one that describes how a native (OS) thread leaves the RTS to service the external call, the other how the same thread handles returning the result of the external call back to the Haskell thread.