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

OS thread or machine

Initially, the OS threads or machines are created by and managed by the OS. Later on, the scheduler can request for more OS threads or machines to be created or destroyed. It is the actual resource upon which a goroutine will be executed. It also maintains information about the main goroutine, the G currently being run on it, thread local storage (tls), and so on:

// Denoted as M in runtime 
type m struct { 
    g0               *g         // goroutine with scheduling stack 
    tls               [6]uintptr // thread-local storage (for x86 extern register) 
    curg            *g         // current running goroutine 
    p                 puintptr   // attached p for executing go code (nil if not executing go code) 
    id                 int32 
    createstack [32]uintptr // stack that created this thread. 
    spinning      bool        // m is out of work and is actively looking for work 
 
    // ... 
} 
主站蜘蛛池模板: 常宁市| 霍邱县| 留坝县| 巫溪县| 安义县| 太康县| 乐昌市| 太原市| 合阳县| 泰兴市| 彰化县| 太和县| 会泽县| 阳原县| 富源县| 隆安县| 比如县| 昌都县| 银川市| 全椒县| 凭祥市| 德钦县| 石嘴山市| 颍上县| 平阴县| 新乡县| 武宣县| 江津市| 清原| 清河县| 奇台县| 左权县| 福泉市| 新干县| 盘山县| 新巴尔虎左旗| 封丘县| 满洲里市| 平度市| 图们市| 桦川县|