Day 72 - Process Scheduling In Operating Systems

In modern Operatnig Systems a lot of processes are being executed at the same time and all of them need resources for completing the execution. But for most of us there is a limited resources and to use them for all the processes efficiently we use Process Scheduling. Process Scheduling is a technique that is used when there are limited resources and many processes are competing for them. This is done to utilize the CPU as much as possible.

In timesharing systems a CPU shares the resources between the process in such speed that the user don't even feel that the machine is being shared by many processes. It is possible to run more than one process at the same time but for that one must have more than one processor which is expensive but modern OS solve this problem by scheduling the processes for efficiently share the resources between them on a single processor machine.

The scheduling of processes is done by a piece of software built into the OS called Scheduler.

Scheduler

The Scheduler is a part of OS that decides in what process to run and provide with the resources at the time. A scheduler makes this decesion by selecting the process from one of the following Queues for scheduling purposes.

  • Job Queue A newly created process goes in Job Queue and wait for main memory allocation.
  • Ready Queue The processes that are in memory and waiting for CPU time.
  • Waiting Queue The proceeses that are witing for a event from some I/O device.

The Scheduler decides what process to schedule by checking the state of the process from the queues and allocate resources to it to complete its execution. A scheduler uses scheduling algorithms for scheduling tasks.

Kinds Of Schedulers

There are mainly three kinds of Schedulers used based on the Queues for scheduling the processes. These are following.

Long Term Scheduler

Long Term Scheduler loads the processes form job queue to the ready queue in the main memory. The job becomes process after it is loaded into the main memory. It also controls the number of processes running at the same time in the main memory. It is done so to efficiently utilize the CPU by not having too little or too much processes in the main memory.

Short Term Scheduler

Short Term Scheduler or also known as CPU scheduler takes the process from the ready queue and allocated CPU to it for execution. It must be fast as it is invoked very frequently and typically allocates the CPU for a very short amount of time and moves the process back to ready queue after the time is over.

Medium Term Scheduler

Medium Term Scheduler temporarly moves the process from the main memory and places it into the secondary memory like hard drive. It swaps the processes in and out based on their state and priority.

Scheduling Algorithms

I have already written about the Scheduling Algorithms in my Algorithms Series that I did before this Series which can be found here in Day 63 and Day 64.


zainscizainsci