Spencer Janssen wrote:
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).
Well, I was thinking more of using them for two things. One is for
speculative work (i.e., doing work which we might need later - but don't
bother unless there's cores going spare). The other is for working on
entirely independent tasks - I don't see how inversion can happen when
one thread is solving problem X and another is solving problem Y. But
sure, it certainly adds more complexity to have priority levels.
[I can also imagine situations where you might want to assign 80% CPU to
one thing, and 20% CPU to the other - but that really does sound hard to
implement...]
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.
Mmm, OK. I'll try that. (I wasn't actually aware that STM is working yet...)
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!
;-)
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe