The context switch is performed by the dispatch handler. It is a kernel mode process. In kernel mode, the dispatch handler updates the process control block (saving the CPU context), updates the yielding processes status, and gives the CPU a new process to run.