From 6e0d91918ab0fac94237b2d14668d0cefddcd415 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Tue, 16 Nov 2021 23:01:19 +0100 Subject: [PATCH] TD2 II.3 add for in threadcreate We've got problem since thread stack are the same --- code/test/threadcreate.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/code/test/threadcreate.c b/code/test/threadcreate.c index 23d896b..9861c8b 100644 --- a/code/test/threadcreate.c +++ b/code/test/threadcreate.c @@ -2,8 +2,13 @@ #include "syscall.h" void f(int c) { - PutChar((char)c); - //GetChar(); + /* Since our stack is shared with other threads, we've got + * a problem here, when executing a thread there is not 8 iterations. + * This is like synchronisation */ + volatile int i; + for (i=0;i<8;i++){ + PutChar((char)c); + } ThreadExit(); } @@ -12,7 +17,7 @@ int main(){ for (i=64; i < 68; i++){ ThreadCreate(f, i); } - PutString("end of main()\n"); + // PutString("end of main()\n"); ThreadExit(); //return 0; }