Before I start my topic, I have to discuss what a dispatcher is.

Dispatcher:

The dispatcher is a program which moves the process from the ready state to the running state. The dispatcher is also known as a short-term scheduler.

Now let me discuss what context switching is.

Context Switching:

Context-switching work is the same as a dispatcher. It moves the process from the ready state to the running state and changes the state of the process from the running state to the ready state.

Suppose we have two processes P1 and P2. Now P1 is in a ready state and P2 is running. Now CPU scheduler (Dispatcher) stops the P2 process and moves P2 to the ready state and then moves process P1 from the ready state to the running state.

Dispatch Latency in OS
Dispatch Latency in OS

Note that PCB (Process Control Block) plays an important role in context switching. PCB stores addresses of process instructions in PC (Program counter), and various registers in PCB. PCB stores addresses of instructions of processes in both states (Ready and Running states).

Suppose we have a process which adds two numbers. Suppose we take three variables a, b, and c. Variable a store’s first number, variable b stores the second number and variable c stores the sum of a and b. The instructions are storing addresses of a, b, and c in memory or PCB.

Now let me discuss what dispatch latency is.

Dispatch Latency:

Dispatch latency is the time taken for the dispatcher to stop one process and start another running. Suppose it takes 1 millisecond for one process to change its state from ready to running so 1 millisecond is dispatch latency.


Share This Story, Choose Your Platform!