I'm experiencing an strange latency problem in which my high priority threads are being kept from executing for about 1ms (one system tick, might be a clue), and I've traced the problem down to a chThdSleepMilliseconds() call in the main program. Pseudocode would be something like this:
(... removed ...)
[edit 1]
Apparently I rushed to blame chThdSleepMilliseconds(). Turns out some code in mac/mac_lld/lwip is keeping interrupts disabled for too long. I should be able to pinpoint it eventually (I'm using a STM32F407VG).
[edit 2]
Ok. I found it. Like most LLD code, mac_lld_start is called with the systen lock acquired, and it does quite a bunch of no-nos like busy waits (mii_write/read, for example). Definitely the STM32 MAC driver needs some rewriting. Keep in mind a macStart() call in this platform will badly break the OS latency.
I don't have the time at the moment to rewrite the code, so as a workaround I'll move the LWIP thread creation (which is the one calling macInit) BEFORE my other time sensitive threads are started.
Strange latency problem in chThdSleepMilliseconds()
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Strange latency problem in chThdSleepMilliseconds()
Hi,
Thanks for finding, the best workaround is to start the driver before doing critical operations as you already did.
Giovanni
Thanks for finding, the best workaround is to start the driver before doing critical operations as you already did.
Giovanni