Rd7
Rd7

Reputation: 45

Scheduling tasks in multithreads

I am trying to schedule tasks in multi threaded systems. my idea is to have a local queue per thread, each thread will fetch the job from its local queue. But when the thread reaches some threshold, it should not fetch the job, rather it should transfer the job to a thread which is below the threshold level.

My doubt is how to set the threshold for the threads.

Upvotes: 0

Views: 867

Answers (2)

Eugene Roeder
Eugene Roeder

Reputation: 219

What threading library are you using?

I use two OSS libraries in all of my threading projects TBB and Cilk Plus. One feature that these higher level runtimes provide is that they automatically schedule tasks on to threads in a way that make efficient use of processor resources. The runtimes are also very effective at load balancing the many task.

www.threadingbuildblocks.org

www.cilkplus.org

Upvotes: 0

Tim Lloyd
Tim Lloyd

Reputation: 38444

An alternative arrangement to this problem is giving threads who have finished their queue the ability to take work from the queue of others. This is better known as "Work Stealing" and is a well known scheduling algorithm e.g.

http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.38.8905

Upvotes: 1

Related Questions