SlideShare a Scribd company logo
EE-332 Operating System
Department of Electrical Engineering | The University of Faisalabad
Zeeshan Iqbal BEE-FA18-022
(Computer)
Experiment # 8
Title:
Introduction to shortest job first scheduling
Objective:
To write a program to implement CPU scheduling algorithm for shortest job first
scheduling.
First-Come First-Serve Scheduling (FCFS)
• First come first serve. With FCFS, the process that requests the CPU first is allocated the
CPU first. The implementation of FCFS policy is easily managed with a FIFO queue such
as customers waiting in line at the bank or the post office.
• 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 the length of the CPU-burst
time given in milliseconds:
Process Burst Time
P1 24
P2 3
P3 3
• In the first Gantt chart below, processes arrive in the order P1, P2, P3. The waiting time
is 0ms for P1, 24 ms for P2, and 27 ms for P3. Thus, the average waiting time for the
three processes is ( 0 + 24 + 27 ) / 3 = 17.0 ms.
• In the second Gantt chart below, processes arrive in the order P2, P3, P1. The same
three processes have an average wait time of ( 0 + 3 + 6 ) / 3 = 3.0 ms. The average
waiting time under a FCFS policy is generally not minimal, and may vary substantially if
the process CPU-burst times vary greatly.
EE-332 Operating System
Department of Electrical Engineering | The University of Faisalabad
Zeeshan Iqbal BEE-FA18-022
(Computer)
ALGORITHM:
• Start the program. Get the number of processes and their burst time.
• Initialize the waiting time for process 1 as 0.
• The processes are stored according to their burst time.
• The waiting time for the processes are calculated a follows:
for(i=2;i<=n;i++).wt.p[i]=p[i=1]+bt.p[i-1].
• The waiting time of all the processes summed and then the average time is calculate
• The waiting time of each processes and average time are displayed.
• Stop the program
PROGRAM (SHORTEST JOB FIRST SCHEDULING):
#include<iostream>
#include<stdio.h>
struct process
{
int pid;
int bt;
int wt,tt;
}
p[10];
int main()
{
int i,n,totwt,tottt,avg1,avg2;
printf("enter the no of process: "); scanf("%d",&n);
for(i=1;i<=n;i++)
{
p[i].pid=i;
printf("enter the burst time(i): "); scanf("%d",&p[i].bt);
}
p[1].wt=0;
p[1].tt=p[1].bt+p[1].wt;
i=2;
while(i<=n)
{
p[i].wt=p[i-1].bt+p[i-1].wt; p[i].tt=p[i].bt+p[i].wt;
EE-332 Operating System
Department of Electrical Engineering | The University of Faisalabad
Zeeshan Iqbal BEE-FA18-022
(Computer)
i ++;
}
i=1;
totwt=tottt=0;
printf("n processid t btt wtt ttn");
while(i<=n){
printf("nt%d t%d t%d t%d",p[i].pid,p[i].bt,p[i].wt,p[i].tt);
totwt=p[i].wt+totwt;
tottt=p[i].tt+tottt;
i++;
}
avg1=totwt/n; avg2=tottt/n;
printf("navg1=%d t avg2=%dt",avg1,avg2);
getc;
return 0;
}
Output:

More Related Content

What's hot

Fetch decode-execute presentation
Fetch decode-execute presentationFetch decode-execute presentation
Fetch decode-execute presentationchantellemallia
 
Instruction cycle presentation
Instruction   cycle presentationInstruction   cycle presentation
Instruction cycle presentation
Moniba Irfan
 
Instruction cycle with interrupts
Instruction cycle with interruptsInstruction cycle with interrupts
Instruction cycle with interrupts
Shubham Jain
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer Architecture
Subhasis Dash
 
OS concepts 2 handling of interrupts
OS concepts 2 handling of interruptsOS concepts 2 handling of interrupts
OS concepts 2 handling of interrupts
Vaibhav Khanna
 
Introduction to Operating Systems - Part1
Introduction to Operating Systems - Part1Introduction to Operating Systems - Part1
Introduction to Operating Systems - Part1
Amir Payberah
 
