4 ms·
His comment regarding preemptive vs cooperative scheduling, so which is it? Does Go have preemptive scheduling or not? I was under the impression that it did ge
by gregors 3y ago
His comment regarding preemptive vs cooperative scheduling, so which is it? Does Go have preemptive scheduling or not? I was under the impression that it did get that somewhat recently? Could anyone point me in the right direction?
- foldr 3y agoYes, this is a mistake in the article. Go has had preemptive scheduling since Go 1.14, released at the beginning of 2020.
- srpablo 3y agoHey, thanks for letting me know! I'll correct the article
- hu3 3y agoIt's preemptive, I just tested. Spawning an infinite loop inside a green-thread while limiting the program to 1 core does not freeze the program. This will output "hello" and exit normally as expected: package main import ( "fmt" "runtime" ) func infiniteLoop() { for {} fmt.Println("world") } func main() { runtime.GOMAXPROCS(1) go infiniteLoop() fmt.Println("hello") } For more information, see Go's source code which is exceptionally well commented: https://go.dev/src/runtime/preempt.go https://go.dev/src/runtime/preempt.go
- srpablo 3y agoHi! Thanks for posting this, it and the replies pointed out an error. I've since corrected the article.