/** Construit la liste des pages sur la gauche */ void ConfigDialog::buildPagesList() { pages_list -> clear(); foreach(ConfigPage *page, pages) { addPageToList(page); }
int main(int argc , char *argv[]) { char str[60]; int pagesToGet[1024]; int totalPagesRequested = 0; char *cacheSizeString = argv[1]; int cacheSize = atoi(cacheSizeString); //Get a line from stdin while(fgets(str, 60, stdin) != NULL) { //If the line doesn't start with a number, go to next line if(!isdigit(str[0])) continue; else { int i = 0; char currentPage[10]; //Get the number at the beginning of line and put into currentPage while(isdigit(str[i])) { currentPage[i] = str[i]; i++; } //After the last digit of the page number we're getting, put a \0 currentPage[i] = '\0'; //Convert currentPage to an int and add that page number to pagesToGet int pageNum = atoi(currentPage); pagesToGet[totalPagesRequested] = pageNum; totalPagesRequested++; } } /////////////////////////// // IMPLEMENTION OF CLOCK // /////////////////////////// int pageFaultCount = 0; int sizeOfList = 0; clockHand = NULL; head = NULL; //Process each page request from pagesToGet[] int i; for(i = 0; i < totalPagesRequested; i++) { bool foundPage = findPageInQueue(pagesToGet[i], sizeOfList); //If the page is already in cache if(foundPage) { //No fault } else { printf("Page fault for page %d\n", pagesToGet[i]); pageFaultCount++; bool added = addPageToList(pagesToGet[i], sizeOfList, cacheSize); if(added) sizeOfList++; } } printf("Total of %d page requests, total of %d page faults\n", totalPagesRequested, pageFaultCount); }