[CMP N426] Computer Systems Security
[CMP N426] Computer Systems Security[CMP N426] Computer Systems Security
[CMP N426] Computer Systems SecurityAhmed Hesham
 
Introduction to Operating Systems - Part3
Introduction to Operating Systems - Part3Introduction to Operating Systems - Part3
Introduction to Operating Systems - Part3
Amir Payberah
 
IO Systems
IO SystemsIO Systems
IO Systems
Amir Payberah
 
Scheduling
SchedulingScheduling
Scheduling
Munazza-Mah-Jabeen
 
Co m1-1
Co m1-1Co m1-1
Operating system
Operating systemOperating system
Operating system
Mark Muhama
 

What's hot (14)

Fetch decode-execute presentation
Fetch decode-execute presentationFetch decode-execute presentation
Fetch decode-execute presentation
 
Cpu & its execution of instruction
Cpu & its execution of instructionCpu & its execution of instruction
Cpu & its execution of instruction
 
Instruction cycle presentation
Instruction   cycle presentationInstruction   cycle presentation
Instruction cycle presentation
 
Instruction cycle with interrupts
Instruction cycle with interruptsInstruction cycle with interrupts
Instruction cycle with interrupts
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer Architecture
 
OS concepts 2 handling of interrupts
OS concepts 2 handling of interruptsOS concepts 2 handling of interrupts
OS concepts 2 handling of interrupts
 
Introduction to Operating Systems - Part1
Introduction to Operating Systems - Part1Introduction to Operating Systems - Part1
Introduction to Operating Systems - Part1
 
[CMP N426] Computer Systems Security
[CMP N426] Computer Systems Security[CMP N426] Computer Systems Security
[CMP N426] Computer Systems Security
 
Introduction to Operating Systems - Part3
Introduction to Operating Systems - Part3Introduction to Operating Systems - Part3
Introduction to Operating Systems - Part3
 
IO Systems
IO SystemsIO Systems
IO Systems
 
Scheduling
SchedulingScheduling
Scheduling
 
Homework solutionsch9
Homework solutionsch9Homework solutionsch9
Homework solutionsch9
 
Co m1-1
Co m1-1Co m1-1
Co m1-1
 
Operating system
Operating systemOperating system
Operating system
 

Similar to Introduction to shortest job first scheduling

CPU Scheduling Part-II.pdf
CPU Scheduling Part-II.pdfCPU Scheduling Part-II.pdf
CPU Scheduling Part-II.pdf
Harika Pudugosula
 
Operating Systems Third Unit - Fourth Semester - Engineering
Operating Systems Third Unit  - Fourth Semester - EngineeringOperating Systems Third Unit  - Fourth Semester - Engineering
Operating Systems Third Unit - Fourth Semester - Engineering
Yogesh Santhan
 
Priority Scheduling.pptx
Priority Scheduling.pptxPriority Scheduling.pptx
Priority Scheduling.pptx
SarupyaDatta1
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
Paurav Shah
 
Process Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdfProcess Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdf
Rakibul Rakib
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)
Harshit Jain
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
Mukesh Chinta
 
Preemptive process example.pptx
Preemptive process example.pptxPreemptive process example.pptx
Preemptive process example.pptx
jamilaltiti1
 
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round RobinComparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Universitas Pembangunan Panca Budi
 
UNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docxUNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docx
karthikaparthasarath
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
mohsinalilarik1
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
KeyreSebre
 
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationUnit iios process scheduling and synchronization
Unit iios process scheduling and synchronization
donny101
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
Shipra Swati
 
CPU SCHEDULING IN OPERATING SYSTEMS IN DETAILED
CPU SCHEDULING IN OPERATING SYSTEMS IN DETAILEDCPU SCHEDULING IN OPERATING SYSTEMS IN DETAILED
CPU SCHEDULING IN OPERATING SYSTEMS IN DETAILED
VADAPALLYPRAVEENKUMA1
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
piku das
 
Process management in os
Process management in osProcess management in os
Process management in os
Miong Lazaro
 

Similar to Introduction to shortest job first scheduling (20)

