[Haskell-cafe] Concurrency questions

Spencer Janssen sjanssen at cse.unl.edu
Mon Jan 7 11:59:02 EST 2008


On Sun, Jan 06, 2008 at 11:30:53AM +0000, Andrew Coppin wrote:
> Just a couple of things I was wondering about...
>
> 1. Is there some way to assign a "priority" to Haskell threads? (The 
> behaviour I'd like is that high priority threads always run first, and low 
> priority threads potentially never run at all unless there's an available 
> processor which is completely idle.)

Not in the current system.  It is not clear that thread priorities are so nice
anyway (see 'priority inversion' on Wikipedia, for example).

> 2. I have a situation where I have a thread generating some data and 
> putting it into a mutable array, and another thread trying to read that 
> data. Is there a way I can make the reader thread block if it tries to read 
> a cell that hasn't been computed yet, but not introduce too much overhead 
> for cells that have been filled in?

I'd probably use an Array of TMVars, they should be faster than MVars when
multiple threads are reading simultaneously.

> 3. Would it be hard to make it so that the number of real threads (the RTS 
> +N flag) could be adjusted at runtime?

I don't know whether it is hard, but I do know that it would be useful!


Cheers,
Spencer Janssen


More information about the Haskell-Cafe mailing list