0% found this document useful (0 votes)
9 views30 pages

Dynamic Process Scheduling in Python

Uploaded by

burugabalaji8
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)
9 views30 pages

Dynamic Process Scheduling in Python

Uploaded by

burugabalaji8
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

MINI PROJECT REPORT ON

DYNAMIC PROCESS SCHEDULING


IN PYTHON
Submitted as a part of Course Curriculum
ADVANCE DATASTUCTURES AND
ALGORITHM ANALYSIS
in
COMPUTER SCIENCE AND ENGINEERING
by
B. BALASUBRAMANYAM (239Y1A0536)
B. UMMAR (239Y1A0516)
E. THIRUPATHAIAH (239Y1A0553)
B. ASHOK NAIK (239Y1A0531)
E. CHARAN (239Y1A0555)

under the Esteemed Supervision of


Dr. V. Lokeswara Reddy, [Link]., Ph.D.

Professor.,

Dept of CSE

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

K.S.R.M. COLLEGE OF ENGINEERING


(UGC-Autonomous)
Approved by AICTE, New Delhi and affiliated to JNTUA, Anantapuramu
Accredited by NAAC with A+ Grade &B. Tech (EEE , ECE, CSE, CE and ME) Programs by NBA

Kadapa, Andhra Pradesh, India– 516 003


2024-2025

i
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
K.S.R.M. COLLEGE OF ENGINEERING
(UGC-Autonomous)
Approved by AICTE , New Delhi and affiliated to JNTUA, Anantapuramu
Accredited by NAAC with A+ Grade & B. Tech (EEE, ECE, CSE, CE and ME) Programs by NBA
Kadapa, Andhra Pradesh, India– 516 003

VISION
To evolve as a center of repute for providing quality academic programs
amalgamated with creative learning and research excellence to produce graduates
with leadership qualities, ethical and human values to serve the nation.

MISSION
M1: To provide high quality education with enriched curriculum blended with
impactful teaching-learning practices.
M2: To promote research, entrepreneurship and innovation through industry
collaborations.
M3: To produce highly competent professional leaders for contributing to
Socioeconomic development of region and the nation.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

VISION
To evolve as a recognized center of excellence in the area of Computer Science and
Engineering and other related inter-disciplinary fields.

MISSION
M1: To produce competent and industry ready professionals through well balanced
curriculum and innovative pedagogy.
M2: To provide conducive environment for research by establishing centre of
excellence and industry collaborations.
M3: To install leadership qualities, ethical values among students through various co-
curricular and extracurricular activities.

ii
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
B. Tech. (COMPUTER SCIENCE AND Engineering)

PROGRAM EDUCATIONAL OBJECTIVES

B. Tech-Computer Science and Engineering Program Objectives.


A graduate of the K.S.R.M.C.E, C.S.E should have a successful career in CSE or a
related field, and within three to five years, should
PEO1: To excel in their career as competent software engineer in IT and allied
organizations.
PEO2: To pursue higher education and to demonstrate research temper for providing
solutions to engineering problems.
PEO3: To contribute for the societal development by exhibiting leadership, through
professional, social and ethical values.

PROGRAM OUTCOMES
PO1 - Engineering Knowledge: Apply the knowledge of mathematics, science,
engineering fundamentals, and an engineering specialization to the solution of
complex engineering problems.
PO2 - Problem Analysis: Identify, formulate, review research literature, and
analyse complex engineering problems reaching substantiated conclusions using
first principles of mathematics, natural sciences, and engineering sciences.
PO3 - Design/Development of solutions: Design solutions for complex
engineering problems and design system components or processes that meet the
specified needs with appropriate consideration for the public health and safety,
and the cultural, societal, and environmental considerations.
PO4 - Conduct investigations of complex problems: Use research-based
knowledge and research methods including design of experiments, analysis and
interpretation of data, and synthesis of the information to provide valid
conclusions. PO5 - Modern tool usage: Create, select, and apply appropriate
techniques, resources, and modern engineering and IT tools including prediction

iii
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
and modelling to complex engineering activities with an understanding of the
limitations.

PO6 - The engineer and society: Apply reasoning informed by the contextual
knowledge to assess societal, health, safety, legal and cultural issues and the
consequent responsibilities relevant to the professional engineering practice.
PO7 - Environment and sustainability: Understand the impact of the
professional engineering solutions in societal and environmental contexts, and
demonstrate the knowledge of, and need for sustainable development.
PO8 - Ethics: Apply ethical principles and commit to professional ethics and
responsibilities and norms of engineering practice.
PO9 - Individual and team work: Function effectively as an individual, and as a
member or leader in diverse teams, and in multidisciplinary settings.
PO10 - Communication: Communicate effectively on complex engineering
activities with the engineering community and with society at large, such as,
being able to comprehend and write effective reports and design documentation,
make effective presentations, and give and receive clear instructions.
PO11 - Project management and finance: Demonstrate knowledge and
understanding of the engineering and management principles and apply these to
one's own work, as a member and leader in a team, to manage projects and in
multidisciplinary environments.
PO12 - Life-long learning: Recognize the need for, and have the preparation and
ability to engage in independent and life-long learning in the broadest context of
technological change.

iv
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
PROGRAM SPECIFIC OUTCOMES
PSOs are the statements that describe what the graduates of a specific engineering
program should be able to:
PSO1-Professional Skills: The ability to understand, analyse and develop the
computer programs in areas related to algorithms, system software, multimedia,
web design, big data analysis and networking for efficient design of computer
based systems of varying complexity.
PSO2-Problem Solving Skills: The ability to apply standard practices and
strategies in software project development using open – ended programming
environments to deliver a quality product or business success
PSO3 – Successful career and Entrepreneurship: The ability to employ modern
computer languages, environments, and platforms in creating innovative career
paths to be an entrepreneur, and Zest for higher studies

v
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
COURSE OUTCOMES

CO1. Prove the correctness and analyze space and time complexity of an algorithm.
CO2. Understand different algorithm design strategies..
CO3. Analyze & Apply standard algorithms.
CO4. Understand Graph/Tree bases applications and appropriate techniques.
CO5. Current trends in Non Deterministic concepts.

CO-PO MAPPING

Course Outcome Program Outcomes Program Specific


Outcomes

PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO PO PO PSO1 PSO2 PSO3
10 11 12

CO1 3 3 3 3

CO2 3 3 3 3

CO3 3 3 2 2 3

CO4 3 3 1

CO5 3 3 3 2 2

vi
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
K.S.R.M. COLLEGE OF ENGINEERING
(UGC-Autonomous)
Approved by AICTE , New Delhi and affiliated to JNTUA, Anantapuramu
Accredited by NAAC with A+ Grade & B. Tech (EEE, ECE, CSE, CE and ME) Programs by
NBA Kadapa, Andhra Pradesh, India– 516003

CERTIFICATE
This is to certify that the ADVANCE DATASTRUCTURES AND ALGORITHM ANALYSIS
Mini Project entitled
DYNAMIC PROCESS SCHEDULING
IN PYTHON
is the bonafide work done & submitted by

B. BALASUBRAMANYAM (239Y1A0536)
B. UMMAR (239Y1A0516)
E. THIRUPATHAIAH (239Y1A0553)
B. ASHOK NAIK (239Y1A0531)
E. CHARAN (239Y1A0555)

in the Department of Computer Science and Engineering, K.S.R.M.C.E, Kadapa and is


submitted to Jawaharlal Nehru Technological University Anantapur, as a part of
“ADVANCE DATASTRUCTURES AND ALGORITHM ANALYSIS” Course in
Computer Science and Engineering during 2023-2027.

Supervisor Head of the Department


Dr. V. Lokeswara Reddy A. Ram Prakash Reddy
[Link], Ph.D. M. Tech, (Ph.D).
Professor Assistant Professor & HOD
Dept of CSE and Allied Dept of CSE and Allied
Branches. Branches.

vii
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
DECLARATION
We hereby declare that this Mini Project report titled “DYNAMIC PROCESS
SCHEDULING IN PYTHON” is a genuine project work carried out by us, in
ADVANCE DATASTRUCTURES AND ALGORITHM ANALYSIS in B.
Tech (Computer Science and Engineering) degree course of Jawaharlal Nehru
Technological University Anantapur and has not been submitted to any other
course or University for the award of any degree by us.

Signature of the Student

B. BALASUBRAMANYAM
B. UMMAR
E. THIRUPATHAIAH
B. ASHOK NAIK
E. CHARAN

