From f277111e1c3ec4fd398464b0a0848497a91536bf Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Fri, 19 Nov 2021 22:09:45 +0100 Subject: [PATCH] TD2 II.4 Error is not a SegFault but a Stack Overflow ' --- code/test/threadcreate.c | 2 +- code/userprog/userthread.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code/test/threadcreate.c b/code/test/threadcreate.c index d19848e..a11cff0 100644 --- a/code/test/threadcreate.c +++ b/code/test/threadcreate.c @@ -14,7 +14,7 @@ void f(int c) { int main(){ int i; - for (i=65; i < 68; i++){ + for (i=65; i < 98; i++){ ThreadCreate(f, i); } // PutString("end of main()\n"); diff --git a/code/userprog/userthread.cc b/code/userprog/userthread.cc index 3904fac..9267df8 100644 --- a/code/userprog/userthread.cc +++ b/code/userprog/userthread.cc @@ -54,7 +54,7 @@ int do_ThreadCreate(int f, int arg){ // Check if we can allocate Stack for our son args->stackAddr = currentThread->space->AllocateUserStack(); if ( args->stackAddr == -1 ) { - fprintf(stderr, "Segmentation Fault - no space avaible on stack\n"); + fprintf(stderr, "Stack Overflow\n"); Exit(1); } DEBUG('x',"Father found stack address: 0x%x\n", args->stackAddr); @@ -88,7 +88,7 @@ void do_ThreadExit(){ if ( currentThread->space->threads == 0 ){ // No threads remains, desallocate addrspace delete currentThread->space; - interrupt->Powerdown(); + Exit(0); } currentThread->Finish(); }