skip to main content
research-article

MCSH, a Lock with the Standard Interface

Published:20 June 2023Publication History
Skip Abstract Section

Abstract

The MCS lock of Mellor-Crummey and Scott (1991), 23 pages. is a very efficient first-come first-served mutual-exclusion algorithm that uses the atomic hardware primitives fetch-and-store and compare-and-swap. However, it has the disadvantage that the calling thread must provide a pointer to an allocated record. This additional parameter violates the standard locking interface, which has only the lock as a parameter. Hence, it is impossible to switch to MCS without editing and recompiling an application that uses locks.

This article provides a variation of MCS with the standard interface, which remains FCFS, called MCSH. One key ingredient is to stack allocate the necessary record in the acquire procedure of the lock, so its life-time only spans the delay to enter a critical section. A second key ingredient is communicating the allocated record between the acquire and release procedures through the lock to maintain the standard locking interface. Both of these practices are known to practitioners, but our solution combines them in a unique way. Furthermore, when these practices are used in prior papers, their correctness is often argued informally. The correctness of MCSH is verified rigorously with the proof assistant PVS, and experiments are run to compare its performance with MCS and similar locks.

REFERENCES

  1. [1] Abadi M. and Lamport L.. 1991. The existence of refinement mappings. Theor. Comput. Sci. 82 (1991), 253284.Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. [2] Auslander M. A., Edelsohn D. J., Krieger O. Y., Rosenburg B. S., and Wisniewski R. W.. 2003. Enhancement to the MCS lock for increased functionality and improved programmability. U.S. patent application number 20030200457 (abondoned).Google ScholarGoogle Scholar
  3. [3] Buhr P. A., Dice D., and Hesselink W. H.. 2015. High-performance N-thread software solutions for mutual exclusion. Concurr. Computat.: Pract. Exp. 27 3 (March 2015), 651701. Google ScholarGoogle ScholarCross RefCross Ref
  4. [4] Buhr Peter A., Dice David, and Hesselink Wim H.. 2022. Locking Micro-Benchmarks. Retrieved from https://github.com/pabuhr/concurrent-locking.Google ScholarGoogle Scholar
  5. [5] Dice Dave and Kogan Alex. 2021. Fissile locks. In Networked Systems, Georgiou Chryssis and Majumdar Rupak (Eds.). Vol. LNCS 12129. Springer International Publishing, Cham, Switzerland, 192208.Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. [6] Dice Dave and Kogan Alex. 2021. Hemlock: Compact and scalable mutual exclusion. In Proceedings of the 33rd ACM Symposium on Parallelism in Algorithms and Architectures. ACM, New York, NY, 173183.Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. [7] Dijkstra Edsger W.. 1965. Cooperating Sequential Processes. Technical Report. Technological University, Eindhoven, 87 pages. https://pure.tue.nl/ws/files/4279816/344354178746665.pdf.Google ScholarGoogle Scholar
  8. [8] Dijkstra Edsger W.. 1965. Solution of a problem in concurrent programming control. Commun. ACM 8, 9 (September 1965), 569.Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. [9] Dijkstra E. W.. 1976. A Discipline of Programming. Prentice-Hall, Englewood Cliffs, NJ.Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. [10] Drepper Ulrich. 2022. Futexes Are Tricky, Red Hat Inc., 12 pages. Retrieved from https://cis.temple.edu/∼giorgio/cis307/readings/futex.pdf.Google ScholarGoogle Scholar
  11. [11] Hesselink Wim H.. 2022. PVS Proof Scripts for Verification of Hardware Locks. Retrieved from http://wimhesselink.nl/mechver/HardwareLocks.Google ScholarGoogle Scholar
  12. [12] Hesselink Wim H.. 2022. Trylock, a case for temporal logic and eternity variables. Sci. Comput. Program. 216, C (April 2022), 12.Google ScholarGoogle Scholar
  13. [13] IBM. 2021. Serially Reusable Programs. Retrieved from https://www.ibm.com/docs/en/ztpf/1.1.0.15?topic=structures-serially-reusable-programs.Google ScholarGoogle Scholar
  14. [14] Lamport L.. 1974. A new solution of Dijkstra’s concurrent programming problem. Commun. ACM 17 (1974), 453455.Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. [15] Lamport L.. 1987. A fast mutual exclusion algorithm. ACM Trans. Comput. Syst. 5 (1987), 111.Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. [16] Long Waiman. 2013. qspinlock: Introducing a 4-byte Queue Spinlock Implementation. Retrieved from https://lwn.net/Articles/561775.Google ScholarGoogle Scholar
  17. [17] Magnusson Peter S., Landin Anders, and Hagersten Erik. 1994. Queue locks on cache coherent multiprocessors. In Proceedings of the 8th International Symposium on Parallel Processing. IEEE Computer Society, Los Alamitos, CA, 165171.Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. [18] Mellor-Crummey J. M. and Scott M. L.. 1991. Algorithms for scalable synchronization on shared-memory multiprocessors. ACM Trans. Comput. Syst. 9 (1991), 2165.Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. [19] Michael Maged M.. 2004. Hazard pointers: Safe memory reclamation for lock-free objects. IEEE Trans. Parallel Distrib. Syst. 15, 6 (June 2004), 491504.Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. [20] Owre S., Shankar N., Rushby J. M., and Stringer-Calvert D. W. J.. 2020. PVS Language Reference Version 7.1. SRI International, Computer Science Laboratory, Menlo Park CA, 113 pages. Retrieved February 7, 2023 from https://pvs.csl.sri.com/doc/pvs-language-reference.pdf.Google ScholarGoogle Scholar
  21. [21] Scott M. L.. 2013. Shared-memory Synchronization. Morgan & Claypool.Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. [22] Wang Tianzheng, Chabbi Milind, and Kimura Hideaki. 2016. Be my guest: MCS lock now welcomes guests. In Proceedings of the 21st ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (PPoPP’16). ACM, New York, NY, Article 21, 12 pages.Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. [23] WikipediA. 2022. Application Binary Interface.Retrieved February 7, 2023 from https://en.wikipedia.org/wiki/Application_binary_interface.Google ScholarGoogle Scholar
  24. [24] WikipediA. 2022. Application Program Interface.Retrieved February 7, 2023 from https://en.wikipedia.org/wiki/API.Google ScholarGoogle Scholar
  25. [25] WikipediA. 2022. Thread-local Storage. Retrieved February 7, 2023 from https://en.wikipedia.org/wiki/Thread-local_storage.Google ScholarGoogle Scholar

Index Terms

  1. MCSH, a Lock with the Standard Interface

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Published in

          cover image ACM Transactions on Parallel Computing
          ACM Transactions on Parallel Computing  Volume 10, Issue 2
          June 2023
          285 pages
          ISSN:2329-4949
          EISSN:2329-4957
          DOI:10.1145/3604626
          Issue’s Table of Contents

          Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 20 June 2023
          • Online AM: 20 February 2023
          • Accepted: 14 February 2023
          • Received: 29 June 2022
          Published in topc Volume 10, Issue 2

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • research-article
        • Article Metrics

          • Downloads (Last 12 months)152
          • Downloads (Last 6 weeks)12

          Other Metrics

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader

        Full Text

        View this article in Full Text.

        View Full Text