Comparative Modeling and Verification of Pthreads and Dthreads

The POSIX threads (Pthreads) library is a thread API for C/C++ to control parallel threads and spawn concurrent process flows. Programming in Pthreads usually suffers from undesirable deadlock and data race problems due to the potential non-deterministic execution behaviors between parallel threads. Dthreads is another multithreading model re-implementing Pthreads, which was proposed by Liu et al. for efficient deterministic multithreading. Under specific test cases, they found out that Dthreads can effectively prevent data races. But they have not made comparison test with Pthreads. In order to formally compare Pthreads with Dthreads over deadlocks and data races, in this paper, we apply CSP (Communicating Sequential Processes) to model part of APIs in Pthreads and Dthreads, as well as two classical example programs. By using the model checker PAT (Process Analysis Toolkit), for our considered examples, we verify that deadlocks and data races exist in Pthreads, but do not exist in Dthreads. Our comparative modeling and verification of Pthreads and Dthreads show that Dthreads is better than Pthreads on eliminating data races and preventing deadlocks.

[1]  Stéphane Lafortune,et al.  Eliminating Concurrency Bugs in Multithreaded Software: An Approach Based on Control of Petri Nets , 2013, Petri Nets.

[2]  Eugene Tsyrklevich,et al.  Dynamic Detection and Prevention of Race Conditions in File Accesses , 2003, USENIX Security Symposium.

[3]  Dragan Bosnacki,et al.  Verification of atomicity preservation in model-to-code transformations using generic Java code , 2016, 2016 4th International Conference on Model-Driven Engineering and Software Development (MODELSWARD).

[4]  Stephen N. Freund,et al.  FastTrack: efficient and precise dynamic race detection , 2009, PLDI '09.

[5]  Brandon Lucia,et al.  Finding concurrency bugs with context-aware communication graphs , 2009, 2009 42nd Annual IEEE/ACM International Symposium on Microarchitecture (MICRO).

[6]  Shengchao Qin,et al.  Semantic theories of programs with nested interrupts , 2015, Frontiers of Computer Science.

[7]  Lin Yan,et al.  Correctness Analysis Based on Testing and Checking for OpenMP Programs , 2009, 2009 Fourth ChinaGrid Annual Conference.

[8]  Sebastian Burckhardt,et al.  Effective Data-Race Detection for the Kernel , 2010, OSDI.

[9]  Jian Xu,et al.  A general noise-reduction framework for fault localization of Java programs , 2013, Inf. Softw. Technol..

[10]  C. A. R. Hoare,et al.  A Theory of Communicating Sequential Processes , 1984, JACM.

[11]  Ling Shi,et al.  Modeling and verifying hierarchical real-time systems using stateful timed CSP , 2013, TSEM.

[12]  Jun Sun,et al.  Developing Model Checkers Using PAT , 2010, ATVA.

[13]  Arnab Ray,et al.  Preventing race condition attacks on file-systems , 2005, SAC '05.

[14]  Andrew William Roscoe,et al.  The Theory and Practice of Concurrency , 1997 .

[15]  Raja Das,et al.  Multicore SDK: A Practical and Efficient Deadlock Detector for Real-World Applications , 2011, 2011 Fourth IEEE International Conference on Software Testing, Verification and Validation.

[16]  Michael Burrows,et al.  Eraser: a dynamic data race detector for multithreaded programs , 1997, TOCS.

[17]  Jun Sun,et al.  Model Checking CSP Revisited: Introducing a Process Analysis Toolkit , 2008, ISoLA.

[18]  Shengchao Qin,et al.  Automated verification of the FreeRTOS scheduler in Hip/Sleek , 2012, 2012 Sixth International Symposium on Theoretical Aspects of Software Engineering.

[19]  Emery D. Berger,et al.  Grace: safe multithreaded programming for C/C++ , 2009, OOPSLA '09.

[20]  Klaus Havelund,et al.  Dynamic Deadlock Analysis of Multi-threaded Programs , 2005, Haifa Verification Conference.

[21]  Jun Sun,et al.  Model checking with fairness assumptions using PAT , 2014, Frontiers of Computer Science.

[22]  Sriram Sankaranarayanan,et al.  Symbolic modular deadlock analysis , 2011, Automated Software Engineering.

[23]  Stephen A. Edwards,et al.  Programming Shared Memory Multiprocessors with Deterministic Message-Passing Concurrency: Compiling SHIM to Pthreads , 2008, 2008 Design, Automation and Test in Europe.

[24]  Shengchao Qin,et al.  Comparative modelling and verification of Pthreads and Dthreads , 2018, J. Softw. Evol. Process..

[25]  Rahul Agarwal,et al.  Detecting Potential Deadlocks with Static Analysis and Run-Time Monitoring , 2005, Haifa Verification Conference.

[26]  Xu Zhou,et al.  An Efficient and Flexible Deterministic Framework for Multithreaded Programs , 2015, Journal of Computer Science and Technology.

[27]  Maria Luisa Villani,et al.  Model Checking Multithreaded Programs by Means of Reduced Models , 2004, LDTA@ETAPS.

[28]  Matt Bishop,et al.  Checking for Race Conditions in File Accesses , 1996, Comput. Syst..

[29]  Emery D. Berger,et al.  Dthreads: efficient deterministic multithreading , 2011, SOSP.

[30]  Sorin Lerner,et al.  RELAY: static race detection on millions of lines of code , 2007, ESEC-FSE '07.

[31]  Koral Ilgun,et al.  USTAT: a real-time intrusion detection system for UNIX , 1993, Proceedings 1993 IEEE Computer Society Symposium on Research in Security and Privacy.

[32]  G. Gopalakrishnan,et al.  Inspect : A Runtime Model Checker for Multithreaded C Programs , 2008 .

[33]  Hemangee K. Kapoor,et al.  A Process Algebraic View of Latency-Insensitive Systems , 2009, IEEE Transactions on Computers.

[34]  A. W. Roscoe,et al.  Using CSP to Detect Errors in the TMN Protocol , 1997, IEEE Trans. Software Eng..

[35]  Shengchao Qin,et al.  Automatically refining partial specifications for heap-manipulating programs , 2014, Sci. Comput. Program..