SlideShare a Scribd company logo
1 of 7
Download to read offline
First come first serve scheduling algorithm (FCFS) is the process that request the CPU to
allocate the resources on the first come priority basis.the Implementation of the first come first
serve scheduling algorithm (FCFS) policy is easily managed with fifo(First in First out)
queue.when a process enters into the ready queue ,its address 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 first come first serve
scheduling algorithm (FCFS) is simple to write and Understand.The First come first serve
scheduling algorithm (FCFS) in non preemptive.The first come first serve scheduling algorithm
(FCFS) have a drawback for time sharing systems.
first come first serve scheduling algorithm Program [Non-Preemptive]:
import java.io.*;
class fcfs {
public static void main(String args[]) throws Exception {
int n, AT[], BT[], WT[], TAT[];//Burst Time,Average Time,Wait Time
float AWT = 0;
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
System.out.println(“Enter no of process”);
n = Integer.parseInt(br.readLine());
BT = new int[n];
WT = new int[n];
TAT = new int[n];
AT = new int[n];
System.out.println(“Enter Burst time for each process ******************************”);
for (int i = 0; i < n; i++) {
System.out.println(“Enter BT for process ” + (i + 1));
BT[i] = Integer.parseInt(br.readLine());
}
System.out.println(“***********************************************”);
for (int i = 0; i < n; i++) {
System.out.println(“Enter AT for process” + i);
AT[i] = Integer.parseInt(br.readLine());
}
System.out.println(“***********************************************”);
WT[0] = 0;
for (int i = 1; i < n; i++) {
WT[i] = WT[i – 1] + BT[i – 1];
WT[i] = WT[i] – AT[i];
}
for (int i = 0; i < n; i++) {
TAT[i] = WT[i] + BT[i];
AWT = AWT + WT[i];
}
System.out.println(” PROCESS BT WT TAT “);
for (int i = 0; i < n; i++) {
System.out.println(” ” + i + ” ” + BT[i] + ” ” + WT[i] + ” ” + TAT[i]);
}
AWT = AWT / n;
System.out.println(“***********************************************”);
System.out.println(“Avg waiting time=” + AWT + “
***********************************************”);
}
}
Shortest job first -
A different approach to CPU scheduling is SJF shortest job first scheduling algorithm.This
associates with each process the length of the latter next CPU burst.When the CPU is available it
is assigned to the process that has the smallest next CPU burst.if two processes have same length
next CPU burst,FCFS scheduling is used to break the tie.Note that a more appropriate term
would be the shortest next CPU burst ,because the scheduling is done by examining the length of
the next CPU burst because the scheduling is done by examining the length of the next CPU
burst of a process,rather than its total length.The real difficulty in SJF shortest job first
scheduling algorithm is knowing the length of the next process.SJF shortest job first scheduling
algorithm scheduling algorithm is optimal which gives the minimum average waiting time for a
given set of processes.
Program-
import java.util.*;
class SJF {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n, BT[], WT[], TAT[];
System.out.println("Enter no of process");
n = sc.nextInt();
BT = new int[n + 1];
WT = new int[n + 1];
TAT = new int[n + 1];
float AWT = 0;
System.out.println("Enter Burst time for each process");
for (int i = 0; i < n; i++) {
System.out.println("Enter BT for process " + (i + 1));
BT[i] = sc.nextInt();
}
for (int i = 0; i < n; i++) {
WT[i] = 0;
TAT[i] = 0;
}
int temp;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - 1; j++) {
if (BT[j] > BT[j + 1]) {
temp = BT[j];
BT[j] = BT[j + 1];
BT[j + 1] = temp;
temp = WT[j];
WT[j] = WT[j + 1];
WT[j + 1] = temp;
}
}
}
for (int i = 0; i < n; i++) {
TAT[i] = BT[i] + WT[i];
WT[i + 1] = TAT[i];
}
TAT[n] = WT[n] + BT[n];
System.out.println(" PROCESS BT WT TAT ");
for (int i = 0; i < n; i++)
System.out.println(" " + i + " " + BT[i] + " " + WT[i] + " " + TAT[i]);
for (int j = 0; j < n; j++)
AWT += WT[j];
AWT = AWT / n;
System.out.println("***********************************************");
System.out.println("Avg waiting time=" + AWT + "
***********************************************");
}
}
Solution
First come first serve scheduling algorithm (FCFS) is the process that request the CPU to
allocate the resources on the first come priority basis.the Implementation of the first come first
serve scheduling algorithm (FCFS) policy is easily managed with fifo(First in First out)
queue.when a process enters into the ready queue ,its address 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 first come first serve
scheduling algorithm (FCFS) is simple to write and Understand.The First come first serve
scheduling algorithm (FCFS) in non preemptive.The first come first serve scheduling algorithm
(FCFS) have a drawback for time sharing systems.
first come first serve scheduling algorithm Program [Non-Preemptive]:
import java.io.*;
class fcfs {
public static void main(String args[]) throws Exception {
int n, AT[], BT[], WT[], TAT[];//Burst Time,Average Time,Wait Time
float AWT = 0;
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
System.out.println(“Enter no of process”);
n = Integer.parseInt(br.readLine());
BT = new int[n];
WT = new int[n];
TAT = new int[n];
AT = new int[n];
System.out.println(“Enter Burst time for each process ******************************”);
for (int i = 0; i < n; i++) {
System.out.println(“Enter BT for process ” + (i + 1));
BT[i] = Integer.parseInt(br.readLine());
}
System.out.println(“***********************************************”);
for (int i = 0; i < n; i++) {
System.out.println(“Enter AT for process” + i);
AT[i] = Integer.parseInt(br.readLine());
}
System.out.println(“***********************************************”);
WT[0] = 0;
for (int i = 1; i < n; i++) {
WT[i] = WT[i – 1] + BT[i – 1];
WT[i] = WT[i] – AT[i];
}
for (int i = 0; i < n; i++) {
TAT[i] = WT[i] + BT[i];
AWT = AWT + WT[i];
}
System.out.println(” PROCESS BT WT TAT “);
for (int i = 0; i < n; i++) {
System.out.println(” ” + i + ” ” + BT[i] + ” ” + WT[i] + ” ” + TAT[i]);
}
AWT = AWT / n;
System.out.println(“***********************************************”);
System.out.println(“Avg waiting time=” + AWT + “
***********************************************”);
}
}
Shortest job first -
A different approach to CPU scheduling is SJF shortest job first scheduling algorithm.This
associates with each process the length of the latter next CPU burst.When the CPU is available it
is assigned to the process that has the smallest next CPU burst.if two processes have same length
next CPU burst,FCFS scheduling is used to break the tie.Note that a more appropriate term
would be the shortest next CPU burst ,because the scheduling is done by examining the length of
the next CPU burst because the scheduling is done by examining the length of the next CPU
burst of a process,rather than its total length.The real difficulty in SJF shortest job first
scheduling algorithm is knowing the length of the next process.SJF shortest job first scheduling
algorithm scheduling algorithm is optimal which gives the minimum average waiting time for a
given set of processes.
Program-
import java.util.*;
class SJF {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n, BT[], WT[], TAT[];
System.out.println("Enter no of process");
n = sc.nextInt();
BT = new int[n + 1];
WT = new int[n + 1];
TAT = new int[n + 1];
float AWT = 0;
System.out.println("Enter Burst time for each process");
for (int i = 0; i < n; i++) {
System.out.println("Enter BT for process " + (i + 1));
BT[i] = sc.nextInt();
}
for (int i = 0; i < n; i++) {
WT[i] = 0;
TAT[i] = 0;
}
int temp;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - 1; j++) {
if (BT[j] > BT[j + 1]) {
temp = BT[j];
BT[j] = BT[j + 1];
BT[j + 1] = temp;
temp = WT[j];
WT[j] = WT[j + 1];
WT[j + 1] = temp;
}
}
}
for (int i = 0; i < n; i++) {
TAT[i] = BT[i] + WT[i];
WT[i + 1] = TAT[i];
}
TAT[n] = WT[n] + BT[n];
System.out.println(" PROCESS BT WT TAT ");
for (int i = 0; i < n; i++)
System.out.println(" " + i + " " + BT[i] + " " + WT[i] + " " + TAT[i]);
for (int j = 0; j < n; j++)
AWT += WT[j];
AWT = AWT / n;
System.out.println("***********************************************");
System.out.println("Avg waiting time=" + AWT + "
***********************************************");
}
}

