Advertisement
smyrrie

Untitled

Nov 30th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. //swapVect es un vector con las paginas que estan en el swap
  2. void AddrSpace::SwapRead(int page,int vpn){
  3. OpenFile * swap = fileSystem -> Open("Swap"); //Open the file
  4. int i = 0;
  5. bool seguir = true;
  6. while (seguir) {
  7. if(swapVect[i] == vpn){ //if the page is in the swap file, we stop.
  8. seguir = false;
  9. } else {
  10. i++;
  11. }
  12. }
  13. swap -> ReadAt(&(machine->mainMemory[page*PageSize]), PageSize, i*PageSize); // We stick out the dirty page from Swap.
  14. swapMap->Clear(i); //We clear our Swap bitMap.
  15. swapVect[i] = -1; // Erase that position in the swap vector.
  16. delete swap; // Erase the opened file swap.
  17. }
  18.  
  19.  
  20. void AddrSpace::SwapWrite(int page , int pos){
  21. OpenFile * swap = fileSystem -> Open("Swap"); //We open the swap file
  22. swap -> WriteAt (&(machine -> mainMemory[page*PageSize]), PageSize, pos*PageSize); //We write the the page to the swap.
  23. delete swap; //We erase the swap opened file
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement