0% found this document useful (0 votes)
3 views2 pages

OS Lab 4

The document outlines an experiment focused on implementing the Shortest Job First (SJF) non-preemptive CPU scheduling algorithm in C programming. It details the steps to calculate average waiting time and turnaround time, including sorting processes by burst time and computing times accordingly. Additionally, it includes sections for student information, observations, conclusions, and questions related to CPU scheduling concepts.

Uploaded by

Srajika Gupta
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)
3 views2 pages

OS Lab 4

The document outlines an experiment focused on implementing the Shortest Job First (SJF) non-preemptive CPU scheduling algorithm in C programming. It details the steps to calculate average waiting time and turnaround time, including sorting processes by burst time and computing times accordingly. Additionally, it includes sections for student information, observations, conclusions, and questions related to CPU scheduling concepts.

Uploaded by

Srajika Gupta
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/ 2

Exp 4 - Part A

Aim: Given the list of processes and their CPU burst times, display the Gantt chart for SJF
(Nonpreempted). Compute and print the average waiting time and average turnaround time using
SJF (Nonpreempted).
Requirements: C Programming knowledge and understanding of CPU scheduling concept.
Outcome: Understand the CPU scheduling algorithm in an operating system..
Theory:
To calculate the average waiting time in the shortest job first algorithm the sorting of the process
based on their burst time in ascending order then calculate the waiting time of each process as the
sum of the bursting times of all the process previous or before to that process.

ALGORITHM:

Step 1: Start the process


Step 2: Accept the number of processes in the ready Queue
Step 3: For each process in the ready Q, assign the process id and accept the CPU burst time
Step 4: Start the Ready Q according the shortest Burst time by sorting according to lowest to
highest burst time.
Step 5: Set the waiting time of the first process as=0 and its turnaround time as its burst time.
Step 6: Sort the processes names based on their Burt time
Step 7 :For each process in the ready queue, calculate
a). Waiting time(n)= waiting time (n-1) + Burst time (n-1)
b). Turnaround time (n)= waiting time(n)+Burst time(n)
Step 8: Calculate
(d) Average waiting time = Total waiting Time / Number of process
(e) Average Turnaround time = Total Turnaround Time / Number of process
Step 9: Stop the process.
Instructions:
1. Take input of processes and their CPU burst times and then draw Gantt chart based on the
concept of SJF, CPU scheduling.
2. Calculate Average Waiting Time and Average Turnaround Time.

Exp.4 - Part B
Name of Student: Roll No.:
Programme:
Output:
Observation & Learning:
Conclusion:
Questions:
1. Distinguish between Preemptive and Nonpreemptive CPU scheduling?
2. What is turnaround time?

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