More Related Content

Similar to First come first serve scheduling algorithm (FCFS) is the process th.pdf

import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdfimport java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdfadhityalapcare
 
I need to find run time analysis and description of the algo.pdf
I need to find run time analysis and description of the algo.pdfI need to find run time analysis and description of the algo.pdf
I need to find run time analysis and description of the algo.pdfaakashenterprises
 
please help finish sorting methods- import java-util-Arrays- import ja.pdf
please help finish sorting methods- import java-util-Arrays- import ja.pdfplease help finish sorting methods- import java-util-Arrays- import ja.pdf
please help finish sorting methods- import java-util-Arrays- import ja.pdfanfenterprises
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple ProgramsUpender Upr
 
Write a program that obtains the execution time of selection sort, bu.pdf
Write a program that obtains the execution time of selection sort, bu.pdfWrite a program that obtains the execution time of selection sort, bu.pdf
Write a program that obtains the execution time of selection sort, bu.pdfarri2009av
 
Where the wild things are - Benchmarking and Micro-Optimisations
Where the wild things are - Benchmarking and Micro-OptimisationsWhere the wild things are - Benchmarking and Micro-Optimisations
Where the wild things are - Benchmarking and Micro-OptimisationsMatt Warren
 
y Bookmarks People Window Helo Online Derivative edusubmi tionassig.docx
 y Bookmarks People Window Helo Online Derivative edusubmi tionassig.docx y Bookmarks People Window Helo Online Derivative edusubmi tionassig.docx
y Bookmarks People Window Helo Online Derivative edusubmi tionassig.docxajoy21
 
Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
 Problem1 java codeimport java.util.Scanner; Java code to pr.pdf Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
Problem1 java codeimport java.util.Scanner; Java code to pr.pdfanupamfootwear
 
Nested For Loops and Class Constants in Java
Nested For Loops and Class Constants in JavaNested For Loops and Class Constants in Java
Nested For Loops and Class Constants in JavaPokequesthero
 
Timers in Unix/Linux
Timers in Unix/LinuxTimers in Unix/Linux
Timers in Unix/Linuxgeeksrik
 
I am asked to provide the testing cases for the following co.pdf
I am asked to provide the testing cases for the following co.pdfI am asked to provide the testing cases for the following co.pdf
I am asked to provide the testing cases for the following co.pdfacecomputertcr
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfeyewatchsystems
 
Round Robin Algorithm in Operating System
Round Robin Algorithm in Operating SystemRound Robin Algorithm in Operating System
Round Robin Algorithm in Operating SystemZeeshan Iqbal
 

Similar to First come first serve scheduling algorithm (FCFS) is the process th.pdf (20)

Insertion Sort Code
Insertion Sort CodeInsertion Sort Code
Insertion Sort Code
 
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdfimport java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
JAVA.pdf
JAVA.pdfJAVA.pdf
JAVA.pdf
 
I need to find run time analysis and description of the algo.pdf
I need to find run time analysis and description of the algo.pdfI need to find run time analysis and description of the algo.pdf
I need to find run time analysis and description of the algo.pdf
 
please help finish sorting methods- import java-util-Arrays- import ja.pdf
please help finish sorting methods- import java-util-Arrays- import ja.pdfplease help finish sorting methods- import java-util-Arrays- import ja.pdf
please help finish sorting methods- import java-util-Arrays- import ja.pdf
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
Write a program that obtains the execution time of selection sort, bu.pdf
Write a program that obtains the execution time of selection sort, bu.pdfWrite a program that obtains the execution time of selection sort, bu.pdf
Write a program that obtains the execution time of selection sort, bu.pdf
 
Where the wild things are - Benchmarking and Micro-Optimisations
Where the wild things are - Benchmarking and Micro-OptimisationsWhere the wild things are - Benchmarking and Micro-Optimisations
Where the wild things are - Benchmarking and Micro-Optimisations
 
y Bookmarks People Window Helo Online Derivative edusubmi tionassig.docx
 y Bookmarks People Window Helo Online Derivative edusubmi tionassig.docx y Bookmarks People Window Helo Online Derivative edusubmi tionassig.docx
y Bookmarks People Window Helo Online Derivative edusubmi tionassig.docx
 
2_2_Event_Mechanism_Chapter_2.pdf
2_2_Event_Mechanism_Chapter_2.pdf2_2_Event_Mechanism_Chapter_2.pdf
2_2_Event_Mechanism_Chapter_2.pdf
 
Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
 Problem1 java codeimport java.util.Scanner; Java code to pr.pdf Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
 
Network security
Network securityNetwork security
Network security
 
Nested For Loops and Class Constants in Java
Nested For Loops and Class Constants in JavaNested For Loops and Class Constants in Java
Nested For Loops and Class Constants in Java
 
Timers in Unix/Linux
Timers in Unix/LinuxTimers in Unix/Linux
Timers in Unix/Linux
 
I am asked to provide the testing cases for the following co.pdf
I am asked to provide the testing cases for the following co.pdfI am asked to provide the testing cases for the following co.pdf
I am asked to provide the testing cases for the following co.pdf
 
Huraira_waris_Assgnment_4.docx
Huraira_waris_Assgnment_4.docxHuraira_waris_Assgnment_4.docx
Huraira_waris_Assgnment_4.docx
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
 
Round Robin Algorithm in Operating System
Round Robin Algorithm in Operating SystemRound Robin Algorithm in Operating System
Round Robin Algorithm in Operating System
 
14 thread
14 thread14 thread
14 thread
 

More from apjewellers

10 (number of bags John had) +10 (number sister gave to him)=20 Numb.pdf
10 (number of bags John had) +10 (number sister gave to him)=20 Numb.pdf10 (number of bags John had) +10 (number sister gave to him)=20 Numb.pdf
10 (number of bags John had) +10 (number sister gave to him)=20 Numb.pdfapjewellers
 
1. Meninges- it consist of durameter arachnoid and piameter. Piamete.pdf
1. Meninges- it consist of durameter arachnoid and piameter. Piamete.pdf1. Meninges- it consist of durameter arachnoid and piameter. Piamete.pdf
1. Meninges- it consist of durameter arachnoid and piameter. Piamete.pdfapjewellers
 
1. B is correct.2. A is correct.Solution1. B is correct.2..pdf
1. B is correct.2. A is correct.Solution1. B is correct.2..pdf1. B is correct.2. A is correct.Solution1. B is correct.2..pdf
1. B is correct.2. A is correct.Solution1. B is correct.2..pdfapjewellers
 
This should mean you want your base to have a pH .pdf
                     This should mean you want your base to have a pH .pdf                     This should mean you want your base to have a pH .pdf
This should mean you want your base to have a pH .pdfapjewellers
 
Solvent Ethanol Solute Sucrose .pdf
                     Solvent Ethanol Solute Sucrose                 .pdf                     Solvent Ethanol Solute Sucrose                 .pdf
Solvent Ethanol Solute Sucrose .pdfapjewellers
 
Tea is boiled with water so that water soluble co.pdf
                     Tea is boiled with water so that water soluble co.pdf                     Tea is boiled with water so that water soluble co.pdf
Tea is boiled with water so that water soluble co.pdfapjewellers
 
Step1 Half life of C14 = 5720 years ;Rate constan.pdf
                     Step1 Half life of C14 = 5720 years ;Rate constan.pdf                     Step1 Half life of C14 = 5720 years ;Rate constan.pdf
Step1 Half life of C14 = 5720 years ;Rate constan.pdfapjewellers
 
last updated Friday, August 14, 2009 Introductio.pdf
                     last updated Friday, August 14, 2009  Introductio.pdf                     last updated Friday, August 14, 2009  Introductio.pdf
last updated Friday, August 14, 2009 Introductio.pdfapjewellers
 
if u have calculated the differential equations t.pdf
                     if u have calculated the differential equations t.pdf                     if u have calculated the differential equations t.pdf
if u have calculated the differential equations t.pdfapjewellers
 
Entropy is related to the disorderness in the sys.pdf
                     Entropy is related to the disorderness in the sys.pdf                     Entropy is related to the disorderness in the sys.pdf
Entropy is related to the disorderness in the sys.pdfapjewellers
 
Decompression sickness (DCS; also known as divers.pdf
                     Decompression sickness (DCS; also known as divers.pdf                     Decompression sickness (DCS; also known as divers.pdf
Decompression sickness (DCS; also known as divers.pdfapjewellers
 
turnover ratio=Average assets sold by the fundAverage daily assets.pdf
turnover ratio=Average assets sold by the fundAverage daily assets.pdfturnover ratio=Average assets sold by the fundAverage daily assets.pdf
turnover ratio=Average assets sold by the fundAverage daily assets.pdfapjewellers
 
The correct answer isE. Normal rework common to all jobs is charge.pdf
The correct answer isE. Normal rework common to all jobs is charge.pdfThe correct answer isE. Normal rework common to all jobs is charge.pdf
The correct answer isE. Normal rework common to all jobs is charge.pdfapjewellers
 
The actual exchange of oxygen for carbon dioxide takes place between.pdf
The actual exchange of oxygen for carbon dioxide takes place between.pdfThe actual exchange of oxygen for carbon dioxide takes place between.pdf
The actual exchange of oxygen for carbon dioxide takes place between.pdfapjewellers
 
sample meanSolutionsample mean.pdf
sample meanSolutionsample mean.pdfsample meanSolutionsample mean.pdf
sample meanSolutionsample mean.pdfapjewellers
 
pH = 10.21 pOH = 14-10.21=3.79 [OH-] = 10-pOH = 1.622x10-4 M.pdf
pH = 10.21 pOH = 14-10.21=3.79 [OH-] = 10-pOH = 1.622x10-4 M.pdfpH = 10.21 pOH = 14-10.21=3.79 [OH-] = 10-pOH = 1.622x10-4 M.pdf
pH = 10.21 pOH = 14-10.21=3.79 [OH-] = 10-pOH = 1.622x10-4 M.pdfapjewellers
 
import java.awt.;class FlowLayoutDemo {    public static void.pdf
import java.awt.;class FlowLayoutDemo {    public static void.pdfimport java.awt.;class FlowLayoutDemo {    public static void.pdf
import java.awt.;class FlowLayoutDemo {    public static void.pdfapjewellers
 
It would be O=OSolutionIt would be O=O.pdf
It would be O=OSolutionIt would be O=O.pdfIt would be O=OSolutionIt would be O=O.pdf
It would be O=OSolutionIt would be O=O.pdfapjewellers
 
Hedgehog (Hh) signalling in tracheal cell migration The main chem.pdf
Hedgehog (Hh) signalling in tracheal cell migration The main chem.pdfHedgehog (Hh) signalling in tracheal cell migration The main chem.pdf
Hedgehog (Hh) signalling in tracheal cell migration The main chem.pdfapjewellers
 

More from apjewellers (20)

10 (number of bags John had) +10 (number sister gave to him)=20 Numb.pdf
10 (number of bags John had) +10 (number sister gave to him)=20 Numb.pdf10 (number of bags John had) +10 (number sister gave to him)=20 Numb.pdf
10 (number of bags John had) +10 (number sister gave to him)=20 Numb.pdf
 
1. Meninges- it consist of durameter arachnoid and piameter. Piamete.pdf
1. Meninges- it consist of durameter arachnoid and piameter. Piamete.pdf1. Meninges- it consist of durameter arachnoid and piameter. Piamete.pdf
1. Meninges- it consist of durameter arachnoid and piameter. Piamete.pdf
 
1. B is correct.2. A is correct.Solution1. B is correct.2..pdf
1. B is correct.2. A is correct.Solution1. B is correct.2..pdf1. B is correct.2. A is correct.Solution1. B is correct.2..pdf
1. B is correct.2. A is correct.Solution1. B is correct.2..pdf
 
This should mean you want your base to have a pH .pdf
                     This should mean you want your base to have a pH .pdf                     This should mean you want your base to have a pH .pdf
This should mean you want your base to have a pH .pdf
 
Solvent Ethanol Solute Sucrose .pdf
                     Solvent Ethanol Solute Sucrose                 .pdf                     Solvent Ethanol Solute Sucrose                 .pdf
Solvent Ethanol Solute Sucrose .pdf
 
Tea is boiled with water so that water soluble co.pdf
                     Tea is boiled with water so that water soluble co.pdf                     Tea is boiled with water so that water soluble co.pdf
Tea is boiled with water so that water soluble co.pdf
 
Step1 Half life of C14 = 5720 years ;Rate constan.pdf
                     Step1 Half life of C14 = 5720 years ;Rate constan.pdf                     Step1 Half life of C14 = 5720 years ;Rate constan.pdf
Step1 Half life of C14 = 5720 years ;Rate constan.pdf
 
last updated Friday, August 14, 2009 Introductio.pdf
                     last updated Friday, August 14, 2009  Introductio.pdf                     last updated Friday, August 14, 2009  Introductio.pdf
last updated Friday, August 14, 2009 Introductio.pdf
 
if u have calculated the differential equations t.pdf
                     if u have calculated the differential equations t.pdf                     if u have calculated the differential equations t.pdf
if u have calculated the differential equations t.pdf
 
D) NaCl .pdf
                     D) NaCl                                       .pdf                     D) NaCl                                       .pdf
D) NaCl .pdf
 
Entropy is related to the disorderness in the sys.pdf
                     Entropy is related to the disorderness in the sys.pdf                     Entropy is related to the disorderness in the sys.pdf
Entropy is related to the disorderness in the sys.pdf
 
Decompression sickness (DCS; also known as divers.pdf
                     Decompression sickness (DCS; also known as divers.pdf                     Decompression sickness (DCS; also known as divers.pdf
Decompression sickness (DCS; also known as divers.pdf
 
turnover ratio=Average assets sold by the fundAverage daily assets.pdf
turnover ratio=Average assets sold by the fundAverage daily assets.pdfturnover ratio=Average assets sold by the fundAverage daily assets.pdf
turnover ratio=Average assets sold by the fundAverage daily assets.pdf
 
The correct answer isE. Normal rework common to all jobs is charge.pdf
The correct answer isE. Normal rework common to all jobs is charge.pdfThe correct answer isE. Normal rework common to all jobs is charge.pdf
The correct answer isE. Normal rework common to all jobs is charge.pdf
 
The actual exchange of oxygen for carbon dioxide takes place between.pdf
The actual exchange of oxygen for carbon dioxide takes place between.pdfThe actual exchange of oxygen for carbon dioxide takes place between.pdf
The actual exchange of oxygen for carbon dioxide takes place between.pdf
 
sample meanSolutionsample mean.pdf
sample meanSolutionsample mean.pdfsample meanSolutionsample mean.pdf
sample meanSolutionsample mean.pdf
 
pH = 10.21 pOH = 14-10.21=3.79 [OH-] = 10-pOH = 1.622x10-4 M.pdf
pH = 10.21 pOH = 14-10.21=3.79 [OH-] = 10-pOH = 1.622x10-4 M.pdfpH = 10.21 pOH = 14-10.21=3.79 [OH-] = 10-pOH = 1.622x10-4 M.pdf
pH = 10.21 pOH = 14-10.21=3.79 [OH-] = 10-pOH = 1.622x10-4 M.pdf
 
import java.awt.;class FlowLayoutDemo {    public static void.pdf
import java.awt.;class FlowLayoutDemo {    public static void.pdfimport java.awt.;class FlowLayoutDemo {    public static void.pdf
import java.awt.;class FlowLayoutDemo {    public static void.pdf
 
It would be O=OSolutionIt would be O=O.pdf
It would be O=OSolutionIt would be O=O.pdfIt would be O=OSolutionIt would be O=O.pdf
It would be O=OSolutionIt would be O=O.pdf
 
Hedgehog (Hh) signalling in tracheal cell migration The main chem.pdf
Hedgehog (Hh) signalling in tracheal cell migration The main chem.pdfHedgehog (Hh) signalling in tracheal cell migration The main chem.pdf
Hedgehog (Hh) signalling in tracheal cell migration The main chem.pdf
 

Recently uploaded

Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactisticshameyhk98
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptxJoelynRubio1
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 

Recently uploaded (20)

Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 

First come first serve scheduling algorithm (FCFS) is the process th.pdf

  • 1. First come first serve scheduling algorithm (FCFS) is the process that request the CPU to allocate the resources on the first come priority basis.the Implementation of the first come first serve scheduling algorithm (FCFS) policy is easily managed with fifo(First in First out) queue.when a process enters into the ready queue ,its address 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 first come first serve scheduling algorithm (FCFS) is simple to write and Understand.The First come first serve scheduling algorithm (FCFS) in non preemptive.The first come first serve scheduling algorithm (FCFS) have a drawback for time sharing systems. first come first serve scheduling algorithm Program [Non-Preemptive]: import java.io.*; class fcfs { public static void main(String args[]) throws Exception { int n, AT[], BT[], WT[], TAT[];//Burst Time,Average Time,Wait Time float AWT = 0; InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); System.out.println(“Enter no of process”); n = Integer.parseInt(br.readLine()); BT = new int[n]; WT = new int[n]; TAT = new int[n]; AT = new int[n]; System.out.println(“Enter Burst time for each process ******************************”); for (int i = 0; i < n; i++) { System.out.println(“Enter BT for process ” + (i + 1)); BT[i] = Integer.parseInt(br.readLine()); } System.out.println(“***********************************************”); for (int i = 0; i < n; i++) { System.out.println(“Enter AT for process” + i); AT[i] = Integer.parseInt(br.readLine()); } System.out.println(“***********************************************”); WT[0] = 0;
  • 2. for (int i = 1; i < n; i++) { WT[i] = WT[i – 1] + BT[i – 1]; WT[i] = WT[i] – AT[i]; } for (int i = 0; i < n; i++) { TAT[i] = WT[i] + BT[i]; AWT = AWT + WT[i]; } System.out.println(” PROCESS BT WT TAT “); for (int i = 0; i < n; i++) { System.out.println(” ” + i + ” ” + BT[i] + ” ” + WT[i] + ” ” + TAT[i]); } AWT = AWT / n; System.out.println(“***********************************************”); System.out.println(“Avg waiting time=” + AWT + “ ***********************************************”); } } Shortest job first - A different approach to CPU scheduling is SJF shortest job first scheduling algorithm.This associates with each process the length of the latter next CPU burst.When the CPU is available it is assigned to the process that has the smallest next CPU burst.if two processes have same length next CPU burst,FCFS scheduling is used to break the tie.Note that a more appropriate term would be the shortest next CPU burst ,because the scheduling is done by examining the length of the next CPU burst because the scheduling is done by examining the length of the next CPU burst of a process,rather than its total length.The real difficulty in SJF shortest job first scheduling algorithm is knowing the length of the next process.SJF shortest job first scheduling algorithm scheduling algorithm is optimal which gives the minimum average waiting time for a given set of processes. Program- import java.util.*; class SJF { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n, BT[], WT[], TAT[]; System.out.println("Enter no of process");
  • 3. n = sc.nextInt(); BT = new int[n + 1]; WT = new int[n + 1]; TAT = new int[n + 1]; float AWT = 0; System.out.println("Enter Burst time for each process"); for (int i = 0; i < n; i++) { System.out.println("Enter BT for process " + (i + 1)); BT[i] = sc.nextInt(); } for (int i = 0; i < n; i++) { WT[i] = 0; TAT[i] = 0; } int temp; for (int i = 0; i < n; i++) { for (int j = 0; j < n - 1; j++) { if (BT[j] > BT[j + 1]) { temp = BT[j]; BT[j] = BT[j + 1]; BT[j + 1] = temp; temp = WT[j]; WT[j] = WT[j + 1]; WT[j + 1] = temp; } } } for (int i = 0; i < n; i++) { TAT[i] = BT[i] + WT[i]; WT[i + 1] = TAT[i]; } TAT[n] = WT[n] + BT[n]; System.out.println(" PROCESS BT WT TAT "); for (int i = 0; i < n; i++) System.out.println(" " + i + " " + BT[i] + " " + WT[i] + " " + TAT[i]); for (int j = 0; j < n; j++)
  • 4. AWT += WT[j]; AWT = AWT / n; System.out.println("***********************************************"); System.out.println("Avg waiting time=" + AWT + " ***********************************************"); } } Solution First come first serve scheduling algorithm (FCFS) is the process that request the CPU to allocate the resources on the first come priority basis.the Implementation of the first come first serve scheduling algorithm (FCFS) policy is easily managed with fifo(First in First out) queue.when a process enters into the ready queue ,its address 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 first come first serve scheduling algorithm (FCFS) is simple to write and Understand.The First come first serve scheduling algorithm (FCFS) in non preemptive.The first come first serve scheduling algorithm (FCFS) have a drawback for time sharing systems. first come first serve scheduling algorithm Program [Non-Preemptive]: import java.io.*; class fcfs { public static void main(String args[]) throws Exception { int n, AT[], BT[], WT[], TAT[];//Burst Time,Average Time,Wait Time float AWT = 0; InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); System.out.println(“Enter no of process”); n = Integer.parseInt(br.readLine()); BT = new int[n]; WT = new int[n]; TAT = new int[n]; AT = new int[n]; System.out.println(“Enter Burst time for each process ******************************”); for (int i = 0; i < n; i++) { System.out.println(“Enter BT for process ” + (i + 1));
  • 5. BT[i] = Integer.parseInt(br.readLine()); } System.out.println(“***********************************************”); for (int i = 0; i < n; i++) { System.out.println(“Enter AT for process” + i); AT[i] = Integer.parseInt(br.readLine()); } System.out.println(“***********************************************”); WT[0] = 0; for (int i = 1; i < n; i++) { WT[i] = WT[i – 1] + BT[i – 1]; WT[i] = WT[i] – AT[i]; } for (int i = 0; i < n; i++) { TAT[i] = WT[i] + BT[i]; AWT = AWT + WT[i]; } System.out.println(” PROCESS BT WT TAT “); for (int i = 0; i < n; i++) { System.out.println(” ” + i + ” ” + BT[i] + ” ” + WT[i] + ” ” + TAT[i]); } AWT = AWT / n; System.out.println(“***********************************************”); System.out.println(“Avg waiting time=” + AWT + “ ***********************************************”); } } Shortest job first - A different approach to CPU scheduling is SJF shortest job first scheduling algorithm.This associates with each process the length of the latter next CPU burst.When the CPU is available it is assigned to the process that has the smallest next CPU burst.if two processes have same length next CPU burst,FCFS scheduling is used to break the tie.Note that a more appropriate term would be the shortest next CPU burst ,because the scheduling is done by examining the length of the next CPU burst because the scheduling is done by examining the length of the next CPU burst of a process,rather than its total length.The real difficulty in SJF shortest job first scheduling algorithm is knowing the length of the next process.SJF shortest job first scheduling
  • 6. algorithm scheduling algorithm is optimal which gives the minimum average waiting time for a given set of processes. Program- import java.util.*; class SJF { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n, BT[], WT[], TAT[]; System.out.println("Enter no of process"); n = sc.nextInt(); BT = new int[n + 1]; WT = new int[n + 1]; TAT = new int[n + 1]; float AWT = 0; System.out.println("Enter Burst time for each process"); for (int i = 0; i < n; i++) { System.out.println("Enter BT for process " + (i + 1)); BT[i] = sc.nextInt(); } for (int i = 0; i < n; i++) { WT[i] = 0; TAT[i] = 0; } int temp; for (int i = 0; i < n; i++) { for (int j = 0; j < n - 1; j++) { if (BT[j] > BT[j + 1]) { temp = BT[j]; BT[j] = BT[j + 1]; BT[j + 1] = temp; temp = WT[j]; WT[j] = WT[j + 1]; WT[j + 1] = temp; } } }
  • 7. for (int i = 0; i < n; i++) { TAT[i] = BT[i] + WT[i]; WT[i + 1] = TAT[i]; } TAT[n] = WT[n] + BT[n]; System.out.println(" PROCESS BT WT TAT "); for (int i = 0; i < n; i++) System.out.println(" " + i + " " + BT[i] + " " + WT[i] + " " + TAT[i]); for (int j = 0; j < n; j++) AWT += WT[j]; AWT = AWT / n; System.out.println("***********************************************"); System.out.println("Avg waiting time=" + AWT + " ***********************************************"); } }