Work stealing
In parallel computing, work stealing is a scheduling strategy for multithreaded computer programs.[src] It solves the problem of executing a dynamically multithreaded computation, one that can "spawn" new threads of execution, on a statically multithreaded computer, with a fixed number of processors (or cores).[src] It does so efficiently in terms of execution time, memory usage, and inter-processor communication.[src] In a work stealing scheduler, each processor in a computer system has a queue of work items (computational tasks, threads) to perform.[src] Each work item consists of a series of instructions, to be executed sequentially, but in the course of its execution, a work item may also spawn new work items that can feasibly be executed in parallel with its other work.[src] These new items are initially put on the queue of the processor executing the work item.[src] When a processor runs out of work, it looks at the queues of the other processors and "steals" their work items.[src] In effect, work stealing distributes the scheduling work over idle processors, and as long as all processors have work to do, no scheduling overhead occurs.[src] Work stealing contrasts with work sharing, another popular scheduling approach for dynamic multithreading, where each work item is scheduled onto a processor when it is spawned.…[src]
In parallel computing, work stealing is a scheduling strategy for multithreaded computer programs.[src] It solves the problem of executing a dynamically multithreaded computation, one that can "spawn" new threads of execution, on a statically multithreaded computer, with a fixed number of processors (or cores).[src] It does so efficiently in terms of execution time, memory usage, and inter-processor communication.[src] In a work stealing scheduler, each processor in a computer system has a queue of work items (computational tasks, threads) to perform.[src] Each work item consists of a series of instructions, to be executed sequentially, but in the course of its execution, a work item may also spawn new work items that can feasibly be executed in parallel with its other work.[src] These new items are initially put on the queue of the processor executing the work item.[src] When a processor runs out of work, it looks at the queues of the other processors and "steals" their work items.[src] In effect, work stealing distributes the scheduling work over idle processors, and as long as all processors have work to do, no scheduling overhead occurs.[src] Work stealing contrasts with work sharing, another popular scheduling approach for dynamic multithreading, where each work item is scheduled onto a processor when it is spawned.[src] Compared to this approach, work stealing reduces the amount of process migration between processors, because no such migration occurs when all processors have work to do.[src] The idea of work stealing goes back to the implementation of the Multilisp programming language and work on parallel functional programming languages in the 1980s.[src] It is employed in the scheduler for the Cilk programming language, the Java fork/join framework, the .NET Task Parallel Library, and the Rust Tokio runtime.[src] ==Execution model== Work stealing is designed for a "strict" fork–join model of parallel computation, which means that a computation can be viewed as a directed acyclic graph with a single source (start of computation) and a single sink (end of computation).[src] Each node in this graph represents either a fork or a join.[src] Forks produce multiple logically parallel computations, variously called "threads" or "strands".[src] Edges represent serial computation.[src] As an example, consider the following trivial fork–join program in Cilk-like syntax: function f(a, b): c ← fork g(a) d ← h(b) join return c + d function g(a): return a × 2 function h(a): b ← fork g(a) c ← a + 1 join return b + c The function call gives rise to the following computation graph: computation.[src] In the graph, when two edges leave a node, the computations represented by the edge labels are logically parallel: they may be performed either in parallel, or sequentially.[src] The computation may only proceed past a join node when the computations represented by its incoming edges are complete.[src] The work of a scheduler, now, is to assign the computations (edges) to processors in a way that makes the entire computation run to completion in the correct order (as constrained by the join nodes), preferably as fast as possible.[src] ==Algorithm== The randomized version of the work stealing algorithm presented by Blumofe and Leiserson maintains several threads of execution and schedules these onto P processors.[src] Each of the processors has a double-ended queue (deque) of threads.[src] Call the ends of the deque "top" and "bottom".[src] Each processor that has a current thread to execute, executes the instructions in the thread one by one, until it encounters an instruction that causes one of four "special" behaviors: A spawn instruction causes a new thread to be created.[src] The current thread is placed at the bottom of the deque, and the processor starts executing the new thread.[src] A stalling instruction is one that temporarily halts execution of its thread.[src] The processor pops a thread off the bottom of its deque and starts executing that thread.[src] If its deque is empty, it starts work stealing, explained below.[src] An instruction may cause a thread to die.[src] The behavior in this case is the same as for an instruction that stalls.[src] An instruction may enable another thread.[src] The other thread is pushed onto the bottom of the deque, but the processor continues execution of its current thread.[src] Initially, a computation consists of a single thread and is assigned to some processor, while the other processors start off idle.[src] Any processor that becomes idle starts the actual process of work stealing, which means the following: it picks another processor uniformly at random; if the other processor's deque is non-empty, it pops the top-most thread off the deque and starts executing that; else, repeat.[src] ===Child stealing vs.[src] continuation stealing=== Note that, in the rule for spawn, Blumofe and Leiserson suggest that the "parent" thread execute its new thread, as if performing a function call (in the C-like program , the function call to completes before the call to is performed).[src] This is called "continuation stealing", because the continuation of the function can be stolen while the spawned thread is executed, and is the scheduling algorithm used in Cilk Plus.[src] It is not the only way to implement work stealing; the alternative strategy is called "child stealing" and is easier to implement as a library, without compiler support.[src] Child stealing is used by Threading Building Blocks, Microsoft's Task Parallel Library and OpenMP, although the latter gives the programmer control over which strategy is used.[src] ==Efficiency== Several variants of work stealing have been proposed.[src] The randomized variant due to Blumofe and Leiserson executes a parallel computation in expected time T_1/P + O(T_\infty) on P processors; here, T_1 is the work, or the amount of time required to run the computation on a serial computer, and T_\infty is the span, the amount of time required on an infinitely parallel machine.[src] This means that, in expectation, the time required is at most a constant factor times the theoretical minimum.[src] However, the running time (in particular, the number of steals executed) can be exponential in T_\infty in the worst case.[src] A localized variant, in which a processor attempts to steal back its own work whenever it is free, has also been analyzed theoretically and practically.[src] ===Space usage=== A computation scheduled by the Blumofe–Leiserson version of work stealing uses O(S_1 P) stack space, if S_1 were the stack usage of the same computation on a single processor, fitting the authors' own earlier definition of space efficiency.[src] This bound requires continuation stealing; in a child stealing scheduler, it does not hold, as can be seen from the following example: for i = 0 to n: fork f(i) join In a child-stealing implementation, all "forked" calls to are put in a work queue that thus grows to size , which can be made arbitrarily large.[src] ==Multiprogramming variant== The work stealing algorithm as outlined earlier, and its analysis, assume a computing environment where a computation is scheduled onto a set of dedicated processors.[src] In a multiprogramming (multi-tasking) environment, the algorithm must be modified to instead schedule computation tasks onto a pool of worker threads, which in turn are scheduled onto the actual processors by an operating system scheduler.[src] At any given time, the OS scheduler will assign to the work stealing process some number of the processors in the computer, because other processes may be using the remaining processors.[src] In this setting, work stealing with a pool of worker threads has the problem that workers acting as thieves may cause livelock: they may block the execution of workers that would actually spawn useful tasks.[src] A variant of work stealing has been devised for this situation, which executes a computation in expected time O\left(\frac{T_1}{P_\mathrm{avg}} + \frac{T_\infty P}{P_\mathrm{avg}}\right), where is the average number of processors allocated to the computation by the OS scheduler over the computation's running time.[src] The multiprogramming work-scheduler differs from the traditional version in two respects: Its queues are non-blocking.[src] While on dedicated processors, access to the queues can be synchronized using locks, this is not advisable in a multiprogramming environment since the operating system might preempt the worker thread holding the lock, blocking the progress of any other workers that try to access the same queue.[src] Before each attempt to steal work, a worker thread calls a " " system call that yields the processor on which it is scheduled to the OS, in order to prevent starvation.[src] Attempts to improve on the multiprogramming work stealer have focused on cache locality issues and improved queue data structures.[src] ==Alternatives== Several scheduling algorithms for dynamically multithreaded computations compete with work stealing.[src] Besides the traditional work sharing approach, there is a scheduler called parallel depth-first (PDF) that improves on the space bounds of work stealing, as well giving better performance in some situations where the cores of a chip multiprocessor share a cache.[src] ==Notes== ==References==[src]
67 sentences · 67 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"Work stealing." encyclopegia.org, 2026, https://encyclopegia.org/wiki/work-stealing. Accessed 25 November 2026.
Chicago
"Work stealing." encyclopegia.org. Accessed November 25, 2026. https://encyclopegia.org/wiki/work-stealing.
APA
encyclopegia.org. (2026). Work stealing. Retrieved November 25, 2026, from https://encyclopegia.org/wiki/work-stealing
Accessed November 25, 2026 · CC BY-SA 4.0 · citation page · JSON