[Haskell-cafe] Simulation and GHC Thread Scheduling

Neil Davies semanticphilosopher at googlemail.com
Sat May 9 07:23:24 EDT 2009


Thomas

You can build your own scheduler very easily using what is already
there.

As with any simulation the two things that you need to capture are
dependency and resource contention. Haskell does both the dependency
stuff beautifully  and the resource contention. Using STM you can even
get nice compositional properties.

All you really have to take care of is how time progresses (if that is
the sort of simulation you are in to).

Yes, refactor the code, choose an appropriate (monadic) framework to
run it in and build a consistent logging/monitoring/measuring model
into it - then things work great.

Cheers

Neil

On 9 May 2009, at 00:22, Thomas DuBuisson wrote:

> All,
> I have a simple Haskell P2P library that I've been playing with in
> simulations of 20 to 600 nodes.   To run the simulation there is a
> Haskell thread (forkIO) for every node in the system, one that starts
> up all the nodes and prints the info (so prints aren't mangled), and
> one that acts as the router.
>
> Before its mentioned - I understand the best way forward would be to
> refactor the code into IO-less 'algorithm' sections and other sections
> that perform the needed IO when I'm not simulating.  I know this would
> allow me to declare what order each node runs in and would free me
> from the scheduler.  I'd like to do that if its practical... but!
>
> None-the-less, here I am saying that there are many interesting little
> simulations that could be done without refactoring and the correctness
> isn't altered by the order of operations (not if the nodes behave
> properly, the slight variation is actually a good test).  What I would
> like to know is are there any plans for GHC to incorporate
> user-definable scheduler?  It would be useful in numerous instance
> beyond this poor example; I know user scheduling was briefly mentioned
> in Li's paper but haven't seen or heard of any interest from others
> since then.
>
> Thomas
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list