IllinoisRoboticsInSpace / IRIS

Illinois Robotics in Space 2022-2023 Season
https://iris.ae.illinois.edu/
8 stars 0 forks source link

Ring Buffer Dependency Not Compiling with Atomic Code #32

Closed ttchalakov closed 6 months ago

ttchalakov commented 6 months ago

Investigating this issue here: https://github.com/MaJerle/lwrb/issues/35

Ring Buffer dependency for Arduino motor driver compiles but without atomic operation.

ttchalakov commented 6 months ago

Closing issue following discussion from linked issue. Summary of what was learned and decided:

  1. lwrb (Light Weight Ring Buffer) is written in C and our C++ project can compile the code without atomic operations enabled, but it can not with atomic operations enabled.
  2. Compilation with atomics does not work because the C header uses _Atomic which is a C keyword and C++ binaries can not link to C specific feature.
  3. While in theory have atomic access to the lwrb is faster than using a mutex, our current implementation will implement thread safety using a mutex for the time being.
  4. The author of lwrb has expressed interest in writing a C++ compatible version of lwrb. It would also be an option for our team to help contribute if anyone is interested because the C code will just need to be rewritten with the <atomic> C++ library instead of stdatomic C library.