- Distributed Computing with Go
- V.N. Nikhil Anurag
- 188字
- 2021-06-24 18:36:11
Goroutine
It is the logical unit of execution that contains the actual instructions for our program/functions to run. It also contains other important information regarding the goroutine, such as the stack memory, which machine (M) it is running on, and which Go function called it. The following are some of the elements in the goroutine struct that might come in handy for this section:
// Denoted as G in runtime type g struct { stack stack // offset known to runtime/cgo m *m // current m; offset known to arm liblink goid int64 waitsince int64 // approx time when the g become blocked waitreason string // if status==Gwaiting gopc uintptr // pc of go statement that created this goroutine startpc uintptr // pc of goroutine function timer *timer // cached timer for time.Sleep // ... }
An interesting thing to know is that when our Go program starts, a goroutine called main goroutine is first launched, and it takes care of setting up the runtime space before starting our program. A typical runtime setup might include things such as maximum stack size, enabling garbage collector, and so on.
推薦閱讀
- 全屋互聯:智能家居系統開發指南
- 網絡操作系統:Windows Server 2003管理與應用
- 精解Windows 8
- 新手易學:系統安裝與重裝
- 構建可擴展分布式系統:方法與實踐
- Windows Server 2012 Hyper-V Cookbook
- Windows Phone 7.5 Data Cookbook
- Implementing Azure DevOps Solutions
- 高性能Linux服務器構建實戰:系統安全、故障排查、自動化運維與集群架構
- Joomla! 3 Template Essentials
- VMware NSX Cookbook
- Linux內核設計的藝術:圖解Linux操作系統架構設計與實現原理
- 計算機系統:基于x86+Linux平臺
- 深入淺出Node.js
- Linux基礎使用與案例