Thread priorities...
Posted: Tue Sep 17, 2019 8:02 pm
In a project I'm working on it looks as if one of my threads is not running as often as it is supposed to.
It is as if there is a high priority thread that is blocking my worker-thread. But each time I stop the system with the debugger, I find that execution stopped in idle_thread.
If my analysis of the following gdb stuff is correct, chibios is running "idle_tread" at prio 1, while my DMX_IO thread is runnable (it is on the rlist).
There is also a blinky thread: It blinks a led. Each time "blinky" toggles the led, it seems that my DMX_IO thread gets a chance to run.
When my DMX_IO thread is waiting for the IO to finish It sleeps for half a milisecond before checking a few global variables, and going to sleep again. But with blinky doing 350 and 700 ms on/off periods that 5 ticks sleep seems to sleep for hundreds of ms (350 or 700 in fact).
Any suggestions to get to the bottom of this?
It is as if there is a high priority thread that is blocking my worker-thread. But each time I stop the system with the debugger, I find that execution stopped in idle_thread.
If my analysis of the following gdb stuff is correct, chibios is running "idle_tread" at prio 1, while my DMX_IO thread is runnable (it is on the rlist).
There is also a blinky thread: It blinks a led. Each time "blinky" toggles the led, it seems that my DMX_IO thread gets a chance to run.
When my DMX_IO thread is waiting for the IO to finish It sleeps for half a milisecond before checking a few global variables, and going to sleep again. But with blinky doing 350 and 700 ms on/off periods that 5 ticks sleep seems to sleep for hundreds of ms (350 or 700 in fact).
Any suggestions to get to the bottom of this?
Code: Select all
(gdb) print ch.rlist
$2 = {queue = {next = 0x20001a60 <waDMX_IO+512>, prev = 0x20001a60 <waDMX_IO+512>},
prio = 0, ctx = {sp = 0x0}, current = 0x20001e00 <ch_idle_thread_wa+144>}
(gdb) print * (thread_t *) 0x20001a60
$4 = {queue = {next = 0x20002368 <ch>, prev = 0x20002368 <ch>}, prio = 130, ctx = {
sp = 0x200019cc <waDMX_IO+364>}, wabase = 0x20001860 <waDMX_IO>, state = 0 '\000',
flags = 0 '\000', u = {rdymsg = -1, exitcode = -1, wtobjp = 0xffffffff,
wttrp = 0xffffffff, wtsemp = 0xffffffff}}
(gdb) print * (thread_t *) 0x20001e00
$5 = {queue = {next = 0x20002368 <ch>, prev = 0x20002368 <ch>}, prio = 1, ctx = {
sp = 0x20001dac <ch_idle_thread_wa+60>}, wabase = 0x20001d70 <ch_idle_thread_wa>,
state = 1 '\001', flags = 0 '\000', u = {rdymsg = 0, exitcode = 0, wtobjp = 0x0,
wttrp = 0x0, wtsemp = 0x0}}
(gdb)