From 4867c68cca8a559e1b5496cf59e241a4144344ef Mon Sep 17 00:00:00 2001
From: Bess <bakere1@student.unimelb.edu.au>
Date: Sun, 28 Mar 2021 23:18:07 +1100
Subject: [PATCH] run print time count
---
allocate.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/allocate.c b/allocate.c
index d1567e4..5c33577 100644
--- a/allocate.c
+++ b/allocate.c
@@ -20,12 +20,14 @@ typedef struct {
int timeRemaining;
int subProcsRunning;
int justStarted;
+ int deltaTime;
} process;
typedef struct {
//int CPUi;
int totalExecutionTimeRemaining; //add all the times of the process
llist *processQueue;
+ int numPorc;
} CPU;
void initializeProcess(char data[], process *newProcess);
@@ -179,7 +181,7 @@ int main(int argc, char *argv[]) {
if (headProcess != NULL && headProcess->justStarted) {
// printf("current time: %d\n", currentTime);
headProcess->justStarted = 0;
- printf("%d,RUNNING,pid=%s,remaining_time=%d,cpu=%d\n",
+ printf("%d,RUNNING,pid=%s,remaining_time=%d,cpu=%d - AAAA line 184\n",
deltaTime+1, headProcess->processID, headProcess->timeRemaining, j);
}
}
@@ -294,7 +296,7 @@ void initializeProcess(char data[], process *newProcess) {
if (token != NULL) {
newProcess->parallelisable = token[0];
}
-
+ newProcess->deltaTime =0;
newProcess->timeCompleted = -1;
newProcess->timeRemaining = newProcess->executionTime;
}
@@ -358,7 +360,11 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll
}
llist_pop(processQueue);
headProcess = headData(processQueue);
- if (headProcess) headProcess->justStarted = -1;
+ if (headProcess){
+ headProcess->justStarted = -1;
+ headProcess->deltaTime = deltaTime;
+ }
+
} else { // finishedprocess is not parallelisable
*numProcessesLeft -= 1;
*numProcessComplete += 1;
@@ -368,12 +374,15 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll
llist_push(processesComplete, headProcess);
llist_pop(processQueue);
headProcess = headData(processQueue);
- if (headProcess) headProcess->justStarted = -1;
+ if (headProcess){
+ headProcess->justStarted = -1;
+ headProcess->deltaTime = deltaTime;
+ }
}
} else { // head process not finished
headProcess->timeRemaining -= deltaTime;
-
+ headProcess->deltaTime = deltaTime;
deltaTime = 0;
// llist_print( processQueue, (void (*)(void *)) &printQEntry );
}
--
GitLab