Code: Select all
void worker_thread_init(/*...*/) {
void* working_area = chCoreAllocAligned(THD_WORKING_AREA_SIZE(stack_size), PORT_WORKING_AREA_ALIGN);
if (!working_area) {
return;
}
/*...*/
chDbgCheck(ch.dbg.lock_cnt == 0);
worker_thread->thread = chThdCreateStatic(working_area, THD_WORKING_AREA_SIZE(stack_size), prio, worker_thread_func, worker_thread);
chThdSleep(TIME_INFINITE);
}
And I've put this debug check at the top of the thread function:
Code: Select all
static THD_FUNCTION(worker_thread_func, arg) {
chDbgCheck(ch.dbg.lock_cnt == 0);
/*...*/
}
The debug check in worker_thread_func fails. The one in worker_thread_init does not.
I've banged my head against this for several hours now. Any idea what's going on?