Reputation: 2398
I am curious as to how the Go language schedules goroutines. Does it switch only during channel requests and I/O or does it have a periodic coroutine switching loop?
Upvotes: 6
Views: 2947
Reputation: 91963
Go does not have a preemptive scheduler yet, but one is planned for 1.2. So no, Go will not switch context during CPU-only calculations, only during I/O (reading from memory is also considered I/O if it isn't in a register already). You can read some discussion about it in Issue 543 - preemptive scheduling.
Upvotes: 8