So it works very similar to normal OS thread context switching, but more explicit?
The code will push all local state to the go routine stack, pop the state for the next go routine and change the stack pointer?
And this is cheaper than context switching as threads have their own 1 or 4 mb stack allocated while go routines have a linked list for its stack (afaik?) ?
is that the major difference?
-j
Yes, goroutine switching occurs a known points; effectively where the goroutine is blocked from proceeding; sending and receiving on channels (if they are full/empty respectively), trying to acquire a locked mutex, and performing IO. These operations happen frequently in a program that interacts with others so things more or less work out.
This could yield interesting properties, because this means that even using channels, maybe we could write concurrent code and still have a chance to have predictable and reproducible execution in testing environment.
Wait… “If any of these fails to produce a correct result…” Really? I believe that we want the correct result under any valid schedule, including the most perverse, and that anything less means a failure of the design of the underlying system. Perhaps I misunderstand what you imply.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Wait… “If any of these fails to produce a correct result…” Really? I believe that we want the correct result under any valid schedule, including the most perverse, and that anything less means a failure of the design of the underlying system. Perhaps I misunderstand what you imply.