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

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.
主站蜘蛛池模板: 长沙市| 龙州县| 兴城市| 辰溪县| 博客| 延庆县| 万全县| 连江县| 剑阁县| 册亨县| 玛沁县| 和林格尔县| 肥西县| 西华县| 秭归县| 章丘市| 紫阳县| 无为县| 微山县| 南部县| 祁东县| 西华县| 香河县| 馆陶县| 海原县| 阜城县| 佛坪县| 辰溪县| 福州市| 永新县| 仪征市| 阳泉市| 宜君县| 托克托县| 阳泉市| 巴东县| 平罗县| 营山县| 上犹县| 当涂县| 贵德县|