Go scheduler work-stealing and blocking syscalls
WHAT IT TESTS: knowledge of the Go runtime scheduler internals. OUTLINE: the GMP model runs goroutines (G) on OS threads (M) attached to logical processors (P); idle P's steal half of another P's run queue; on a blocking syscall the M detaches with its G.
WHAT IT TESTS: whether you understand Go's GMP scheduler and how it stays utilized under blocking. ANSWER OUTLINE: Go uses the GMP model: goroutines (G) are multiplexed onto OS threads (M), each of which must hold a logical processor (P, bounded by GOMAXPROCS) to run Go code. Each P has a local run queue plus a shared global queue. When a P's local queue empties, it tries the global queue and then steals roughly half the goroutines from another P's queue, keeping all P's busy.
Read the original → interview
- #go
- #scheduler
- #goroutines
- #work-stealing
- #concurrency
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.