|Version 1 (modified by simonpj, 9 years ago) (diff)|
Concurrent programming in GHC
This page contains notes and information about how to write concurrent programs in GHC.
Please feel free to add stuff here (login guest, password guest).
- Basic concurrency: forkIO and MVars. Read Tackling the awkward squad: monadic input/output, concurrency, exceptions, and foreign-language calls in Haskell. The original paper about Concurrent Haskell contains quite a few examples about how to write concurrent programs. A larger example is
- Software Transactional Memory (STM) is a new way to coordinate concurrent threads. STM will be in GHC 6.6, and is described in the paper Composable memory transactions. The paper Lock-free data structures using Software Transactional Memory in Haskell gives further examples of concurrent programming using STM.
- Foreign function interface. If you are calling foreign functions in a concurrent program, you need to know about bound threads. They are described in a Haskell workshop paper, Extending the Haskell Foreign Function Interface with Concurrency.
Using concurrency in GHC
- You get access to concurrency operations by importing the library Control.Concurrent.
- The GHC manual gives a few useful flags that control scheduling (not usually necessary) RTS options.