Hi.
I have project on STM32F303 mcu with ChibiOS 17.6.5.
It has 5 threads. At some moment one thread is stopping. The DEBUG shows that his state is CH_STATE_READY.
This happens very rarely. Maybe once an hour or maybe less. This began to happen after certain changes in the program:
One of then is that I switched to tickless mode with CH_CFG_ST_FREQUENCY = 10000 and CH_CFG_ST_TIMEDELTA = 2.
If I changed compiller options then the problem dissapears. What is the reason that the thread is in Ready state all time and do not switch to Run state at all. May be this is effect of corruption of system variables by other error or may be 10kHz is too fast for 72MHz MCU or what it can be?
Thread freezes in Ready state
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Thread freezes in Ready state
10kHz is not too much, all demos use those settings.
Are debug options enabled in chconf.h?
Giovanni
Are debug options enabled in chconf.h?
Giovanni
-
- Posts: 276
- Joined: Mon Sep 24, 2012 3:52 pm
- Location: Donetsk
- Been thanked: 32 times
- Contact:
Re: Thread freezes in Ready state
I was developed the project long time with all debug options on and have no problems. When I released the final project with all debug options off then I have troubles.
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Thread freezes in Ready state
Which option triggers the trouble? any of them? all of them? a specific one?
Probably it is a race condition triggered when the code becomes "faster".
Giovanni
Probably it is a race condition triggered when the code becomes "faster".
Giovanni
-
- Posts: 276
- Joined: Mon Sep 24, 2012 3:52 pm
- Location: Donetsk
- Been thanked: 32 times
- Contact:
Re: Thread freezes in Ready state
This is difficult to understand because I need hours to try one variant. I have 2 global options: DEBUG (all debug options and assertions is ON and compiller optimization is OFF) and RELESE (all debug options are OFF and compiller optimization is MAX).
Strange thing that I added some new functionaliity that does not interact with this thread, but if I switch option to OFF of the new functionality in runtime then I have no trouble with that thread. When the thread is freezes the new functionality stay working and other functionality working too.
Now I have working project with frozen thread. I can show You some variables if it will help.
I tried to debug the stack of the thread to find the point of the trouble but can't find it exact. Plus compiler optimizations change the code.
Strange thing that I added some new functionaliity that does not interact with this thread, but if I switch option to OFF of the new functionality in runtime then I have no trouble with that thread. When the thread is freezes the new functionality stay working and other functionality working too.
Now I have working project with frozen thread. I can show You some variables if it will help.
I tried to debug the stack of the thread to find the point of the trouble but can't find it exact. Plus compiler optimizations change the code.
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Thread freezes in Ready state
I am not sure to understand what do you mean by "stopping" in ready state. Is it never executed again while other threads are still running?
Look at the state of all other threads and to the trace buffer, you can use the ChibiOS debug plugin for this.
You may also use chSysIntegrityCheckI() in some thread in order to check system integrity.
Giovanni
Look at the state of all other threads and to the trace buffer, you can use the ChibiOS debug plugin for this.
You may also use chSysIntegrityCheckI() in some thread in order to check system integrity.
Giovanni
-
- Posts: 276
- Joined: Mon Sep 24, 2012 3:52 pm
- Location: Donetsk
- Been thanked: 32 times
- Contact:
Re: Thread freezes in Ready state
Hello.
I am using KEIL, debug plugin not possible.
Yes, the thread never running while other threads still running. The variable state of this thread is zero = CH_STATE_READY and never changed.
I was found that this happened after executing the code
About chSysIntegrityCheckI() it is interesting, I will try it.
I am using KEIL, debug plugin not possible.
I am not sure to understand what do you mean by "stopping" in ready state. Is it never executed again while other threads are still running?
Yes, the thread never running while other threads still running. The variable state of this thread is zero = CH_STATE_READY and never changed.
I was found that this happened after executing the code
Code: Select all
chThdSleepMicroseconds(500);
About chSysIntegrityCheckI() it is interesting, I will try it.
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Thread freezes in Ready state
If a ready thread is never executed probably it is because there is an higher priority thread that does not release the CPU.
Giovanni
Giovanni
-
- Posts: 276
- Joined: Mon Sep 24, 2012 3:52 pm
- Location: Donetsk
- Been thanked: 32 times
- Contact:
Re: Thread freezes in Ready state
There are no threads that load the CPU for 100% and this thread has maximum priority. When I pause the execution of the program it is often is in IDLE loop.
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Thread freezes in Ready state
alexblack wrote:There are no threads that load the CPU for 100% and this thread has maximum priority. When I pause the execution of the program it is often is in IDLE loop.
Clip2net_180529104204.jpg
Then it is possible that the thread is not in the ready list even if it is ready, do that integrity check. you may also inspect the ready list using the debugger and see if it is as expected.
Giovanni
Return to “Development and Feedback”
Who is online
Users browsing this forum: No registered users and 75 guests