From be8bced8677627f319a36d2b601b4ade4026a60b Mon Sep 17 00:00:00 2001 From: Bess <bakere1@student.unimelb.edu.au> Date: Mon, 29 Mar 2021 13:33:38 +1100 Subject: [PATCH] not sure --- allocate.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/allocate.c b/allocate.c index 462e4da..a6817a9 100644 --- a/allocate.c +++ b/allocate.c @@ -174,6 +174,10 @@ int main(int argc, char *argv[]) { printf("Error in test file "); exit(1); } + // log finished processes. + + + // Log started processes. for (int j = 0; j < numCPU; j++) { headProcess = headData(CPUs[j].processQueue); @@ -184,8 +188,11 @@ int main(int argc, char *argv[]) { headProcess->startTime, headProcess->processID, headProcess->timeRemAtStartTime , j); headProcess->justStarted = 0; } + } +// + } fclose(f); } else { @@ -220,19 +227,29 @@ int main(int argc, char *argv[]) { CPUs[j].totalExecutionTimeRemaining -= deltaTime; } } - // Log process starts - for (int j = 0; j < numCPU; j++) { - headProcess = headData(CPUs[j].processQueue); - //next process in queue started - if (headProcess != NULL && headProcess->justStarted) { - // printf("current time: %d\n", currentTime); - printf("%d,RUNNING,pid=%s,remaining_time=%d,cpu=%d\n", - headProcess->startTime, headProcess->processID, headProcess->timeRemaining, j); - headProcess->justStarted = 0; + //logged finished processes + if (headProcess != NULL && headProcess->timeCompleted != -1) { +// printf("%d,FINISHED,pid=%s,proc_remaining=%d\n", +// headProcess->timeCompleted, headProcess->processID, numProcessesLeft); +// current = current->next; +// } + + + // Log process starts + for (int j = 0; j < numCPU; j++) { + headProcess = headData(CPUs[j].processQueue); + //next process in queue started + if (headProcess != NULL && headProcess->justStarted) { + // printf("current time: %d\n", currentTime); + printf("%d,RUNNING,pid=%s,remaining_time=%d,cpu=%d\n", + headProcess->startTime, headProcess->processID, headProcess->timeRemaining, j); + headProcess->justStarted = 0; + } +// } - } // currentTime += deltaTime; + } } // printf("Completed Queue:"); // llist_print(completedProcesses, (void (*)(void *)) &printQEntry); @@ -355,8 +372,8 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll paralizedProcess->timeRemaining = 0; headProcess->timeRemaining = 0; //printf("process had finished: Current time: %d, deltaTime: %d\n", currentTime, deltaTime); - printf("%d,FINISHED,pid=%s,proc_remaining=%d\n", - paralizedProcess->timeCompleted, paralizedProcess->processID, *numProcessesLeft); +// printf("%d,FINISHED,pid=%s,proc_remaining=%d\n", +// paralizedProcess->timeCompleted, paralizedProcess->processID, *numProcessesLeft); // Could accumulate statistics here instead of keeping list of completed processes llist_push(processesComplete, paralizedProcess); } @@ -372,8 +389,8 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll } else { // finishedprocess is not parallelisable *numProcessesLeft -= 1; *numProcessComplete += 1; - printf("%d,FINISHED,pid=%s,proc_remaining=%d\n", - headProcess->timeCompleted, headProcess->processID, *numProcessesLeft); +// printf("%d,FINISHED,pid=%s,proc_remaining=%d\n", +// headProcess->timeCompleted, headProcess->processID, *numProcessesLeft); // Could accumulate statistics here instead of keeping list of completed processes llist_push(processesComplete, headProcess); llist_pop(processQueue); -- GitLab