viii
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
ACKNOWLEDGEMENTS
An endeavor over a long period can be successful only with the advice and
supports of many well-wishers. We take this opportunity to express our gratitude
and appreciation to all of them.

We are extremely thankful to our beloved Managing Director Dr. K Chandra


Obul Reddy Sir who took keen interest and encouraged us in every effort
throughout this course. We are deeply indebted to the supervisor, Dr. V.
Lokeswara Reddy, [Link]., Ph.D. Professor, Department of Computer Science and
Engineering for valuable guidance, constructive criticism and keen interest
evinced throughout the course of our ADS&AA project work. We are really
fortunate to associate ourselves with such an advising and helping guide in every
possible way, at all stages, for the successful completion of this work.

We express our deep sense of gratitude to Sri A. Ram Prakash Reddy, M. Tech.,
(Ph.D.,)., Assistant Professor and Head of Department of Computer Science and
Engineering for his valuable guidance and constant encouragement given to us
during this ADS&AA project and the course. We take this opportunity to express
our deep gratitude and appreciation to all those who encouraged us for
successfully completion of this ADVANCE DATASTRUCTURES AND ALGORITHM
ANALYSIS Project work. We wish to express our sincere to gratitude to Dr. T.
NAGESWARA PRASAD, [Link]., Ph.D. Vice Principal of K.S.R.M.C.E,
Kadapa and Dr.V.S.S. MURTHY, [Link]., Ph.D. Principal of K.S.R.M.C.E,
Kadapa and for their consistent help and encouragement to complete the
ADS&AA project work. We are pleased to express our heart full thanks to our
faculty in Department of CSE of KSRMCE for their moral support and good
wishes. Finally, we have a notation to express our sincere thanks to friends and all
those who guided, inspired and helped us in the completion of our project work.

B. BALASUBRAMANYAM
B. UMMAR
E. THIRUPATHAIAH
B. ASHOK NAIK
E. CHARAN

ix
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
INDEX

TOPIC Page No

ABSTRACT 1

1. INTRODUCTION 2

2. MODULES 3-4

2.1. tkinter 3

2.2. [Link]
3

2.3. heapq
3

2.4. Exception Handling


4

3. PROJECT PICTORIAL REPRESENTATION 5


4. SOURCE CODE
6 -13

5. INPUT AND OUTPUT SCREENS 14 – 18

CONCLUSION 19

REFERENCE 20

x
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
ABSTRACT

Dynamic Process Scheduling is a crucial aspect of operating systems and resource management,
aimed at optimizing the execution of processes to enhance system performance and responsiveness.
This project explores the implementation of a dynamic process scheduling algorithm in Python,
designed to adaptively allocate CPU time to processes based on their priority and resource
requirements. By leveraging real-time metrics and performance indicators, the algorithm dynamically
adjusts scheduling decisions, ensuring that high-priority tasks receive timely execution while
maintaining overall system efficiency.

The project encompasses the development of a simulation environment where various scheduling
strategies, including Round Robin, Shortest Job First, and Priority Scheduling, are evaluated under
different workload scenarios. Through rigorous testing and analysis, we assess the impact of dynamic
scheduling on throughput, turnaround time, and waiting time. The results demonstrate significant
improvements in process handling and resource utilization compared to static scheduling approaches.

This project not only provides insights into the complexities of process scheduling but also serves as a
practical tool for understanding the principles of operating systems. The implementation in Python
allows for extensibility and ease of experimentation, making it a valuable resource for students and
professionals interested in operating systems and concurrent programming.

