Reputation: 1370
What is the architecture behind Golang's Go Routine?
I believe that Go doesn't just fork a new thread for each routine.
Upvotes: 2
Views: 677
Reputation: 544
There have been Go implementations in the past that did in fact create a new thread for each goroutine.
In the main Go implementation, a Go routine is basically just a stack (usually small) with some additional context (in 1.5, see type g
in runtime/runtime2.go). Changing from goroutine to another means changing the stack pointer and the thread-local variable that points to the currently running goroutine.
Upvotes: 6