官术网_书友最值得收藏!

Context or processor

We have a global scheduler which takes care of bringing up new M, registering G, and handling system calls. However, it does not handle the actual execution of goroutines. This is done by an entity called Processor, which has its own internal scheduler and a queue called runqueue (runq in code) consisting of goroutines that will be executed in the current context. It also handles switching between various goroutines and so on:

// Denoted as P in runtime code 
type p struct { 
    id     int32 
    m     muintptr // back-link to associated m (nil if idle) 
    runq [256]guintptr 
 
    //... 
} 
From Go 1.5 onwards, a Go runtime can have a maximum number of  GOMAXPROCS Ps running at any given point in the program's lifetime. Of course, we can change this number by either setting the  GOMAXPROCS environment variable or by calling the  GOMAXPROCS()  function.
主站蜘蛛池模板: 靖州| 锡林浩特市| 琼海市| 淮阳县| 龙山县| 若尔盖县| 通海县| 青海省| 那曲县| 惠州市| 澄江县| 邵阳县| 新民市| 淳化县| 龙海市| 绥中县| 沁水县| 连南| 清远市| 鄂尔多斯市| 平安县| 昔阳县| 新丰县| 调兵山市| 攀枝花市| 白山市| 虹口区| 盐城市| 灵山县| 禄劝| 中方县| 泾阳县| 白山市| 扬州市| 宿州市| 安阳市| 林芝县| 台南县| 临沭县| 新化县| 武宣县|