Skip to main content

CPU Scheduling in Operating System

CPU Scheduling in Operating System

What is CPU or Process Scheduling -
Let say , there are 5 different applications in our  computer system Hard Drive A , B ,C , D , E . When we execute these apps , we say them processes . Some of these processes load into main memory at the booting time and some of execute when we require to execute But the procedure of loading those processes from hard disk to main memory and then execute , may wait also for some time , and to execute all processes in a proper scheduled way to improve overall throughput and efficiency of system is to be said , Process or Cpu scheduling .

What are the different states in which processes reside - 


Process States

The execution or life of a process from its origin to end , can be categorized into some different stages , from where that process passes during entite life cycle . We say process states to these stages and the different states are - 
  1. Ready State
  2. Running Queue 
  3. Wait Queue 
  4. Running Queue
  5. Termination

What is Dispatcher - 
Dispatcher is a function in operating systems that picks up a processes from a state and loads that into another state . 
There are basically three types of Schedulers -
1. Long Term Scheduler - This schedular loads the jobs or processes from physical hard disk into the
    Ready queue to start the execution .
2. Short Term Scheduler - This schedular move the process from ready to running state . Context
    switching is to be performed by Mid Term Schedular .
3. Mid Term Scheduler - This schedular is responsible for Resuming and Suspending the the various
    processes . Swapping of processes is an example of Mid term schedular .

Why we do Cpu scheduling - 
There are various factors in an operating system and makes that OS more frequent to use . Some factors that forces to use scheduling algorithms into OS are -
  1. CPU Utilization - Utilization means to Keep the CPU as busy as possible. CPU utilization may range from 0 to100 percent. In a real system, it should range from 40 percent (for a lightly loaded system) to 90 percent (for a heavily used system). CPU Scheduling plays a vital role in the CPU utilization . It is obvious that if we want to complete the all executed processes in a short reasonable time , then cpu must be more utilized . Utilized CPU understands the behavior of the available processes and use the best suited scheduling algorithm to complete those processes in a short span of time and handling the large processes efficiently . 
  2. Throughput - It means that the number of processes completed per unit time . 
  3. Load Time - It is the time taken by the dispatcher to load a particular process or job to put into the main memory Ready Queue . 
  4. Turn Around Time = Total Completion Time - Arrival Time 
  5. Waiting Time = Turn Around Time - Burst Time 

Various CPU scheduling algorithms - 
  1. First Come First Serve ( FCFS ) - This algorithm executes all the available processes in the First Come First Serve manner . 
    FCFS
  2. Shortest Remaining Time First ( SRTF ) - This algorithm execute all the available processes in Shortest remaining time first manner . It will execute the process with shortest remaining time to complete first . This algorithm may be of two types - Preemptive and Non-Preemptive SRTF algorithm .
    SJF
  3. Priority Scheduling - This algorithm only work according to the priorities allocated to processes . These priorities to different processes can be categorized by cpu as their functioning .
    Priority Scheduling
  4. Round Robin Scheduling - This algorithm focuses to let all the processes execute with the same time units and no process can wait to start for a long time . We use a Time Slice in this algorithm that forces all the processes to execute in the slices .
    Round Robin Scheduling
  5. Multilevel Queue Scheduling - This scheduling algorithm divides the Ready Queue in several separate Queues . Each Queue in this Ready State follow the different Scheduling algorithms . The processes assigned to these different queues may be based on different critarias like their memory size , priority or process type . 
  6. Multilevel Feedback Queue Scheduling - Multilevel feedback queue scheduling is almost same as multilevel queue scheduling . It also divide the Ready queue in several separate queues but A process can move among these queues . This algorithm keeps tracking analyzing the behavour and time of execution and accordingly can change the process priority .    

Comments