What is the role of the dispatcher in context switching ?

Victor Mehta 176 Reputation points
2021-02-02T17:52:32.82+00:00

Would some one be able to share what exactly is the role of the dispatcher in context switching ? My understanding is that the dispatcher is responsible for loading of the context of a process on to the CPU and the saving the context of the current executing process. Does this sound correct ?

Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
5,099 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Vicky Wang 2,646 Reputation points
    2021-02-03T09:28:27.293+00:00

    Context Switching

    Switching the CPU to another process requires saving the state of the old process and loading the saved state for the new process. This task is known as a context switch.
    The context of a process is represented in the Process Control Block(PCB) of a process; it includes the value of the CPU registers, the process state and memory-management information. When a context switch occurs, the Kernel saves the context of the old process in its PCB and loads the saved context of the new process scheduled to run.
    Context switch time is pure overhead, because the system does no useful work while switching. Its speed varies from machine to machine, depending on the memory speed, the number of registers that must be copied, and the existence of special instructions(such as a single instruction to load or store all registers). Typical speeds range from 1 to 1000 microseconds.
    Context Switching has become such a performance bottleneck that programmers are using new structures(threads) to avoid it whenever possible.

    0 comments No comments

  2. Victor Mehta 176 Reputation points
    2021-02-06T16:35:52.3+00:00

    Thanks Vicky. Can someone tell me if kernel code for the scheduler runs on a separate CPU/Core or does it share ?

    0 comments No comments

  3. Castorix31 83,206 Reputation points
    2021-02-06T17:35:13.5+00:00

    You can find details in this extract of Mark Russinovich book, "Windows Internals" :

    Processes, Threads, and Jobs in the Windows Operating System
    (it is complex...)

    0 comments No comments

  4. Vicky Wang 2,646 Reputation points
    2021-02-10T08:33:38.887+00:00

    Hi,

    Just checking in to see if the information provided was helpful.

    Please let us know if you would like further assistance.

    Best Regards,
    Vicky

    0 comments No comments