This Article 
   
 Share 
   
 Bibliographic References 
   
 Add to: 
 
Digg
Furl
Spurl
Blink
Simpy
Google
Del.icio.us
Y!MyWeb
 
 Search 
   
Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects
June 2004 (vol. 15 no. 6)
pp. 491-504

Abstract—Lock-free objects offer significant performance and reliability advantages over conventional lock-based objects. However, the lack of an efficient portable lock-free method for the reclamation of the memory occupied by dynamic nodes removed from such objects is a major obstacle to their wide use in practice. This paper presents hazard pointers, a memory management methodology that allows memory reclamation for arbitrary reuse. It is very efficient, as demonstrated by our experimental results. It is suitable for user-level applications—as well as system programs—without dependence on special kernel or scheduler support. It is wait-free. It requires only single-word reads and writes for memory access in its core operations. It allows reclaimed memory to be returned to the operating system. In addition, it offers a lock-free solution for the ABA problem using only practical single-word instructions. Our experimental results on a multiprocessor system show that the new methodology offers equal and, more often, significantly better performance than other memory management methods, in addition to its qualitative advantages regarding memory reclamation and independence of special hardware support. We also show that lock-free implementations of important object types, using hazard pointers, offer comparable performance to that of efficient lock-based implementations under no contention and no multiprogramming, and outperform them by significant margins under moderate multiprogramming and/or contention, in addition to guaranteeing continuous progress and availability, even in the presence of thread failures and arbitrary delays.

