the short-term scheduler
Think of a taxi dispatcher at a busy stand: many cabs are idling in line (ready), and every few seconds the dispatcher waves the next one forward to a waiting passenger. The short-term scheduler is that dispatcher of decisions for the CPU — it is the part of the OS that, very frequently, picks which ready process gets the processor next. It is called short-term because it runs again and again on a millisecond timescale, unlike a long-term scheduler that occasionally decides which jobs to admit into the system at all.
When does it run? Whenever the current process can no longer keep the CPU: it terminated, it blocked on I/O, its time quantum expired, or a higher-priority process became ready. At each of these moments the short-term scheduler examines the ready queue and applies its policy — first-come-first-served, round-robin, priority, whatever the OS uses — to choose one process. It does not itself perform the switch; it only makes the choice, then the dispatcher carries it out. Because it runs so often, the scheduler must be fast: time spent deciding is time the CPU is not doing useful work.
Worth distinguishing the three classic schedulers. The long-term (job) scheduler controls the degree of multiprogramming by admitting new processes slowly; it is absent on most modern interactive systems. The medium-term scheduler may swap whole processes out of memory to relieve pressure. The short-term scheduler is the one people usually mean by the scheduler, and it is the heart of CPU scheduling.
Process A is running when it calls read() and blocks waiting for the disk. That event triggers the short-term scheduler, which scans the ready queue, picks process B by its policy, and tells the dispatcher to switch to B — all in microseconds, so the CPU barely sits idle.
The short-term scheduler fires on every blocking, preemption, or termination — many times per second.
The scheduler only DECIDES; the actual handover (saving and restoring registers, switching address spaces) is the dispatcher's job. Confusing the two is a common beginner slip.