Skip to main content
Log in

Concurrency bugs in multithreaded software: modeling and analysis using Petri nets

  • Published:
Discrete Event Dynamic Systems Aims and scope Submit manuscript

Abstract

In this paper, we apply discrete-event system techniques to model and analyze the execution of concurrent software. The problem of interest is deadlock avoidance in shared-memory multithreaded programs. We employ Petri nets to systematically model multithreaded programs with lock acquisition and release operations. We define a new class of Petri nets, called Gadara nets, that arises from this modeling process. We investigate a set of important properties of Gadara nets, such as liveness, reversibility, and linear separability. We propose efficient algorithms for the verification of liveness of Gadara nets, and report experimental results on their performance. We also present modeling examples of real-world programs. The results in this paper lay the foundations for the development of effective control synthesis algorithms for Gadara nets.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Institutional subscriptions

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7

Similar content being viewed by others

Notes

  1. It should also be noticed that, in the particular case that the identified RIDM siphon is actually unreachable, the monitor places resulting from the MPLE synthesis do not compromise the maximal permissiveness of the synthesized control logic.

  2. Technically, the notation M 0 in Eq. 6 should be substituted by \(M_0^c\).

  3. Constraint (21) does not completely characterize the correct pricing of A(p, t) for all arcs. But what we need for liveness verification (and RIDM siphon construction) is the correct pricing of \(\overline{M}(p)\), which is guaranteed by the nature and role of the objective function (16).

  4. For a given Gadara net, if the iterative control technique converges before the pre-selected random number of iterations are completed, we output the converged net and disregard the remaining iterations.

  5. Sample statistics are based on log-scale data.

