Skip to content
Snippets Groups Projects
Commit be8bced8 authored by Elizabeth Baker's avatar Elizabeth Baker
Browse files

not sure

parent 5d5f723b
No related branches found
No related tags found
No related merge requests found
...@@ -174,6 +174,10 @@ int main(int argc, char *argv[]) { ...@@ -174,6 +174,10 @@ int main(int argc, char *argv[]) {
printf("Error in test file "); printf("Error in test file ");
exit(1); exit(1);
} }
// log finished processes.
// Log started processes. // Log started processes.
for (int j = 0; j < numCPU; j++) { for (int j = 0; j < numCPU; j++) {
headProcess = headData(CPUs[j].processQueue); headProcess = headData(CPUs[j].processQueue);
...@@ -184,8 +188,11 @@ int main(int argc, char *argv[]) { ...@@ -184,8 +188,11 @@ int main(int argc, char *argv[]) {
headProcess->startTime, headProcess->processID, headProcess->timeRemAtStartTime , j); headProcess->startTime, headProcess->processID, headProcess->timeRemAtStartTime , j);
headProcess->justStarted = 0; headProcess->justStarted = 0;
} }
} }
//
} }
fclose(f); fclose(f);
} else { } else {
...@@ -220,6 +227,14 @@ int main(int argc, char *argv[]) { ...@@ -220,6 +227,14 @@ int main(int argc, char *argv[]) {
CPUs[j].totalExecutionTimeRemaining -= deltaTime; CPUs[j].totalExecutionTimeRemaining -= deltaTime;
} }
} }
//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 // Log process starts
for (int j = 0; j < numCPU; j++) { for (int j = 0; j < numCPU; j++) {
headProcess = headData(CPUs[j].processQueue); headProcess = headData(CPUs[j].processQueue);
...@@ -230,10 +245,12 @@ int main(int argc, char *argv[]) { ...@@ -230,10 +245,12 @@ int main(int argc, char *argv[]) {
headProcess->startTime, headProcess->processID, headProcess->timeRemaining, j); headProcess->startTime, headProcess->processID, headProcess->timeRemaining, j);
headProcess->justStarted = 0; headProcess->justStarted = 0;
} }
//
} }
// currentTime += deltaTime; // currentTime += deltaTime;
} }
}
// printf("Completed Queue:"); // printf("Completed Queue:");
// llist_print(completedProcesses, (void (*)(void *)) &printQEntry); // llist_print(completedProcesses, (void (*)(void *)) &printQEntry);
...@@ -355,8 +372,8 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll ...@@ -355,8 +372,8 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll
paralizedProcess->timeRemaining = 0; paralizedProcess->timeRemaining = 0;
headProcess->timeRemaining = 0; headProcess->timeRemaining = 0;
//printf("process had finished: Current time: %d, deltaTime: %d\n", currentTime, deltaTime); //printf("process had finished: Current time: %d, deltaTime: %d\n", currentTime, deltaTime);
printf("%d,FINISHED,pid=%s,proc_remaining=%d\n", // printf("%d,FINISHED,pid=%s,proc_remaining=%d\n",
paralizedProcess->timeCompleted, paralizedProcess->processID, *numProcessesLeft); // paralizedProcess->timeCompleted, paralizedProcess->processID, *numProcessesLeft);
// Could accumulate statistics here instead of keeping list of completed processes // Could accumulate statistics here instead of keeping list of completed processes
llist_push(processesComplete, paralizedProcess); llist_push(processesComplete, paralizedProcess);
} }
...@@ -372,8 +389,8 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll ...@@ -372,8 +389,8 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll
} else { // finishedprocess is not parallelisable } else { // finishedprocess is not parallelisable
*numProcessesLeft -= 1; *numProcessesLeft -= 1;
*numProcessComplete += 1; *numProcessComplete += 1;
printf("%d,FINISHED,pid=%s,proc_remaining=%d\n", // printf("%d,FINISHED,pid=%s,proc_remaining=%d\n",
headProcess->timeCompleted, headProcess->processID, *numProcessesLeft); // headProcess->timeCompleted, headProcess->processID, *numProcessesLeft);
// Could accumulate statistics here instead of keeping list of completed processes // Could accumulate statistics here instead of keeping list of completed processes
llist_push(processesComplete, headProcess); llist_push(processesComplete, headProcess);
llist_pop(processQueue); llist_pop(processQueue);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment