Work Stealing

From NovaOrdis Knowledge Base
Revision as of 19:21, 26 February 2024 by Ovidiu (talk | contribs) (→‎Internal)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

External

  • "Concurrency in Go" by Katherine Cox-Buday, Chapter 6. Goroutines and the Go Runtime

Internal

Overview

The work stealing goroutine scheduling follows the following basic rules:

  1. At a fork point, add tasks to the tail of the duque associated with the thread.
  2. If the thread is idle, steal work from the head of deque associated with some other random thread.
  3. At a join point that cannot be realized (for example, the goroutine it is synchronized with has not completed yet), pop work off the tail of the thread's own duque.
  4. If the thread's deque is empty, either stall at a join or steal work from the head of a random thread's associated duque.