Operating Systems: What is CPU Scheduling

In this tutorial series, we are going to talk about one of the major subjects in the field of operating systems: CPU Scheduling and its Algorithms

Basic Terminology

Here are a few terms that we'll be using throughout the tutorial.

  • [accordion]
    • What is a Process
      • While a program is getting executed by the CPU, it's referred to as a process. A program is a piece of code that instructs the CPU to perform a specific task. It contains instructions for the CPU that are followed one after the other.
    • What is a Ready Queue
      • A process isn't directly sent to the processor for running. First, it's loaded into the main memory. In main memory, they reside in the ready-queue that holds all processes that are ready to run, as its name suggests.

CPU Scheduling

Single-processor systems are able to execute only one process at a time. It arises a question that how multi-programming systems deal with multiple processes using one processor.

This is where the concept of CPU scheduling, AKA process scheduling, comes in.

Imagine a scenario in which a process, let's call it p1 — contains instructions to print a document — is waiting because the printer is busy. It has occupied the CPU but won't use it until the printer becomes available. Is it an efficient use of the CPU? Absolutely not!

It would be OK if it was the only process that needed CPU but in case of multi-programming, dozens of processes are held in the memory. All of them have to be executed one by one.

How about we save the state of p1, terminate it temporarily, take another process from the ready queue and give it control of CPU and let it execute. When the printer becomes free, give CPU back to the process p1 and start its execution from where it was stopped.

I/O and CPU Bursts

The purpose of the previous example was to introduce the concept of Input/Output (I/O) and CPU bursts. A process is not always executing. It may need to take breaks for completion of some input or output requests. In the given example, it was a request for the printer. These breaks are also called waiting-time or I/O bursts.

On the other hand, while the process is not waiting but running, this state is called CPU burst. So, it turns out that a process throughout its completion goes through CPU and I/O bursts.

The goal is to not let the CPU sit idle. So, when the CPU is in waiting-state, i.e. waiting for some input/output, CPU scheduler selects a process from the memory and allocate the CPU to it. Making the CPU as productive as possible.

For this purpose, It may use one of the algorithms that we'll study throughout the tutorial.

For instance, five processes — call them p1, p2, p3, p4, p5  arrive in the queue. The job is to decide in what order should they be run to make the efficient use of the CPU.

Different algorithms will pick them up in different sequences.

Each algorithm may adopt one of the following two schemes of scheduling.

Non-Preemptive Scheduling

If one process has started running, it will release the CPU only if it has completed OR switched to waiting-state. This scheme of scheduling is known as non-preemptive scheduling. This method was used in Windows versions prior to Windows 95.

Preemptive Scheduling

In preemptive scheduling, a process can be terminated even while it's running if a process with high priority needs the CPU. This method was used in versions that came after Windows 95.

Scheduling Criteria

All algorithms are not the same. An appropriate algorithm must be selected for a particular situation. There are some properties that help us differentiate one algorithm from the other.

CPU Utilization

As mentioned earlier, more the CPU remains busy, the better. CPU utilization, measured in percents, spans from 0 to 100. Less percentage shows CPU is getting wasted.

Throughput

Throughput is the measure of work being done by the CPU. It indicates the number of processes that are getting completed in a given unit of time.

Waiting Time

A process may spend a lot of time waiting in the ready queue. An efficient algorithm tends to reduce waiting time. It's the total amount of time a process wasted being in the ready state.

Turnaround Time

From a process request to its completion, the total interval spent is referred to as Turnaround time. A process spends time in waiting-state, ready state, and running state. The sum of all those intervening periods outputs the Turnaround time.

Response Time

It's the interval between the process request and the first response.

Now there, you have some basic understanding of how CPU scheduling works, you are ready to move forward to some prominent scheduling algorithms.
Name

Android,1,Blogger,1,CPU Scheduling,1,Fiverr,1,Freelancing,1,General,1,Java,1,Operating Systems,1,Programming,2,
ltr
item
Dr. Puchki: Operating Systems: What is CPU Scheduling
Operating Systems: What is CPU Scheduling
This tutorial elaborate in details the concept of CPU scheduling in terms of Operating Systems. Examples are given for better understanding.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgphQgvm25ymarqnR_v-AdDJvwqptwxLQ3_I2f05KJYkx_suPgXlKCNGomFJIgv9RVBLfotj9q5Za_lzEgIxlqoHEudyB5u3SUl694VnfeqTKSbN2L9ujvkvR5qW6LLjjKyYrQrZsFnBmg/s320/cpu_scheduling.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgphQgvm25ymarqnR_v-AdDJvwqptwxLQ3_I2f05KJYkx_suPgXlKCNGomFJIgv9RVBLfotj9q5Za_lzEgIxlqoHEudyB5u3SUl694VnfeqTKSbN2L9ujvkvR5qW6LLjjKyYrQrZsFnBmg/s72-c/cpu_scheduling.png
Dr. Puchki
https://drpuchki.blogspot.com/2018/05/os-cpu-scheduling.html
https://drpuchki.blogspot.com/
https://drpuchki.blogspot.com/
https://drpuchki.blogspot.com/2018/05/os-cpu-scheduling.html
true
3384871108122834397
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy