- 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.
推薦閱讀
- 構建高可用Linux服務器(第4版)
- Linux內核完全注釋(20周年版·第2版)
- Ansible權威指南
- Windows Phone 7.5 Data Cookbook
- 嵌入式應用程序設計綜合教程(微課版)
- 網絡操作系統管理與應用(第三版)
- Linux運維最佳實踐
- Microsoft Operations Management Suite Cookbook
- 直播系統開發:基于Nginx與Nginx-rtmp-module
- 8051軟核處理器設計實戰
- 無蘋果不生活 The New iPad隨身寶典
- 突破平面3ds Max動畫設計與制作
- Building Telephony Systems With Asterisk
- Linux軟件管理平臺設計與實現
- Windows Vista終極技巧金典