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

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.
主站蜘蛛池模板: 龙海市| 马鞍山市| 肃宁县| 富民县| 云梦县| 襄汾县| 金沙县| 余干县| 花莲市| 武宣县| 虎林市| 海原县| 三明市| 台州市| 雅江县| 莆田市| 江安县| 原平市| 张家界市| 循化| 封开县| 泽普县| 台北市| 红桥区| 凉城县| 开封县| 鄢陵县| 西昌市| 通化县| 阿城市| 长白| 罗甸县| 确山县| 虎林市| 米泉市| 普安县| 长汀县| 社会| 泽州县| 白河县| 仙桃市|