Skip to main content

A Portable Lock-Free Bounded Queue

  • Conference paper
  • First Online:
Algorithms and Architectures for Parallel Processing (ICA3PP 2016)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 10048))

Abstract

Attaining efficient and portable lock-free containers is challenging as almost any CPU family implements slightly different memory models and atomic read-modify-write operations. C++11 offers a memory model and operation abstractions that enable portable implementations of non-blocking algorithms. In this paper, we present a first scalable and portable lock-free bounded queue supporting multiple readers and multiple writers. Our design uses unique empty values to decouple writing an element from incrementing the tail during enqueue. Dequeue employs a helping scheme that delays helping in the regular case, thereby reducing contention on shared memory. We evaluate our implementation on architectures featuring weak and strong memory consistency models. Our comparison with known blocking and lock-free designs shows that the presented implementation scales well on architectures that implement a weak memory consistency model.

P. Pirkelbauer—This work was partially funded by a Google Research Award, and by NSF grants CNS-0821497 and CNS-1229282. We thank the anonymous reviewers for their suggestions for improvements.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

References

  1. Batty, M., Dodds, M., Gotsman, A.: Library abstraction for C/C++ concurrency. SIGPLAN Not. 48(1), 235–248 (2013)

    Article  MATH  Google Scholar 

  2. Boehm, H.-J., Adve, S.V.: Foundations of the C++ concurrency memory model. In: PLDI 2008, pp. 68–78. ACM (2008)

    Google Scholar 

  3. Feldman, S., Dechev, D.: A wait-free multi-producer multi-consumer ring buffer. SIGAPP Appl. Comput. Rev. 15(3), 59–71 (2015)

    Article  Google Scholar 

  4. Franke, H., Russell, R., Kirkwood, M.: Fuss, futexes, furwocks: fast user level locking in linux. In: Linux Symposium in Ottawa, pp. 479–491 (2002)

    Google Scholar 

  5. Fraser, K., Harris, T.: Concurrent programming without locks. ACM Trans. Comput. Syst. 25(2), 5 (2007)

    Article  Google Scholar 

  6. Frechilla, F.: Yet another implementation of a lock-free circular array queue, April 2011. http://www.codeproject.com/Articles/153898/Yet-another-implementation-of-a-lock-free-circular. Accessed 3 Mar 2013

  7. Greenebaum, K., Barzel, R.: Audio Anecdotes II: Tools, Tips, and Techniques for Digital Audio. A K Peters/CRC Press, Natick (2004)

    Google Scholar 

  8. Hedström, K.: Lock-free single-producer - single consumer circular queue, December 2012. http://www.codeproject.com/Articles/43510/Lock-Free-Single-Producer-Single-Consumer-Circular. Accessed 10 Jan 2013

  9. Herlihy, M., Shavit, N.: The Art of Multiprocessor Programming, revised 1st edn. Morgan Kaufmann Publishers Inc., San Francisco (2012)

    Google Scholar 

  10. Herlihy, M.P., Wing, J.M.: Linearizability: a correctness condition for concurrent objects. ACM Trans. Program. Lang. Syst. 12(3), 463–492 (1990)

    Article  Google Scholar 

  11. ISO/IEC 14882 International Standard. Programming Language C++. JTC1/SC22/WG21 - The C++ Standards Committee (2011)

    Google Scholar 

  12. Kirsch, C., Lippautz, M., Payer, H.: Fast and scalable k-FIFO queues. Technical report TR2012-04, University of Salzburg (2012)

    Google Scholar 

  13. Kogan, A., Petrank, E.: Wait-free queues with multiple enqueuers and dequeuers. In: PPoPP 2011, pp. 223–234. ACM, New York (2011)

    Google Scholar 

  14. Lamport, L.: Specifying concurrent program modules. ACM Trans. Program. Lang. Syst. 5(2), 190–222 (1983)

    Article  MATH  Google Scholar 

  15. Lee, P.P.C., Bu, T., Chandranmenon, G.: A lock-free, cache-efficient shared ring buffer for multi-core architectures. In: ANCS 2009, pp. 78–79. ACM, New York (2009)

    Google Scholar 

  16. Luchangco, V., Moir, M., Shavit, N.: Nonblocking k-compare-single-swap. In: Proceedings of the Fifteenth Annual ACM Symposium on Parallel Algorithms and Architectures, SPAA 2003, pp. 314–323. ACM, New York (2003)

    Google Scholar 

  17. McKenney, P.: Memory ordering in modern microprocessors (draft), September 2007. http://www.rdrop.com/users/paulmck/scalability/paper/ordering.2007.09.19a.pdf. Accessed 20 Feb 2013

  18. Michael, M.M.: Safe memory reclamation for dynamic lock-free objects using atomic reads and writes. In: PODC 2002, pp. 21–30. ACM, New York (2002)

    Google Scholar 

  19. Michael, M.M.: CAS-based lock-free algorithm for shared deques. In: Kosch, H., Böszörményi, L., Hellwagner, H. (eds.) Euro-Par 2003. LNCS, vol. 2790, pp. 651–660. Springer, Heidelberg (2003). doi:10.1007/978-3-540-45209-6_92

    Chapter  Google Scholar 

  20. Moir, M., Nussbaum, D., Shalev, O., Shavit, N.: Using elimination to implement scalable and lock-free FIFO queues. In: SPAA 2005, pp. 253–262. ACM, New York (2005)

    Google Scholar 

  21. Norris, B., Demsky, B.: CDSchecker: checking concurrent data structures written with C/C++ atomics. In: OOPSLA 2013, pp. 131–150. ACM, New York (2013)

    Google Scholar 

  22. Pirkelbauer, P.: Non-blocking programming techniques. University of Innsbruck, Invited Talk (2013)

    Google Scholar 

  23. Pirkelbauer, P.: Portable non-blocking data structures. University of Alabama, Invited Talk (2013)

    Google Scholar 

  24. Sarkar, S., Memarian, K., Owens, S., Batty, M., Sewell, P., Maranget, L., Alglave, J., Williams, D.: Synchronising C/C++ and POWER. In: PLDI, PLDI 2012, pp. 311–322. ACM, New York (2012)

    Google Scholar 

  25. Savage, S., Burrows, M., Nelson, G., Sobalvarro, P., Anderson, T.: Eraser: a dynamic data race detector for multithreaded programs. ACM Trans. Comput. Syst. 15(4), 391–411 (1997)

    Article  Google Scholar 

  26. Shafiei, N.: Non-blocking array-based algorithms for stacks and queues. In: Garg, V., Wattenhofer, R., Kothapalli, K. (eds.) ICDCN 2009. LNCS, vol. 5408, pp. 55–66. Springer, Heidelberg (2008). doi:10.1007/978-3-540-92295-7_10

    Chapter  Google Scholar 

  27. Shann, C.-H., Huang, T.L., Chen, C.: A practical nonblocking queue algorithm using compare-and-swap. In: 7th International Conference on Parallel and Distributed Systems, pp. 470–475 (2000)

    Google Scholar 

  28. Dechev, D., Feldman, S., LaBorde, P.: Tervel (2015). http://ucf-cs.github.io/Tervel/

  29. Stone, J.M.: A nonblocking compare-and-swap algorithm for a shared circular queue. In: Parallel and Distributed Computing in Engineering Systems, pp. 147–152. Elsevier Science B.V. (1992)

    Google Scholar 

  30. Stroustrup, B.: The C++ Programming Language, 4th edn. Addison-Wesley Professional, Salt Lake City (2013)

    MATH  Google Scholar 

  31. Tsigas, P., Zhang, Y.: A simple, fast and scalable non-blocking concurrent FIFO queue for shared memory multiprocessor systems. In: SPAA 2001, pp. 134–143. ACM, New York (2001)

    Google Scholar 

  32. Vyukov, D.: Bounded MPMC queue (2013). http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue. Accessed 21 May 2016

  33. Williams, A.: C++ Concurrency in Action: Practical Multithreading. Manning Publications, Shelter Island (2012)

    Google Scholar 

  34. Yang, C., Mellor-Crummey, J.: A wait-free queue as fast as fast as fetch-and-add. In: PPoPP 2016, pp. 16:1–16:13. ACM, New York (2016)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Peter Pirkelbauer .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2016 Springer International Publishing AG

About this paper

Cite this paper

Pirkelbauer, P., Milewicz, R., Gonzalez, J.F. (2016). A Portable Lock-Free Bounded Queue. In: Carretero, J., Garcia-Blas, J., Ko, R., Mueller, P., Nakano, K. (eds) Algorithms and Architectures for Parallel Processing. ICA3PP 2016. Lecture Notes in Computer Science(), vol 10048. Springer, Cham. https://doi.org/10.1007/978-3-319-49583-5_4

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-49583-5_4

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-49582-8

  • Online ISBN: 978-3-319-49583-5

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics