O'Reilly logo

Distributed Computing with Go by V.N. Nikhil Anurag

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

OS thread or machine

Initially, the OS threads or machines are created by and managed by the OS. Later on, the scheduler can request for more OS threads or machines to be created or destroyed. It is the actual resource upon which a goroutine will be executed. It also maintains information about the main goroutine, the G currently being run on it, thread local storage (tls), and so on:

// Denoted as M in runtime type m struct { g0 *g // goroutine with scheduling stack tls [6]uintptr // thread-local storage (for x86 extern register) curg *g // current running goroutine p puintptr // attached p for executing go code (nil if not executing go code) id int32 createstack [32]uintptr // stack that created this thread. spinning bool // m is out of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required