- 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.
推薦閱讀
- 零起點學Linux系統管理
- 網絡操作系統:Windows Server 2003管理與應用
- Learning Android Intents
- Kali Linux滲透測試全流程詳解
- 網絡操作系統管理與應用(第三版)
- Windows Server 2019 Administration Fundamentals
- 竹林蹊徑:深入淺出windows驅動開發
- 嵌入式實時操作系統μC/OS原理與實踐
- RHCSARHCE 紅帽Linux認證學習指南(第7版)EX200 & EX300
- 計算機應用基礎(Windows 7+Office 2016)
- Linux系統最佳實踐工具:命令行技術
- HTML5 Enterprise Application Development
- 大學計算機應用基礎實踐教程(Windows 7+MS Office 2010)
- Office 365 User Guide
- Java EE 8 High Performance