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

bug 2) fixed

parent aa7d11bc
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,8 @@ typedef struct {
int timeRemaining;
int subProcsRunning;
int justStarted;
int deltaTime;
int startTime;
int timeRemAtStartTime;
} process;
typedef struct {
......@@ -164,7 +165,7 @@ int main(int argc, char *argv[]) {
parableProcess[i].parallelisable = newProcess->parallelisable;
parableProcess[i].timeCompleted = -1;
parableProcess[i].timeRemaining = parableProcess[i].executionTime;
parableProcess[i].deltaTime = newProcess->deltaTime;
parableProcess[i].timeRemAtStartTime = newProcess->timeRemAtStartTime;
addProcessToQueue(CPUs[i].processQueue, &parableProcess[i], currentTime, i);
}
numProcessesLeft += 1;
......@@ -179,10 +180,9 @@ int main(int argc, char *argv[]) {
//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->timeRemAtStartTime , j);
headProcess->justStarted = 0;
printf("%d,RUNNING,pid=%s,remaining_time=%d,cpu=%d - AAAA line 184\n",
currentTime - headProcess->deltaTime, headProcess->processID,
headProcess->timeRemaining + headProcess->deltaTime, j);
}
}
......@@ -226,9 +226,9 @@ int main(int argc, char *argv[]) {
//next process in queue started
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",
currentTime, headProcess->processID, headProcess->timeRemaining, j);
headProcess->startTime, headProcess->processID, headProcess->timeRemaining, j);
headProcess->justStarted = 0;
}
}
......@@ -296,10 +296,11 @@ void initializeProcess(char data[], process *newProcess) {
if (token != NULL) {
newProcess->parallelisable = token[0];
}
newProcess->deltaTime =0;
newProcess->justStarted =0;
newProcess->startTime = 0;
newProcess->timeCompleted = -1;
newProcess->timeRemaining = newProcess->executionTime;
newProcess->timeRemAtStartTime = newProcess->timeRemaining;
newProcess->justStarted = 0;
}
process *headData(llist *q) {
......@@ -363,7 +364,8 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll
headProcess = headData(processQueue);
if (headProcess){
headProcess->justStarted = -1;
headProcess->deltaTime = deltaTime;
headProcess->startTime = currentTime - deltaTime;
headProcess->timeRemAtStartTime = headProcess->timeRemaining;
}
} else { // finishedprocess is not parallelisable
......@@ -377,13 +379,13 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll
headProcess = headData(processQueue);
if (headProcess){
headProcess->justStarted = -1;
headProcess->deltaTime = deltaTime;
headProcess->startTime = currentTime - deltaTime;
}
}
} else { // head process not finished
headProcess->timeRemaining -= deltaTime;
headProcess->deltaTime = deltaTime;
// headProcess->deltaTime = deltaTime;
deltaTime = 0;
// llist_print( processQueue, (void (*)(void *)) &printQEntry );
}
......@@ -424,9 +426,10 @@ void addProcessToQueue(llist *processQueue, process *newProcess, int currentTime
process *headProcess;
llist_add_inorder(newProcess, processQueue, (int (*)(void *, void *)) &leastTimeRemaining);
headProcess = headData(processQueue);
if ( oldProcess != NULL && !strncmp(headProcess->processID, oldProcess->processID, sizeof (newProcess->processID)) )
if ( !strncmp(headProcess->processID, newProcess->processID, sizeof (newProcess->processID)) ) {
headProcess->justStarted = -1;
headProcess->startTime = currentTime;
}
}
process *getNextProcessB(FILE *f, llist *arrivals, process *readAhead) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment