TD2 II.4 Various fixes on stack allocation

This commit is contained in:
Yorick Barbanneau 2021-11-19 16:52:57 +01:00
parent 3877e32b59
commit c3892a2fa7
4 changed files with 13 additions and 11 deletions

View file

@ -52,11 +52,12 @@ int do_ThreadCreate(int f, int arg){
args->arg = arg;
// Check if we can allocate Stack for our son
int stackAddr = currentThread->space->AllocateUserStack();
if ( stackAddr == -1 ) {
args->stackAddr = currentThread->space->AllocateUserStack();
if ( args->stackAddr == -1 ) {
fprintf(stderr, "Segmentation Fault - no space avaible on stack\n");
Exit(1);
}
DEBUG('x',"Father found stack address: 0x%x\n", args->stackAddr);
// create a new Thread and start it
Thread * newThread = new Thread("new thread");