When threads must run together
Some parallel jobs have threads that constantly talk to each other and wait on each other. If only some of their threads are running while the rest are paused, the running ones stall waiting for absent partners. Gang scheduling solves this by running all threads of a job together, as a gang, on multiple cores at once.
Why it matters
- A tightly coupled job often uses busy waiting at synchronization points. A thread spins waiting for a peer.
- If that peer is not scheduled, the spinning thread wastes its whole time slice.
- Scheduling the whole gang at once means peers are present, so the wait is short and useful.
How it works
The scheduler treats the gang as one unit. It finds a moment when enough cores are free, then schedules every gang member simultaneously and de schedules them together. This needs coordination across cores and can leave cores idle while it waits for a big enough slot.
Key idea
Gang scheduling runs all threads of a tightly coupled job at once across cores so synchronization waits stay short, trading some core idle time for far less wasted spinning.