mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
120d17c124
This is not a scheduler in the runtime, instead every goroutine is mapped to a single OS thread - meaning 1:1 scheduling. While this may not perform well (or at all) for large numbers of threads, it greatly simplifies many things in the runtime. For example, blocking syscalls can be called directly instead of having to use epoll or similar. Also, we don't need to do anything special to call C code - the default stack is all we need.
30 lines
586 B
Go
30 lines
586 B
Go
//go:build scheduler.threads
|
|
|
|
package runtime
|
|
|
|
import "internal/task"
|
|
|
|
func gcMarkReachable() {
|
|
task.GCStopWorldAndScan()
|
|
}
|
|
|
|
// Scan globals inside the stop-the-world phase. Called from the STW
|
|
// implementation in the internal/task package.
|
|
//
|
|
//go:linkname gcScanGlobals internal/task.gcScanGlobals
|
|
func gcScanGlobals() {
|
|
findGlobals(markRoots)
|
|
}
|
|
|
|
// Function called from assembly with all registers pushed, to actually scan the
|
|
// stack.
|
|
//
|
|
//go:export tinygo_scanstack
|
|
func scanstack(sp uintptr) {
|
|
markRoots(sp, task.StackTop())
|
|
}
|
|
|
|
func gcResumeWorld() {
|
|
task.GCResumeWorld()
|
|
}
|