[For complete, up-to-date TBB information visit: http://www.ThreadingBuildingBlocks.org]

TbbRef (Ver. 20): 8.1 Scheduling Algorithm

8.1 Scheduling Algorithm

The scheduler employs task stealing. Each thread keeps a "ready pool" of tasks that are ready to run. The ready pool is structured as an array of lists of task, where the list for the ith element corresponds to tasks at level i in the tree. The lists are manipulated in last-in first-out order. A task at level i spawns child tasks at level i+1. A thread pulls tasks from the deepest non-empty list in the array. If there are no non-empty lists, the thread randomly steals a task from the shallowest list of another thread. A thread also implicitly steals if it completes the last child, in which case it starts executing the task that was waiting on the children.

The task scheduler tends to strike a good balance between locality of reference, space efficiency, and parallelism. The scheduling technique is similar to that used by Cilk (Blumofe 1995 ).

[For complete, up-to-date TBB information visit: http://www.ThreadingBuildingBlocks.org]