Skip to content

Scheduler

Category: Scheduling · Status: stub

One line: The part of an operating system or runtime that decides which ready thread or task runs next, on which core, and for how long.

Also called: thread scheduler, process scheduler.

How it connects

flowchart LR
  n_context_switch["Context switch"]
  n_scheduler["Scheduler"]
  n_scheduling_policy["Scheduling policy"]
  n_scheduler -->|uses| n_context_switch
  n_scheduler -->|uses| n_scheduling_policy
  classDef center stroke-width:3px
  class n_scheduler center
  classDef outside stroke-dasharray: 4 3
  class n_context_switch,n_scheduling_policy outside

In each language

Rust Threads are scheduled by the OS; async tasks by the chosen runtime, such as Tokio's ↗
Go The runtime schedules goroutines onto threads, running Go code on at most GOMAXPROCS CPUs at once
Java Platform threads by the OS; virtual threads ↗ by a scheduler in the JDK, using as many platform threads as there are processors by default
C# TaskScheduler decides where tasks run
Kotlin A CoroutineDispatcher, such as Dispatchers.Default or Dispatchers.IO, runs coroutines on its pool of threads
Erlang and Elixir Scheduler threads ↗ (+S), by default one per logical processor
Haskell setNumCapabilities sets how many Haskell threads can run truly simultaneously
The operating system sched(7): Linux's policies SCHED_OTHER, SCHED_FIFO, SCHED_RR and SCHED_DEADLINE

Where to read more