Grokking Concurrency in Go
0% completed
Work Stealing and Preemption
One possible output:
main ran again after 21ms
The program has a single P, and a goroutine that never stops computing. When main goes to sleep, the busy goroutine gets the P and keeps it. After 20 ms the timer of main is due, but the P that must run that timer is busy. Yet main still runs soon after, prints its line, and ends the program.
Something took the P away from a goroutine that never gave it up. The same scheduler also moves goroutines between Ps when one P runs out of work
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%