"Daniel P. Berrange" <berrange(a)redhat.com> writes:
[...]
Goroutines are basically a union of the thread + coroutine concepts.
The
Go runtime will create N OS level threads, where the default N currently
matches the number of logical CPU cores you host has (but is tunable to
other values). The application code just always creates Goroutines which
are userspace threads just like coroutines. The Go runtime will dynamically
switch goroutines at key points, and automatically pick suitable OS level
threads to run them on to maximize concurrency. Most cleverly goroutines
have a 2 KB default stack size, and runtime will dynamically grow the
stack if that limit is reached.
Does this work even when the stack limit is exceeded in a C function?
So this avoids the problem of picking
a
suitable stack size, and avoids any danger of overruns. As a result it
is possible for a process to create *1000's* of goroutines and have less
overhead than if you tried todo the same thing in C with threads+coroutines
manually.
[...]