Live data from Hacker News

Comparison of the Go and Erlang concurrency models (2011)

informit.com

11–12 of 12 posts

Re: Comparison of the Go and Erlang concurrency models (2011)

#11
post #4
post #2

Very neat! > Go calls its threads goroutines as a pun on coroutines, to indicate that they're lighter than real operating-system threads. A pun? Maybe. But the point of calling them go-routines instead of co-routines is that they _are not coroutines_. There isn't a requirement of cooperation on the programmer's part as there usually is with coroutines (at least as I experienced them in Python, having to place Yield()…

> With goroutines the cooperation is handled by the implementation/compiler -- i.e. Yield() calls are automatically inserted by the compiler -- rather than by the programmer manually by hand. The compiler only inserts yeilds at some call sites. It's not a total solution like real preemptive scheduling, so you still need to be careful.

Newer Go versions (1.2 I think?) use preemptive scheduling so you don't have to do anything special: that's my point entirely.

Goroutines by specification have the potential to run all at the same time, in the exact way that OS-level threads do.

In older _implementatoins_ of Go, goroutines were not preemptively scheduled, and exactly as you say you had to be careful.

Re: Comparison of the Go and Erlang concurrency models (2011)

#12
post #8
post #4

Earlier quoted context omitted.

> With goroutines the cooperation is handled by the implementation/compiler -- i.e. Yield() calls are automatically inserted by the compiler -- rather than by the programmer manually by hand. The compiler only inserts yeilds at some call sites. It's not a total solution like real preemptive scheduling, so you still need to be careful.

That's old information; every function call causes the check now.

Correct from 1.2, except inlined calls, see here http://stackoverflow.com/questions/21102078/golang-methods-t...

and http://dave.cheney.net/2014/06/07/five-things-that-make-go-f...

Post reply on HN