[1] T.E. Anderson, B.N. Bershad, E.D. Lazowska, and H.M. Levy, Scheduler Activations: Effective Kernel Support for the User-Level Management of Parallelism ACM Trans. Computer Systems, vol. 10, no. 1, pp. 53-79, Feb. 1992.
[2] T.H. Cormen, C.E. Leiserson, and R.L. Rivest, Introduction to Algorithms. MIT Press, 1990.
[3] D.L. Detlefs, P.A. Martin, M. Moir, and G.L. Steele Jr., Lock-Free Reference Counting Proc. 20th Ann. ACM Symp. Principles of Distributed Computing, pp. 190-199, Aug. 2001.
[4] M.B. Greenwald, Non-Blocking Synchronization and System Design PhD thesis, Stanford Univ., Aug. 1999.
[5] T.L. Harris, A Pragmatic Implementation of Non-Blocking Linked Lists Proc. 15th Int'l Symp. Distributed Computing, pp.*nbsp;300-314, Oct. 2001.
[6] T.L. Harris, K. Fraser, and I.A. Pratt, A Practical Multi-Word Compare-and-Swap Operation Proc. 16th Int'l Symp. Distributed Computing, pp. 265-279, Oct. 2002.
[7] D. Hendler and N. Shavit, Work Dealing Proc. 14th Ann. ACM Symp. Parallel Algorithms and Architectures, pp. 164-172, Aug. 2002.
[8] M.P. Herlihy, Wait-Free Synchronization ACM Trans. Programming Languages and Systems, vol. 13, no. 1, pp. 124-149, Jan. 1991.
[9] M.P. Herlihy, A Methodology for Implementing Highly Concurrent Objects ACM Trans. Programming Languages and Systems, vol. 15, no. 5, pp. 745-770, Nov. 1993.
[10] M.P. Herlihy, V. Luchangco, and M. Moir, The Repeat Offender Problem: A Mechanism for Supporting Dynamic-Sized Lock-Free Data Structures Proc. 16th Int'l Symp. Distributed Computing, pp. 339-353, Oct. 2002.
[11] IBM, IBM System/370 Extended Architecture, Principles of Operation, publication no. SA22-7085, 1983.
[12] L.I. Kontothanassis, R.W. Wisniewski, and M.L. Scott, Scheduler-Conscious Synchronization ACM Trans. Computer Systems, vol. 15, no. 1, pp. 3-40, Feb. 1997.
[13] P.E. McKenney and J.D. Slingwine, Read-Copy Update: Using Execution History to Solve Concurrency Problems Proc. 10th IASTED Int'l Conf. Parallel and Distributed Computing and Systems, Oct. 1998.
[14] J.M. Mellor-Crummey and M.L. Scott, Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors ACM Trans. Computer Systems, vol. 9, no. 1, pp. 21-65, Feb. 1991.
[15] J.M. Mellor-Crummey and M.L. Scott, Scalable Reader-Writer Synchronization for Shared-Memory Multiprocessors Proc. Third ACM Symp. Principles and Practice of Parallel Programming, pp. 106-113, Apr. 1991.
[16] M.M. Michael, High Performance Dynamic Lock-Free Hash Tables and List-Based Sets Proc. 14th Ann. ACM Symp. Parallel Algorithms and Architectures, pp. 73-82, Aug. 2002.
[17] M.M. Michael, Safe Memory Reclamation for Dynamic Lock-Free Objects Using Atomic Reads and Writes Proc. 21st Ann. ACM Symp. Principles of Distributed Computing, pp. 21-30, July 2002. earlier version in Research Report RC 22317, IBM T.J. Watson Research Center, Jan. 2002.
[18] M.M. Michael, CAS-Based Lock-Free Algorithm for Shared Deques Proc. Ninth Euro-Par Conf. Parallel Processing, pp. 651-660, Aug. 2003.
[19] M.M. Michael, ABA Prevention Using Single-Word Instructions Technical Report RC 23089, IBM T.J. Watson Research Center, Jan. 2004.
[20] M.M. Michael, Scalable Lock-Free Dynamic Memory Allocation Proc. 2004 ACM SIGPLAN Conf. Programming Language Design and Implementation, June 2004.
[21] M.M. Michael and M.L. Scott, Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms Proc. 15th Ann. ACM Symp. Principles of Distributed Computing, pp. 267-275, May 1996.
[22] M.M. Michael and M.L. Scott, Nonblocking Algorithms and Preemption-Safe Locking on Multiprogrammed Shared Memory Multiprocessors J. Parallel and Distributed Computing, vol. 51, no. 1, pp. 1-26, May 1998.
[23] S. Prakash,Y.H. Lee,, and T. Johnson,“A nonblock algorithm for shared queues using compare-and-swap,” IEEE Trans. Computers, vol. 43, no. 5, 1994.
[24] L. Rudolph and Z. Segall, Dynamic Decentralized Cache Schemes for MIMD Parallel Processors Proc. 11th Int'l Symp. Computer Architecture, pp. 340-347, June 1984.
[25] O. Shalev and N. Shavit, Split-Ordered Lists: Lock-Free Extensible Hash Tables Proc. 22nd Ann. ACM Symp. Principles of Distributed Computing, pp. 102-111, July 2003.
[26] N. Shavit and D. Touitou, Software Transactional Memory Distributed Computing, vol. 10, no. 2, pp. 99-116, 1997.
[27] H. Tang, K. Shen, and T. Yang, Program Transformation and Runtime Support for Threaded MPI Execution on Shared Memory Machines ACM Trans. Programming Languages and Systems, vol. 22, no. 4, pp. 673-700, July 2000.
[28] J. Turek, D. Shasha, and S. Prakash, Locking Without Blocking: Making Lock Based Concurrent Data Structure Algorithms Nonblocking Proc. 11th ACM Symp. Principles of Database Systems, pp. 212-222, June 1992.
[29] J.D. Valois, Lock-Free Linked Lists Using Compare-and-Swap Proc. 14th Ann. ACM Symp. Principles of Distributed Computing, pp. 214-222, Aug. 1995.
[30] J. Zahoran,E.D. Lazowska,, and D.L. Eager,“The effect of scheduling discipline on spin overhead in shared memory parallel systems,” IEEE Trans. Parallel and Distributed Systems, vol. 2, no. 2, pp. 180-198, 1991.

Index Terms:
Lock-free, synchronization, concurrent programming, memory management, multiprogramming, dynamic data structures.
Citation:
Maged M. Michael, "Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects," IEEE Transactions on Parallel and Distributed Systems, vol. 15, no. 6, pp. 491-504, June 2004, doi:10.1109/TPDS.2004.8
Usage of this product signifies your acceptance of the Terms of Use.