Miscellaneous
lockfree is a collection of lock-free data structures written in standard C++11 and suitable for all platforms - from deeply embedded to HPC.
Lock-free data structures are data structures that are thread and interrupt safe for concurrent use without having to use mutual exclusion mechanisms. They are most useful for inter process communication and often scale much better than lock-based structures with the number of operations and threads.
Single-producer single-consumer data structures:
Note: These data structures are more performant and should generally be used whenever there is only one thread/interrupt pushing data and another one retrieving it.
Multi-producer multi-consumer data structures:
Note: These data structures are more general, supporting multiple producers and consumers at the same time. However, they have storage and performance overhead compared to single producer single consumer data structures. They also require atomic instructions which can be missing from some low-end microcontrollers.
There are three main ways to get the library:
lockfree uses cacheline alignment for indexes to avoid the False Sharing phenomenon by default, avoiding the performance loss of cacheline invalidation on cache coherent systems. This aligns the indexes to...
Why would I use this over locking data structures on a hosted machine?
The biggest reason you would want to use a lock-free data structure in such a scenario would be performance. Locking has a non-negligible runtime cost on hosted systems as every lock requires a syscall. Additional benefits would be performance from cache locality as lock-free data structures are array-based or code portability to non-POSIX environments.
Why use this over RTOS-provided IPC mechanisms on an embedded system?
While locking usually isn't expensive on embedded systems such as microcontrollers, there is a wide variety of RTOS-es and no standardized API for locking. lockfree provides a way to build portable embedded code with a negligible performance cost as opposed to locking. Code using lockfree can be compiled to run on any embedded platform supporting C++11. Additionally, the code can easily be tested on a host machine without the need for mocking.
What advantages does using C++ over C provide for the library?