Sobes.tech
Senior

Tell me about the Golang scheduler, how does it work with blocking operations

sobes.tech AI

Answer from AI

In Go, the goroutine scheduler manages the execution of thousands of lightweight threads (goroutines) on a limited number of system threads.

For blocking operations, such as system calls or input/output operations, the scheduler releases the system thread on which the goroutine was running and starts another ready goroutine on that thread. This is achieved by executing blocking operations in separate threads or using asynchronous calls, without blocking the entire scheduler.

For example, if a goroutine calls a blocking system call, the scheduler starts another goroutine on the same system thread so it doesn't remain idle.

Thus, the Go scheduler ensures efficient use of system threads and high concurrency, hiding blocking operations from the user.