OS_lab_Assignment1_Report
OS_lab_Assignment1_Report
Technology
Experiment Name:
Course ID : CSE-336
Course Title : Operating System (Sessional)
Submitted To Submitted By
1.Name Of Experiment
Implementation of existing CPU scheduling algorithms and development of a new scheduling
algorithm.
2. Objectives
The primary objective of this experiment is to implement and analyze a range of CPU
Scheduling program i.e. First-Come-First-Serve (FCFS), Shortest Job First (SJF), Priority
Scheduling, and Round Robin (RR) and apply learned logic into developing a new scheduling
algorithm.
The purpose of this study is to evaluate and compare performances of each algorithm on basis
of the key metrics:
3. Tools Used
• Programming Language: C++ (Recommended)
• IDE: Visual Studio Code
• Libraries: Standard C++ Libraries for vector manipulation, queues, and input/output
handling.
This algorithm selects the process with the shortest burst time for execution next. It
exists in two forms:
Preemptive SJF (also known as Shortest Remaining Time First): A running process can
be preempted if a new process with a shorter burst time arrives.
• Priority Scheduling:
Each process is assigned a priority level. The scheduler selects the process with the
highest priority (typically represented by the lowest numerical value). This algorithm
can be either preemptive or non-preemptive. It may lead to starvation of lower-priority
processes unless aging is implemented.
• Round Robin (RR):
Designed for time-sharing systems, RR assigns each process a fixed time quantum.
Processes are executed in a circular queue manner, ensuring that no process is starved.
If a process doesn't complete within its time slice, it is preempted and moved to the
back of the queue.
• Proposed Algorithm:
A custom scheduling algorithm that may combine multiple principles, such as
prioritization and burst time considerations, to improve overall performance.
Output:
BEGIN
1. Initialize:
- currentTime ← 0
- completed ← 0
isStarted ← false
- Arrival_Time ≤ currentTime
- remainingTime > 0
currentTime ← currentTime + 1
CONTINUE
c. From readyQueue:
remainingTime ← remainingTime - 1
currentTime ← currentTime + 1
f. IF remainingTime == 0:
Completion_Time ← currentTime
completed ← completed + 1
3. END WHILE
4. Calculate:
- AWT ← total Waiting_Time / total number of processes
- ATT ← total Turnaround_Time / total number of processes
5. Display:
END
7.Results
Table of Arrival Time, Burst Time, and Priority
Process I.D Arrival Time(AT) Burst Time Priority
P1 6 2 3
P2 3 1 2
P3 1 7 3
P4 8 4 2
P5 6 2 4
P6 3 0 5
• CPU scheduling For FCFS
• CPU scheduling For Non-Preemptive SJF
9.Discussion
The experimental analysis indicates that the Proposed Scheduling Algorithm
demonstrates better performance compared to conventional CPU scheduling
algorithms, particularly in minimizing average waiting time and average turnaround
time. By integrating the principles of Priority Scheduling with the Shortest Remaining
Time First (SRTF) approach, the proposed algorithm achieves a more balanced and
responsive scheduling strategy.
The performance of standard algorithms can be summarized as follows:
• First Come First Serve (FCFS): While simple to implement, FCFS often results in
elevated waiting times when longer processes are scheduled before shorter ones,
leading to inefficient CPU utilization.
• Shortest Job First (SJF): This algorithm is effective at reducing turnaround time;
however, it may cause starvation of longer processes, particularly in the non-
preemptive form.
• Priority Scheduling: Though it prioritizes critical tasks, it does not account for the
burst time of processes. As a result, shorter but lower-priority processes may
experience unnecessary delays.
In contrast, the Proposed Algorithm addresses the shortcomings of these methods by
first evaluating process priority and then selecting among processes with equal
priority based on the shortest remaining burst time. This hybrid decision-making
process ensures both responsiveness to high-priority tasks and efficiency in handling
short-duration processes.
The combined consideration of priority and burst time enables the algorithm to
achieve lower average waiting and turnaround times without significantly increasing
response time or risking starvation. Therefore, it provides a more adaptable and
equitable solution for dynamic, real-world scheduling scenarios where process
characteristics can vary widely.