Recommended way to exit and create threads
Posted: Mon Nov 14, 2016 7:28 am
Hello all,
I have 2 threads which exit themselves and are created by the other, like so:
Is this a recommended way to exit and create the threads?
Thanks.
I have 2 threads which exit themselves and are created by the other, like so:
Code: Select all
static THD_FUNCTION(Thread6, arg)
{
(void)arg;
chRegSetThreadName("6");
/*
* Wait for some error condition to occur
*/
chThdCreateStatic(waThread3, sizeof(waThread3), 62, Thread3, NULL );
chThdExit(0);
}
static THD_FUNCTION(Thread3,arg)
{
(void)arg;
chRegSetThreadName("3");
/*
* Execute some functions
*/
chThdCreateStatic(waThread6, sizeof(waThread6), 50, Thread6, NULL );
chThdSleepMilliseconds(1000);
chThdExit(0);
}
void main()
{
chThdCreateStatic(waThread3, sizeof(waThread3), 62, Thread3, NULL );
while(true)
{
chThdSleepMilliseconds(100);
}
}
In chconf.h
#define CH_CFG_USE_REGISTRY TRUE
#define CH_CFG_USE_WAITEXIT TRUE
Is this a recommended way to exit and create the threads?
Thanks.