TD3:I6 Use PageProvider in AddrSpace
First Working version, need better error handling
This commit is contained in:
parent
7deeec90f1
commit
f7eca8c6ac
5 changed files with 16 additions and 9 deletions
|
@ -32,7 +32,7 @@ THREAD_O := main.o list.o scheduler.o synch.o synchlist.o \
|
||||||
|
|
||||||
USERPROG_O := addrspace.o bitmap.o exception.o progtest.o console.o \
|
USERPROG_O := addrspace.o bitmap.o exception.o progtest.o console.o \
|
||||||
consoledriver.o machine.o mipssim.o translate.o \
|
consoledriver.o machine.o mipssim.o translate.o \
|
||||||
userthread.o papeprovider.o
|
userthread.o pageprovider.o
|
||||||
|
|
||||||
VM_O :=
|
VM_O :=
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -99,7 +99,12 @@ AddrSpace::AddrSpace (OpenFile * executable)
|
||||||
pageTable = new TranslationEntry[numPages];
|
pageTable = new TranslationEntry[numPages];
|
||||||
for (i = 0; i < numPages; i++)
|
for (i = 0; i < numPages; i++)
|
||||||
{
|
{
|
||||||
pageTable[i].physicalPage = i; // for now, phys page # = virtual page #
|
// pageTable[i].physicalPage = i; // for now, phys page # = virtual page #
|
||||||
|
#ifdef CHANGED
|
||||||
|
int newPage = pageProvider->GetEmptyPage();
|
||||||
|
ASSERT(newPage != -1);
|
||||||
|
pageTable[i].physicalPage = newPage;
|
||||||
|
#endif
|
||||||
pageTable[i].valid = TRUE;
|
pageTable[i].valid = TRUE;
|
||||||
pageTable[i].use = FALSE;
|
pageTable[i].use = FALSE;
|
||||||
pageTable[i].dirty = FALSE;
|
pageTable[i].dirty = FALSE;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
PageProvider::PageProvider(int n) {
|
PageProvider::PageProvider(int n) {
|
||||||
|
DEBUG ('x', "PageProvider constructor, pages: %i\n", n);
|
||||||
page = new BitMap(n);
|
page = new BitMap(n);
|
||||||
page->Mark(0);
|
page->Mark(0);
|
||||||
}
|
}
|
||||||
|
@ -13,12 +14,13 @@ PageProvider::~PageProvider(){
|
||||||
}
|
}
|
||||||
|
|
||||||
int PageProvider::GetEmptyPage() {
|
int PageProvider::GetEmptyPage() {
|
||||||
int page = page->Find();
|
DEBUG ('x', "GetEmptyPage()\n");
|
||||||
if(emptyPage != -1)
|
int newPage = page->Find();
|
||||||
|
if(newPage == -1)
|
||||||
return -1;
|
return -1;
|
||||||
memset(machine->mainMemory+emptyPage * PageSize, 0, PageSize);
|
memset(machine->mainMemory+newPage * PageSize, 0, PageSize);
|
||||||
DEBUG ('a', "Allocated page: %i\n", page);
|
DEBUG ('x', "PageProvider: Allocated page: %i\n", newPage);
|
||||||
return page;
|
return newPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PageProvider::ReleasePage(int n) {
|
void PageProvider::ReleasePage(int n) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue