Skip to main content

Module runtime

Module runtime 

Source
Expand description

Goroutine scheduler internals.

Ported from src/runtime/ in https://github.com/golang/go. Each submodule maps to the Go source file(s) shown below.

§v0.2.0 additions

New module / symbolPurpose
stacknewstack, copystack, sigsegv_handlerDynamic goroutine stack growth (Step 3)
mpthread_id, setup_sigaltstackPer-M thread ID + 64 KiB alternate signal stack (Step 4)
schedasync_preempt2, sigurg_handlerNon-cooperative goroutine preemption via SIGURG (Step 4)
asm_amd64/asm_arm64async_preempt_trampolineSave/restore all registers around the preemption yield (Step 4)
sysmonpthread_kill(SIGURG) in preemptoneSignal delivery for async preemption (Step 4)
netpollepoll (Linux) / kqueue (macOS) / IOCP (Windows) I/O backend (Step 5)

§v0.3.0 additions

New module / symbolPurpose
gcasgstatus, castogscanstatus, casfrom_gscanstatus, readgstatusCentralised atomic G state-transition helpers (mirrors Go’s casgstatus)
gscan_stackGSCAN freeze/unfreeze scaffolding for a future GC stack scanner
syscallentersyscall/exitsyscallG transitions to/from GSYSCALL state
stackcopystackG transitions through GCOPYSTACK during stack-copy
schedpreemptmG transitions through GPREEMPTED (Go 1.14+ async-preempt protocol)
parkgoreadyAccepts GPREEMPTED as well as GWAITING when readying a G
asm_amd64/asm_arm64systemstack, systemstack_callRuns a closure on the M’s g0 stack via a naked RSP/SP switch
This moduleGo source
gruntime/runtime2.go
mruntime/runtime2.go, runtime/proc.go
pruntime/runtime2.go, runtime/proc.go
schedruntime/proc.go, runtime/preempt.go
stackruntime/stack.go, runtime/signal_unix.go
netpollruntime/netpoll_epoll.go, runtime/netpoll_kqueue.go, runtime/netpoll_windows.go
parkruntime/proc.go (gopark / goready)
sudogruntime/runtime2.go, runtime/proc.go
syscallruntime/proc.go (entersyscall / exitsyscall)
sysmonruntime/proc.go (sysmon / retake)
timeruntime/time.go
asm_amd64runtime/asm_amd64.s, runtime/preempt_amd64.s
asm_arm64runtime/asm_arm64.s, runtime/preempt_arm64.s