- 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.
推薦閱讀
- 每天5分鐘玩轉Kubernetes
- 鴻蒙生態:開啟萬物互聯的智慧新時代
- Learn Helm
- 混沌工程實戰:手把手教你實現系統穩定性
- Windows Phone 8 Application Development Essentials
- Instant Optimizing Embedded Systems using Busybox
- Linux系統安全基礎:二進制代碼安全性分析基礎與實踐
- 竹林蹊徑:深入淺出windows驅動開發
- OpenStack系統架構設計實戰
- Kali Linux高級滲透測試
- Windows 7使用詳解(修訂版)
- Linux軟件管理平臺設計與實現
- Mastering Windows 8 C++ App Development
- Learning Continuous Integration with Jenkins(Second Edition)
- Java EE 7 Developer Handbook