TD2 II.4 Error is not a SegFault but a Stack Overflow

'
This commit is contained in:
Yorick Barbanneau 2021-11-19 22:09:45 +01:00
parent c3892a2fa7
commit f277111e1c
2 changed files with 3 additions and 3 deletions

View file

@ -14,7 +14,7 @@ void f(int c) {
int main(){ int main(){
int i; int i;
for (i=65; i < 68; i++){ for (i=65; i < 98; i++){
ThreadCreate(f, i); ThreadCreate(f, i);
} }
// PutString("end of main()\n"); // PutString("end of main()\n");

View file

@ -54,7 +54,7 @@ int do_ThreadCreate(int f, int arg){
// Check if we can allocate Stack for our son // Check if we can allocate Stack for our son
args->stackAddr = currentThread->space->AllocateUserStack(); args->stackAddr = currentThread->space->AllocateUserStack();
if ( args->stackAddr == -1 ) { if ( args->stackAddr == -1 ) {
fprintf(stderr, "Segmentation Fault - no space avaible on stack\n"); fprintf(stderr, "Stack Overflow\n");
Exit(1); Exit(1);
} }
DEBUG('x',"Father found stack address: 0x%x\n", args->stackAddr); DEBUG('x',"Father found stack address: 0x%x\n", args->stackAddr);
@ -88,7 +88,7 @@ void do_ThreadExit(){
if ( currentThread->space->threads == 0 ){ if ( currentThread->space->threads == 0 ){
// No threads remains, desallocate addrspace // No threads remains, desallocate addrspace
delete currentThread->space; delete currentThread->space;
interrupt->Powerdown(); Exit(0);
} }
currentThread->Finish(); currentThread->Finish();
} }