vm.c
//This method cannot be replaced with mappages because mappages cannot turn off PTE_PG bit
This method cannot be replaced with mappages because mappages cannot turn off PTE_PG bit
This method cannot be replaced with mappages because mappages cannot turn off PTE_PG bit
void fixPagedInPTE(int userPageVAddr, int pagePAddr, pde_t * pgdir){
  pte_t *pte;
  pte = walkpgdir(pgdir, (int*)userPageVAddr, 0);
  if (!pte)
    panic("PTE of swapped page is missing");
  if (*pte & PTE_P)
  	panic("PAGE IN REMAP!");
  *pte |= PTE_P | PTE_W | PTE_U;      
  *pte &= ~PTE_PG;    								
  *pte |= pagePAddr;  								
  lcr3(v2p(proc->pgdir)); 
}
void fixPagedInPTE ( int userPageVAddr , int pagePAddr , pde_t * pgdir ) { pte_t * pte ; pte = walkpgdir ( pgdir , ( int * ) userPageVAddr , 0 ) ; if ( ! pte ) panic ( " " ) ; if ( * pte & PTE_P ) panic ( " " ) ; * pte |= PTE_P | PTE_W | PTE_U ; * pte &= ~ PTE_PG ; * pte |= pagePAddr ; lcr3 ( v2p ( proc -> pgdir ) ) ; }
This method cannot be replaced with mappages because mappages cannot turn off PTE_PG bit
This method cannot be replaced with mappages because mappages cannot turn off PTE_PG bit
//Turn on needed bits //Turn off inFile bit //Map PTE to the new Page //refresh CR3 register