Hello,
if I use several threads in RTX V5 I can pass control to another thread if I call a function like osDelay(), osThreadYield() etc.
If the thread does not pass control to another thread, the round-robin-timeout passes control to another thread.
Can I trigger on such a round-robin-timeout event?
Thank you.
Hello Gunnar,
to pass control between threads, you should not use the functions that you have mentioned. Please take a look at the Thread Flags: https://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__ThreadFlagsMgmt.html which should be much better suited or that purpose.
Kind regards,
Christopher
Hi Christopher,
thank you for an answer.You are right, if I want to explicitely pass control to another thread I would rather send a flag.The main question is:If fy firmware has a bug and does *not* pass control to another thread with same priority, I would not see this bug directly, because the scheduler automatically passes control to the other thread if the round-robin-timeout is reached.Therefor I would like to get an event for this case. (event: thread change caused by round-robin-timeout).
Regards,
Gunnar
Sounds like a job for: EventRecorder! Check out http://www2.keil.com/mdk5/cmsis/rtx/rtos-awareness, which shows events from thread preemption.
As mentioned earlier, the EventRecorder shows when a thread is preempted. However this event is generated on any thread preemption and not just on round-robin timeout. There is no separate event on just round-robin timeout.
If you want to go along this path, here are some options.
1) You can build the OS with Debug, link this library and add the source to your project (no need to build it) and put a break point in the code that does the does the Round Robin Preemption
2) There are 3 calls to EvrRtxThreadPreempted(). 1 is in the Round Robin Code, 1 in ThreadBlock and 1 in threadYield. Remove the ones in ThreadBlock and ThreadYield. This will mean that any ThreadPreempted will now only be for Round Robin.
Thanks a lot for this hints.Option 1) sounds good.
I will try to add an EventRecorder entry in the code when the RoundRobin Preemtion is done.