#include #include #include #include using namespace std; #include "fits.h" int main(int argc, char *argv[]){ string *algType = new string; deque *procDeque = new deque; fillProcDeque(argv[1], procDeque, algType); runAlgorithm(procDeque, algType); return 0; } void fillProcDeque(char *filename, deque *procDeque, string *algType){ ifstream procFile; procItem procreq; /* tem procItem */ string algtype; procFile.open(filename); procFile >> algtype; (*algType) = algtype; while(!procFile.eof()){ procFile >> procreq.procName; if(procreq.procName == "kill") procFile >> procreq.killProc; else procFile >> procreq.procSize; procDeque->push_back(procreq); } procFile.close(); return; } void runAlgorithm(deque *procDeque, string *algType){ memItem *memStart; string *LRUstring; memItem *mitem; deque::iterator procit; char procName; int procSize; int numSwaps = 0; /* number of swaps */ //Initialize first memory block mitem = new memItem; mitem->process = '0'; /* Hole */ mitem->size = 128; /* Whole thing */ mitem->next = NULL; mitem->prev = NULL; memStart = mitem; // Your stuff here printStats(NULL, '0', numSwaps); /* final stats */ } //deletes a process from memory void killProcess(memItem *memStart, char procName, string *LRUstring){ } bool isInMemory(memItem *memStart, char procName){ memItem *mi = memStart; } void guaranteeHole(memItem *memStart, int procSize, string *LRUstring, int &numSwaps){ int largestHoleSize = 0; memItem *mi; /* iterator */ } } void insertProc(memItem *memStart, char procName, int procSize, string *algType, string *LRUstring){ static memItem *nfPointer = NULL; static char lastProc = '0'; memItem *mi; /* Iterator */ memItem *foundHole = NULL; int bestSizeSoFar; // At the end of these if's, foundHole will point to the // hole that can contain the process mi = memStart; if((*algType) == "ff"){ } if(*algType == "bf"){ } if(*algType == "wf"){ } if(*algType == "nf"){ } // Now put the process in the hole } void LRUupdate(string *LRUstring, char procName){ int p; } void printStats(memItem *memStart, char procName, int numSwaps){ // Some variables for final stats static int totalNumLoads = 0; /* #times this fn. called */ static int totalPercentMem = 0; static int totalNumProcs = 0; static int totalNumHoles = 0; // Some local variables memItem *mi; /* iterator */ int numHoles = 0; int numProcs = 0; int usedMem = 0; int percentMem = 0; } void showMem(memItem *memStart){ }