Question: multilevelRR schedule.c #include schedule.h #include / * * * Function to initialize any global variables for the scheduler. * / void init ( )
multilevelRR
schedule.c
#include "schedule.h
#include
Function to initialize any global variables for the scheduler.
void init
Function to add a process to the scheduler
@Param process Pointer to the process control block for the process that
needs to be scheduled. PCB is defined in the header.
@return truefalse response for if the addition was successful
int addProcessPCB process
return ;
Function to get the next process from the scheduler
@Param time pass by reference variable to store the quanta of time
the scheduled process should run for
@Return returns pointer to process control block that needs to be executed
returns NULL if there is no process to be scheduled.
PCB nextProcessint time
return NULL;
Function that returns a boolean True False based on if there are any
processes still scheduled
@Return if there are processes still scheduled if there are no more
scheduled processes
int hasProcess
return ;
schedule.h
#ifndef scheduleh
#define scheduleh
typedef struct
int pid;
int priority;
PCB;
void init;
int addProcessPCB process;
PCB nextProcessint time;
int hasProcess;
#endif
sim.c
#include
#include
#include
#include
#include
#include
#include
#include
#include "schedule.h
main The simulator's main routine
int mainint argc, char argv
int processes;
init;
int i;
fori;i;i
processesi;
int priority i;
printfScheduled Process: d Priority:d
i priority;
PCB proc PCB mallocsizeofPCB;
procpid i;
procprioritypriority;
addProcessproc;
PCB process NULL;
int count ;
int time ;
whilehasProcess
process nextProcess&time;
ifprocess
printfNULL Process, something went wrong in your code.
;
exit;
for;time;time
printfProcess d executed
processpid;
processesprocesspid;
ifprocessesprocesspid
printfProcess d Finished
processpid;
count;
ifprocessesprocesspid
addProcessprocess;
else
freeprocess;
ifcount
for;i;i
processesi;
int priority i;
printfScheduled Process: d Priority:d
i priority;
PCB proc PCB mallocsizeofPCB;
procpid i;
procprioritypriority;
addProcessproc;
exit; control never reaches here
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
