A single producer single - single consumer queue implemented by a ring buffer with C11's 'stdatomic.h'
Go to file
Steffen Vogel b602dcd2df Merge branch 'master' of github.com:stv0g/c11-stdatomic-queue 2017-03-31 15:26:13 +02:00
.gitignore Improvements in unbounded queue from gprof results---needs further testing 2016-09-30 15:09:29 +02:00
Makefile SPSC bounded without atomic functions 2016-09-18 21:41:16 +02:00
README.md Initial results for cycles/op added in README 2016-09-27 15:22:51 +02:00
c11threads.h Added C11 threads.h dop-in replacement for compilers with missing C11 thread support (almost all) 2016-08-27 15:54:36 -04:00
memory.c Minor changes to compile the unbounded SPSC queue code 2016-09-09 14:39:50 +02:00
memory.h Minor changes to compile the unbounded SPSC queue code 2016-09-09 14:39:50 +02:00
mpmc_queue.c renamed function (incorrect meaning) 2016-08-28 21:15:47 -04:00
mpmc_queue.h Change MPMC queue to compile on Linux 2016-09-09 18:38:17 +02:00
mpmc_test.c Replace rdtsc with clock_gettime to run on Octopus machine, MPMC shows too good result--not correct most probably 2016-09-21 17:44:56 +02:00
mpmc_test_fib.c Replace rdtscp with rdtsc for older CPU version testing 2016-09-28 17:58:09 +02:00
spsc_queue.c Merge branch 'master' of github.com:stv0g/c11-stdatomic-queue 2017-03-31 15:26:13 +02:00
spsc_queue.h Add atomic functions, memory not freed at the end due to unknown reason 2016-09-18 22:45:10 +02:00
spsc_test_fib.c Replace memory_order_consume with memory_order_acquire as in MPMC implementation 2016-09-30 16:25:57 +02:00
spsc_ub_queue.c Replace memory_order_consume with memory_order_acquire as in MPMC implementation 2016-09-30 16:25:57 +02:00
spsc_ub_queue.h Improvements in unbounded queue from gprof results---needs further testing 2016-09-30 15:09:29 +02:00
spsc_ub_test_default.c Add cycle/op logic in spsc_ub 2016-09-11 15:10:35 +02:00
spsc_ub_test_fib.c Replace rdtscp with rdtsc for older CPU version testing 2016-09-28 17:58:09 +02:00

README.md

Lock-free queues for C11

This Git repository contains lightweight simple implementation of lockless SPSC and MPMC queues.

Some reading material

Existing implementations

Credits

Initial Testing Results

All tests are using mem_heap. All tests use *_fib test.

With clock_gettime function for cycle/op measurement: Octopus Machine: MPMC: 52-54 cycles/op --Something wrong, results too good to be true?? Bounded SPSC: 230-300 cycles/op Unbounded SPSC: 300-400 cycles/op Side note: MPMC default test gets stuck with N=20000000, runs ok with N=2000000 with 160 cycles/op Ubuntu VM: MPMC: 90 cycles/op --Again result too good to be true in my opinion Bounded SPSC: 60-65 cycles/op Unbounded SPSC: 170-175 cycles/op

With rdtscp function for cycle/op measurement: Octopus Machine: Doesn't support rdtscp function, illegal instruction error. So alternate clock_gettime was used as above.

Ubuntu VM: MPMC: 160-200 cycles/op Bounded SPSC: 160-165 cycles/op Unbounded SPSC: 400-420 cycles/op

License

BSD 2-Clause License

All rights reserved.

  • Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.