1
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
1. INTRODUCTION
In the realm of modern computing, efficient process management is paramount for optimizing system
performance and ensuring user satisfaction. At the heart of this management lies process scheduling,
a critical function of operating systems that determines the order in which processes are executed.
With the increasing complexity and resource demands of contemporary applications, the need for
adaptive and dynamic scheduling mechanisms has become more pronounced.
Traditional scheduling algorithms, such as First-Come, First-Served (FCFS), Round Robin, Shortest
Job First (SJF), and Priority Scheduling, offer foundational approaches to process management.
However, these static methods often struggle to adapt to the changing demands of processes in real-
time. For instance, while Round Robin provides fairness among processes, it may lead to increased
waiting times for high-priority tasks. Similarly, SJF can minimize average waiting time but may
starve longer processes. These limitations highlight the need for a more dynamic approach that can
respond to varying workloads and priorities.
This project aims to develop and implement a comprehensive dynamic process scheduling algorithm
in Python that integrates multiple scheduling techniques. By leveraging real-time metrics such as
process priority, execution time, and resource consumption, the proposed algorithm dynamically
adjusts scheduling decisions to optimize system performance. The goal is to ensure that high-priority
tasks receive timely execution while maximizing overall CPU utilization and minimizing wait times.
To facilitate this exploration, we will create a simulation environment that allows for the evaluation
of various scheduling strategies under diverse workload scenarios. The simulation will include a
comparative analysis of traditional algorithms alongside the dynamic scheduling approach, providing
insights into their performance under different conditions. Key performance indicators such as
throughput, turnaround time, and average waiting time will be measured to assess the effectiveness of
each method.
By synthesizing the strengths of established scheduling techniques within a dynamic framework, this
project seeks to advance the understanding of process scheduling principles and their practical
applications. The implementation in Python not only makes the project accessible and extensible but
also serves as an educational tool for students and professionals interested in operating systems and
concurrent programming.
Ultimately, this project aspires to contribute to the field of resource management by demonstrating
the advantages of dynamic scheduling and providing a platform for further research and
experimentation. Through this work, we aim to empower users to engage with the complexities of
process scheduling and explore innovative solutions to the challenges posed by modern computing
environments.

2
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
2. MODULES

2.1. tkinter
Purpose:
tkinter is the standard GUI toolkit for Python, allowing developers to create graphical user
interfaces for their applications. It provides a variety of widgets, such as buttons, labels,
entry fields, and text areas, that can be used to build interactive applications.
How it Works:
• In this code, tkinter is used to create the main application window and various input
fields for users to enter process details (like name, arrival time, burst time, and
priority). It also includes buttons to add processes and start the scheduling algorithm.
The Text widget is used to display the results of the scheduling operations.
The messagebox submodule is utilized to show error messages when user input is
invalid, enhancing user experience by providing feedback.

2.2. [Link]
Purpose:
The deque (double-ended queue) class from the collections module provides an efficient
way to append and pop elements from both ends of a queue. It is particularly useful for
implementing queues in scheduling algorithms, where processes may need to be added and
removed frequently.
How it Works:
• In the Round Robin scheduling algorithm, a deque is used to manage the queue of
processes. As processes are executed for a time slice, they are either completed and
removed from the queue or added back to the end of the queue if they require more
time. This allows for efficient management of the order in which processes are
scheduled.

2.3. heapq
Purpose:

The heapq module provides an implementation of the heap queue algorithm, also
known as a priority queue. It allows for efficient retrieval of the smallest (or
highest priority) element from a collection.
How it Works:
• In the Preemptive Priority and Shortest Remaining Time First (SRTF) scheduling
algorithms, heapq is used to manage a priority queue of processes. Processes are
3
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
pushed onto the heap based on their priority or remaining burst time, allowing the
scheduler to efficiently select the next process to execute. The use of a heap ensures
that the process with the highest priority (or the shortest remaining time) is always at
the front of the queue, facilitating optimal scheduling decisions.

2.4. Exception Handling

Purpose:
While not a separate module, exception handling is crucial in robust programming. It allows
developers to manage errors gracefully without crashing the application.
How it Works:
• In this code, try and except blocks are used to catch potential errors that may arise
during user input processing or scheduling operations. For example, if a user fails to
fill in all fields for a process, an error message is displayed
using [Link], prompting the user to correct their input. This
improves the reliability of the application and enhances user experience by
providing clear feedback on what went wrong.

4
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
3. PROJECT PICTORIAL REPRESENTATION

5
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
4. SOURCE CODE
import tkinter as tk
from tkinter import messagebox
from collections import deque
import heapq
class Process:
def __init__(self, name, arrival_time, burst_time, priority):
[Link] = name
self.arrival_time = int(arrival_time)
self.burst_time = int(burst_time)
[Link] = int(priority)
self.completion_time = 0
self.turn_around_time = 0
self.waiting_time = 0
self.response_time = 0
self.remaining_time = int(burst_time)

