Professional Documents
Culture Documents
Submitted by
CERTIFICATE
Date:
Signature of the faculty in-charge
Signature of Chairman
Department of Computer Science & Engineering
DECLARATION
We hereby declare that the work presented in this mini project entitled –
“Priority Scheduling” has been carried out by us and it has not been
submitted for the award of any degree, diploma or the mini project of any
other college or university.
Contents Page no
1.Introduction 08
2.Problem Statement 09
3.S/W & H/W Requirements 10
4.Design 11
4.1 Algorithm/Methodology 11
4.2 Description of Modules/Program 11
5.OutPut Screenshots 21
6.Conclusion 24
7.References 25
ABSTRACT
Scheduling is one of the most important activities of the process manager which
take decision to choose which of the process in the ready queue will be assigned
to the CPU. There are different types of scheduling algorithms available for
taking decision. One of them is Priority Scheduling Algorithm, which is based on
the priority assigned to each process. In priority scheduling the Processes are
executed on the basis of priority, the process having highest priority is executed
first. In case of similar priority FCFS is used. In this paper, the priority scheduling
algorithm is used in such a way that, in case of similar priority SJF algorithm is
used instead of FCFS and average waiting time and average turnaround time is
calculated. The comparative analysis is performed on the SJF based priority
scheduling and FCFS based priority scheduling to compare the average waiting
time and average turnaround time Index Terms-CPU, FCFS, SJF, priority.
CONTENTS
SL.NO Page No
Cover Page………………………………………………………….... i
Certificate…………………………………………………………….. ii
Declaration……………………………………………………………. iii
Acknowledgement…………………………………………………….. iv
Contents………………………………………………………………... v
Abstract…………………………………………………………………vi
Chapters:
1. Introduction…………………………………………………... 8
2. Problem Statement…………………………………………… 9
3. S/W & H/W Requirements…………………………………... 10
4. Design………………………………………………………... 11
4.1 Algorithm/Methodology
4.2 Description of Modules/Program
5. Output Screenshots…………………………………………… 21
6. Conclusion……………………………………………………. 24
7. References……………………………………………………. 25
Chapter:1
INTRODUCTION
Priority Scheduling is a method of scheduling processes that is
based on priority. In this algorithm, the scheduler selects the
tasks to work as per the priority.
The processes with higher priority should be carried out first,
whereas jobs with equal priorities are carried out on a round-
robin or FCFS basis. Priority depends upon memory
requirements, time requirements, etc.
Chapter:2
PROBLEM STATEMENT
One of the most important problems in operating systems
designing is CPU Scheduling and challenge in this field is to
build a program to achieve proper scheduling. In case of
priority scheduling algorithm when similar priority jobs arrive
then FCFS is used and as a consequence the average waiting
and turnaround time becomes relatively higher. The process
that arrives first is executed first, no matter how long it takes
the CPU. So in this case if long burst time processes are execute
earlier, then other process will remain in waiting queue for a
long time. This type of arrangement of processes in the ready
queue results in the higher average waiting and turnaround
time.
Chapter:3
REQUIREMENTS
Environment Used: Java
Hardware Used
System: intel i3 or later
Storage:10 GB or more
Ram:8GB or More
Software Requirements
• Net Beans IDE
• Virtual Box
Chapter:4
DESIGN
4.1 ALGORITHM/METHODOLOGY
for (int i = 0; i < numberOfProcess - 1; i++)
temp ← priority[j];
priority[j + 1] ← temp;
temp ← burstTime[j];
burstTime[j + 1] ← temp;
temp2 ← process[j];
process[j + 1] ←temp2;
WindowEvent:
A low- level event that indicates that a window has changed its status. This low-level event is
generated by a window object when it is opened, closed, activated, deactivated, iconified, or
when focus is transferred into or out of the window.
Swing:
Swing is a lightweight java (GUI)that is used to create various applications. Swing has
platform-independent components. It enables the user to create buttons and scroll bars. Swing
includes packages for creating desktop applications in java.
File:
In java, with the help of file class, we can work with files. The files class is inside the java.io
package .the files class can used by creating an object of the class and then specifying the name
of the file.
Random:
Random class is part of java. util package. An instance of java Random class is used to generate
random numbers. This class provides several methods to generate random numbers of type
integer, double, long, float etc.
PROGRAM CODE:
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.*;
import java.io.File;
import java.util.Random;
public SchedulingGUI() {
initComponents();
jLabel7.setIcon(new javax.swing.ImageIcon("src\\main\\java\\dark-abstract-tech-
background_53876-90630.jpg"));
setResizable(false);
jComboBox1.setModel(new DefaultComboBoxModel<>(algorithms));
addWindowListener(new WindowListener());
setLocationRelativeTo(null);
thread.start();
@SuppressWarnings("unchecked")
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setLayout(new AbsoluteLayout());
jLabel2.setText("# of Process:");
jLabel3.setText("Algorithm:");
jButton1.setText("Browse");
jButton1.addActionListener(new java.awt.event.ActionListener() {
jButton1ActionPerformed(evt);
});
jPanel1.add(jButton1, new AbsoluteConstraints(490, 240, 140, 30));
jButton2.setText("Team Info");
jButton2.addActionListener(new java.awt.event.ActionListener() {
jButton2ActionPerformed(evt);
});
jLabel4.setText("CPU Scheduling");
jLabel1.setText("Simulation");
jLabel5.setText("Source:");
jTextField1.setText("0");
jPanel1.add(jTextField1, new AbsoluteConstraints(490, 290, 140, 30));
nextStep2.setText("Start");
nextStep2.addActionListener(new java.awt.event.ActionListener() {
nextStep2ActionPerformed(evt);
});
jLabel7.setIcon(new javax.swing.ImageIcon("D:\\Programming
Files\\CPUSchedulingSimulation\\src\\main\\java\\dark-abstract-tech-background_53876-
90630.jpg")); // NOI18N
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE))
);
jPanel1.getAccessibleContext().setAccessibleName("");
pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
fileChooser.showOpenDialog(null);
sourcePath = file.getAbsolutePath();
}//GEN-LAST:event_jButton1ActionPerformed
}//GEN-LAST:event_jButton2ActionPerformed
private void nextStep2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_nextStep2ActionPerformed
if(sourcePath.isEmpty())
else {
selectedAlgo = jComboBox1.getSelectedItem().toString();
NUM_OF_PROCESSES = Integer.parseInt(jTextField1.getText());
jobs[(i-1)] = newJob;
sim.start();
this.dispose();
}//GEN-LAST:event_nextStep2ActionPerformed
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
java.util.logging.Logger.getLogger(SchedulingGUI.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
java.util.logging.Logger.getLogger(SchedulingGUI.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
java.util.logging.Logger.getLogger(SchedulingGUI.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
java.util.logging.Logger.getLogger(SchedulingGUI.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
java.awt.EventQueue.invokeLater(new Runnable() {
new SchedulingGUI().setVisible(true);
});
}
Chapter:5
OUTPUT SNAPSHOTS
Fig-1
Fig-2
Fig-3
Fig-4
Fig-5
Chapter:6
CONCLUSION
There are many scheduling algorithms having their own benefits and drawbacks. Scheduling
can also be done on the basis of priority. Each process assigned a priority and the process
which has highest priority will execute first. In case of similar priority generally FCFS is used
to select the next process. If SJF based priority scheduling algorithm is used when two or more
process having similar priority, instead of FCFS, then the average waiting time and average
turnaround time is reduced. We proposed SJF based priority scheduling algorithm in which,
the process that having lowest burst time will execute first. The existing FCFS based priority
scheduling algorithm and proposed SJF based priority scheduling algorithm is analyzed and
the result shows that the average waiting time and average turnaround time is reduced.
.
Chapter:7
REFERENCES
[1]F. Kanehiro, H. Hirukawa, and S. Kajita. OpenHRP: Open Architecture Humanoid
Robotics Platform. The International Journal of Robotics Research, 23(2):155–165, 2004.
[3] H.S. Ahn, Y. M. Beak, I.-K. Sa, W. S. Kang, J. H. Na, and J. Y. Choi. Design of
Reconfigurable Heterogeneous Modular Architecture for Service Robots. In IEEE/RSJ 2008
International Conference on Intelligent Robots and Systems, pages 1313–1318, Sept. 2008.
[5] K. Lin, S. Natarajan, and J. W. S. Liu. Imprecise Results: Utilizing Partial Computations in
Real-Time Systems.
[6] Proceedings of the 8th IEEE Real-Time Systems Symposium, pages 210–217, Dec. 1987.
[7] Abraham Silberschatz, Peter Baer Galvin, Greg Gagne, “Operating System Concepts”, 7th
Edition, John Wiley & Sons, ISBN: 978-81-265-2051-0, 2005