References

  • Allen LV (2010) Verification and anomaly detection for event-based control of manufacturing systems. PhD thesis, University of Michigan

  • Auer A, Dingel J, Rudie K (2009) Concurrency control generation for dynamic threads using discrete-event systems. In: Proc. Allerton conference on communication, control and computing

  • Boer ER, Murata T (1994) Generating basis siphons and traps of Petri nets using the sign incidence matrix. IEEE Trans Circuits Syst—I 41(4):266–271

    Article  MathSciNet  Google Scholar 

  • Cano EE, Rovetto CA, Colom JM (2010) An algorithm to compute the minimal siphons in S 4 PR nets. In: Proc. international workshop on discrete event systems, pp 18–23

  • Cassandras CG, Lafortune S (2008) Introduction to discrete event systems, 2nd edn. Springer, Boston

    Book  MATH  Google Scholar 

  • Chu F, Xie XL (1997) Deadlock analysis of Petri nets using siphons and mathematical programming. IEEE Trans Robot Autom 13(6):793–804

    Article  Google Scholar 

  • Delaval G, Marchand H, Rutten E (2010) Contracts for modular discrete controller synthesis. In: Proc. ACM conference on languages, compilers and tools for embedded systems

  • Dijkstra EW (1982) The mathematics behind the Banker’s Algorithm. In: Selected Writings on Computing: A Personal Perspective. Springer-Verlag, New York, pp 308–312

    Chapter  Google Scholar 

  • Dragert C, Dingel J, Rudie K (2008) Generation of concurrency control code using discrete-event systems theory. In: Proc. ACM international symposium on foundations of software engineering

  • Engler D, Ashcraft K (2003) RacerX: effective, static detection of race conditions and deadlocks. In: Proc. the 19th ACM symposium on operating systems principles

  • Ezpeleta J, Colom JM, Martínez J (1995) A Petri net based deadlock prevention policy for flexible manufacturing systems. IEEE Trans Robot Autom 11(2):173–184

    Article  Google Scholar 

  • Ezpeleta J, García-Vallés F, Colom JM (2002) A banker’s solution for deadlock avoidance in FMS with flexible routing and multiresource states. IEEE Trans Robot Autom 18(4):621–625

    Article  Google Scholar 

  • Flanagan C, Leino KRM, Lillibridge M, Nelson G, Saxe JB, Stata R (2002) Extended static checking for Java. In: Proc. the ACM SIGPLAN 2002 conference on programming language design and implementation

  • Gamatie A, Yu H, Delaval G, Rutten E (2009) A case study on controller synthesis for data-intensive embedded system. In: Proc. international conference on embedded software and systems

  • Giua A (1992) Petri nets as discrete event models for supervisory control. PhD thesis, Rensselaer Polytechnic Institute

  • Gurobi (2010) Gurobi optimizer. http://www.gurobi.com/

  • Hopcroft JE, Motwani R, Ullman JD (2006) Introduction to automata theory, languages, and computation, 3rd edn. Addison Wesley

    Google Scholar 

  • Iordache MV, Antsaklis PJ (2006) Supervisory control of concurrent systems: a Petri net structural approach. Birkhäuser, Boston

    MATH  Google Scholar 

  • Iordache MV, Antsaklis PJ (2009) Petri nets and programming: a survey. In: Proc. 2009 American control conference, pp 4994–4999

  • Iordache MV, Antsaklis PJ (2010) Concurrent program synthesis based on supervisory control. In: Proc. 2010 American control conference, pp 3378–3383

  • Jeng M, Xie X (2001) Modeling and analysis of semiconductor manufacturing systems with degraded behaviors using Petri nets and siphons. IEEE Trans Robot Autom 17(5):576–588

    Article  Google Scholar 

  • Kavi KM, Moshtaghi A, Chen D (2002) Modeling multithreaded applications using Petri nets. Int J Parallel Program 35(5):353–371

    Article  Google Scholar 

  • Kelly T, Wang Y, Lafortune S, Mahlke S (2009) Eliminating concurrency bugs with control engineering. IEEE Computer 42(12):52–60

    Article  Google Scholar 

  • Li Z, Zhou M, Wu N (2008) A survey and comparison of Petri net-based deadlock prevention policies for flexible manufacturing systems. IEEE Trans Syst Man Cybern Part C 38(2):173–188

    Article  MATH  Google Scholar 

  • Liao H, Lafortune S, Reveliotis S, Wang Y, Mahlke S (2010) Synthesis of maximally-permissive liveness-enforcing control policies for Gadara Petri nets. In: Proc. the 49th IEEE conference on decision and control

  • Liao H, Stanley J, Wang Y, Lafortune S, Reveliotis S, Mahlke S (2011) Deadlock-avoidance control of multithreaded software: an efficient siphon-based algorithm for Gadara Petri nets. In: Proc. the 50th IEEE conference on decision and control

  • Liu C, Kondratyev A, Watanabe Y, Desel J, Sangiovanni-Vincentelli A (2006) Schedulability analysis of Petri nets based on structural properties. In: Proc. international conference on application of concurrency to system design

  • Murata T (1989) Petri nets: properties, analysis and applications. Proc IEEE 77(4):541–580

    Article  Google Scholar 

  • Murata T, Shenker B, Shatz SM (1989) Detection of Ada static deadlocks using Petri net invariants. IEEE Trans Softw Eng 15(3):314–326

    Article  Google Scholar 

  • Musuvathi M, Qadeer S, Ball T, Basler G, Nainar PA, Neamtiu I (2008) Finding and reproducing Heisenbugs in concurrent programs. In: Proc. the 8th USENIX symposium on operating systems design and implementation

  • Nazeem A, Reveliotis S, Wang Y, Lafortune S (2010) Optimal deadlock avoidance for complex resource allocation systems through classification theory. In: Proc. the 10th international workshop on discrete event systems

  • Nazeem A, Reveliotis S, Wang Y, Lafortune S (2011) Designing compact and maximally permissive deadlock avoidance policies for complex resource allocation systems through classification theory: the linear case. IEEE Trans Autom Control 56(8):1818–1833

    Article  MathSciNet  Google Scholar 

  • Nir-Buchbinder Y, Tzoref R, Ur S (2008) Deadlocks: From exhibiting to healing. In: Proc. workshop on runtime verification

  • Novark G, Berger ED, Zorn BG (2007) Exterminator: automatically correcting memory errors with high probability. In: Proc. programming language design and implementation

  • Novark G, Berger ED, Zorn BG (2008) Exterminator: automatically correcting memory errors with high probability. Commun ACM 51(12):87–95

    Article  Google Scholar 

  • Park J, Reveliotis SA (2001) Deadlock avoidance in sequential resource allocation systems with multiple resource acquisitions and flexible routings. IEEE Trans Autom Control 46(10):1572–1583

    Article  MathSciNet  MATH  Google Scholar 

  • Park J, Reveliotis SA (2002) Liveness-enforcing supervision for resource allocation systems with uncontrollable behavior and forbidden states. IEEE Trans Robot Autom 18(2):234–240

    Article  Google Scholar 

  • Park S, Lu S, Zhou Y (2009) Ctrigger: exposing atomicity violation bugs from their hiding places. In: Proc. 14th international conference on architecture support for programming languages and operating systems

  • Phoha VV, Nadgar AU, Ray A, Phoha S (2004) Supervisory control of software systems. IEEE Trans Comput 53(9):1187–1199

    Article  Google Scholar 

  • Qin F, Tucek J, Sundaresan J, Zhou Y (2005) Rx: treating bugs as allergies—a safe method to survive software failures. In: Proc. the 20th ACM symposium on operating systems principles, pp 235–248

  • Reisig W (1985) Petri nets: an introduction. Springer, New York

    MATH  Google Scholar 

  • Reveliotis SA (2005) Real-time management of resource allocation systems: a discrete-event systems approach. Springer, New York

    MATH  Google Scholar 

  • Sutter H, Larus J (2005) Software and the concurrency revolution. ACM Queue 3(7):54–62

    Article  Google Scholar 

  • Wallace C, Jensen P, Soparkar N (1996) Supervisory control of workflow scheduling. In: Proc. international workshop on advanced transaction models and architectures

  • Wang Y (2009) Software failure avoidance using discrete control theory. PhD thesis, University of Michigan

  • Wang Y, Kelly T, Kudlur M, Lafortune S, Mahlke SA (2008) Gadara: dynamic deadlock avoidance for multithreaded programs. In: Proc. the 8th USENIX symposium on operating systems design and implementation, pp 281–294

  • Wang Y, Lafortune S, Kelly T, Kudlur M, Mahlke S (2009a) The theory of deadlock avoidance via discrete control. In: Proc. the 36th annual ACM SIGPLAN-SIGACT symposium on principles of programming languages, pp 252–263

  • Wang Y, Liao H, Reveliotis S, Kelly T, Mahlke S, Lafortune S (2009b) Gadara nets: Modeling and analyzing lock allocation for deadlock avoidance in multithreaded software. In: Proc. the 48th IEEE conference on decision and control, pp 4971–4976

  • Wang Y, Cho HK, Liao H, Nazeem A, Kelly TP, Lafortune S, Mahlke S, Reveliotis S (2010) Supervisory control of software execution for failure avoidance: experience from the Gadara project. In: Proc. international workshop on discrete event systems

  • Yamalidou K, Moody J, Lemmon M, Antsaklis P (1996) Feedback control of Petri nets based on place invariants. Automatica 32(1):15–28

    Article  MathSciNet  MATH  Google Scholar 

Download references

Acknowledgements

We thank Ahmed Nazeem, Manjunath Kudlur, and the reviewers for many helpful comments.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Hongwei Liao.

Additional information

This work was partially supported by NSF grant CCF-0819882 and an award from HP Labs Innovation Research Program (University of Michigan) and by NSF grants CMMI-0619978 and CMMI-0928231 (Georgia Institute of Technology).

Rights and permissions

Reprints and permissions

About this article

Cite this article

Liao, H., Wang, Y., Cho, H.K. et al. Concurrency bugs in multithreaded software: modeling and analysis using Petri nets. Discrete Event Dyn Syst 23, 157–195 (2013). https://doi.org/10.1007/s10626-012-0139-x

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10626-012-0139-x

Keywords

Navigation