Version 18 (modified by john@…, 13 years ago) (diff)



on the wiki:


Papers and other docs:


  • Vital for some modern applications and large applications commonly require it.
  • Stable MVar implementation is well understood and tested.


  • Imposes non trivial implementation constraints.
  • Providing a 'select' and non-blocking IO would be enough to allow people to implement something like it themselves in haskell and are provided by most systems as primitives.
  • Things like the 'poor man's concurrency monad' can achieve some of the benefits


  • Standardise on Concurrent Haskell without STM. It is our view that even in the presence of STM, MVars offer functionality that is distinct from STM and separately useful, so this leaves room for growth.


  • Decide how much pre-emption is acceptable, and figure out how to specify this.
  • Should we specify what an implementation that doesn't provide concurrency should do? (e.g. provide an implementation of MVars in terms of IORefs, so that concurrency-safe libraries can be written portably).
  • Require bound thread support, or make it optional? (YHC has concurrency with non-blocking foreign calls, but doesn't have bound threads as yet.)


what is provided

At least the following interface will be provided

  • Control.Concurrent.MVar - everything except addMVarFinalizer
  • Control.Concurrent - ThreadId?,myThreadId,forkIO,yield,threadWaitRead[1],threadWaitWrite[1],threadDelay,threadSetPriority[2],threadGetPriority[2]

the FFI must be able to handle 'concurrent nonrentrant' imports, but not necessarily 'concurrent reentrant' ones.

Progress Guarentee

  • if any haskell thread is runnable then at least one thread will be running.
  • foreign calls marked 'concurrent' will not interfere will the above rule.

MVar Guarentees

initial proposal is here:

Misc library stuff

yield is guarenteed to choose an alternate thread if another one exists and is runnable.

[2] priorities are advisory, but higher priority threads should be run in preference to lower priority ones.

threadDelay guarentees the thread will wait as long as its argument at a minimum. it may be blocked for longer.


[1] may be moved to another module, routines working on Handles should be added too.

[2] possibly, if we decide to go with priorities

Optional extensions to basic standard

These are optional extensions a compiler may implement. In some implementations they may entail a run-time cost to non-concurrent code or a compiler might need a special option to enable them. However, A compiler is not required to provide more than one concurrency model as long as it can meet the requirements of the standard and any options it claims to support.

If a compiler documents that it supports one of the following options, then it must adhere to the rules of that option as well.

Optional Feature 1 - Preemption

The standard only requires a progress guarentee, that a thread is always running, making progress. If an implementation supports context switching during arbitrary, perhaps even pure, computations and meets the stronger fairness guarentees, then it can be said to support the 'Preemption' option.

Fairness Guarentee

  • no starvation

new library calls provided

  • mergeIO, nmergeIO

Optional Feature 2 - OS threads

The implementation allows multiple haskell threads to run at once via the operating systems threading service. May take advantange of SMP architectures.

  • forkOS,isCurrentThreadBound,runInBoundThread,runInUnboundThread
  • bound threads
  • concurrent reentrant supported