def fcfs(processes):
[Link](key=lambda p: p.arrival_time)
current_time = 0
for process in processes:

if process.arrival_time > current_time:


current_time = process.arrival_time

process.completion_time = current_time + process.burst_time


process.turn_around_time = process.completion_time - process.arrival_time
process.waiting_time = process.turn_around_time - process.burst_time

6
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
current_time = process.completion_time

def sjf(processes):
[Link](key=lambda p: (p.arrival_time, p.burst_time))
current_time = 0
for process in processes:

if process.arrival_time > current_time:


current_time = process.arrival_time

process.completion_time = current_time + process.burst_time


process.turn_around_time = process.completion_time - process.arrival_time
process.waiting_time = process.turn_around_time - process.burst_time
current_time = process.completion_time

def round_robin(processes, time_quantum):


queue = deque(processes)
current_time = 0
while queue:
process = [Link]()
if process.arrival_time > current_time:
current_time = process.arrival_time

if process.remaining_time > time_quantum:


current_time += time_quantum
process.remaining_time -= time_quantum
[Link](process)
else:
7
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
current_time += process.remaining_time
process.completion_time = current_time
process.remaining_time = 0

process.turn_around_time = process.completion_time - process.arrival_time


process.waiting_time = process.turn_around_time - process.burst_time

def non_preemptive_priority(processes):
[Link](key=lambda p: ([Link], p.arrival_time))
current_time = 0
for process in processes:
if process.arrival_time > current_time:
current_time = process.arrival_time

process.completion_time = current_time + process.burst_time


process.turn_around_time = process.completion_time - process.arrival_time
process.waiting_time = process.turn_around_time - process.burst_time
current_time = process.completion_time

def preemptive_priority(processes):
pq = []
current_time = 0
remaining_processes = len(processes)
while remaining_processes > 0:

for process in processes:


if process.arrival_time <= current_time and process.remaining_time > 0
and process not in pq:
8
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
[Link](pq, ([Link], process.arrival_time, process))

if pq:
priority, arrival_time, process = [Link](pq)

if process.remaining_time > 0:
time_slice = min(process.remaining_time, 1)
current_time += time_slice
process.remaining_time -= time_slice

if process.remaining_time == 0:
process.completion_time = current_time
process.turn_around_time = process.completion_time - process.arrival_time
process.waiting_time = process.turn_around_time - process.burst_time
remaining_processes -= 1
else:
current_time += 1

def srtf(processes):
[Link](key=lambda p: p.arrival_time)
current_time = 0
remaining_processes = len(processes)
processes_heap = []
while remaining_processes > 0:

for process in processes:


if process.arrival_time <= current_time and process.remaining_time > 0:
[Link](processes_heap, (process.remaining_time, process.arrival_time, process))

9
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
if processes_heap:
remaining_time, arrival_time, process = [Link](processes_heap)
time_slice = 1
current_time += time_slice
process.remaining_time -= time_slice
if process.remaining_time == 0:
process.completion_time = current_time
process.turn_around_time = process.completion_time - process.arrival_time
process.waiting_time = process.turn_around_time - process.burst_time
remaining_processes -= 1
else:
current_time += 1

class SchedulingApp:
def __init__(self, root):
[Link] = root
[Link]("Dynamic Process Scheduling in Python")
self.num_processes = 0
[Link] = []
self.create_widgets()

def create_widgets(self):
self.instruction_label = [Link]([Link], text="Enter the number of processes
and their details.")
self.instruction_label.grid(row=0, columnspan=2, pady=10)
self.num_process_label = [Link]([Link], text="Number of Processes:")
self.num_process_label.grid(row=1, column=0, padx=10, pady=5)
self.num_process_entry = [Link]([Link])
10
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
self.num_process_entry.grid(row=1, column=1, padx=10, pady=5)
self.process_entries_frame = [Link]([Link])
self.process_entries_frame.grid(row=2, columnspan=2, pady=10)
self.add_process_button = [Link]([Link], text="Add Process",
command=self.add_process_entry)
self.add_process_button.grid(row=3, columnspan=2, pady=5)
self.algorithm_label = [Link]([Link], text="Select Scheduling Algorithm:")
self.algorithm_label.grid(row=4, column=0, padx=10, pady=5)
self.algorithm_var = [Link]()
self.algorithm_var.set("FCFS")
self.algorithm_menu = [Link]([Link], self.algorithm_var, "FCFS", "SJF",
"Round Robin", "Non-Preemptive Priority", "Preemptive Priority", "SRTF")
self.algorithm_menu.grid(row=4, column=1, padx=10, pady=5)
self.start_button = [Link]([Link], text="Start Scheduling", command=self.start_scheduling)
self.start_button.grid(row=5, columnspan=2, pady=20)
self.output_text = [Link]([Link], height=10, width=50)
self.output_text.grid(row=6, columnspan=2, padx=10, pady=10)

def add_process_entry(self):
num = int(self.num_process_entry.get())
if self.num_processes < num:
self.process_entries_frame.destroy()
self.process_entries_frame = [Link]([Link])
self.process_entries_frame.grid(row=2, columnspan=2, pady=10)
[Link] = []
for i in range(num):
process_label = [Link](self.process_entries_frame, text=f"Process {i+1}:")
process_label.grid(row=i, column=0, padx=5, pady=5)
name_entry = [Link](self.process_entries_frame)
11
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
name_entry.grid(row=i, column=1, padx=5, pady=5)
arrival_time_entry = [Link](self.process_entries_frame)
arrival_time_entry.grid(row=i, column=2, padx=5, pady=5)
burst_time_entry = [Link](self.process_entries_frame)
burst_time_entry.grid(row=i, column=3, padx=5, pady=5)
priority_entry = [Link](self.process_entries_frame)
priority_entry.grid(row=i, column=4, padx=5, pady=5)
[Link]({
'name': name_entry,
'arrival_time': arrival_time_entry,
'burst_time': burst_time_entry,
'priority': priority_entry
})
self.num_processes = num

def start_scheduling(self):
self.output_text.delete(1.0, [Link])
try:
self.processes_data = []
for process in [Link]:
name = process['name'].get()
arrival_time = process['arrival_time'].get()
burst_time = process['burst_time'].get()
priority = process['priority'].get()

if name and arrival_time and burst_time and priority:


self.processes_data.append(Process(name, arrival_time, burst_time, priority))
else:
[Link]("Input Error", "Please fill in all fields for each process.")
12
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
return

algorithm = self.algorithm_var.get()
if algorithm == "FCFS":
fcfs(self.processes_data)
elif algorithm == "SJF":
sjf(self.processes_data)
elif algorithm == "Round Robin":
time_quantum = 4
round_robin(self.processes_data, time_quantum)
elif algorithm == "Non-Preemptive Priority":
non_preemptive_priority(self.processes_data)
elif algorithm == "Preemptive Priority":
preemptive_priority(self.processes_data)
elif algorithm == "SRTF":
srtf(self.processes_data)

self.output_text.insert([Link], "Scheduling Results:\n")


for p in self.processes_data:
self.output_text.insert([Link], f"{[Link]} - Completion Time: {p.completion_time}\n")

except Exception as e:
[Link]("Error", str(e))

if __name__ == "__main__":
root = [Link]()
app = SchedulingApp(root)
[Link]()

13
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
5. INPUT AND OUTPUT SCREENS

1. Input
A. Add Process:
The interface is for a dynamic process scheduling program GUI, allowing the user to enter the number
of processes, their details, select the scheduling algorithm, and start the scheduling process.

B. Enter the Process Details:


This interface allows the user to input the number of processes, their details, and choose the
scheduling algorithm before starting the scheduling process.
• The user can input the number of processes and their details (process ID, arrival time, burst
time, and priority).
• The user can select from various scheduling algorithms, including First-Come First-Serve
(FCFS).
• Once the input is complete, the user can start the scheduling process, and the results will be
displayed.

14
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
C. Selecting Algorithm:
The interface allows for specifying the number of processes, their details, and selection of scheduling
algorithms.
• The user can enter the number of processes.
• For each process, the user can enter the process name, arrival time, burst time, and priority.
• The user can select from a list of scheduling algorithms, including FCFS, SJF, Round Robin,
Non-Preemptive Priority, Preemptive Priority, and SRTF.
• The user can start the scheduling process.

15
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
[Link]:
A. First Come First Serve:
The shows the results of a dynamic process scheduling simulation using the First Come First Serve
(FCFS) algorithm.

B. Shortest Job First (SJF):


This application uses Shortest Job First (SJF) algorithm to display the scheduling results with
completion time of each process.

16
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
C. Round Robin:
The results show the completion time for each process after scheduling using Round Robin.

D. Non-Preemptive Prioritty:
The results show the completion time for each process after scheduling using Non-Preemptive
Prioritty.

17
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
E. Preemptive Prioritty:
The results show the completion time for each process after scheduling using Preemptive Prioritty.

F. SRTF:
The results show the completion time for each process after scheduling using SRTF.

18
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
CONCLUSION

The Python program implements a dynamic process scheduling application using the Tkinter
library for a graphical user interface (GUI). The application allows users to input multiple
processes, each defined by its name, arrival time, burst time, and priority. Users can choose from
several scheduling algorithms to manage the execution of these processes, including:
1. First-Come, First-Served (FCFS): Processes are executed in the order of their arrival.
2. Shortest Job First (SJF): Processes with the shortest burst time are executed first.
3. Round Robin: Each process is assigned a fixed time slice, allowing for fair sharing of
CPU time among processes.
4. Non-Preemptive Priority: Processes are executed based on priority, with ties broken by
arrival time.
5. Preemptive Priority: Similar to non-preemptive priority, but allows for the interruption
of a currently running process if a higher-priority process arrives.
6. Shortest Remaining Time First (SRTF): A preemptive version of SJF where the process
with the least remaining time is executed next.
Features of the Program:
• User -Friendly Interface: The GUI allows users to easily input process details and select
scheduling algorithms without requiring any command-line interaction.
• Dynamic Input Handling: Users can specify the number of processes and add them
dynamically, ensuring flexibility.
• Error Handling: The application includes error handling to manage invalid inputs,
ensuring robust operation.
• Output Display: The results of the scheduling, including completion times for each
process, are displayed in a text box for easy review.
Purpose of the Program:
The primary purpose of this program is to provide a visual and interactive way for users to
understand and explore different CPU scheduling algorithms. It serves as an educational tool for
students and professionals alike, helping them to visualize how various algorithms manage
process execution and their respective impacts on performance metrics such as completion time,
turnaround time, and waiting time. By experimenting with different algorithms and process
configurations, users can gain insights into the advantages and disadvantages of each scheduling
strategy in a controlled environment.

19
KSRM COLLEGE OF ENGINEERING
II YEAR CSE
REFERENCES
1. CPU Scheduling in Operating Systems - GeeksforGeeks
JobScheduling
An overview of different scheduling algorithms such as FCFS, SJN, Priority Scheduling,
and Round Robin.
2. Real Python
A comprehensive online resource with tutorials, articles, and courses on Python
programming.
realpython
3. GitHub
I used the GitHub repository JobScheduling_c as a reference to convert C code to Python for
my job scheduling project.

20
KSRM COLLEGE OF ENGINEERING
II YEAR CSE

Common questions

Powered by AI

The project extends the understanding of process scheduling principles by integrating multiple scheduling techniques into a dynamic framework and evaluating their performance under various conditions. It emphasizes the complexities and adaptability of scheduling in real-time, demonstrating the impact of combining traditional methods like Round Robin and Shortest Job First with dynamic adjustments based on real-time metrics such as priority and resource usage. This synthesis leads to a more comprehensive view of how processes can be managed efficiently in modern computing environments, highlighting the need for adaptability in scheduling decisions. The project's Python implementation also allows for further exploration and experimentation, providing an educational tool for delving deeper into operating systems and concurrent programming .

Using Python for implementing a dynamic process scheduling algorithm offers several benefits such as ease of experimentation and extensibility. Python's readability and concise syntax make it ideal for rapid development and prototyping of scheduling algorithms, allowing developers to focus more on logic and less on language intricacies. Additionally, Python's extensive libraries, such as tkinter for GUI and heapq for priority queues, provide essential tools that enhance the functionality and user interaction of the scheduler. Python's flexibility also aids in educational contexts, where students can easily modify and extend the scheduler to explore different scheduling strategies and metrics, fostering a deeper understanding of operating systems and concurrency .

The project serves as a practical educational tool by providing hands-on experience in implementing and experimenting with various scheduling algorithms in Python. It offers a simulation environment where students can observe the behavior of different scheduling strategies under a variety of load conditions, enhancing their understanding of complex concepts in operating systems. The dynamic scheduling algorithm implementation itself is extensible, allowing for easy modification and experimentation, which fosters an interactive learning experience. Additionally, the use of Python as a programming language makes the project accessible, facilitating exploration of principles like concurrency and real-time process management, crucial for both academic and professional development in computer science .

The dynamic scheduling project provides insights into the limitations of traditional static scheduling algorithms by highlighting their inability to adapt to changing process demands in real-time. Static methods, such as First-Come, First-Served (FCFS) and Shortest Job First (SJF), operate with fixed priorities and time slices, which can lead to issues like long waiting times for high-priority tasks and starvation of longer processes. The project's comparative analysis shows that while static algorithms are straightforward to implement, they lack the responsiveness of dynamic approaches, resulting in suboptimal performance when faced with varying workloads and priorities. This underscores the need for dynamic mechanisms that adjust scheduling to current system conditions, thus maximizing efficiency and minimizing latency .

Real-time metrics are significant in the dynamic process scheduling algorithm as they provide the necessary data to make informed scheduling decisions that optimize system performance. Metrics such as process priority, execution time, and resource consumption enable the scheduler to adjust decisions dynamically, ensuring that high-priority tasks are executed promptly while balancing system load. This adaptability to real-time conditions minimizes wait times and maximizes CPU utilization, addressing the shortfalls of static scheduling approaches which often fail to adapt to fluctuating demands. Through the use of these metrics, the algorithm can maintain efficient throughput and responsiveness, crucial for maintaining performance in complex computing environments .

The key performance indicators used in this project to measure the effectiveness of scheduling techniques include throughput, turnaround time, and average waiting time. These indicators provide insight into how well the system performs under various scheduling strategies. Throughput measures the number of processes completed in a given time frame; turnaround time indicates the total time taken for a process to complete; and average waiting time reflects the delay experienced by processes before execution. By assessing these metrics, the project evaluates how different algorithms, including dynamic scheduling methods, fulfill the goals of optimizing resource utilization and process handling .

Python's heapq module enhances the functionality of priority scheduling algorithms by providing an efficient priority queue implementation that allows easy retrieval of the highest-priority element. In the context of scheduling, heapq ensures that the process with the highest priority or the shortest remaining time is always at the front of the queue, facilitating optimal scheduling decisions. This capability is critical for preemptive priority and Shortest Remaining Time First (SRTF) algorithms, as it allows them to dynamically adjust the order of execution based on real-time process characteristics. This efficiency helps maintain a low computational overhead when managing priorities, improving the throughput and responsiveness of the scheduling system .

In the project, tkinter plays the role of providing a graphical user interface (GUI) that allows users to interact with the dynamic process scheduling program easily. It contributes by offering a structured way to input processes' details and select scheduling algorithms using interactive widgets like buttons, labels, and text fields. Tkinter's GUI capabilities facilitate user interaction by presenting input fields for process attributes and offering options to select among algorithms like FCFS and SJF. The GUI enhances user experience by ensuring the inputs are clear and the scheduling results are displayed effectively, making the scheduler accessible and user-friendly .

Exception handling is crucial in the implementation of scheduling algorithms in Python to manage potential errors gracefully, ensuring the robustness of the application. In scenarios where user inputs might be invalid or unforeseen errors occur during scheduling operations, exception handling prevents the application from crashing. Instead, it provides feedback and error messages to the user, enhancing the reliability and user experience of the application. For instance, if all fields for a process are not filled, the program uses exception handling to prompt the user to correct their input rather than terminating abruptly .

The dynamic process scheduling algorithm in Python improves system performance by adapting to real-time metrics such as process priority and resource consumption. Unlike static methods, which are fixed and less responsive to changing conditions, the dynamic approach adjusts scheduling decisions on the fly. This results in high-priority tasks receiving timely execution and an overall improvement in CPU utilization. By evaluating various scheduling strategies under different workloads, the project demonstrated that a dynamic approach reduces wait times and enhances throughput compared to static methods, which may lead to inefficiencies like increased wait times for urgent tasks or starvation of longer processes .

You might also like