We are building an extremely latency sensitive application. Our full application takes about 2500 clock cycles in a process apart from locking, and there are two locks that need to be acquired and released. We expect no contention 99.98% of the time. Using pthread lock and unlock takes about 1800 additional cycles. Any pointers in faster formulations ? Writing locks based on atomic operations might be tricky. We would prefer using standard code as in Linux headers or boost headers if possible.
As a suggestion, try spin_mutex from Intel's Threading Building Blocks library. It's open-source (GPLv2), so you can also inspect sources for implementation details.
Also you may look at this: Is my spin lock implementation correct and optimal?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With