From: simonpj Date: Tue, 31 Aug 1999 08:49:00 +0000 (+0000) Subject: [project @ 1999-08-31 08:49:00 by simonpj] X-Git-Tag: Approximately_9120_patches~5853 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=be205c3562c3e95015f42f7fffdd550bf18bedbd;p=ghc-hetmet.git [project @ 1999-08-31 08:49:00 by simonpj] Small changes to concurrency documentation --- diff --git a/ghc/docs/libraries/Concurrent.sgml b/ghc/docs/libraries/Concurrent.sgml index 95dea95..6d67bb6 100644 --- a/ghc/docs/libraries/Concurrent.sgml +++ b/ghc/docs/libraries/Concurrent.sgml @@ -82,6 +82,24 @@ thread itself. This means the thread itself can't be garbage collected until you drop the Scheduling +

+ +GHC uses preemptive multitasking: context switches can occur +at any time. At present, Hugs uses cooperative multitasking: +context switches only occur when you use one of the primitives defined +in this module. This means that programs such as: + + +main = forkIO (write 'a') >> write 'b' + where write c = putChar c >> write c + + +will print either yield action forces a context-switch to any other currently runnable threads (if any), and is occasionally useful when implementing concurrency abstractions: @@ -90,6 +108,39 @@ implementing concurrency abstractions: yield :: IO () + + +Finally, there are operations to delay a concurrent thread, and to +make one wait:delay a concurrent thread +wait for a file descriptor + + +threadDelay :: Int -> IO () -- delay rescheduling for N microseconds +threadWaitRead :: Int -> IO () -- wait for input on specified file descriptor +threadWaitWrite :: Int -> IO () -- (read and write, respectively). + + +The +Calling a foreign C procedure (such as all threads, in both +GHC and Hugs. The GHC I/O system uses non-blocking I/O internally to implement +thread-friendly I/O, so calling standard Haskell I/O functions blocks +only the thead making the call. + +

@@ -137,7 +188,7 @@ time a thread gets to inspect the result and act upon it, other threads may have accessed the [a] -> IO [a] nmergeIO :: [[a]] -> IO [a] +These actions fork one thread for each input list that concurrently +evaluates that list; the results are merged into a single output list. + Note: Hugs does not provide the functions IO a writeSample :: SampleVar a -> a -> IO () - -

- -Finally, there are operations to delay a concurrent thread, and to -make one wait:delay a concurrent thread -wait for a file descriptor - - -threadDelay :: Int -> IO () -- delay rescheduling for N microseconds -threadWaitRead :: Int -> IO () -- wait for input on specified file descriptor -threadWaitWrite :: Int -> IO () -- (read and write, respectively). - - -The The The The full interface for the IO () threadWaitWrite :: Int -> IO () - Pre-emptive vs. Cooperative multitasking -

- -GHC uses preemptive multitasking: Context switches can occur at any -time, except if you call a C function (like -main = forkIO (write 'a') >> write 'b' - where write c = putChar c >> write c - - -will print either GHC-specific concurrency issues