k_sleep() and C++
Kim Bønderga rd <kim@...>
I posted this (slightly modified) on slack a week ago, but didn't really get any response (on my primary problem)
Hope this is better
I'm mixing CPP and threads.
I've made a C++ 'thread'-class wrapping some of the normal k_thread functions.
The 'entry' function is a static function within the class, using first argument to denote the actual instance of my thread object.Something like this:
From the constructor:
The stack is defined in my thread class like this:
The static runner:
and the instance-specific runner:
threadFunc is a private method like this (example):
It has been working fine on Zephyr 2.2 but now on Zephyr 2.4 I often see crashes with BUS ERRORs.
It seems to always come if a thread calls k_sleep() (but not everytime I call k_sleep())
Inspired by samples/cpp_synchronization I tried changing my k_sleep()'s to k_timer_status_sync() . It made my sample project work again.
I can live with that, but eventually I'll call something calling k_sleep()
Can anyone explain if I'm doing something wrong (and why) or is it a coincidence that k_timer_status_sync() approach is working?