Page 1 of 1

chThdCreateStatic hangs

Posted: Wed Jul 27, 2016 1:17 am
by Al B
Hi,

In testing LwIP, had an issue with chThdCreateStatic hanging, if CH_CFG_NO_IDLE_THREAD = TRUE.

In the lwip_bindings/lwipthread.c lwipInit code:
/* Creating the lwIP thread (it changes priority internally).*/
chThdCreateStatic(wa_lwip_thread, sizeof (wa_lwip_thread),
chThdGetPriorityX() - 1, lwip_thread, (void *)opts);

this causes chSchReadyI to hang since it can't insert the thread (line 231).

Easy enough to work around, by creating an IDLE thread, or by changing priority of the lwip thread, but maybe some other checks/protection should also be provided in the OS?

Thanks,
Al

Re: chThdCreateStatic hangs

Posted: Wed Jul 27, 2016 8:20 am
by Giovanni
Hi,

When that option is set to TRUE the main() function is your idle thread, you must not sleep in there. This option is there for compatibility with NIL or if you want to save one thread when you have nothing to do in main().

About the lwIP thread, probably there should be an assertion there, it cannot work with this option enabled. You may initialize lwIP from another thread as workaround.

Giovanni