Operating System Scheduling algorithms (2024)

Operating System Scheduling algorithms (1)

  • Operating System Tutorial
  • OS - Home
  • OS - Overview
  • OS - Components
  • OS - Types
  • OS - Services
  • OS - Properties
  • OS - Processes
  • OS - Process Scheduling
  • OS - Scheduling algorithms
  • OS - Multi-threading
  • OS - Memory Management
  • OS - Virtual Memory
  • OS - I/O Hardware
  • OS - I/O Software
  • OS - File System
  • OS - Security
  • OS - Linux
  • OS - Exams Questions with Answers
  • OS - Exams Questions with Answers
  • Operating System Useful Resources
  • OS - Quick Guide
  • OS - Useful Resources
  • OS - Discussion
  • Selected Reading
  • UPSC IAS Exams Notes
  • Developer's Best Practices
  • Questions and Answers
  • Effective Resume Writing
  • HR Interview Questions
  • Computer Glossary
  • Who is Who

'; var adpushup = adpushup || {}; adpushup.que = adpushup.que || []; adpushup.que.push(function() { adpushup.triggerAd(ad_id); });

A Process Scheduler schedules different processes to be assigned to the CPU based on particular scheduling algorithms. There are six popular process scheduling algorithms which we are going to discuss in this chapter −

  • First-Come, First-Served (FCFS) Scheduling
  • Shortest-Job-Next (SJN) Scheduling
  • Priority Scheduling
  • Shortest Remaining Time
  • Round Robin(RR) Scheduling
  • Multiple-Level Queues Scheduling

These algorithms are either non-preemptive or preemptive. Non-preemptivealgorithms are designed so that once a process enters the running state, it cannot be preempted until it completes its allotted time, whereas the preemptive scheduling is based on priority where a scheduler may preempt a low priority running process anytime when a high priority process enters into a ready state.

First Come First Serve (FCFS)

  • Jobs are executed on first come, first serve basis.
  • It is a non-preemptive, pre-emptive scheduling algorithm.
  • Easy to understand and implement.
  • Its implementation is based on FIFO queue.
  • Poor in performance as average wait time is high.

Operating System Scheduling algorithms (3)

Wait time of each process is as follows −

Average Wait Time: (0+4+6+13) / 4 = 5.75

Shortest Job Next (SJN)

  • This is also known as shortest job first, or SJF

  • This is a non-preemptive, pre-emptive scheduling algorithm.

  • Best approach to minimize waiting time.

  • Easy to implement in Batch systems where required CPU time is known in advance.

  • Impossible to implement in interactive systems where required CPU time is not known.

  • The processer should know in advance how much time process will take.

Given: Table of processes, and their Arrival time, Execution time

ProcessArrival TimeExecution TimeService Time
P0050
P1135
P22814
P3368

Operating System Scheduling algorithms (4)

Waiting time of each process is as follows −

ProcessWaiting Time
P00 - 0 = 0
P15 - 1 = 4
P214 - 2 = 12
P38 - 3 = 5

Average Wait Time: (0 + 4 + 12 + 5)/4 = 21 / 4 = 5.25

Priority Based Scheduling

  • Priority scheduling is a non-preemptive algorithm and one of the most common scheduling algorithms in batch systems.

  • Each process is assigned a priority. Process with highest priority is to be executed first and so on.

  • Processes with same priority are executed on first come first served basis.

  • Priority can be decided based on memory requirements, time requirements or any other resource requirement.

Given: Table of processes, and their Arrival time, Execution time, and priority. Here we are considering 1 is the lowest priority.

ProcessArrival TimeExecution TimePriorityService Time
P00510
P113211
P228114
P33635

Operating System Scheduling algorithms (5)

Waiting time of each process is as follows −

ProcessWaiting Time
P00 - 0 = 0
P111 - 1 = 10
P214 - 2 = 12
P35 - 3 = 2

Average Wait Time: (0 + 10 + 12 + 2)/4 = 24 / 4 = 6

Shortest Remaining Time

  • Shortest remaining time (SRT) is the preemptive version of the SJN algorithm.

  • The processor is allocated to the job closest to completion but it can be preempted by a newer ready job with shorter time to completion.

  • Impossible to implement in interactive systems where required CPU time is not known.

  • It is often used in batch environments where short jobs need to give preference.

Round Robin Scheduling

  • Round Robin is the preemptive process scheduling algorithm.

  • Each process is provided a fix time to execute, it is called a quantum.

  • Once a process is executed for a given time period, it is preempted and other process executes for a given time period.

  • Context switching is used to save states of preempted processes.

Operating System Scheduling algorithms (6)

Wait time of each process is as follows −

ProcessWait Time : Service Time - Arrival Time
P0(0 - 0) + (12 - 3) = 9
P1(3 - 1) = 2
P2(6 - 2) + (14 - 9) + (20 - 17) = 12
P3(9 - 3) + (17 - 12) = 11

Average Wait Time: (9+2+12+11) / 4 = 8.5

Multiple-Level Queues Scheduling

Multiple-level queues are not an independent scheduling algorithm. They make use of other existing algorithms to group and schedule jobs with common characteristics.

  • Multiple queues are maintained for processes with common characteristics.
  • Each queue can have its own scheduling algorithms.
  • Priorities are assigned to each queue.

For example, CPU-bound jobs can be scheduled in one queue and all I/O-bound jobs in another queue. The Process Scheduler then alternately selects jobs from each queue and assigns them to the CPU based on the algorithm assigned to the queue.

Advertisem*nts

';adpushup.triggerAd(ad_id); });

Operating System Scheduling algorithms (2024)

FAQs

What scheduling algorithm is used by operating system? ›

Operating systems use scheduling algorithms like FCFS (First Come, First Served), SJF (Shortest Job Next), Priority Scheduling, Round Robin, Multilevel Queue, Multilevel Feedback Queue, and Fair Share.

What are the algorithms for scheduling system? ›

First in, first out (FIFO), also known as first come, first served (FCFS), is the simplest scheduling algorithm. FIFO simply queues processes in the order that they arrive in the ready queue. This is commonly used for a task queue, for example as illustrated in this section.

What are the 6 scheduling algorithms? ›

6.3 Scheduling Algorithms
  • 1 First-Come First-Serve Scheduling, FCFS. ...
  • 2 Shortest-Job-First Scheduling, SJF. ...
  • 3 Priority Scheduling. ...
  • 4 Round Robin Scheduling. ...
  • 5 Multilevel Queue Scheduling. ...
  • 6 Multilevel Feedback-Queue Scheduling.

Which scheduling algorithm is best in OS? ›

Priority based scheduling works efficiently in this case because generally kernel based processes have higher priority when compared to user based processes. For example, the scheduler itself is a kernel based process, it should run first so that it can schedule other processes.

What is the best scheduling algorithm to use? ›

The FCFS is better for a small burst time. The SJF is better if the process comes to processor simultaneously. The last algorithm, Round Robin, is better to adjust the average waiting time desired. Round Robin quantum time will set it towards more SJF or FCFS value.

How many CPU scheduling algorithms are there in OS? ›

There are two main types of CPU scheduling, preemptive and non-preemptive. Preemptive scheduling is when a process transitions from a running state to a ready state or from a waiting state to a ready state. Non-preemptive scheduling is employed when a process terminates or transitions from running to waiting state.

Which scheduling is used in real time OS? ›

Priority-based scheduling—A scheduling policy in which the RTOS schedules threads according to priority.

How many types of algorithms are there in OS? ›

Six types of process scheduling algorithms are: First Come First Serve (FCFS), 2) Shortest-Job-First (SJF) Scheduling, 3) Shortest Remaining Time, 4) Priority Scheduling, 5) Round Robin Scheduling, 6) Multilevel Queue Scheduling.

What is the CPU scheduling? ›

CPU scheduling is a process which allows one process to use the CPU while the execution of another process is on hold(in waiting state) due to unavailability of any resource like I/O etc, thereby making full use of CPU. The aim of CPU scheduling is to make the system efficient, fast and fair.

Which scheduling algorithm is best why? ›

MLFQ is often used to optimize the execution time of tasks on the CPU. The Multilevel Feedback Queue algorithm is a dynamic priority scheduling algorithm that categorizes jobs into multiple priority queues. The MLFQ algorithm allows for jobs to move between queues based on runtime, processing time, and priority.

What are the 5 scheduling algorithm optimization criteria? ›

CPU scheduling techniques encourage efficient use of system resource and effective task processing by analysing and prioritising criteria such as CPU Utilization, Throughput, Turnaround Time, Waiting Time, and Response Time.

How many types of scheduling algorithms are there? ›

What are the various types of operating system scheduling algorithms? Operating system scheduling algorithms include First-Come-First-Serve, Shortest Job Next, Priority Scheduling, Round Robin, and Multilevel Queue Scheduling. First-Come-First-Serve (FCFS) is the simplest type of scheduling algorithm.

How many types of scheduling are there? ›

Six types of process scheduling algorithms are: First Come First Serve (FCFS), 2) Shortest-Job-First (SJF) Scheduling, 3) Shortest Remaining Time, 4) Priority Scheduling, 5) Round Robin Scheduling, 6) Multilevel Queue Scheduling.

Top Articles
Latest Posts
Article information

Author: Edmund Hettinger DC

Last Updated:

Views: 6510

Rating: 4.8 / 5 (78 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Edmund Hettinger DC

Birthday: 1994-08-17

Address: 2033 Gerhold Pine, Port Jocelyn, VA 12101-5654

Phone: +8524399971620

Job: Central Manufacturing Supervisor

Hobby: Jogging, Metalworking, Tai chi, Shopping, Puzzles, Rock climbing, Crocheting

Introduction: My name is Edmund Hettinger DC, I am a adventurous, colorful, gifted, determined, precious, open, colorful person who loves writing and wants to share my knowledge and understanding with you.