Assignment 4
Assignment 4
Q) What is SJF ?
A)The shortest job first (SJF) or shortest job next, is a scheduling policy that
selects the waiting process with the smallest execution time to execute next.
SJN, also known as Shortest Job Next (SJN), can be pre-emptive or non-pre-
emptive.
1) FCFS ALGORITHM
import java.text.ParseException;
class GFG {
}
}
Output:
Output:
C. CPU SCHEDULING USING PRIORITY
PROGRAM:
#include <stdio.h>
int main()
{
int i, n, j, a[10], b[10], pri[10], pro[10], temp1, temp2, temp3;
float avgWT = 0, avgTAT = 0;
// Swap priority
temp2 = pri[i];
pri[i] = pri[j];
pri[j] = temp2;
// Calculate averages
avgWT /= n;
avgTAT /= n;
// Print averages
printf("\nAverage Waiting Time = %.2f", avgWT);
printf("\nAverage Turnaround Time = %.2f\n", avgTAT);
return 0;
}
OUTPUT