ch.rlist initialization with CH_CFG_NO_IDLE_THREAD Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
Post Reply
lungj
Posts: 8
Joined: Wed Feb 03, 2016 7:57 am
Been thanked: 1 time

ch.rlist initialization with CH_CFG_NO_IDLE_THREAD

Post by lungj »

It looks like if CH_CFG_NO_IDLE_THREAD is enabled, the thread ready list's next/prev values are set incorrectly. This causes problems when attempting to sleep: an invalid thread address is selected as the next element by queue_fifo_remove in chSchGoSleepS. Is this behaviour intentional?

Code: Select all

int main(void) {
   halInit();
   chSysInit();

   while(1) {
      chThdSleepMilliseconds(1000); // This fails if CH_CFG_NO_IDLE_THREAD is TRUE.
   }
   return 0;
}
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ch.rlist initialization with CH_CFG_NO_IDLE_THREAD

Post by Giovanni »

Hi,

When CH_CFG_NO_IDLE_THREAD is enabled then the main() function is the idle thread, you must never try to sleep in there. Doing so causes the problems you are describing.

Giovanni
faisal
Posts: 382
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 45 times
Been thanked: 62 times

Re: ch.rlist initialization with CH_CFG_NO_IDLE_THREAD

Post by faisal »

Giovanni wrote:Hi,

When CH_CFG_NO_IDLE_THREAD is enabled then the main() function is the idle thread, you must never try to sleep in there. Doing so causes the problems you are describing.

Giovanni


Is this still the case? If so, there should be an assert somewhere to catch this. I think chSchGoSleepS is the right place.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ch.rlist initialization with CH_CFG_NO_IDLE_THREAD

Post by Giovanni »

Yes, an assertion is a good idea.

Giovanni
Dzarda
Posts: 21
Joined: Sat Feb 28, 2015 2:28 pm
Has thanked: 7 times
Been thanked: 5 times

Re: ch.rlist initialization with CH_CFG_NO_IDLE_THREAD

Post by Dzarda »

I got burned by this again, I think that an assertion should be very suitable.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ch.rlist initialization with CH_CFG_NO_IDLE_THREAD

Post by Giovanni »

Moving into "bug reports" so it is not lost in the noise.

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ch.rlist initialization with CH_CFG_NO_IDLE_THREAD

Post by Giovanni »

Hi,

Assertion added in thunk code.

Giovanni
Post Reply