Professional Documents
Culture Documents
SOURCE CODE
//SJFS -preemptive
#include<stdio.h>
int main()
{
int n;
printf("Enter the number of processes: ");
scanf("%d", &n);
int at[n], bt[n], ct[n], at_copy[n], bt_copy[n], val, max_time = 0;
printf("Enter the arrival time and burst time for the processes:\n");
for(int i=0; i<n; i++){
printf("\nEnter arrival time for process[%d] ", i+1);
scanf("%d", &val);
at[i] = val;
if(max_time < val)
max_time = val;
at_copy[i] = val;
printf("Enter burst time for process[%d] ", i+1);
scanf("%d", &val);
bt[i] = val;
bt_copy[i] = val;
}
int time = 0, i = 0, process = 0;
while(process != n)
{
if(at[i] <= time && at[i] != -1)