Question: Hi I need help with my code. so it doesnt allow me to input any number nor does it display the turnaround time and the
Hi I need help with my code. so it doesnt allow me to input any number nor does it display the turnaround time and the waiting time. Can you please help me #include
#include
#include
#define EXIT
#define INVALID
#define CPU
#define PID
Function prototypes
int displayMenu;
void cpuScheduling;
void fcfsint process int at int bt;
void sjfint process int at int bt;
void displayScheduleint process int at int bt int wt int tat;
int main
int choice INVALID;
Main loop
while choice EXIT
choice displayMenu;
Execute CPU scheduling functionality for choice CPU
if choice CPU
cpuScheduling;
Exit the program if choice is EXIT
else if choice EXIT
exitEXITSUCCESS;
return ;
Function to display the OS Management Menu and get user's choice
int displayMenu
int choice INVALID;
Display the OS Management Menu
printf
OS Management Menu
;
printf CPU Scheduling
;
printf Exit
;
Prompt user for choice and validate
do
printfEnter your choice: ;
scanfd &choice;
if choice EXIT choice CPU
printfInvalid choice. Please enter a valid choice.
;
choice INVALID;
while choice INVALID;
return choice;
Function to perform CPU scheduling
void cpuScheduling
Fixed data for processes as per the assignment
int process;
int at;
int bt;
Perform FCFS and SJF scheduling
fcfsprocess at bt;
sjfprocess at bt;
FirstCome, FirstServed scheduling algorithm
void fcfsint process int at int bt
Calculate waiting times and turnaround times for FCFS
int wt tat;
wt;
for int i ; i ; i
wti bti wti ati;
if wti
wti;
for int i ; i ; i
tati bti wti;
Display schedule and statistics for FCFS
displayScheduleprocess at bt wt tat;
Shortest Job First scheduling algorithm
void sjfint process int at int bt
Sort processes based on burst time for SJF
for int i ; i ; i
for int j ; j i; j
if btj btj
Swap burst times
int temp btj;
btj btj ;
btj temp;
Swap process IDs
temp processj;
processj processj ;
processj temp;
Swap arrival times
temp atj;
atj atj ;
atj temp;
Calculate waiting times and turnaround times for SJF
int wt tat;
wt;
for int i ; i ; i
wti bti wti ati;
if wti
wti;
for int i ; i ; i
tati bti wti;
Display schedule and statistics for SJF
displayScheduleprocess at bt wt tat;
Function to display schedule and statistics
void displayScheduleint process int at int bt int wt int tat
Display schedule and statistics
printf
Processt Arrival Timet Burst Timet Waiting Timet Turnaround Time
;
for int i ; i ; i
printfdt dtt dtt dtt d
processi ati bti wti tati;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
