The CPU cannot understand text and can only execute binary machine code instructions one at a time. After each instruction is executed, the PC register points to the next savings.

On 64-bit machines, the PC register = RIP

For the Go Program executable, the run depends on two parts: the user program and the Go Runtime.

So what is Go Runtime?

“Think of runtime as modules that automatically load/run during program execution for additional functionality.”

The figure above illustrates the call and location of the GO program during execution. For runtime, there are several parts:

Part of the role
scheduler The scheduler manages all the backgroundG,M,PExecute circular scheduling
netpoll Network rotation training is responsible for managing the networkfdRelated read and write
memory Responsible for memory allocation
garbage The GC collector

At the heart of these modules is scheduler, which concatenates all runtime processes.

The scheduling component

go func(a) {
  println("Hello, Scheduler!")}Copy the code

When you execute this code, you’re submitting a calculation to the Runtime. The task execution is in the Runtime, the process is similar to production tasks, consumption tasks.

Isn’t that the production-consumption model?

So: The Go scheduling process is essentially a production-consumption process.