Search code examples
c#multithreadingmulticore

Dividing workload on several threads


I was wondering if anyone knows about a good article which describes dividing workload on to several Threads? Preferebly it would be written for C# but it's really the concept I'm after, so it's not an issue if it's written for a different, similar, language.

I have a problem where I would have to divide a large amount of computing into several threads and then Sum the generated data after one iteration completes (so I would need to know that all threads have finished) and then start a new iteration, supplying all the threads with the data generated in the last iteration (the data would be modified before the end of each iteration).

I hope this makes sense, and is possible. Either way I would appreciate some advice on how to tackle the problem of computing large amounts of data divided on to several threads (so I can use more than one processor's core).

Thank you for your answers!


Solution

  • You should look at Parallel FX (PFX), you can find the blog here and the download link here (Thanks Marc).

    Unfortunately I don't know if this will be released for .NET 2.0/3.5 as it is currently slated for .NET 4.0.

    If you're looking at implementing it yourself, look into Work Stealing Algorithms.

    There is also a library named Power Threading, by Jeffrey Richter from Wintellect which has some rather good classes available for you.