CPU Scheduling Part-II.pdf
CPU Scheduling Part-II.pdfCPU Scheduling Part-II.pdf
CPU Scheduling Part-II.pdf
 
Operating Systems Third Unit - Fourth Semester - Engineering
Operating Systems Third Unit  - Fourth Semester - EngineeringOperating Systems Third Unit  - Fourth Semester - Engineering
Operating Systems Third Unit - Fourth Semester - Engineering
 
Priority Scheduling.pptx
Priority Scheduling.pptxPriority Scheduling.pptx
Priority Scheduling.pptx
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Process Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdfProcess Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdf
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
 
Preemptive process example.pptx
Preemptive process example.pptxPreemptive process example.pptx
Preemptive process example.pptx
 
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round RobinComparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
 
Unit 2 notes
Unit 2 notesUnit 2 notes
Unit 2 notes
 
UNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docxUNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docx
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
 
Os module 2 ba
Os module 2 baOs module 2 ba
Os module 2 ba
 
Operating System Sheduling
Operating System ShedulingOperating System Sheduling
Operating System Sheduling
 
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationUnit iios process scheduling and synchronization
Unit iios process scheduling and synchronization
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
 
CPU SCHEDULING IN OPERATING SYSTEMS IN DETAILED
CPU SCHEDULING IN OPERATING SYSTEMS IN DETAILEDCPU SCHEDULING IN OPERATING SYSTEMS IN DETAILED
CPU SCHEDULING IN OPERATING SYSTEMS IN DETAILED
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Process management in os
Process management in osProcess management in os
Process management in os
 

More from Zeeshan Iqbal

Bankers Algorithm in Operating System
Bankers Algorithm in Operating SystemBankers Algorithm in Operating System
Bankers Algorithm in Operating System
Zeeshan Iqbal
 
Deadlock Prevention in Operating System
Deadlock Prevention in Operating SystemDeadlock Prevention in Operating System
Deadlock Prevention in Operating System
Zeeshan Iqbal
 
Round Robin Algorithm in Operating System
Round Robin Algorithm in Operating SystemRound Robin Algorithm in Operating System
Round Robin Algorithm in Operating System
Zeeshan Iqbal
 
Programming Under Unix and Linux
Programming Under Unix and LinuxProgramming Under Unix and Linux
Programming Under Unix and Linux
Zeeshan Iqbal
 
BASH Shell Scripting – Part III &IV
BASH Shell Scripting – Part III &IVBASH Shell Scripting – Part III &IV
BASH Shell Scripting – Part III &IV
Zeeshan Iqbal
 
BASH Shell Scripting – Part II
BASH Shell Scripting – Part IIBASH Shell Scripting – Part II
BASH Shell Scripting – Part II
Zeeshan Iqbal
 
Introduction to base shell scripting
Introduction to base shell scriptingIntroduction to base shell scripting
Introduction to base shell scripting
Zeeshan Iqbal
 
Working with files and directories in Linux
Working with files and directories in LinuxWorking with files and directories in Linux
Working with files and directories in Linux
Zeeshan Iqbal
 
Introduction to command line interface.
Introduction to command line interface.Introduction to command line interface.
Introduction to command line interface.
Zeeshan Iqbal
 
Introduction of Linux
Introduction of LinuxIntroduction of Linux
Introduction of Linux
Zeeshan Iqbal
 
Pakistan study notes
Pakistan study notesPakistan study notes
Pakistan study notes
Zeeshan Iqbal
 

More from Zeeshan Iqbal (11)

Bankers Algorithm in Operating System
Bankers Algorithm in Operating SystemBankers Algorithm in Operating System
Bankers Algorithm in Operating System
 
Deadlock Prevention in Operating System
Deadlock Prevention in Operating SystemDeadlock Prevention in Operating System
Deadlock Prevention in Operating System
 
Round Robin Algorithm in Operating System
Round Robin Algorithm in Operating SystemRound Robin Algorithm in Operating System
Round Robin Algorithm in Operating System
 
Programming Under Unix and Linux
Programming Under Unix and LinuxProgramming Under Unix and Linux
Programming Under Unix and Linux
 
