Replies: 2 comments 3 replies
-
Without much thinking, I would say that µOS++ might benefit from the use of it in some locations, but I see two difficulties:
This is a tough question, and I don't have an answer yet. Generally, by design, However, my feeling is that not all these actions that must be done uninterrupted really need this, and some might be reworked to use std::atomic, but it is hard to tell now. This will definitely require some thorough understanding of the atomic primitives, on both Arm and RISC-V devices. There is also the question of performances in a multi-threaded environment, and how exactly the locks are implemented. I did a quick test with:
and the generated code for a Cortex-M7 looks like this:
which is a small busy wait loop to access the associated monitor. It might not be a big deal, and happen very rarely, but generally multi-threaded implementations should avoid busy waits, since they simply waste cycles. I am open to any other thoughts on the subject. |
Beta Was this translation helpful? Give feedback.
-
Also, from what I see the RISC-V toolchain is not there yet. Or does that depend on the specific RISC-V architecture? I have a small project for a ch32v003 microcontroller (RV32EC) and atomic is not implemented. When I use an atomic in that project I get a linker error:
|
Beta Was this translation helpful? Give feedback.
-
Now that modern arm gcc for bare-metal includes an implementation of std::atomic I was wondering if µOS++ might benefit from the use of it in some locations. From what I've seen, std::atomic<uint32_t> is always lock free on cortex-M4 (not on cortex-M0 though) and I think some structures might benefit from it.
Also, I am curious how locking of the atomic library compares to the locking that µOS++ is currently using (e.g. disabling the interrupts below a pre-defined priority).
Beta Was this translation helpful? Give feedback.
All reactions