ch.rlist initialization with CH_CFG_NO_IDLE_THREAD

Discussions and support about ChibiOS/RT, the free embedded RTOS.
lungj
Posts: 8
Joined: Wed Feb 03, 2016 7:57 am
Been thanked: 1 time

ch.rlist initialization with CH_CFG_NO_IDLE_THREAD

Postby lungj » Wed Apr 13, 2016 11:46 pm

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: 11729
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 496 times
Been thanked: 421 times
Contact:

Re: ch.rlist initialization with CH_CFG_NO_IDLE_THREAD

Postby Giovanni » Thu Apr 14, 2016 7:54 am

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: 236
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 32 times
Been thanked: 31 times

Re: ch.rlist initialization with CH_CFG_NO_IDLE_THREAD

Postby faisal » Wed Apr 10, 2019 7:08 pm

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: 11729
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 496 times
Been thanked: 421 times
Contact:

Re: ch.rlist initialization with CH_CFG_NO_IDLE_THREAD

Postby Giovanni » Wed Apr 10, 2019 8:57 pm

Yes, an assertion is a good idea.

Giovanni


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 2 guests