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

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.
主站蜘蛛池模板: 平湖市| 无为县| 富源县| 高要市| 海丰县| 衡阳县| 正安县| 简阳市| 娱乐| 高邑县| 咸阳市| 彭州市| 上高县| 肇源县| 石首市| 邢台县| 察雅县| 鄂伦春自治旗| 苏州市| 镇康县| 行唐县| 金川县| 稻城县| 岳阳县| 富平县| 武定县| 普格县| 嘉鱼县| 准格尔旗| 绿春县| 永定县| 海淀区| 营山县| 集安市| 张掖市| 鹤山市| 阿克陶县| 洛隆县| 屯留县| 遂平县| 榕江县|