skip to main content
research-article
Open Access

Deadlock avoidance in parallel programs with futures: why parallel tasks should not wait for strangers

Published:12 October 2017Publication History
Skip Abstract Section

Abstract

Futures are an elegant approach to expressing parallelism in functional programs. However, combining futures with imperative programming (as in C++ or in Java) can lead to pernicious bugs in the form of data races and deadlocks, as a consequence of uncontrolled data flow through mutable shared memory.

In this paper we introduce the Known Joins (KJ) property for parallel programs with futures, and relate it to the Deadlock Freedom (DF) and the Data-Race Freedom (DRF) properties. Our paper offers two key theoretical results: 1) DRF implies KJ, and 2) KJ implies DF. These results show that data-race freedom is sufficient to guarantee deadlock freedom in programs with futures that only manipulate unsynchronized shared variables. To the best of our knowledge, these are the first theoretical results to establish sufficient conditions for deadlock freedom in imperative parallel programs with futures, and to characterize the subset of data races that can trigger deadlocks (those that violate the KJ property).

From result 2), we developed a tool that avoids deadlocks in linear time and space when KJ holds, i.e., when there are no data races among references to futures. When KJ fails, the tool reports the data race and optionally falls back to a standard deadlock avoidance algorithm by cycle detection. Our tool verified a dataset of ∼2,300 student’s homework solutions and found one deadlocked program. The performance results obtained from our tool are very encouraging: a maximum slowdown of 1.06× on a 16-core machine, always outperforming deadlock avoidance via cycle-detection. Proofs of the two main results were formalized using the Coq proof assistant.

