TD3 II.4 Betten error handling on ForkExec()

This commit is contained in:
Yorick Barbanneau 2021-12-17 00:36:28 +01:00
parent 215a071a13
commit 20e058d610
2 changed files with 5 additions and 3 deletions

View file

@ -102,7 +102,9 @@ AddrSpace::AddrSpace (OpenFile * executable)
// pageTable[i].physicalPage = i; // for now, phys page # = virtual page # // pageTable[i].physicalPage = i; // for now, phys page # = virtual page #
#ifdef CHANGED #ifdef CHANGED
int newPage = pageProvider->GetEmptyPage(); int newPage = pageProvider->GetEmptyPage();
ASSERT(newPage != -1); if (newPage == -1) {
throw std::bad_alloc();
}
pageTable[i].physicalPage = newPage; pageTable[i].physicalPage = newPage;
#endif #endif
pageTable[i].valid = TRUE; pageTable[i].valid = TRUE;

View file

@ -99,7 +99,7 @@ void do_ThreadExit(){
void StartUserProc( void * args ){ void StartUserProc( void * args ){
currentThread->space->InitRegisters(); currentThread->space->InitRegisters();
currentThread->space->RestoreState(); currentThread->space->RestoreState();
machine->DumpMem("memory.svg"); //machine->DumpMem("memory.svg");
machine->Run(); machine->Run();
} }
@ -119,7 +119,7 @@ int do_ForkExec( const char * c){
try { try {
space = new AddrSpace(file); space = new AddrSpace(file);
}catch(const std::bad_alloc& e) { }catch(const std::bad_alloc& e) {
fprintf(stderr,"no empty space on memory\n"); fprintf(stderr,"Could not allocate Memory\n");
Exit(1); Exit(1);
} }