runtime: map every goroutine to a new OS thread

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.
This commit is contained in:
Ayke van Laethem
2024-10-24 10:26:17 +02:00
committed by Ron Evans
parent 193f91b870
commit 120d17c124
17 changed files with 653 additions and 13 deletions
+10 -1
View File
@@ -1,9 +1,14 @@
//go:build (gc.conservative || gc.precise || gc.boehm) && !tinygo.wasm
//go:build (gc.conservative || gc.precise || gc.boehm) && !tinygo.wasm && !scheduler.threads
package runtime
import "internal/task"
func gcMarkReachable() {
markStack()
findGlobals(markRoots)
}
// markStack marks all root pointers found on the stack.
//
// This implementation is conservative and relies on the stack top (provided by
@@ -36,3 +41,7 @@ func scanstack(sp uintptr) {
markCurrentGoroutineStack(sp)
}
}
func gcResumeWorld() {
// Nothing to do here (single threaded).
}