Concurrency
Parallel Go, goroutines as kernel threads, stop-the-world GC and atomic context.
- Go runs in parallel. Kernel callbacks run Go on whatever CPU they
arrive on, concurrently, like HTTP handlers: protect shared state with
sync.Mutex(or atomics/kernel.SpinLockin atomic context). - Goroutines are kernel threads:
go, channels,select,sync, timers andtime.Sleepwork. At rmmod, after theOnExithooks, goroutines blocked in waits or sleeps are ended; ones still computing are waited for (stop them from anOnExithook). - Garbage collection stops the world: it waits until every task running
Go reaches a transition (returns to the kernel, blocks, sleeps, or calls
a
//gokm:blockingfunction). A tight loop without those delays it. - Atomic context (softirq, spinlocks held): Go can run there through
frameworks that offer it (
netdev.AtomicTransmit). Blocking there (mutex, channel, sleep) is a recoverable panic, not a deadlock. - Panics in framework callbacks become
EIO(logged).