#5- CPU SCHEDULING ALGORITHMS

 CPU Scheduling Algorithms--

  CPU Scheduling algorithms are used by the operating system to determine the order in which processes are executed on the CPU.


1. First come, first served(FCFS): 

In the FCFS scheduling algorithm, the process that arrives first is executed first. it follows a non-preemptive approach, meaning that once a process starts running, it continues until it completes or voluntarily gives up the CPU.  

FCFS is simple to understand but may lead to poor utilization of the CPU if long processes arrive before shorter ones.



2. Shortest Job Next(SJN) or Shortest Job First(SJF):

SJN or SJF Scheduling selects the process with the shortest total execution time next. it can be either non-preemptive or preemptive. if a new process with a shorter burst time arrives, the currently running process may be preempted.


*3. Round Robin(RR):

 Round Robin is a preemptive scheduling algorithm that assigns a fixed time Quantum (e.g., 12 milliseconds) to each process in a circular manner. Once a Process exhausts its time quantum, it is moved to the back of the ready Queue, allowing the next process in line to execute. RR provides fair execution to all processes but may suffer from high context-switching overhead and may not be efficient for long-running processes.


4. Priority Scheduling:  
 
 Priority scheduling assigns a priority value to each process, and the CPU is allocated to the process with the process with the highest priority .
it can be either preemptive or non-preemptive. In preemptive priority scheduling, if a higher-priority process arrives, the currently running process may be preempted. in non-preemptive priority scheduling the process continues executing until it completes or voluntarily gives up the CPU.




*5.Multilevel Queue Scheduling:

It may happen that processes in the ready queue can be divided into different classes where each class has its own scheduling needs. For example, a common division is a foreground (interactive) process and a background (batch) process. These two classes have different scheduling needs. For this kind of situation, Multilevel Queue Scheduling is used. 


  

Features of Multilevel Queue (MLQ) CPU Scheduling:

  • Multiple queues: In MLQ scheduling, processes are divided into multiple queues based on their priority, with each queue having a different priority level. Higher-priority processes are placed in queues with higher priority levels, while lower-priority processes are placed in queues with lower priority levels.

  • Priorities assigned: Priorities are assigned to processes based on their type, characteristics, and importance. For example, interactive processes like user input/output may have a higher priority than batch processes like file backups.
  • Preemption: Preemption is allowed in MLQ scheduling, which means a higher priority process can preempt a lower priority process, and the CPU is allocated to the higher priority process. This helps ensure that high-priority processes are executed in a timely manner.
  • Scheduling algorithmDifferent scheduling algorithms can be used for each queue, depending on the requirements of the processes in that queue. For example, Round Robin scheduling may be used for interactive processes, while First Come First Serve scheduling may be used for batch processes.
  • Feedback mechanism: A feedback mechanism can be implemented to adjust the priority of a process based on its behavior over time. For example, if an interactive process has been waiting in a lower-priority queue for a long time, its priority may be increased to ensure it is executed in a timely manner.
  • Efficient allocation of CPU timeMLQ scheduling ensures that processes with higher priority levels are executed in a timely manner, while still allowing lower priority processes to execute when the CPU is idle.
  • Fairness: MLQ scheduling provides a fair allocation of CPU time to different types of processes, based on their priority and requirements.
  • Customizable: MLQ scheduling can be customized to meet the specific requirements of different types of processes.




Comments