- 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.
推薦閱讀
- Cybersecurity:Attack and Defense Strategies
- 無蘋果不生活 OS X Mountain Lion隨身寶典
- Windows Server 2012 Hyper-V Cookbook
- 異質結原理與器件
- RESS Essentials
- Windows Server 2019 Administration Fundamentals
- 嵌入式實時操作系統μC/OS原理與實踐
- Linux基礎使用與案例
- 精解Windows 10
- UI設計手繪表現從入門到精通
- Windows網絡編程(第2版)
- Microsoft Hyper-V Cluster Design
- Getting Started with UDK
- BuddyPress Theme Development
- 15分鐘!畫出我的漫畫角色:賣萌篇