
On Mon, Jan 07, 2008 at 10:59:02AM -0600, 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).
I think using STM properly should reduce the risk of priority inversion, as long as you can replace most critical sections with transactions. AFAIU, when there are many transactions sharing some TVars, the transactions that have the biggest chance of being committed are the ones that finish first. It would still be possible for short (cheap computations and few TVar accesses), frequent low-priority transactions to cause frequent rollbacks of a long high-priority transactions, causing a priority inversion. But then, maybe it would be possible to help high-priority to finish - with STM there's much more you can do, like (transparently) rolling back the low-priority transactions. Still, it could be a bit hard to do it properly, without starving low-priority transactions. Best regards Tomasz