home tutorials faq contact
CS tutorials Share you information

Lab 3: Tutorial

This 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:

  • Assignment overview. Details on each topic in a general level and how they are implemented in Nachos.

  • Walk-through. A complete step-by-step guide on how to implement the code necessary to complete each assignment.

  • Frequently asked questions. Questions and answers to common problems students face while completing each assignment.

  • Helpful links. Links to academic and other websites that offer Nachos assistance and documentation.

  • Documentation. Detailed documentation listing all of the classes, structures, functions defined in Nachos.

  • Roadmap. High-level overview of the source code, focusing on the big picture rather than on the details.

  • Source code. The source code solution to each assignment.

This includes both documentation on understanding the concepts for each assignment and how to get started. Topics are accompanied with animations.

All 5 Assignments Tutorial Package

$149.99
Save 40%

Thread Synchronization Assignment Tutorial

$29.99

Multiprogramming and System Calls Assignment Tutorial

$49.99

Virtual Memory Assignment Tutorial

$49.99

Distributed Networking Assignment Tutorial

$39.99

File System Assignment Tutorial

$39.99

Nachos
Tutorials
Roadmap
Source Code

Introduction
Threads
Interrupts
Synchronization
System Calls
Exception Handling
Multiprogramming
File System
Networking

Tutorials
Lab 1 Tutorial
Lab 2 Tutorial
Lab 3 Tutorial
Lab 4 Tutorial
Lab 5 Tutorial


© 1999-2008 - All rights reserved. CS tutorials™ and the logo are registered trademarks of CS tutorials.