0% found this document useful (0 votes)
56 views

Assignment No. B5

The document discusses four CPU scheduling algorithms: First Come First Serve (FCFS), Shortest Job First (SJF), Priority scheduling, and Round Robin. It provides details on how each algorithm works, examples to calculate waiting time, turnaround time, and more. The learning objective is to simulate and compare the different algorithms. Students will learn how CPU scheduling decides which process to execute next based on the scheduling strategy.

Uploaded by

pagir
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

Assignment No. B5

The document discusses four CPU scheduling algorithms: First Come First Serve (FCFS), Shortest Job First (SJF), Priority scheduling, and Round Robin. It provides details on how each algorithm works, examples to calculate waiting time, turnaround time, and more. The learning objective is to simulate and compare the different algorithms. Students will learn how CPU scheduling decides which process to execute next based on the scheduling strategy.

Uploaded by

pagir
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Shri Chhatrapati Shivaji Maharaj College of Engineering, Nepti SPOSL

Experiment No: B5
Name of the Student: Roll No:

Date of Conduction : Date of Evaluation :

Criteria: Timely / Late Performance Understanding Lab Quiz Neatness Total

(02) (02) (02) (02) (02) (10)

Marks:

Sign of Teacher

Title: Write a Java program (using OOP features) to implement following scheduling algorithms:
FCFS, SJF (Preemptive), Priority (Non-Preemptive) and Round Robin (Preemptive).

Aim: Implement Job scheduling algorithm


1) FCFS
2) Shortest Job first
3) Priority
4) Round Robin

Problem Statement: To write programs to implement FCFS, SJF, and Priority & RR Scheduling
Algorithms.

Prerequisite: 1. Explain Uniprocessor scheduling.


2. Define FCFS, SJF, RR, and Priority.

Learning Objective: - To Simulate and compare different CPU scheduling algorithm.


1. FCFS
2. Shortest Job first
3. Priority
4. Round Robin

Learning Outcome: After completion of this assignment students will be able to:
How CPU scheduling decides the processing of upcoming process request by
Considering different scheduling algorithms.

Theory:
Problem Explanation:
CPU scheduling deals with the problem of deciding which of the processes in the ready queue
Is to be allowed to utilize the CPU. The criteria for selection for a algorithm are,
1. The maximum throughput
2. Least turnaround time.

1
Shri Chhatrapati Shivaji Maharaj College of Engineering, Nepti SPOSL

3. Minimum waiting time.


4. Maximum CPU utilization.
5. Also the variance in response time must be minimum. In Preemptive job, a currently executing
Job can be removed and a new job can take its place, however in Non-Preemptive this is not possible.

1) FIRST COME FIRST SERVE:

This is the simplest CPU scheduling algorithm. The Process that request the CPU first, is the one to
which it is allocated first. The algorithm is implemented using a job queue. When a process
Requests the CPU it is added at the tail of the job queue.
The CPU is allocated to the process at the head of the queue. However the TAT varies, which is not
favorable.

2) SHORTEST JOB FIRST:

This algorithm associates with it the length of the next CPU burst. When the CPU is available, it is
assigned to that job with the smallest CPU burst. This algorithm provides the minimum average waiting
time. The major problem with this knows the CPU burst of a job.

2
Shri Chhatrapati Shivaji Maharaj College of Engineering, Nepti SPOSL

3) PRIORITY BASED SCHEDULING:

● Priority scheduling is a non-preemptive algorithm and one of the most common scheduling
algorithms in batch systems.
● Each process is assigned a priority. Process with highest priority is to be executed first and so
on.
● Processes with same priority are executed on first come first served basis.
● Priority can be decided based on memory requirements, time requirements or any other
resource requirement.

Wait time of each process is as follows −

Process Wait Time : Service Time - Arrival Time

P0 9-0=9

P1 6-1=5

P2 14 - 2 = 12

P3 0-0=0

3
Shri Chhatrapati Shivaji Maharaj College of Engineering, Nepti SPOSL

SHORTEST REMAINING TIME:


● Shortest remaining time (SRT) is the preemptive version of the SJN algorithm.

● The processor is allocated to the job closest to completion but it can be preempted by a newer
ready job with shorter time to completion.
● Impossible to implement in interactive systems where required CPU time is not known.
● It is often used in batch environments where short jobs need to give preference.

4) ROUND ROBIN SCHEDULING:


● Round Robin is the preemptive process scheduling algorithm.

● Each process is provided a fix time to execute, it is called a quantum.


● Once a process is executed for a given time period, it is preempted and other process executes
for a given time period.
● Context switching is used to save states of preempted processes.

Implementation Logic:-

1. Choose how to represent a process & how to keep track of different parameters of all
Processes.
2. Choose with which rules the scheduler will choose the next process.
3. Design an algorithm that applies the above rules. Take into consideration arrival time,
Priority, quantum etc appropriately.
4. Implement the algorithm.

Solve following examples with Gantt Chart & Calculate WT, AWT, TT & ATT:

1) FCFS:-

4
Shri Chhatrapati Shivaji Maharaj College of Engineering, Nepti SPOSL

Solve following examples with Gantt Chart & Calculate WT, AWT, TT & ATT:

2) SJF:-

5
Shri Chhatrapati Shivaji Maharaj College of Engineering, Nepti SPOSL

Solve following examples with Gantt Chart & Calculate WT, AWT, TT & ATT:

3) Priority:-

6
Shri Chhatrapati Shivaji Maharaj College of Engineering, Nepti SPOSL

4) RR:-

Draw Gantt Chart & Calculate the Avg. Turnaround time and Avg. waiting time of the processes on the basis
of round robin scheduling algorithm. Assume Time Quantum is set to 4 units.

7
Shri Chhatrapati Shivaji Maharaj College of Engineering, Nepti SPOSL

Applications:-

8
Shri Chhatrapati Shivaji Maharaj College of Engineering, Nepti SPOSL

FCFS:-
___________________________________________________________________________________
___________________________________________________________________________________
SJF:
___________________________________________________________________________________
___________________________________________________________________________________
PRIORITY:
___________________________________________________________________________________
___________________________________________________________________________________
ROUND ROBIN
___________________________________________________________________________________
___________________________________________________________________________________

Conclusion:-
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________
___________________________________________________________________________________

LAB QUIZ
1. List types of scheduler & scheduling.
-------------------------------------------------------------------------------------------------------------

9
Shri Chhatrapati Shivaji Maharaj College of Engineering, Nepti SPOSL

-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------

2. List and define scheduling criteria.

-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------

3. Define preemption & non-preemption.

-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------

4. State FCFS, SJF, Priority & Round Robin scheduling.

-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------

5. Compare FCFS, SJF, RR, Priority?

-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------

10

You might also like