0% found this document useful (0 votes)
12 views6 pages

Understanding Process Scheduling in OS

A process in computing is an instance of a program being executed, managed by the operating system through process scheduling, which determines the order of execution for multiple processes. There are two main categories of scheduling: non-preemptive and preemptive, along with three types of schedulers: long-term, short-term, and medium-term. Context switching is essential for multitasking operating systems, allowing processes to share a CPU by saving and restoring their states.

Uploaded by

middenchopra
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views6 pages

Understanding Process Scheduling in OS

A process in computing is an instance of a program being executed, managed by the operating system through process scheduling, which determines the order of execution for multiple processes. There are two main categories of scheduling: non-preemptive and preemptive, along with three types of schedulers: long-term, short-term, and medium-term. Context switching is essential for multitasking operating systems, allowing processes to share a CPU by saving and restoring their states.

Uploaded by

middenchopra
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Processes

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.

Process schedulers are fundamental components of operating systems responsible for


deciding the order in which processes are executed by the CPU. In simpler terms, they
manage how the CPU allocates its time among multiple tasks or processes that are
competing for its attention.

What is Process Scheduling?


Process scheduling is the activity of the process manager that handles the removal of the
running process from the CPU and the selection of another process based on a particular
strategy.

Process scheduling is an essential part of a Multiprogramming operating system. Such


operating systems allow more than one process to be loaded into the executable memory
at a time and the loaded process shares the CPU using time multiplexing.
Categories of Scheduling
Scheduling falls into one of two categories:

● Non-Preemptive: In this case, a process’s resource cannot be taken before the

process has finished running. When a running process finishes and transitions to

a waiting state, resources are switched.

● Preemptive: In this case, the OS assigns resources to a process for a predetermined period.

The process switches from running state to ready state or from waiting state to ready state

during resource allocation. This switching happens because the CPU may give other

processes priority and substitute the currently active process for the higher priority

process.

Types of Process Schedulers


There are three types of process schedulers:

1. Long Term or Job Scheduler - 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.

2. Short-Term or CPU Scheduler - 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.

● Switching to user mode.

● Jumping to the proper location in the newly loaded program

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.
Some Other Schedulers
● I/O Schedulers: I/O schedulers are in charge of managing the execution of I/O

operations such as reading and writing to discs or networks. They can use

various algorithms to determine the order in which I/O operations are executed,

such as FCFS (First-Come, First-Served) or RR (Round Robin).

● Real-Time Schedulers: In real-time systems, real-time schedulers ensure that

critical tasks are completed within a specified time frame. They can prioritize and

schedule tasks using various algorithms such as EDF (Earliest Deadline First) or

RM (Rate Monotonic)

Two-State Process Model Short-Term


The terms “running” and “non-running” states are used to describe the two-state process

model.

● 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
● The base and limit register value
● Currently used register
● Changed State
● I/O State information
● Accounting information

Common questions

Powered by AI

Preventing starvation is crucial because if high burst time processes are neglected due to prioritization of shorter, more frequent tasks, these longer processes may never receive sufficient CPU time to complete their execution. This leads to inefficiency and resource underutilization in the system. CPU schedulers are designed to prevent such scenarios by using algorithms that ensure fair allocation of resources, balancing attention between short and long burst tasks, and thus optimizing overall system throughput and responsiveness .

The dispatcher plays a critical role in the process scheduling by performing several key functions: it switches the context of the CPU to the next process as determined by the short-term scheduler, transitions the execution mode of the CPU to user mode, and initiates the program by moving the instruction pointer to the appropriate program location. These functions are essential for transitioning a process from the ready state to the running state, thereby facilitating effective process execution .

The use of linked lists for implementing process queues offers several advantages, such as dynamic memory allocation, which allows efficient space usage and the easy addition or removal of processes without shifting elements. However, linked lists also have disadvantages like increased memory usage due to storage of additional pointers and potentially slower access times compared to array-based implementations due to lack of direct indexing capabilities. These trade-offs impact overall system performance in task management .

Medium-term scheduling optimizes the execution environment by performing operations such as swapping, which involves moving processes between main memory and disk. This is done to adjust the process mix, enhance memory utilization, and meet changing memory demands. By suspending or resuming processes based on current resource availability and requirements, it effectively manages system workloads, reducing overcommitment of memory and maintaining a balanced CPU and I/O task distribution in multitasking environments .

Different scheduling algorithms like First-Come, First-Served (FCFS) and Round Robin affect I/O scheduling performance by determining the order and timing of task execution. FCFS ensures simplicity and fairness, processing requests in the order they arrive, which can lead to inefficiencies due to the convoy effect. Alternatively, Round Robin uses time-slicing to improve response times and ensures equitable resource sharing among processes. The choice of algorithm affects system throughput, latency, and resource utilization dynamics in I/O operations, often balancing between fairness and efficiency .

The long-term scheduler contributes to system efficiency by controlling the degree of multiprogramming and making strategic decisions on selecting a mix of I/O-bound and CPU-bound processes to enter the 'Ready State'. I/O-bound processes tend to spend more time performing input/output operations than using the CPU, while CPU-bound processes devote more time to computations. By maintaining a balanced workload between these two types, the scheduler maximizes the utilization of system resources, thereby enhancing overall system performance .

Real-time schedulers are preferred in scenarios where tasks must be completed within strict time constraints, such as in embedded systems, robotics, and other real-time applications. They ensure predictability and reliability by using prioritization algorithms like Earliest Deadline First (EDF) or Rate Monotonic (RM), making them suitable for applications where timing is crucial. These schedulers optimize for minimal latency and precise execution timing, which are critical for maintaining system integrity in real-time environments .

Process scheduling plays a critical role in a multiprogramming operating system by ensuring that multiple processes residing in executable memory have fair and efficient access to the CPU. It enhances CPU utilization by using time multiplexing, which involves allocating CPU time among various processes competing for attention. Effective scheduling prevents CPU time wastage and maximizes process execution efficiency, ultimately optimizing overall system performance .

Context switching is crucial for enabling multitasking in an operating system by allowing multiple processes to share a single CPU efficiently. It achieves this by saving and restoring the state of a process from the Process Control Block (PCB) whenever a transition occurs between CPU tasks. This mechanism ensures that processes can be resumed from the exact state they were in before preemption, allowing seamless execution flow among concurrent tasks and thereby improving multitasking capabilities .

Preemptive scheduling allows the CPU resources to be reallocated from a currently running process to another process before the first one finishes, typically based on priority or time slice expiration. Non-preemptive scheduling, on the other hand, ensures that a running process retains its resources until it either completes its execution or voluntarily enters a waiting state. These approaches vary mainly in their handling of resource allocation continuity and how they manage CPU time sharing among processes .

You might also like