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

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 
 
    // ... 
} 
主站蜘蛛池模板: 临颍县| 南阳市| 溧阳市| 高州市| 保德县| 滁州市| 宜昌市| 镇雄县| 深水埗区| 勃利县| 濮阳县| 韶关市| 安顺市| 册亨县| 筠连县| 文登市| 东乡县| 安泽县| 察隅县| 隆安县| 确山县| 辉南县| 黄骅市| 横山县| 沅陵县| 怀仁县| 萨嘎县| 松溪县| 西宁市| 海门市| 农安县| 台山市| 镇原县| 永年县| 常宁市| 新河县| 怀远县| 光山县| 万载县| 济阳县| 浦城县|