0% found this document useful (0 votes)
17 views4 pages

Handout B5

Uploaded by

tushar
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)
17 views4 pages

Handout B5

Uploaded by

tushar
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
You are on page 1/ 4

Assignment No-B-05

MES Wadia College of Engineering Pune-01


Department of Computer Engineering
Name of Student: Class:
Semester/Year: Roll No:
Date of Performance: Date of Submission:
Examined By: Experiment No: Part B-05

PART: B ASSIGNMENT NO: 5


AIM: Write a program to simulate CPU Scheduling Algorithms: FCFS, SJF (Preemptive),
Priority (Non-Preemptive) and Round Robin (Preemptive).

OBJECTIVES:
• To study the basics of scheduling algorithms and learn concept of Preemptive and
Non-Preemptive scheduling.
• To understand aggregation functions.

PRE-REQUISITES:
1. Java basics.
2. Basics of Operating System.

APPARATUS:

THEORY:
A. First Come First Serve
• Jobs are executed on first come, first serve basis.
• It is a non-preemptive, pre-emptive scheduling algorithm.
• Easy to understand and implement.
• Its implementation is based on FIFO queue.

Department of Computer Engineering Page 1


Assignment No-B-05

Wait time of each process is as follows –


Process Wait Time : Service Time -
Arrival Time
P0 0-0=0

P1 5-1=4

P2 8-2=6

P3 16 - 3 = 13

Average Wait Time: (0+4+6+13) / 4 = 5.75

B. Shortest Job First (Preemptive)


• In this scheduling algorithm, the process with the smallest amount of time remaining until
completion is selected to execute. Since the currently executing process is the one with the
shortest amount of time remaining by definition, and since that time should only reduce as
execution progresses, processes will always run until they complete or a new process is
added that requires a smaller amount of time.

PROCESS DURATION ORDER ARRIVAL TIME

P1 9 1 0

P2 2 2 2

Department of Computer Engineering Page 2


Assignment No-B-05

P1 waiting time: 4-2 = 2


P2 waiting time: 0
The average waiting time (AWT): (0 + 2) / 2 = 1

C. Priority (Non-Preemptive)
• 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 the highest priority is to be executed first and so on.
Processes with the 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.

Process Burst Time Priority


P1 10 2
P2 5 0
P3 8 1

P1 P2 P3
0 10 18 23

D. Round Robin (Preemptive)


• 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.

Department of Computer Engineering Page 3


Assignment No-B-05

Wait time of each process is as follows –


Process Wait Time : Service Time - Arrival Time

P0 (0 - 0) + (12 - 3) = 9

P1 (3 - 1) = 2

P2 (6 - 2) + (14 - 9) + (20 - 17) = 12

P3 (9 - 3) + (17 - 12) = 11

Average Wait Time: (9+2+12+11) / 4 = 8.5

CONCLUSION:

QUESTIONS:

1. What is scheduling?

2. Explain Preemptive and Non- Preemptive scheduling.

3. Define CPU Utilization, Throughput, Response time, Turnaround time, Waiting


Time, Fairness.

Department of Computer Engineering Page 4

You might also like