[Haskell-cafe] ANN: MSem replacement for QSem

ChrisK haskell at list.mightyreason.com
Sat Apr 11 07:26:19 EDT 2009


"Grasshopper, try to take the stone from my hand"

Hello all,

  After looking at the code for QSem [1], I realize it is not exception safe.
And it does more work than needed.

  I have a proposed replacement module MSem at
http://haskell.org/haskellwiki/SafeConcurrent on the wiki.

  I claim this is a safer, more correct, and more efficient replacement for
QSem.  But I may be tragically wrong which is where you come in.  Please try and
find some strange concurrency bug that I have missed.  Once there is reviewed
replacement code I will propose changing the base package.

  Exception safe replacements for QSemN and SampleVar are also needed.

  The MSem code I have can be generalized into an "MSemN", but the semantics are
be different from "QSemN".  This MSemN only considers the needs of the first
blocked waiter instead of all of them.  The code MSemN is on the same wiki page,
perhaps someone will find this variant useful.

Cheers,
  Chris

[1]
http://www.haskell.org/ghc/docs/latest/html/libraries/base/src/Control-Concurrent-QSem.html



More information about the Haskell-Cafe mailing list