Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //swapVect es un vector con las paginas que estan en el swap
- void AddrSpace::SwapRead(int page,int vpn){
- OpenFile * swap = fileSystem -> Open("Swap"); //Open the file
- int i = 0;
- bool seguir = true;
- while (seguir) {
- if(swapVect[i] == vpn){ //if the page is in the swap file, we stop.
- seguir = false;
- } else {
- i++;
- }
- }
- swap -> ReadAt(&(machine->mainMemory[page*PageSize]), PageSize, i*PageSize); // We stick out the dirty page from Swap.
- swapMap->Clear(i); //We clear our Swap bitMap.
- swapVect[i] = -1; // Erase that position in the swap vector.
- delete swap; // Erase the opened file swap.
- }
- void AddrSpace::SwapWrite(int page , int pos){
- OpenFile * swap = fileSystem -> Open("Swap"); //We open the swap file
- swap -> WriteAt (&(machine -> mainMemory[page*PageSize]), PageSize, pos*PageSize); //We write the the page to the swap.
- delete swap; //We erase the swap opened file
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement