← Lessons

quiz vs the machine

Platinum1850

Concurrency

The Gang Scheduling

Running all threads of a tightly coupled job at the same time across cores.

5 min read · advanced · beat Platinum to climb

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.

Check yourself

Answer to earn rating on the learn ladder.

1. Why do tightly coupled jobs benefit from gang scheduling?

2. How does a gang scheduler treat a job's threads?

3. What is a cost of gang scheduling?