I hope I explained the problem well enough. Any help that anyone can provide would be greatly appreciated. Here's the relevant code:
const int SIZE = 30; struct ProcessData { int processNumber; int burstTime; int waitTime; int turnAroundTime; int endTime; int completionFlag; int leftToProcess; //For Round Robin Algorithm }; void SJFSim(ProcessData newData[], int& count); ... void SJFSim(ProcessData newData[], int& count) { //These variables are for my analysis float totalRunTime = 0; float totalWaitTime = 0; float totalTurnAroundTime = 0; float totalBurstTime = 0; float avgRunTime = 0; float avgWaitTime = 0; float avgTurnAroundTime = 0; float avgNormalizedTurnAroundTime = 0; //Variables Relavant to Traversal int i = 0; int j = 0; int k = 0; int nextProcessMarker = 0; int previousProcessMarker = 0; int temp = 0; //Analysis on Initial Read newData[i].waitTime = 0; newData[i].endTime = newData[i].burstTime + newData[i].waitTime; newData[i].turnAroundTime = newData[i].burstTime; newData[i].completionFlag = 1; totalRunTime = newData[i].turnAroundTime; totalBurstTime = newData[i].burstTime; previousProcessMarker = i; //Set this as the last job processed for (i = 1; i < count; ++i) { //Set Boundary To Only Those Processes That Have Come In During Previous Execution temp = totalBurstTime; if (temp > 30) temp = 30; if (newData[i].completionFlag != 1) { for (j = 0; j < temp; j++) { //If this is the smallest data in within the boundaries if ((newData[i].burstTime < newData[j].burstTime) && ((newData[i].completionFlag != 1  newData[j].completionFlag != 1))) { //Set this job to process nextProcessMarker = i; } } } //Code to generate analysis on End times, etc. newData[nextProcessMarker].turnAroundTime = newData[nextProcessMarker].burstTime + newData[previousProcessMarker].burstTime; newData[nextProcessMarker].waitTime = newData[previousProcessMarker].burstTime + newData[previousProcessMarker].waitTime; newData[nextProcessMarker].endTime = newData[nextProcessMarker].burstTime + newData[nextProcessMarker].waitTime; totalTurnAroundTime = totalTurnAroundTime + newData[nextProcessMarker].turnAroundTime; totalRunTime = totalRunTime + newData[nextProcessMarker].turnAroundTime; totalWaitTime = totalRunTime + newData[nextProcessMarker].waitTime; totalBurstTime = totalBurstTime + newData[nextProcessMarker].burstTime; //Set This Data As Completed newData[nextProcessMarker].completionFlag = 1; previousProcessMarker = nextProcessMarker; } //Calculate Averages avgRunTime = totalRunTime / count; avgWaitTime = totalWaitTime / count; avgTurnAroundTime = totalTurnAroundTime / count; avgNormalizedTurnAroundTime = totalTurnAroundTime / totalBurstTime; //Output Averages cout << "# \tTime \tEnd \tTurn \tWait" << endl << endl; for (int j = 0; j < count; j++) { cout << newData[j].processNumber << "\t" << newData[j].burstTime << "\t " << newData[j].endTime << "\t" << newData[j].turnAroundTime << "\t" << newData[j].waitTime << endl; } cout << endl << "Global Averages" << endl << "" << endl; cout << "Turnaround Time:\t\t" << avgTurnAroundTime << "ms" << endl; cout << "Normalized Turnaround Time:\t" << avgNormalizedTurnAroundTime << "ms" << endl; cout << "Wait Time:\t\t\t" << avgWaitTime << "ms" << endl; }
I have also attached the full program for reference.
Attached File(s)

main.txt (6.33K)
Number of downloads: 3907
This post has been edited by Sms231: 16 March 2007  04:04 PM