Sobes.tech
Junior — Middle

How does the operating system distribute the execution of two processes launched on the same CPU core?

sobes.tech AI

Answer from AI

The operating system uses a scheduler to allocate CPU time among multiple processes, even if it has only one core.

The main principle is multitasking with time sharing. Processes receive a time quantum during which they execute. After the quantum expires, the scheduler pauses the current process and switches to another.

This happens very quickly (milliseconds), creating the illusion of simultaneous execution.

In Go, besides the OS, there is its own goroutine scheduler, which distributes the execution of lightweight threads (goroutines) within one or more system threads, but at the process level, this is already the OS's task.

How does the operating system distribute the… - sobes.tech