I recently discovered ChibiOS/RT and so far I like it, but there is one problem. If I want to run the code down below, it forever stays in the while loop of thread 1 and never executes the code of thread 2. Am I doing something wrong? I am using a ARM Cortex-M33
I am using this code:
https://gitlab.soft.vub.ac.be/yvdriess/ ... chibiOS/os
Code: Select all
#include "ch.h"
int a = 0;
#define THREADS_STACK_SIZE 128
#define WA_SIZE THD_WA_SIZE(THREADS_STACK_SIZE)
static WORKING_AREA(waThread1, THREADS_STACK_SIZE);
Thread* t1;
static msg_t Thread1(void *p) {
while(1){ <<<<<<<<<<<<<<<<<<<<it stays forever in this while-loop
a++;
if(a > 100) a = 0;
}
chThdExit(0);
return 0;
}
static WORKING_AREA(waThread2, THREADS_STACK_SIZE);
Thread* t2;
static msg_t Thread2(void *p) {
while(1){ <<<<<<<<<<<<<<<<<<<<it never reaches this while-loop
a--;
if(a < -100) a = 0;
}
chThdExit(0);
return 0;
}
int main(){
chSysInit();
t1 = chThdCreateStatic(waThread1, sizeof(waThread1),
NORMALPRIO + 2, Thread1, NULL);
t2 = chThdCreateStatic(waThread2, sizeof(waThread2),
NORMALPRIO + 2, Thread2, NULL);
while(1);
return 0;
}
Thanks in advance,
Arjon