added OS theory code
This commit is contained in:
parent
2313ae0e01
commit
bb32f2abc5
@ -1,7 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
# define MAX 4
|
# define MAX 4
|
||||||
|
|
||||||
@ -24,7 +23,6 @@
|
|||||||
*b = temp;
|
*b = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Function to calculate Completion Time, Turnaround Time, and Waiting Time
|
// Function to calculate Completion Time, Turnaround Time, and Waiting Time
|
||||||
void calculate_times(Process processes[], int n) {
|
void calculate_times(Process processes[], int n) {
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
@ -33,7 +31,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Function to calculate average times
|
// Function to calculate average times
|
||||||
void calculate_averages(Process processes[], int n, float *avg_ct,
|
void calculate_averages(Process processes[], int n, float *avg_ct,
|
||||||
float *avg_tat, float *avg_wt, float *avg_rt) {
|
float *avg_tat, float *avg_wt, float *avg_rt) {
|
||||||
@ -42,7 +39,6 @@
|
|||||||
*avg_wt = 0;
|
*avg_wt = 0;
|
||||||
*avg_rt = 0;
|
*avg_rt = 0;
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
*avg_ct += processes[i].ct;
|
*avg_ct += processes[i].ct;
|
||||||
*avg_tat += processes[i].tat;
|
*avg_tat += processes[i].tat;
|
||||||
@ -50,7 +46,6 @@
|
|||||||
*avg_rt += processes[i].rt;
|
*avg_rt += processes[i].rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
*avg_ct /= n;
|
*avg_ct /= n;
|
||||||
*avg_tat /= n;
|
*avg_tat /= n;
|
||||||
*avg_wt /= n;
|
*avg_wt /= n;
|
||||||
@ -74,7 +69,6 @@
|
|||||||
printf("\n-----------------------------------------------------------\n");
|
printf("\n-----------------------------------------------------------\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Function to display the process table
|
// Function to display the process table
|
||||||
void display_table(Process processes[], int n) {
|
void display_table(Process processes[], int n) {
|
||||||
printf("--------------------------------------------------------------------"
|
printf("--------------------------------------------------------------------"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user