Process Schedulers in Operating System
Process Schedulers in Operating System
In computing, a process is the instance of a computer program that is being executed by one
or many threads. Scheduling is important in many different computer environments. One of
the most important areas of scheduling is which programs will work on the CPU. This task is
handled by the Operating System (OS) of the computer and there are many different ways in
which we can choose to configure programs.
Categories of Scheduling
Scheduling falls into one of two categories:
It brings the new process to the ‘Ready State’. It controls the Degree of Multi-programming,
i.e., the number of processes present in a ready state at any point in time. It is important that
the long-term scheduler make a careful selection of both I/O and CPU-bound processes. I/O-
bound tasks are which use much of their time in input and output operations while CPU-
bound processes are which spend their time on the CPU. The job scheduler increases
efficiency by maintaining a balance between the two. They operate at a high level and are
typically used in batch-processing systems.
It is responsible for selecting one process from the ready state for scheduling it on the running
state. Note: Short-term scheduler only selects the process to schedule it doesn’t load the
process on running. Here is when all the scheduling algorithms are used. The CPU scheduler
is responsible for ensuring no starvation due to high burst time processes.
The dispatcher is responsible for loading the process selected by the Short-term scheduler on
the CPU (Ready to Running State) Context switching is done by the dispatcher only. A
dispatcher does the following:
Switching context.
3. Medium-Term Scheduler
It is responsible for suspending and resuming the process. It mainly does swapping (moving
processes from main memory to disk and vice versa). Swapping may be necessary to improve
the process mix or because a change in memory requirements has overcommitted available
memory, requiring memory to be freed up. It is helpful in maintaining a perfect balance
between the I/O bound and the CPU bound. It reduces the degree of multiprogramming.
Running: A newly created process joins the system in a running state when it is
created.
Not Running: Processes that are not currently running are kept in a queue and await
execution. A pointer to a specific process is contained in each entry in the queue.
Linked lists are used to implement the queue system. This is how the dispatcher is
used. When a process is stopped, it is moved to the back of the waiting queue. The
process is discarded depending on whether it succeeded or failed. The dispatcher then
chooses a process to run from the queue in either scenario.
Context Switching
In order for a process execution to be continued from the same point at a later time, context
switching is a mechanism to store and restore the state or context of a CPU in the Process
Control block. A context switcher makes it possible for multiple processes to share a single
CPU using this method. A multitasking operating system must include context switching
among its features.
The state of the currently running process is saved into the process control block when the
scheduler switches the CPU from executing one process to another. The state used to set the
computer, registers, etc. for the process that will run next is then loaded from its own PCB.
After that, the second can start processing.
Context Switching
In order for a process execution to be continued from the same point at a later time, context
switching is a mechanism to store and restore the state or context of a CPU in the Process
Control block. A context switcher makes it possible for multiple processes to share a single
CPU using this method. A multitasking operating system must include context switching
among its features.
Program Counter
Scheduling information
Changed State
Accounting information
Conclusion
In conclusion, process schedulers are essential parts of operating systems that manage how
the CPU handles multiple tasks or processes. They ensure that processes are executed
efficiently, making the best use of CPU resources and maintaining system responsiveness. By
choosing the right process to run at the right time, schedulers help optimize overall system
performance, improve user experience, and ensure fair access to CPU resources among
competing processes.
In an operating system, CPU scheduling refers to a technique that permits one process to
utilize the CPU while keeping the other programs waiting or put on hold.
IPC is an operating system technique that facilitates data sharing, synchronization, and
communication between processes.
The operating system uses a data structure called a Process Control Block (PCB) to store and
handle process-related data.