Programming Languages Go Subjective
Oct 04, 2025

Explain the Go scheduler and goroutine implementation.

Detailed Explanation
Go Scheduler (GMP Model): • G: Goroutines (lightweight threads) • M: OS threads (machine) • P: Processors (logical CPUs) • Work-stealing scheduler • Cooperative scheduling with preemption Scheduler Features: • GOMAXPROCS controls parallelism • Goroutines multiplexed on OS threads • Blocking syscalls don't block other goroutines • Network poller for async I/O • Stack grows/shrinks dynamically Example: runtime.GOMAXPROCS(4) // Use 4 OS threads for i := 0; i < 1000; i++ { go worker(i) }
Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback