TD2 II.3 add for in threadcreate

We've got problem since thread stack are the same
This commit is contained in:
Yorick Barbanneau 2021-11-16 23:01:19 +01:00
parent feff887fa0
commit 6e0d91918a

View file

@ -2,8 +2,13 @@
#include "syscall.h" #include "syscall.h"
void f(int c) { void f(int c) {
PutChar((char)c); /* Since our stack is shared with other threads, we've got
//GetChar(); * 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(); ThreadExit();
} }
@ -12,7 +17,7 @@ int main(){
for (i=64; i < 68; i++){ for (i=64; i < 68; i++){
ThreadCreate(f, i); ThreadCreate(f, i);
} }
PutString("end of main()\n"); // PutString("end of main()\n");
ThreadExit(); ThreadExit();
//return 0; //return 0;
} }