A number of types of schedulers are available that suit the different needs of
different operating systems. Presently, there are three categories of the
schedulers:
- Long-term schedulers
- Medium-term schedulers
- Short-term schedulers
Apart
from the schedulers there is one more component involved in the scheduling
process and is known as the dispatcher.
- It is the dispatcher that gives a process power to control the
CPU.
- To which process this control is to be given is selected by the short-term scheduler.
- This whole process involves the following three steps:
- Switching the context
- Turning on the user code
- Making a jump to the exact location of the
program from where it has to be restarted.
- Values
taken from the program counter are analyzed by the dispatcher and accordingly
it fetches instructions and feeds data in to the registers.
- The dispatcher
unlike the other system components needs to be very quick since it is invoked
during all the switches that occur.
- Whenever a context switch is invoked, the
processor gets in to an idle state for a very small period of time.
- Hence, it
is required that the context switches that are not necessary might be avoided.
- The
dispatcher takes some time for stopping one process and start running the other
one.
- The dispatch latency is what we call this time.
- Scheduling
and dispatch are complex processes and interrelation to each other.
- These two
are very much essential for the operation of the operating system.
- Today, architectural extensions are available for the modern processors that provide a
number of banks of registers.
- Swapping of these registers in hardware is
possible and therefore a certain number of tasks are capable of retaining their
full registers.
- Whenever an interrupt triggers the dispatcher, it sends to it
the full set of the registers belonging to the process that was being executed
at the time of occurrence of the interrupt.
- Here, the program counter is not
considered.
- Therefore, it is important that the dispatcher should be written
carefully for storing the present states of the registers on being triggered.
- In
other words, we can say that for the dispatcher itself, there is no immediate
context.
- This saves it from the same problem.
Process of Dispatcher
Below we try to describe in
simple words what actually the process is.
- The program presently having
the context is executed by the processor. Things used by this program
include stack base, flags, program counter, and registers and so on. There
is a possible exception of the reserved register that is native to the
operating system. The executing program does not have any knowledge
regarding the dispatcher.
- For dispatcher a timed
interrupt is triggered. Here the program counter jumps to the address listed
in the BIOS interrupt. This marks the beginning of the execution of the
dispatch sub routine. The dispatcher then deals with the stacks and the
registers etc. of the program that raised the interrupt.
- Dispatcher like the other
programs consists of some sets of instructions that operate up on the
register of the current program. These instructions know everything of the
previously executed programs. Out of these, the first few instructions are
responsible for storing the state of the program.
- Dispatcher next determines
which program should be given the CPU next for executing. Now it deletes
all the statistics of the previously executed state and fills in the
details of the next process to be executed.
- Dispatcher jumps to the address
mentioned in the program counter and establishes a full context on the
processor.
- Actually
dispatcher does not really require registers since its only work is to write
the current state of the CPU in to a memory location that has been
predetermined.
- It then loads in to the CPU another process from other
predetermined location.
No comments:
Post a Comment