Go Scheduler that populates local runqueue P?

Look at this well-known image taken from morsmachine.dk/go-scheduler

enter image description here

Gray lists are local runqueues of P. If this queue is empty, they will be populated by go programs from the global runqueue.

The question is, who fills the local runqueue P?

Scheduler without synchronization or does each P do it for itself (mutex)?

PS The article omitted this information.

+4
source share
1 answer

All this is taken from src / runtime / proc1.go :

schedule () findrunnable, a G P. , G . G "" M.

, schedule " ":

// Check the global runnable queue once in a while to ensure fairness.
// Otherwise two goroutines can completely occupy the local runqueue
// by constantly respawning each other.

, lock(&sched.lock).

+4

Source: https://habr.com/ru/post/1608846/


All Articles