|
| |
![]() |
|
Lab 3: TutorialThis is ONLY a preview of the tutorial. If you would like to view the entire tutorial, you must purchase the tutorial.Implementing the TLB--So, first of all you will have to change the addrspace's Restore State function so that instead of assigning the machine->pageTable to the user page table. You will have to invalidate the TLB entries so that when another process comes in it should get these entries invalidated , since these pages belong to the different process. --You will have to write the code for catching the PageFault Exception in Exception handler function in userprog/exception.cc. Lets see further how to write it . -- Now Recall the path we followed from the vm directory and we got assertion failure. When you will change the RestoreState function you will not get the assertion failure. But since you have to do further . the Translate function will see that the tlb does not contain the required page so it will return the PageFaultException . So, when ReadMem Function will see exception it will raise the exception and will pass the exception name which is obviously the PageFaultException , to the RaiseException function. The second argument will be the address at which the exception occurred . That address will be stored in the BadVaddrReg register in the RaiseExceptionFunction. Now, you have to do something in exception handler function in exception.cc
If (PagefaultException)
{
**get the virtual address at which the page fault occurred
by using machine->ReadRegister(....)
**calculate the virtual page number .
**find the physical page number corresponding to that virtual page number
, from the user page Table.
** Load the TLB entry with that page number and make it valid
**Increment the TLB index
}
...
int PageFaultExceptionHandler(int vaddr)
{
#ifdef USE_TLB
DEBUG('F', "PageFaultException has occured.\n");
// calculate the vpn
DEBUG('F', "Virtual address passed was 0x%x\n", vaddr);
int vpn = vaddr / PageSize;
DEBUG('F', "Calculated vpn was 0x%x\n", vpn);
TranslationEntry* PT = currentThread->space->PageTable();
/* TranslationEntry TE;
TranslationEntry TEold; AddrSpace *pSpace = NULL;
TE.virtualPage = vpn;
if (SUCCESS == memmgrObj.IsInMem(&TE, currentThread->space)) {
DEBUG('F', "Swap into TLB index %d, vpn = 0x%x, ppn = 0x%x\n",
TLBIndex, vpn, TE.physicalPage);
machine->tlb[TLBIndex].virtualPage = TE.virtualPage;
...
This is ONLY a preview of the tutorial. If you would like to view the entire tutorial, you must purchase the tutorial.Each tutorial comes with the following:
This includes both documentation on understanding the concepts for each assignment and how to get started. Topics are accompanied with animations.
|
Nachos Introduction Tutorials |
||||||||||||||||||
| © 1999-2008 - All rights reserved. CS tutorials™ and the logo are registered trademarks of CS tutorials. | |||||||||||||||||||