Unit 2Process Scheduling
Unit 2Process Scheduling
. Job queue:
Contains all submitted jobs.
Processes are stored here in a wait state until they are ready to
go to the execution stage.
This is the first and most basic state that acts as a default
storage of new jobs added to a scheduling system.
Long Term Scheduler Picks a process from Job Queue and
moves to ready queue
3. Medium-Term Scheduler
Medium Term Scheduler (MTS) is responsible for moving a process
from memory to disk (or swapping).
It reduces the degree of multiprogramming (Number of
processes present in main memory).
A running process may become suspended if it makes an I/O
request. A suspended processes cannot make any progress
towards completion. In this condition, to remove the process
from memory and make space for other processes, the
suspended process is moved to the secondary storage. This
process is called swapping, and the process is said to be
swapped out or rolled out. Swapping may be necessary to
improve the process mix (of CPU bound and IO bound)
When needed, it brings process back into memory and pick up
right where it left off.
It is faster than long term and slower than short term
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).
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.
Conclusion
Process schedulers are the essential parts of operating system
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
4. Waiting Time
A scheduling algorithm does not affect the time required to
complete the process once it starts execution. It only affects the
waiting time of a process i.e. time spent by a process waiting in
the ready queue.
Waiting Time = Turnaround Time – Burst Time.
5. Response Time
In an interactive system, turn-around time is not the best
criterion. A process may produce some output fairly early and
continue computing new results while previous results are
being output to the user. Thus another criterion is the time
taken from submission of the process of the request until the
first response is produced. This measure is called response
time.
Response Time = CPU Allocation Time(when the CPU was
allocated for the first) – Arrival Time
sd
Importance of Selecting the Right CPU Scheduling
Algorithm for Specific Situations
It is important to choose the correct CPU scheduling algorithm
because different algorithms have different priorities for
different CPU scheduling criteria.Different algorithms have
different strengths and weaknesses. Choosing the wrong CPU
scheduling algorithm in a given situation can result in
suboptimal performance of the system.
Example: Here are some examples of CPU scheduling
algorithms that work well in different situations.
Round Robin scheduling algorithm works well in a time-sharing
system where tasks have to be completed in a short period of
time. SJF scheduling algorithm works best in a batch
processing system where shorter jobs have to be completed
first in order to increase throughput.Priority scheduling
algorithm works better in a real-time system where certain
tasks have to be prioritized so that they can be completed in a
timely manner.
Factors Influencing CPU Scheduling Algorithms
There are many factors that influence the choice of CPU
scheduling algorithm. Some of them are listed below.
The number of processes.
The processing time required.
The urgency of tasks.
The system requirements.
Selecting the correct algorithm will ensure that the system will
use system resources efficiently, increase productivity, and
improve user satisfaction.
CPU Scheduling Algorithms
There are several CPU Scheduling Algorithms, that are listed
below.
First Come First Served (FCFS)
Shortest Job First (SJF)
Longest Job First (LJF)
Priority Scheduling
Round Robin (RR)
Shortest Remaining Time First (SRTF)
Longest Remaining Time First (LRTF)
Approaches to Multiple-Processor
Scheduling
One approach is when all the scheduling decisions and I/O
processing are handled by a single processor which is called
the Master Server and the other processors executes only
the user code. This is simple and reduces the need of data
sharing. This entire scenario is called Asymmetric
Multiprocessing. A second approach uses Symmetric
Multiprocessing where each processor is self scheduling. All
processes may be in a common ready queue or each
processor may have its own private queue for ready processes.
The scheduling proceeds further by having the scheduler for
each processor examine the ready queue and select a process
to execute