0% found this document useful (0 votes)
14 views12 pages

OS CEA Report

This document presents a Priority-Based Round Robin (PBRR) Scheduling Algorithm designed to enhance CPU scheduling in real-time operating systems by integrating priority handling with traditional Round Robin techniques. The algorithm aims to reduce average waiting time and turnaround time while ensuring fairness among processes, and it has been implemented and tested using the C programming language on a Linux platform. The findings indicate significant performance improvements over conventional scheduling methods, highlighting the algorithm's adaptability to varying workloads and its potential for future enhancements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views12 pages

OS CEA Report

This document presents a Priority-Based Round Robin (PBRR) Scheduling Algorithm designed to enhance CPU scheduling in real-time operating systems by integrating priority handling with traditional Round Robin techniques. The algorithm aims to reduce average waiting time and turnaround time while ensuring fairness among processes, and it has been implemented and tested using the C programming language on a Linux platform. The findings indicate significant performance improvements over conventional scheduling methods, highlighting the algorithm's adaptability to varying workloads and its potential for future enhancements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

NATIONAL UNIVERSITY OF TECHNOLOGY

COMPUTER ENGINEERING DEPARTMENT

Subject/Course Name

OPERATING SYSTEM LAB


CEA

Department Registration Number/Name Semester

CEN F22604023/Muhammad Zarar Fall 2024/6th


F22604045/Saad shakeel
F22604030/ Mustansar Munir

Date Of Instructor’s Name Instructor’s Signature


Submission

MAY 26th , 2024 Sir. Ijaz

Table of content
Introduction

 Overview
 Problem Statement

Background and Objectives

 Literature Review
 Project Goals

Research Methodology

 Methodology
 Code

Findings and Analysis

 Results
 Discussion

ABSTRACT
This paper presents an enhanced CPU scheduling approach designed to optimize performance in
real-time operating systems. The proposed method combines the strengths of Round Robin (RR)
and Priority-Based (PB) scheduling algorithms to address key limitations in existing techniques.
While Round Robin scheduling is effective in reducing process starvation due to its fairness and
simplicity, it often results in high waiting time, response time, and turnaround time, making it
less suitable for real-time environments. By integrating a priority index alongside the traditional
time quantum, the new hybrid algorithm retains the benefits of Round Robin while incorporating
priority handling to improve overall efficiency. Comparative analysis demonstrates that the
proposed algorithm significantly reduces average waiting time and turnaround time compared to
the conventional Round Robin approach, offering a more effective solution for real-time CPU
scheduling.

INTRODUCTION:
Overview:

In contemporary computing environments, effective CPU scheduling is essential for maximizing


system performance and ensuring equitable resource distribution among processes. Traditional
scheduling algorithms such as First-Come, First-Served (FCFS), Shortest Job Next (SJN), and
Round Robin (RR) each offer distinct advantages and drawbacks. FCFS is straightforward to
implement but suffers from the "convoy effect," where short tasks are delayed by longer ones.
SJN achieves minimal average waiting time but depends on precise knowledge of process
execution times, which is often impractical. RR promotes fairness by allocating a fixed time slice
(quantum) to each process but can incur excessive context-switching overhead if the quantum is
not optimally configured.

To overcome these limitations, this project proposes the implementation of a Priority-Based


Round Robin (PBRR) Scheduling Algorithm using the C programming language on a Linux
platform. This hybrid scheduling method integrates the fairness of the Round Robin approach
with the responsiveness of priority-based scheduling, allowing processes to be scheduled
according to both priority and fairness criteria.

The PBRR algorithm enhances the traditional Round Robin model by introducing process
priorities. Processes are placed in a ready queue ordered by priority, with the highest priority
process positioned at the front. The CPU allocates a user-defined time quantum to the process at
the head of the queue. Once the quantum expires, the process is reinserted into the queue based
on its priority. Importantly, processes are not preempted before completing their assigned
quantum, even if a higher-priority process arrives during execution. This approach ensures that
high-priority tasks receive timely CPU access while preserving the cyclic and fair nature of
Round Robin scheduling.
The proposed algorithm also accommodates processes that require I/O operations. After
completing their initial CPU burst, processes transition to perform I/O tasks and are reinserted
into the ready queue upon I/O completion. Each process terminates after finishing its second
CPU burst. To ensure fairness in cases where multiple processes arrive simultaneously with
identical priorities, the algorithm employs the First-Come, First-Served (FCFS) strategy, using
the order of entries in the input file to resolve any remaining scheduling conflicts.

User input is collected at runtime, including arrival time, CPU burst durations, I/O time, and
priority level for each process. The system supports scheduling for up to ten processes, with
appropriate error handling implemented to notify the user if this limit is exceeded.

(Priority based Round Robin)


The project is structured into multiple phases, including the design and implementation of the
scheduling algorithm, thorough testing and validation to ensure functional accuracy, and the
development of comprehensive documentation and reporting. The testing phase involves
executing a diverse set of test cases with varying process parameters and time quantum values to
confirm that the algorithm behaves in accordance with the defined scheduling rules. Performance
evaluation is conducted using key metrics such as average waiting time, average turnaround
time, and CPU utilization, providing a quantitative assessment of the algorithm’s efficiency and
effectiveness.
Project Statement: In the field of operating system design, efficient CPU scheduling is
crucial for optimizing process execution, maximizing system throughput, and ensuring effective
resource utilization. Conventional scheduling algorithms—such as First-Come, First-Served
(FCFS), Shortest Job Next (SJN), and Round Robin (RR)—offer unique benefits but also present
notable limitations. FCFS, though simple to implement, often leads to the "convoy effect," where
shorter processes are delayed by longer ones, reducing overall system efficiency. SJN minimizes
average waiting time by prioritizing shorter jobs, but its effectiveness depends on prior
knowledge of job durations, which is often impractical in dynamic computing environments. RR
scheduling promotes fairness by assigning fixed time quanta to each process; however, it can
incur significant context-switching overhead when the quantum size is not optimally configured.

The primary objective of this project is to design and implement a Priority-Based Round Robin
(PBRR) Scheduling Algorithm in the C programming language on a Linux platform. This hybrid
approach seeks to integrate the fair time-sharing characteristics of Round Robin with the
responsiveness and efficiency of priority-based scheduling, offering a more balanced and
adaptable solution for modern multitasking systems.

Problem Description

The proposed scheduling algorithm must satisfy a set of technical requirements and operational
constraints to ensure robust and efficient performance. Foremost, it must effectively integrate
process priorities into its scheduling logic. Each process is assigned a priority level upon entry
into the system, and the scheduler is required to consistently select the highest-priority ready
process for execution, thereby ensuring that critical tasks are given precedence over less urgent
ones.

In parallel, the algorithm must implement a Round Robin scheduling mechanism, allocating CPU
time in fixed-length quanta. Upon the expiration of a time quantum, the currently executing
process is returned to the ready queue if it has not yet completed execution. A key requirement is
that processes must not be preempted in the middle of a quantum, thereby preserving the
integrity and predictability of each allocated time slice.

Efficient handling of I/O operations is also essential. After completing their initial CPU burst,
processes perform I/O tasks and must re-enter the ready queue upon completion. The scheduler
must manage these transitions seamlessly to prevent unnecessary execution delays and ensure
continuous CPU utilization.
In scenarios where multiple processes arrive simultaneously with equal priorities, the algorithm
must apply a First-Come, First-Served (FCFS) policy to resolve scheduling ties, ensuring
fairness and predictability in execution order.

The implementation will be carried out in the C programming language, utilizing the Linux
operating system’s features for process control and scheduling. Users will input key process
attributes at runtime, including arrival times, CPU burst durations, I/O times, and priority levels.
The system will support dynamic scheduling of up to ten processes, with appropriate error
messages displayed if the process limit is exceeded.