BASH Shell Scripting – Part III &IV
BASH Shell Scripting – Part III &IVBASH Shell Scripting – Part III &IV
BASH Shell Scripting – Part III &IV
 
BASH Shell Scripting – Part II
BASH Shell Scripting – Part IIBASH Shell Scripting – Part II
BASH Shell Scripting – Part II
 
Introduction to base shell scripting
Introduction to base shell scriptingIntroduction to base shell scripting
Introduction to base shell scripting
 
Working with files and directories in Linux
Working with files and directories in LinuxWorking with files and directories in Linux
Working with files and directories in Linux
 
Introduction to command line interface.
Introduction to command line interface.Introduction to command line interface.
Introduction to command line interface.
 
Introduction of Linux
Introduction of LinuxIntroduction of Linux
Introduction of Linux
 
Pakistan study notes
Pakistan study notesPakistan study notes
Pakistan study notes
 

Recently uploaded

STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 

Recently uploaded (20)

STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 

Introduction to shortest job first scheduling

  • 1. EE-332 Operating System Department of Electrical Engineering | The University of Faisalabad Zeeshan Iqbal BEE-FA18-022 (Computer) Experiment # 8 Title: Introduction to shortest job first scheduling Objective: To write a program to implement CPU scheduling algorithm for shortest job first scheduling. First-Come First-Serve Scheduling (FCFS) • First come first serve. With FCFS, the process that requests the CPU first is allocated the CPU first. The implementation of FCFS policy is easily managed with a FIFO queue such as customers waiting in line at the bank or the post office. • 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 the length of the CPU-burst time given in milliseconds: Process Burst Time P1 24 P2 3 P3 3 • In the first Gantt chart below, processes arrive in the order P1, P2, P3. The waiting time is 0ms for P1, 24 ms for P2, and 27 ms for P3. Thus, the average waiting time for the three processes is ( 0 + 24 + 27 ) / 3 = 17.0 ms. • In the second Gantt chart below, processes arrive in the order P2, P3, P1. The same three processes have an average wait time of ( 0 + 3 + 6 ) / 3 = 3.0 ms. The average waiting time under a FCFS policy is generally not minimal, and may vary substantially if the process CPU-burst times vary greatly.
  • 2. EE-332 Operating System Department of Electrical Engineering | The University of Faisalabad Zeeshan Iqbal BEE-FA18-022 (Computer) ALGORITHM: • Start the program. Get the number of processes and their burst time. • Initialize the waiting time for process 1 as 0. • The processes are stored according to their burst time. • The waiting time for the processes are calculated a follows: for(i=2;i<=n;i++).wt.p[i]=p[i=1]+bt.p[i-1]. • The waiting time of all the processes summed and then the average time is calculate • The waiting time of each processes and average time are displayed. • Stop the program PROGRAM (SHORTEST JOB FIRST SCHEDULING): #include<iostream> #include<stdio.h> struct process { int pid; int bt; int wt,tt; } p[10]; int main() { int i,n,totwt,tottt,avg1,avg2; printf("enter the no of process: "); scanf("%d",&n); for(i=1;i<=n;i++) { p[i].pid=i; printf("enter the burst time(i): "); scanf("%d",&p[i].bt); } p[1].wt=0; p[1].tt=p[1].bt+p[1].wt; i=2; while(i<=n) { p[i].wt=p[i-1].bt+p[i-1].wt; p[i].tt=p[i].bt+p[i].wt;
  • 3. EE-332 Operating System Department of Electrical Engineering | The University of Faisalabad Zeeshan Iqbal BEE-FA18-022 (Computer) i ++; } i=1; totwt=tottt=0; printf("n processid t btt wtt ttn"); while(i<=n){ printf("nt%d t%d t%d t%d",p[i].pid,p[i].bt,p[i].wt,p[i].tt); totwt=p[i].wt+totwt; tottt=p[i].tt+tottt; i++; } avg1=totwt/n; avg2=tottt/n; printf("navg1=%d t avg2=%dt",avg1,avg2); getc; return 0; } Output: