Go

Goroutines & the Scheduler Interview Questions

35 Go interview questions on goroutines & the scheduler, with detailed answers and code.

0/577 known
35 questions
Goroutines & the SchedulerQ148Medium

A goroutine is a function running concurrently and scheduled by the Go runtime in user space. An OS thread is scheduled by the kernel. The main differences: Stack: a…

Goroutines & the SchedulerQ149Medium

The scheduler is built from three parts: G (goroutine): holds the goroutine's stack, saved registers ( gobuf ) and status ( _Grunnable , _Grunning , _Gwaiting ,…

Goroutines & the SchedulerQ151Hard

package main import ( "fmt" "runtime" "sync" ) func main() { runtime.GOMAXPROCS(1) var wg sync.WaitGroup for i := range 5 { wg.Add(1) go func() { defer wg.Done()…

Goroutines & the SchedulerQ153Hard

package main import ( "fmt" "runtime" "time" ) func main() { runtime.GOMAXPROCS(1) go func() { for { } }() time.Sleep(10 * time.Millisecond) fmt.Println("done") } Go…

Goroutines & the SchedulerQ159Hard

sysmon is a runtime thread that runs without a P , so it keeps working even when every P is busy or stuck. It wakes up adaptively, every 20 µs to 10 ms, backing off when…

Goroutines & the SchedulerQ162Medium

A goroutine leak is a goroutine that stays blocked forever, or runs forever, after its work no longer matters. It keeps its stack and everything that stack references,…

Next topicChannels & select