Lock-Free Dynamically Resizable Arrays
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.
Keywordslock-free STL C++ vector concurrency real-time systems
Unable to display preview. Download preview PDF.
- 1.Alexandrescu, A., Michael, M.: Lock-free data structures with hazard pointers. C++ User Journal (November 2004)Google Scholar
- 2.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)Google Scholar
- 4.Becker, P.: Working Draft, Standard for Programming Language C++, ISO WG21N2009 (April 2006)Google Scholar
- 7.Fraser, K.: Practical lock-freedom. Technical Report UCAM-CL-TR-579, University of Cambridge, Computer Laboratory (February 2004)Google Scholar
- 8.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)Google Scholar
- 16.Intel. Ia-32 intel architecture software developer’s manual, vol. 3: System programming guide (2004)Google Scholar
- 17.Intel. Reference for Intel Threading Building Blocks, version 1.0 (April 2006)Google Scholar
- 18.ISO/IEC 14882 International Standard. Programming languages C++. American National Standards Institute (September 1998)Google Scholar
- 23.Michael, M.M., Scott, M.L.: Correction of a memory management method for lock-free data structures. Technical Report TR599 (1995)Google Scholar
- 24.Robison, A.: Intel Corporation. Personal communication (April 2006)Google Scholar
- 26.Stroustrup, B.: The C++ Programming Language. Addison-Wesley Longman Publishing Co., Inc., Boston (2000)Google Scholar