References

  1. Paulo Sérgio Almeida, Carlos Baquero, and Victor Fonte. 2008. Interval Tree Clocks. In OPODIS (LNCS), Vol. 5401. Springer, Article 18, 16 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Utpal Banerjee, Brian Bliss, Zhiqiang Ma, and Paul Petersen. 2006. A theory of data race detection. In PADTAD. ACM, 69–78. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Carlos Baquero and Nuno Preguiça. 2016. Why Logical Clocks Are Easy. Commun. ACM 59, 4 (2016), 43–47. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Kenneth P. Birman and Thomas A. Joseph. 1987. Reliable Communication in the Presence of Failures. Theoretical Computer Science 5, 1 (1987), 47–76. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Robert D. Blumofe and Charles E. Leiserson. 1998. Space-Efficient Scheduling of Multithreaded Computations. Computing 27, 1 (1998), 202–229. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Gérard Boudol. 2009. A Deadlock-Free Semantics for Shared Memory Concurrency. In ICTAC (LNCS), Vol. 5684. Springer, 140–154. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Chandrasekhar Boyapati, Robert Lee, and Martin Rinard. 2002a. Ownership Types for Safe Programming: Preventing Data Races and Deadlocks. In OOPSLA. ACM, 211–230. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Chandrasekhar Boyapati, Robert Lee, and Martin Rinard. 2002b. Ownership types for safe programming: preventing data races and deadlocks. In OOPSLA. ACM, 211–230. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Vincent Cavé, Jisheng Zhao, Jun Shirako, and Vivek Sarkar. 2011. Habanero-Java: The New Adventures of Old X10. In PPPJ. ACM, 51–61. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Philippe Charles, Christian Grothoff, Vijay Saraswat, Christopher Donawa, Allan Kielstra, Kemal Ebcioglu, Christoph von Praun, and Vivek Sarkar. 2005. X10: an object-oriented approach to non-uniform cluster computing. In OOPSLA. ACM, 519–538. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Tiago Cogumbreiro, Raymond Hu, Francisco Martins, and Nobuko Yoshida. 2015. Dynamic Deadlock Verification for General Barrier Synchronisation. In PPoPP. ACM, 150–160. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Don Coppersmith and Shmuel Winograd. 1990. Matrix Multiplication via Arithmetic Progressions. Symbolic Computation 9, 3 (1990), 251–280. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. 2009. Introduction to Algorithms (3 rd ed.). MIT.Google ScholarGoogle Scholar
  14. Camil Demetrescu and Giuseppe F. Italiano. 2005. Trade-offs for Fully Dynamic Transitive Closure on DAGs: Breaking Through the O(n 2 ) Barrier. JACM 52, 2 (2005), 147–156. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Edsger W. Dijkstra. 1965. Cooperating Sequential Processes. Technical Report. Technical University of Eindhoven. EWD-123.Google ScholarGoogle Scholar
  16. Anne Dinning and Edith Schonberg. 1991. Detecting Access Anomalies in Programs with Critical Sections. In PADD. ACM, 85–96. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Dawson Engler and Ken Ashcraft. 2003. RacerX: effective, static detection of race conditions and deadlocks. In SOSP. ACM, 237–252. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Mingdong Feng and Charles E. Leiserson. 1997. Efficient detection of determinacy races in Cilk programs. In SPAA. ACM, 1–11. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Colin J. Fidge. 1988. Timestamps in Message-Passing Systems that Preserve the Partial Ordering. In ACSC, Vol. 10. University of Queensland, 55–66.Google ScholarGoogle Scholar
  20. Cormac Flanagan and Stephen N. Freund. 2009. FastTrack: efficient and precise dynamic race detection. In PLDI. ACM, 121–133. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Andy Georges, Dries Buytaert, and Lieven Eeckhout. 2007. Statistically Rigorous Java Performance Evaluation. In OOPSLA. ACM, 57–76. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Prodromos Gerakios, Nikolaos Papaspyrou, Konstantinos Sagonas, and Panagiotis Vekris. 2011. Dynamic Deadlock Avoidance in Systems Code Using Statically Inferred Effects. In PLOS. ACM, Article 5, 5 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Ok-Kyoon Ha and Yong-Kee Jun. 2015. An Efficient Algorithm for On-the-fly Data Race Detection Using an Epoch-based Technique. Scientific Programming 2015 (2015), 14. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Robert H. Halstead, Jr. 1985. MULTILISP: A Language for Concurrent Symbolic Computation. Transactions on Programming Languages and Systems 7, 4 (1985), 501–538. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Tobias Hilbrich, Bronis R. de Supinski, Martin Schulz, and Matthias S. Müller. 2009. A graph based approach for MPI deadlock detection. In ICS. ACM, 296–305. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Tobias Hilbrich, Joachim Protze, Martin Schulz, Bronis R. de Supinski, and Matthias S. Müller. 2012. MPI runtime error detection with MUST: advances in deadlock detection. In SC. IEEE, Article 30, 11 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Shams Imam and Vivek Sarkar. 2014. Habanero-Java Library: A Java 8 Framework for Multicore Programming. In PPPJ. ACM, 75–86. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Shams Imam, Jisheng Zhao, and Vivek Sarkar. 2015. A Composable Deadlock-Free Approach to Object-Based Isolation. In Euro-Par (LNCS), Vol. 9233. Springer, 426–437. Google ScholarGoogle ScholarCross RefCross Ref
  29. Sreekaanth S. Isloor and T. Anthony Marsland. 1980. The Deadlock Problem: An Overview. Computer 13, 9 (1980), 58–78. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Edgar Knapp. 1987. Deadlock detection in distributed databases. Computing Survey 19, 4 (1987), 303–328. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Bettina Krammer, Tobias Hilbrich, Valentin Himmler, Blasius Czink, Kiril Dichev, and Matthias S. Müller. 2008. MPI Correctness Checking with Marmot. In PTW. Springer, 61–78. Google ScholarGoogle ScholarCross RefCross Ref
  32. Leslie Lamport. 1978. Time, Clocks, and the Ordering of Events in a Distributed System. Commun. ACM 21, 7 (1978), 558–565. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Peng Li, Kunal Agrawal, Jeremy Buhler, and Roger D. Chamberlain. 2010. Deadlock Avoidance for Streaming Computations with Filtering. In SPAA. ACM, 243–252. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Glenn R. Luecke, Hua Chen, James Coyle, Jim Hoekstra, Marina Kraeva, and Yan Zou. 2003. MPI-CHECK: a tool for checking Fortran 90 MPI programs. CCPE 15, 2 (2003), 93–100. Google ScholarGoogle ScholarCross RefCross Ref
  35. Jeremy Manson, William Pugh, and Sarita V. Adve. 2005. The Java Memory Model. In POPL. ACM, 378–391. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Friedemann Mattern. 1989. Virtual time and global states in distributed systems. In WDAG. North-Holland/Elsevier, 215–226.Google ScholarGoogle Scholar
  37. John Mellor-Crummey. 1991. On-the-fly detection of data races for programs with nested fork-join parallelism. In SC. ACM, 24–33. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Toshimi Minoura. 1982. Deadlock Avoidance Revisited. JACM 29, 4 (1982), 1023–1048. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Andrey Mokhov and Victor Khomenko. 2014. Algebra of Parameterised Graphs. Transactions on Embedded Computing Systems 13, 4s, Article 143 (2014), 22 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Ian Munro. 1971. Efficient Determination of the Transitive Closure of a Directed Graph. Inform. Process. Lett. 1, 2 (1971), 56–58. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. V. Krishna Nandivada, Jun Shirako, Jisheng Zhao, and Vivek Sarkar. 2013. A Transformation Framework for Optimizing Task-Parallel Programs. Transactions on Programming Languages and Systems 35, 1, Article 3 (2013), 48 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Armand Navabi, Xiangyu Zhang, and Suresh Jagannathan. 2008. Quasi-static Scheduling for Safe Futures. In PPoPP. ACM, 23–32. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Raghavan Raman, Jisheng Zhao, Vivek Sarkar, Martin Vechev, and Eran Yahav. 2012. Efficient data race detection for async-finish parallelism. Formal Methods in System Design 41, 3 (2012), 321–347. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Veselin Raychev, Martin Vechev, and Manu Sridharan. 2013. Effective Race Detection for Event-driven Programs. In OOPSLA. ACM, 151–166. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Spiridon A. Reveliotis, Mark A. Lawley, and Placid M. Ferreira. 1997a. Polynomial-complexity deadlock avoidance policies for sequential resource allocation systems. Transactions on Automatic Control 42, 10 (1997), 1344–1357. Google ScholarGoogle ScholarCross RefCross Ref
  46. Spiridon A. Reveliotis, Mark A. Lawley, and Placid M. Ferreira. 1997b. Polynomial-complexity deadlock avoidance policies for sequential resource allocation systems. Transactions on Automatic Control 42, 10 (1997), 1344–1357. Google ScholarGoogle ScholarCross RefCross Ref
  47. Stefan Savage, Michael Burrows, Greg Nelson, Patrick Sobalvarro, and Thomas Anderson. 1997. Eraser: A Dynamic Data Race Detector for Multithreaded Programs. Transactions on Computer Systems 15, 4 (1997), 391–411. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Reinhard Schwarz and Friedemann Mattern. 1994. Detecting Causal Relationships in Distributed Computations: In Search of the Holy Grail. Distributed Computing 7, 3 (1994), 149–174. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. Jun Shirako, David M. Peixotto, Vivek Sarkar, and William N. Scherer. 2008. Phasers: a unified deadlock-free construct for collective and point-to-point synchronization. In ICS. ACM, 277–288. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. Lorna A. Smith, J. Mark Bull, and Jan Obdrzálek. 2001. A Parallel Java Grande Benchmark Suite. In SC. ACM, 10. Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. Rishi Surendran and Vivek Sarkar. 2016. Dynamic Determinacy Race Detection for Task Parallelism with Futures. In RV (LNCS), Vol. 10012. Springer, 368–385. Google ScholarGoogle ScholarCross RefCross Ref
  52. Raja Vallée-Rai, Phong Co, Etienne Gagnon, Laurie Hendren, Patrick Lam, and Vijay Sundaresan. 1999. Soot - a Java Bytecode Optimization Framework. In CASCON. IBM, Article 13, 160–170 pages.Google ScholarGoogle Scholar
  53. Philippe Virouleau, Pierrick Brunet, François Broquedis, Nathalie Furmento, Samuel Thibault, Olivier Aumage, and Thierry Gautier. 2014. Evaluation of OpenMP Dependent Tasks with the KASTORS Benchmark Suite. In IWOMP (LNCS), Vol. 8766. Springer, 16–29. Google ScholarGoogle ScholarCross RefCross Ref
  54. Anh Vo. 2011. Scalable Formal Dynamic Verification of MPI Programs Through Distributed Causality Tracking. Ph.D. Dissertation. University of Utah. Advisor(s) Gopalakrishnan, Ganesh. AAI3454168.Google ScholarGoogle ScholarDigital LibraryDigital Library
  55. Adam Welc, Suresh Jagannathan, and Antony Hosking. 2005. Safe Futures for Java. In OOPSLA. ACM, 439–453. Google ScholarGoogle ScholarDigital LibraryDigital Library
  56. Amy Williams, William Thies, and Michael D. Ernst. 2005. Static Deadlock Detection for Java Libraries. In ECOOP (LNCS), Vol. 3586. Springer, 602–629. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Deadlock avoidance in parallel programs with futures: why parallel tasks should not wait for strangers

          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 Proceedings of the ACM on Programming Languages
            Proceedings of the ACM on Programming Languages  Volume 1, Issue OOPSLA
            October 2017
            1786 pages
            EISSN:2475-1421
            DOI:10.1145/3152284
            Issue’s Table of Contents

            Copyright © 2017 Owner/Author

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 12 October 2017
            Published in pacmpl Volume 1, Issue OOPSLA

            Permissions

            Request permissions about this article.

            Request Permissions

            Check for updates

            Qualifiers

            • research-article

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader
          About Cookies On This Site

          We use cookies to ensure that we give you the best experience on our website.

          Learn more

          Got it!