- Distributed Computing with Go
- V.N. Nikhil Anurag
- 151字
- 2021-06-24 18:36:11
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.
推薦閱讀
- 全屋互聯:智能家居系統開發指南
- Windows Server 2019 Cookbook
- 樂學Windows操作系統
- Linux運維實戰:CentOS7.6操作系統從入門到精通
- 阿里云數字新基建系列:云原生操作系統Kubernetes
- Learning Android Intents
- 開源安全運維平臺OSSIM疑難解析:入門篇
- Windows Server 2012網絡操作系統企業應用案例詳解
- 完美應用RHEL 8
- Kali Linux高級滲透測試
- Linux基礎使用與案例
- Cassandra 3.x High Availability(Second Edition)
- 電腦辦公(Windows 10 + Office 2016)入門與提高(超值版)
- Linux內核修煉之道
- Azure Resource Manager Templates Quick Start Guide