OBJECTIVE:

Literature Review: Research in this area has explored both static and dynamic priority models. In
static systems, priorities are assigned at process initiation and remain fixed, whereas dynamic
approaches adjust priorities based on runtime factors such as process aging or task completion. These
strategies are designed to maintain system responsiveness while mitigating the risk of indefinite
postponement for lower-priority processes.

More recently, attention has shifted toward the practical implementation of these hybrid
algorithms in real-world operating systems, with a particular focus on the Linux platform. The
open-source and modular nature of Linux makes it an ideal environment for developing and
testing custom scheduling strategies. A growing body of literature documents both the
implementation challenges and the performance improvements associated with integrating
priority-based RR algorithms into Linux, offering valuable insights and performance benchmarks
for future development.

Project Goals:

The primary objective of this project is to design and implement a Priority-Based Round Robin
(PBRR) Scheduling Algorithm using the C programming language on a Linux platform. This
implementation involves extending the traditional Round Robin (RR) scheduling algorithm by
integrating priority-based decision-making. The aim is to ensure that processes are scheduled
according to their priority levels while maintaining the equitable time-sharing characteristics
inherent to the Round Robin approach. The overarching goal is to achieve an optimal balance
between fairness and efficiency—delivering timely CPU access to high-priority processes
without causing starvation among lower-priority ones.

A central focus of the project is the development of a robust and modular scheduling algorithm
in C that seamlessly interfaces with the Linux environment. This includes managing the ready
queue, implementing fixed-length time quanta, and enforcing scheduling decisions only at
quantum expiration. The algorithm must account for the combined complexity of priority
handling and Round Robin time-slicing, ensuring predictable and fair CPU allocation across
diverse workloads.
Testing and validation represent critical phases of the project. The implemented algorithm will
be rigorously tested with a wide range of process configurations and time quantum values to
verify its correctness, stability, and performance. Key validation criteria include ensuring that the
highest-priority ready process consistently gains CPU access, no process is preempted mid-
quantum, and the overall scheduling behavior aligns with the defined rules of the PBRR model.
Performance metrics such as average waiting time, turnaround time, and CPU utilization will
also be used to assess the effectiveness of the algorithm in real-world scenarios.

Finally, the project aims to document the entire process, including the design, implementation,
testing procedures, and results. The comprehensive report will detail the project design, the
challenges encountered, and the solutions implemented. It will also include a comparison of the
different sets of data used for testing, highlighting the performance and accuracy of the
algorithm. The goal is to provide a thorough understanding of the project, its outcomes, and its
contributions to the field of operating systems and scheduling algorithms.

RESEARCH AND METHODOLOGY:

The methodology adopted for implementing the Priority-Based Round Robin (PBRR)
Scheduling Algorithm follows a structured, multi-phase approach designed to ensure the
successful design, development, testing, and validation of the algorithm on a Linux platform
using the C programming language. The approach comprises the following key stages:

1. Problem Understanding and Requirement Analysis


The initial phase involved a thorough examination of the problem domain and a detailed
analysis of the algorithm's functional and technical requirements. This included an in-
depth review of traditional scheduling algorithms such as First-Come, First-Served
(FCFS), Shortest Job Next (SJN), and Round Robin (RR), along with their limitations.
From this analysis, the essential features for the proposed hybrid algorithm—combining
RR with priority-based scheduling—were identified and defined.
2. Algorithm Design
The design phase focused on integrating priority-based scheduling into the Round Robin
framework. This involved defining core data structures, such as the Process structure to
encapsulate process attributes (e.g., arrival time, burst time, priority), and formalizing the
scheduling rules. Pseudocode was developed to outline the logical flow and support a
smooth transition from conceptual design to code implementation.
3. Implementation
Following the design phase, the algorithm was implemented using the C programming
language. The implementation emphasized accurate state management for processes,
efficient handling of I/O operations, priority-based process selection, and enforcement of
the time-slicing mechanism. Key considerations included modular code structure, proper
memory management, and maintaining scheduling fairness while optimizing CPU
utilization.
4. Testing Strategy
A comprehensive testing strategy was employed to ensure the algorithm's correctness and
robustness. This included:

 Unit testing of individual functions and components,


 Integration testing to validate the interaction between modules, and
 System-level testing using diverse process sets and varying time quantum
