Practical 6 OS
Practical 6 OS
Code:
#include <stdio.h>
current_time = proc[i].completion_time;
}
}
if (min_index == -1) {
current_time++;
} else {
visited[min_index] = 1;
proc[min_index].completion_time = current_time + proc[min_index].burst_time;
proc[min_index].turnaround_time = proc[min_index].completion_time -
proc[min_index].arrival_time;
proc[min_index].waiting_time = proc[min_index].turnaround_time -
proc[min_index].burst_time;
current_time = proc[min_index].completion_time;
completed++;
}
}
}
int main() {
int n, choice;
printf("Enter number of processes: ");
scanf("%d", &n);
if (choice == 1) {
FCFS(proc, n);
} else if (choice == 2) {
SJN(proc, n);
} else {
printf("Invalid choice!\n");
return 0;
}
displayProcesses(proc, n);
return 0;
}
Output: