Abstract
First-in-first-out (FIFO) queues are among the most fundamental and highly studied concurrent data structures. The most effective and practical dynamic-memory concurrent queue implementation in the literature is the lock-free FIFO queue algorithm of Michael and Scott, included in the standard Java TM Concurrency Package. This work presents a new dynamic-memory concurrent lock-free FIFO queue algorithm that in a variety of circumstances performs better than the Michael and Scott queue. The key idea behind our new algorithm is a novel way of replacing the singly-linked list of Michael and Scott, whose pointers are inserted using a costly compare-and-swap (CAS) operation, by an “optimistic” doubly - linked list whose pointers are updated using a simple store, yet can be “fixed” if a bad ordering of events causes them to be inconsistent. We believe it is the first example of such an “optimistic” approach being applied to a real world data structure.
Similar content being viewed by others
References
Afek Y., Attiya H., Dolev D., Gafni E., Merritt M. and Shavit N. (1993). Atomic snapshots of shared memory. J. ACM. 40(4): 873–890
Agesen O., Detlefs D., Flood C., Garthwaite A., Martin P., Moir M., Shavit N. and Steele G. (2002). DCAS-based concurrent deques. Theo. Comput. Syst. 35(3): 349–386
Cormen T., Leiserson C., Rivest R. and Stein C. (2001). Introduction to Algorithms, 2nd edn. MIT Press, Cambridge
Craig, T.: Building FIFO and priority-queueing spin locks from atomic swap. Technical Report TR 93-02-02, Department of Computer Science, University of Washington (1993)
Gottlieb A., Lubachevsky B.D. and Rudolph L. (1983). Basic techniques for the efficient coordination of very large numbers of cooperating sequential processors. ACM Trans. Progr. Lang. Syst. 5(2): 164–189
Herlihy, M., Luchangco, V., Martin, P., Moir, M.: Dynamic-sized lock-free data structures. In: Proceedings of the Twenty-first Annual Symposium on Principles of Distributed Computing, pp. 131–131. ACM, New York (2002)
Herlihy, M., Luchangco, V., Moir, M.: The repeat offender problem: A mechanism for supporting lock-free dynamic-sized data structures. In: Proceedings of the 16th International Symposium on Distributed Computing, vol. 2508, pp. 339–353. Springer, Heidelberg (2002). A improved version of this paper is in preparation for journal submission
Herlihy, M., Luchangco, V., Moir, M.: Obstruction-free synchronization: double-ended queues as an example. In: Proceedings of the 23rd International Conference on Distributed Computing Systems, pp. 522–529. IEEE (2003)
Herlihy M.P. and Wing J.M. (1990). Linearizability: a correctness condition for concurrent objects. ACM Trans. Progr. Lang. Syst. (TOPLAS) 12(3): 463–492
Hwang K. and Briggs F.A. (1990). Computer Architecture and Parallel Processing. McGraw-Hill, New York
Intel. Pentium Processor Family User’s Manual: vol 3. In: Architecture and Programming Manual, 1994
Lamport L. (1983). Specifying concurrent program modules. ACM Trans. Progr. Lang. Syst. 5(2): 190–222
Lea, D.: The java concurrency package (JSR-166). http://gee.cs.oswego.edu/dl/concurrency-interest/index.html
Lea, D.: The java.util.concurrent synchronizer framework. In: Workshop on Concurrency and Synchronization in Java Programs, pp. 1–9 (2004)
Luchangco, V., Moir, M., Shavit, N.: On the uncontended complexity of consensus. In: Proceedings of the 17th International Conference on Distributed Computing, pp. 45–59 (2003)
Magnussen, P., Landin, A., Hagersten, E.: Queue locks on cache coherent multiprocessors. In: Proceedings of the 8th International Symposium on Parallel Processing (IPPS), pp. 165–171. IEEE Computer Society (1994)
Mellor-Crummey J. and Scott M. (1991). Algorithms for scalable synchronization on shared—memory multiprocessors. ACM Trans. Comput. Syst. 9(1): 21–65
Mellor-Crummey, J.M.: Concurrent queues: Practical fetch-and-φ algorithms. Technical Report 229, University of Rochester (1987)
Michael M. and Scott M. (1998). Nonblocking algorithms and preemption-safe locking on multiprogrammed shared—memory multiprocessors. J. Parallel Distrib. Comput. 51(1): 1–26
Michael M.M. (2004). Hazard pointers: safe memory reclamation for lock-free objects. IEEE Trans. Parallel Distrib. Syst. 15(6): 491–504
Moir, M.: Practical implementations of non-blocking synchronization primitives. In: Proceedings of the 16th Annual ACM Symposium on Principles of Distributed Computing, pp. 219–228 (1997)
Moir, M., Shavit, N.: Chapter 47 – Concurrent Data Structures – Handbook of Data Structures and Applications, 1st edn. Chapman and Hall/CRC, London (2004)
Prakash, S., Lee, Y.-H., Johnson, T.: Non-blocking algorithms for concurrent data structures. Technical Report 91–002, Department of Information Sciences, University of Florida (1991)
Prakash S., Lee Y.-H. and Johnson T. (1994). A non-blocking algorithm for shared queues using compare-and-swap. IEEE Trans. Comput. 43(5): 548–559
Rajwar, R., Goodman, J.: Speculative lock elision: enabling highly concurrent multithreaded execution. In: Proceedings of the 34th Annual International Symposium on Microarchitecture, pp. 294–305 (2001)
Scherer, W.N., Scott, M.L.: Nonblocking concurrent data structures with condition synchronization. In: Proceedings of the 18th International Symposium on Distributed Computing, pp. 174–187. Springer, Berlin (2004)
Stone H.S. (1987). High-performance Computer Architecture. Addison-Wesley Longman, Reading
Stone, J.: A simple and correct shared-queue algorithm using compare-and-swap. In:Proceedings of the 1990 Conference on Supercomputing, pp. 495–504. IEEE Computer Society
Treiber, R.K.: Systems programming: coping with parallelism. Technical Report RJ 5118, IBM Almaden Research Center (1986)
Tsigas, P., Zhang, Y.: A simple, fast and scalable non-blocking concurrent fifo queue for shared memory multiprocessor systems. In: Proceedings of the Thirteenth Annual ACM Symposium on Parallel Algorithms and Architectures, pp. 134–143. ACM, New york (2001)
Valois, J.: Implementing lock-free queues. In: Proceedings of the Seventh International Conference on Parallel and Distributed Computing Systems, pp. 64–69 (1994)
Valois, J.D.: Lock-free linked lists using compare-and-swap. In: Symposium on Principles of Distributed Computing, pp. 214–222 (1995)
Weaver D. and Germond T. (1994). The SPARC Architecture Manual Version 9. Prentice Hall, Englewood Cliffs
Author information
Authors and Affiliations
Corresponding author
Additional information
A preliminary version of this paper appeared in the proceedings of the 18th International Conference on Distributed Computing (DISC) 2004, pages 117–131.
Rights and permissions
About this article
Cite this article
Ladan-Mozes, E., Shavit, N. An optimistic approach to lock-free FIFO queues. Distrib. Comput. 20, 323–341 (2008). https://doi.org/10.1007/s00446-007-0050-0
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00446-007-0050-0