Question: PROCESS * sjf _ process _ selector ( PROCESS _ LIST * pl ) { / / Don't change the first line of the existing
PROCESS sjfprocessselectorPROCESSLIST pl
Don't change the first line of the existing code
PROCESS p;
Initialize the shortest process pointer to NULL
PROCESS shortestprocess NULL;
Iterate through the process list to find the process with the shortest remaining time
for int i ; i plnumprocesses; i
PROCESS currentprocess plprocessesi;
If the current process is shorter than the previously found shortest process
or if there's no shortest process found yet, update the shortest process pointer
if shortestprocess NULL currentprocesstimeremaining shortestprocesstimeremaining
shortestprocess currentprocess;
Assign the shortestprocess to p
p shortestprocess;
Return the process with the shortest remaining time
return p;
"FAILED":
"testprocentryentrysjf
procsjf
These Test cases are failing for this code.
TestSJFprocsjfdisabledfalse
SCHEDULERSTATS stats getemptystatsblock;
SCHEDULERPARAMS params SCHEDULERPARAMS
timeslice
processselectionfunc sjfprocessselector
;
testprocparams stats;
crexpectstatsnumprocessesstarted;
crexpectstatsnumprocessescompleted;
crexpectstatscompletiontimef;
crexpectstatssumofturnaroundtimesf;
crexpectstatssumofresponsetimef;
crexpectstatsaverageturnaroundtime f;
crexpectstatsaverageresponsetimef;
printf
;
TestRR testprocentryentryrrdisabledfalse
SCHEDULERSTATS stats getemptystatsblock;
SCHEDULERPARAMS params SCHEDULERPARAMS
timeslice
processselectionfunc rrprocessselector
;
testprocentryentryparams stats;
crexpectstatsnumprocessesstarted;
crexpectstatsnumprocessescompleted;
crexpectstatscompletiontime;
crexpectstatssumofturnaroundtimes;
crexpectstatssumofresponsetime;
crexpectstatsaverageturnaroundtime ;
crexpectstatsaverageresponsetime;
printf
;
Make the changes in the code so the test case passes.
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
