Abstract
We present a first lock-free design and implementation of a dynamically resizable array (vector). The most extensively used container in the C++ Standard Template Library (STL) is vector, offering a combination of dynamic memory management and constant-time random access. Our approach is based on a single 32-bit word atomic compare-and-swap (CAS) instruction. It provides a linearizable and highly parallelizable STL-like interface, lock-free memory allocation and management, and fast execution. Our current implementation is designed to be most efficient on multi-core architectures. Experiments on a dual-core Intel processor with shared L2 cache indicate that our lock-free vector outperforms its lock-based STL counterpart and the latest concurrent vector implementation provided by Intel by a large factor. The performance evaluation on a quad dual-core AMD system with non-shared L2 cache demonstrated timing results comparable to the best available lock-based techniques. The presented design implements the most common STL vector’s interfaces, namely random access read and write, tail insertion and deletion, pre-allocation of memory, and query of the container’s size. Using the current implementation, a user has to avoid one particular ABA problem.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Alexandrescu, A., Michael, M.: Lock-free data structures with hazard pointers. C++ User Journal (November 2004)
An, P., Jula, A., Rus, S., Saunders, S., Smith, T., Tanase, G., Thomas, N., Amato, N., Rauchwerger, L.: STAPL: A Standard Template Adaptive Parallel C++ Library. In: LCPC 2001, Cumberland Falls, Kentucky, pp. 193–208(August 2001)
Barnes, G.: A method for implementing lock-free shared-data structures. In: SPAA 1993: Proceedings of the fifth annual ACM symposium on Parallel algorithms and architectures, pp. 261–270. ACM Press, New York (1993)
Becker, P.: Working Draft, Standard for Programming Language C++, ISO WG21N2009 (April 2006)
Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to algorithms. MIT Press, Cambridge (2001)
Detlefs, D.L., Flood, C.H., Garthwaite, A.T., Martin, P.A., Shavit, N.N., Steele Jr., G.L.: Even better DCAS-based concurrent deques. In: Herlihy, M.P. (ed.) DISC 2000. LNCS, vol. 1914, pp. 59–73. Springer, Heidelberg (2000)
Fraser, K.: Practical lock-freedom. Technical Report UCAM-CL-TR-579, University of Cambridge, Computer Laboratory (February 2004)
Garlan, D., Reinholtz, W.K., Schmerl, B., Sherman, N.D., Tseng, T.: Bridging the gap between systems design and space systems software. In: SEW 2005, Washington, DC, USA, pp. 34–46. IEEE Computer Society Press, Los Alamitos (2005)
Gidenstam, A., Papatriantafilou, M., Tsigas, P.: Allocating memory in a lock-free manner. In: Brodal, G.S., Leonardi, S. (eds.) ESA 2005. LNCS, vol. 3669, pp. 329–342. Springer, Heidelberg (2005)
Harris, T.L.: A pragmatic implementation of non-blocking linked-lists. In: Welch, J.L. (ed.) DISC 2001. LNCS, vol. 2180, pp. 300–314. Springer, Heidelberg (2001)
Harris, T.L., Fraser, K., Pratt, I.A.: A practical multi-word compare-and-swap operation. In: Malkhi, D. (ed.) DISC 2002. LNCS, vol. 2508. Springer, Heidelberg (2002)
Hendler, D., Shavit, N., Yerushalmi, L.: A scalable lock-free stack algorithm. In: SPAA 2004: Proceedings of the sixteenth annual ACM symposium on Parallelism in algorithms and architectures, pp. 206–215. ACM Press, New York (2004)
Herlihy, M.: A methodology for implementing highly concurrent data objects. ACM Trans. Program. Lang. Syst. 15(5), 745–770 (1993)
Herlihy, M., Luchangco, V., Martin, P., Moir, M.: Nonblocking memory management support for dynamic-sized data structures. ACM Trans. Comput. Syst. 23(2), 146–196 (2005)
Herlihy, M.P., Wing, J.M.: Linearizability: a correctness condition for concurrent objects. ACM Trans. Program. Lang. Syst. 12(3), 463–492 (1990)
Intel. Ia-32 intel architecture software developer’s manual, vol. 3: System programming guide (2004)
Intel. Reference for Intel Threading Building Blocks, version 1.0 (April 2006)
ISO/IEC 14882 International Standard. Programming languages C++. American National Standards Institute (September 1998)
Michael, 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)
Michael, M.M.: High performance dynamic lock-free hash tables and list-based sets. In: SPAA 2002: Proceedings of the fourteenth annual ACM symposium on Parallel algorithms and architectures, pp. 73–82. ACM Press, New York (2002)
Michael, M.M.: Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects. IEEE Trans. Parallel Distrib. Syst. 15(6), 491–504 (2004)
Michael, M.M.: Scalable lock-free dynamic memory allocation. In: PLDI 2004: Proceedings of the ACM SIGPLAN 2004 Conf. on Programming language design and implementation, pp. 35–46. ACM Press, New York (2004)
Michael, M.M., Scott, M.L.: Correction of a memory management method for lock-free data structures. Technical Report TR599 (1995)
Robison, A.: Intel Corporation. Personal communication (April 2006)
Shalev, O., Shavit, N.: Split-ordered lists: lock-free extensible hash tables. In: PODC 2003: Proceedings of the twenty-second annual symposium on Principles of distributed computing, pp. 102–111. ACM Press, New York (2003)
Stroustrup, B.: The C++ Programming Language. Addison-Wesley Longman Publishing Co., Inc., Boston (2000)
Sundell, H., Tsigas, P.: Lock-Free and Practical Doubly Linked List-Based Deques Using Single-Word Compare-and-Swap. In: Higashino, T. (ed.) OPODIS 2004. LNCS, vol. 3544, pp. 240–255. Springer, Heidelberg (2005)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2006 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Dechev, D., Pirkelbauer, P., Stroustrup, B. (2006). Lock-Free Dynamically Resizable Arrays. In: Shvartsman, M.M.A.A. (eds) Principles of Distributed Systems. OPODIS 2006. Lecture Notes in Computer Science, vol 4305. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11945529_11
Download citation
DOI: https://doi.org/10.1007/11945529_11
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-49990-9
Online ISBN: 978-3-540-49991-6
eBook Packages: Computer ScienceComputer Science (R0)