1

What is the architecture behind Golang's Go Routine?

I believe that Go doesn't just fork a new thread for each routine.

user2864740
  • 60,010
  • 15
  • 145
  • 220
Bhoomtawath Plinsut
  • 1,337
  • 1
  • 16
  • 31
  • 6
    http://programmers.stackexchange.com/questions/222642/are-go-langs-goroutine-pools-just-green-threads ,http://stackoverflow.com/questions/18058164/is-golang-goroutine-a-coroutine - more insteresting reading, search for 'green threads', as the term commonly fits in the talk – user2864740 Sep 24 '15 at 02:28
  • Without an extra careful reading of the spec: I think this is an implementation "detail". – Volker Sep 24 '15 at 07:08

1 Answers1

5

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.