A handoff occurs when a kernel thread is blocked by a system call. The go scheduler will assign the run queue to an idle kernel thread (if available) or a new thread will be created.

Handoffs are not desirable as it can be expensive to create a new kernel thread.

  • An immediate handoff will occur if the scheduler knows a goroutine will be blocked on a syscall for a long time
  • The scheduler may let the thread block
    • System monitor may periodically check to see if the thread is blocked in a syscall - if so the scheduler may do a handoff

After the system call terminates

Once the kernel thread returns from a system call, the scheduler will assign the goroutine to one of:

  1. The previous processor (if idle)
  2. Any other idle processor
  3. Assign the goroutine to the run queue