Synchronize multiple threads, so as to make them all wait until say the system init is complete.
I'm thinking Events, so all the required threads calll chEvtWaitOne( EVENT_MASK(0) ); before the while(1);
Once system init is completed, call chEvtBroadcast( &eventsource ); and the threads waiting will come to life.
Is one to many feasible ?
Synchronize Multiple Threads
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Synchronize Multiple Threads
Hi,
Yes, it is feasible but why don't just create them after initialization?
Giovanni
Yes, it is feasible but why don't just create them after initialization?
Giovanni
Re: Synchronize Multiple Threads
so this is my application structure
As you can see i normally create the thread when i call to initialize the module. What this means is the threads start to run.
I could put the chThdCreateStatic is another function that is called later, but this does not seem logical
Code: Select all
int main(void)
{
halInit();
chSysInit();
initModuleA();
initModuleB();
initModuleC();
initModuleD();
while(1)
{
chThdSleepMilliseconds(1000);
}
}
void initModuleA(void)
{
init module vars etc
chThdCreateStatic( MODWA,
sizeof(MODWA),
NORMALPRIO,
ThreadFunc,
NULL );
}
As you can see i normally create the thread when i call to initialize the module. What this means is the threads start to run.
I could put the chThdCreateStatic is another function that is called later, but this does not seem logical