values to assess the algorithm’s behavior across different scheduling
scenarios.

5. Performance Evaluation
The final phase involved a systematic evaluation of the algorithm's performance using
key metrics, including average waiting time, average turnaround time, and CPU
utilization rate. These metrics were analyzed to quantify the efficiency and effectiveness
of the PBRR algorithm in managing system resources and meeting real-time scheduling
demands.

CODE

The code of project is given below:


Output:

ANALYSIS

Result : During testing, significant improvements were observed in key metrics such as
Average Waiting Time (AWT), Turnaround Time (TAT), and CPU Utilization Rate. The
algorithm effectively minimized AWT by prioritizing higher-priority processes within the
scheduling queue, ensuring they received preferential CPU access over lower-priority tasks. This
approach optimized resource allocation and enhanced system responsiveness by reducing the
waiting times of critical processes.

Turnaround Time, which measures the total time from process arrival to completion, was
systematically analyzed. The implementation demonstrated the algorithm’s ability to balance
turnaround times across different priority levels, ensuring timely execution and completion of
tasks even under varying workload conditions.

Scenario-Based Evaluations

In-depth testing scenarios evaluated the algorithm's adaptability to dynamic workloads and
varying time quantum sizes. Smaller quantum values allowed for quicker context switches,
thereby improving responsiveness but at the potential cost of increased overhead. Conversely,
larger quantum sizes improved throughput but could reduce responsiveness. The optimal
quantum size was found to depend on workload characteristics and system requirements,
illustrating the algorithm’s flexibility to adapt effectively across diverse operational
environments.

Discussions

The implementation and testing of the Priority-Based Round Robin Scheduling Algorithm
revealed several important insights relevant to operating system scheduling strategies. Its
primary strength lies in effectively balancing process priority with equitable CPU time allocation
through the Round Robin mechanism. By prioritizing higher-priority processes while ensuring
all processes receive fair CPU access, the algorithm successfully minimizes average waiting
times and enhances system responsiveness.

This hybrid approach addresses key limitations of traditional algorithms such as First-Come,
First-Served (FCFS) and Shortest Job Next (SJN), which either ignore process importance or risk
starving lower-priority tasks. Comparative analysis shows the algorithm’s superiority in
optimizing CPU utilization and reducing waiting times under various workloads. Unlike FCFS,
which may lead to poor resource utilization under high demand, and SJN, which can starve less
urgent tasks, the Priority-Based Round Robin algorithm dynamically adapts to both priorities and
fairness.

The algorithm’s flexibility in handling different time quantum sizes and priority distributions
was also evaluated. Smaller quantum sizes improved responsiveness by enabling faster context
switching, albeit with increased overhead, while larger quanta enhanced throughput by reducing
context switches at the cost of latency. This adaptability allows the algorithm to be tuned for
specific system needs and workload characteristics, optimizing performance across diverse
operational contexts.
Future work could focus on dynamic quantum adjustment algorithms and improved I/O
management to further enhance efficiency. Adaptive quantum sizing based on real-time
workload feedback may increase responsiveness and resource utilization in dynamic
environments.

Overall, the Priority-Based Round Robin Scheduling Algorithm demonstrates a robust, efficient,
and adaptable solution for modern CPU scheduling, offering significant improvements in
managing process priorities, optimizing CPU use, and boosting system performance.

You might also like