0% found this document useful (0 votes)
5 views6 pages

11226experiment No 5-Scheduling

The document outlines an experiment focused on process management and scheduling algorithms, requiring students to write programs for non-preemptive and preemptive scheduling. It covers various CPU scheduling algorithms including First-Come First-Served, Shortest Job First, Priority Scheduling, and Round-Robin, detailing their implementation and average waiting times. Students are expected to submit their code, input/output parameters, observations, conclusions, and answers to questions based on their practical experience.

Uploaded by

wogef67818
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)
5 views6 pages

11226experiment No 5-Scheduling

The document outlines an experiment focused on process management and scheduling algorithms, requiring students to write programs for non-preemptive and preemptive scheduling. It covers various CPU scheduling algorithms including First-Come First-Served, Shortest Job First, Priority Scheduling, and Round-Robin, detailing their implementation and average waiting times. Students are expected to submit their code, input/output parameters, observations, conclusions, and answers to questions based on their practical experience.

Uploaded by

wogef67818
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
You are on page 1/ 6

Experiment No-05

PART A
(PART A : TO BE REFFERED BY STUDENTS)

A.1 Aim:
Process Management: Scheduling
a. Write a program to demonstrate the concept of non-preemptive scheduling algorithms.
b. Write a program to demonstrate the concept of preemptive scheduling algorithms

A-2 Prerequisite
Knowledge about C/C++ and Java Programming.
A.3 OutCome
After successful completion students will able to Interpret and examine different process
scheduling algorithms.

A.4 Theory:

CPU scheduling deals with the problem of deciding which of the processes in the ready queue is
to be allocated the CPU. There are many different CPU scheduling algorithms.

1. FIRST-COME , FIRST- SERVED SCHEDULING:


By far the simplest CPU-scheduling algorithms is the first-come , first-served(FCFS)
scheduling algorithm. With this scheme, the process that request the CPU first is allocated the
CPU first. The implementation of the FCFS policy is easily managed with FIFO queue. When a
process enters the ready queue , its PCB is linked onto the tail of the queue. When the CPU is
free, it is allocated to the process at the head of the queue. The running process is then removed
from the queue. The code for FCFS scheduling is simple to write and understand. The average
waiting time under the FCFS policy, however, is often quite long. Consider the following set of
processes that arrive at time 0, with length of the CPU burst given in milliseconds:
Waiting time for P1 = 0 ; p2 = 24; P3 = 27
Average waiting time: (0 + 24 + 27)/3 = 17

2. SHORTEST-JOB-FIRST SCHEDULING :
A different approach to CPU scheduling is the shortest-job-first (SJF) scheduling
algorithm. This algorithm associates with each process the length of the process’s next
CPU burst. When the CPU is available, it is assigned to the process that has the smallest
next CPU burst. If the next CPU bursts of two processes are the same, FCFS scheduling
is used to break the tie. As an example of SJF scheduling, consider the following set of
processes, with the length of the CPU burst given in milliseconds:

The waiting time is 3 milliseconds for process P1, 16 milliseconds for process P2, 9 milliseconds
for process P3, and 0 milliseconds for process P4. Thus, the average waiting time is (3 + 16 + 9 +
0)/4 = 7 milliseconds. By comparison, if we were using the FCFS scheduling scheme, the
average waiting time would be 10.25 milliseconds.
The SJF scheduling algorithm is provably optimal, in that it gives the minimum average waiting
time for a given set of processes. Moving a short process before a long one decreases the waiting
time of the short process more than it increases the waiting time of the long process.
Consequently, the average waiting time decreases.

3. PRIORITY SCHEDULING:
The SJF algorithm is a special case of the general priority scheduling algorithm. A
priority is associated with each process, and the CPU is allocated to the process with the
highest priority. Equal-priority processes are scheduled in FCFS order. An SJF algorithm
is simply a priority algorithm where the priority (p) is the inverse of the (predicted) next
CPU burst. The larger the CPU burst, the lower the priority and vice versa. 16 Note that
we discuss scheduling in terms of high priority and low priority. Some systems use low
numbers to represent low priority; others use low numbers for high priority. This
difference can lead to confusion. In this text, we assume that low numbers represent high
priority As an example, consider the following set of processes, assumed to have arrived
at time 0, in the order P1, l2, ..., P5. with the length of the CPU burst given in
milliseconds:

The average waiting time is 8.2 milliseconds.Priority scheduling can be either preemptive or
non-preemptive. When a process arrives at the ready queue, its priority is compared with the
priority of the currently running process. A preemptive priority scheduling algorithm will
preempt the CPU if the priority of the newly arrived process is higher than the priority of the
currently running process. A non-preemptive priority scheduling algorithm will simply put the
new process at the head of the ready queue.

4. ROUND-ROBIN SCHEDULING:
The round-robin (RR) scheduling algorithm is designed especially for timesharing
systems. It is similar to FCFS scheduling, but preemption is added to switch between
processes. A small unit of time, called a time quantum or time slice, is defined. A time
quantum is generally from 10 to 100 milliseconds. The ready queue is treated as a
circular queue. The CPU scheduler goes around the ready queue, allocating the CPU to
each process for a time interval of up to 1 time quantum. To implement RR scheduling,
we keep the ready queue as a FIFO queue of processes. New processes are added to the
tail of the ready queue. The CPU scheduler picks the first process from the ready queue,
sets a timer to interrupt after 1 time quantum, and dispatches the process.
The average waiting time under the RR policy is often long. Consider the following set of
processes that arrive at time 0, with the length of the CPU burst given in milliseconds:

If we use a time quantum of 4 milliseconds, then process Pi gets the first 4 milliseconds.
Since it requires another 20 milliseconds, it is preempted after the first time quantum, and
the CPU is given to the next process in the queue, process P2. Since process P2 does not
need 4 milliseconds, it quits before its time quantum expires. The CPU is then given to
the next process, process P3. Once each process has received 1 time quantum, the CPU is
returned to process P1 for an additional time quantum. The resulting RR schedule is:
The average waiting time is 17/3 = 5.66 milliseconds In the RR scheduling algorithm, no
process is allocated the CPU for more than 1 time quantum in a row . If a process’s CPU
burst exceeds 1 time quantum, that process is preempted and is put back in the ready
queue. The RR scheduling algorithm is thus preemptive.

PART B
(PART B : TO BE COMPLETED BY STUDENTS)

(Students must submit the soft copy as per following segments within two hours of the
practical. The soft copy must be uploaded on the Blackboard or emailed to the concerned lab
in charge faculties at the end of the practical in case the there is no Black board access
available)

Roll. No. Name:


Class Batch:
Date of Experiment: Date of Submission:
Grade:

B.1 Software Code written by student:


(Paste your Search material completed during the 2 hours of practical in the lab here)

Program Code for FCFS/SJF and RR/Priority in C/C++ or JAVA.

B.2 Input and Output:


(Command parameters/options as per syntax and output)
Input: The number of process with their Arrival Time and Burst Time.
Output: The Gantt chart or Table to display waiting time, completion time, average waiting
time and average throughput of all processes.

B.3 Observations and learning:


(Students are expected to comment on the output obtained with clear observations and
learning for each task/ sub part assigned)

B.4 Conclusion:
(Students must write the conclusion as per the attainment of individual outcome listed above
and learning/observation noted in section B.3)
B.5 Question of Curiosity
(To be answered by student based on the practical performed and learning/observations)
Q1. Who schedule the process for CPU allocation and execution?

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy