用户名: 密码: 验证码:
多线程程序中数据竞争故障的动态检测技术研究
详细信息    本馆镜像全文|  推荐本文 |  |   获取CNKI官网全文
摘要
随着支持多线程技术的操作系统与多核处理器技术的普及,多线程技术不再是一个很遥远的话题。我们在享受着Microsoft Word编写文档与Netscape Firefox浏览网页带来便利的同时,也希望构造自己的多线程应用,但是多线程程序设计相对传统的程序设计而言还是很困难并且容易出错。在多线程程序设计中,很容易因为没有使用同步保护机制从而导致产生数据竞争故障,但是该故障很难通过一两次运行程序而发现,并且纵使发现有数据竞争故障,针对该故障的调试信息也非常难以获取。因此,研究如何有效的检测多线程程序中数据竞争故障并根据被测程序的实际情况给予程序设计人员有效的故障信息,是一个非常值得研究的问题。
     目前,有很多专家学者在数据竞争故障的检测方面做出了不少工作,其中利用lockset算法来检测数据竞争故障是该领域的主流做法,因而从lockset算法派生出Racer算法、Goodlock算法等。由于基于lockset算法的检测是采用了动态测试方法,即需要运行待测程序,所以本文引入面向方面编程技术(AOP,Aspect OrientedProgramming),对待测程序设置切入点来在线监测待测程序的运行状态,通过切入点能够更为准确的获取待测程序运行时的现场数据,并通过定义多线程程序变量状态图和变量集合用于对lockset算法进行有效的补充,在此基础上提出了基于变量状态图与锁集的数据竞争故障动态检测算法,并通过该算法对数据竞争故障进行了有效检测。本文的主要工作如下:
     (1)研究了面向方面编程技术在程序动态测试中的应用
     研究了面向方面编程技术的原理、特点与功能,特别是面向方面编程技术中的切入点设置问题,包括针对待测方法的切入点以及对变量的构造函数切入点的设置问题,以及在程序动态检测中的应用方式。
     (2)基于lockset算法的数据竞争故障检测方法的研究
     针对lockset算法所存在的问题,定义了一种用于描述多线程程序中变量状态的变量状态图和记录程序运行时变量的变量集合,通过变量状态图使原有lockset检测算法降低误报率,通过变量集合使原有lockset检测算法支持运行时期的变量分配,即动态内存变量,在此基础上提出基于变量状态图与锁集的数据竞争故障动态检测算法。该算法减少了误报情况的发生,使检测更为有效。给出了多线程程序中数据竞争故障动态检测的系统框架。
     (3)实验验证与结果分析
     利用AspectJ完成对待测程序的切入点设置与运行事件获取工作,利用Java和AspectJ实现了多线程程序中数据竞争故障检测系统原型。以多线程程序访问变量(包括读写操作)为例,使用本文提出的多线程数据竞争故障检测方法进行了实验,发现该方法较之lockset算法减少了误报的情况,使检测更为有效,并且提供了lockset算法所不能提供的故障现场信息。
With the support of multi-threaded operating system and the popularity of multi-core processor technology, multi-threading technology is no longer the subject of a very distant. We enjoy the convenience that writing with Microsoft Word or browsing by Netscape Firefox, but also want to build their multi-threaded applications, but multi-threaded programming is relatively traditional programming design which is still very difficult and error-prone, In multi-threaded programming, it is easy to rise because there is no protection mechanism in order to synchronize the data lead to date race fault, however, the fault is difficult to run through one or two times and found, and even if the fault has been found, the debug information for the fault is also very difficult to obtain. Therefore, studying how to effectively test multi-threaded program and give programmers effective fault information is a very worthwhile research.
     At present, there are many experts and scholars make a lot of work in detection of data race fault, lockset algorithm which use to detect data race fault in the mainstream of practice, which derived from the lockset algorithm such as Racer algorithm and Goodlock algorithm. As a result of lockset-based detection algorithm use dynamic testing methods, which need to run the test program, therefore, this paper introduces the technical aspect-oriented programming (AOP, Aspect Oriented Programming), treatment of test program to set up the pointcut for online monitoring the test program's state and through the pointcut to more accurate gain run-time data. Defining the variable state graphic and variable set for the lockset algorithm effectively supplement and designing the variable sate graphic and lockset based dynamic data race fault detection algorithm. The main work is as follows:
     (1) The research on the AOP technology in the process of dynamic testing
     Research on the AOP techniques such as its principles, characteristics and functions,especially the technical in the setting up pointcut, including setting up pointcut on methods or variable's constructor, as well as dynamic testing procedures applied in such a manner.
     (2) The research on lockset based dynamic data race fault detection algorithm
     Definition of variable set and variable state graphic, through the variable set so thatthe original detection algorithm to support the detection of the variable assignment at run time which is dynamic memory variables, through the variable state graphic so that the original detection algorithm to reduce fake alarm rate, on the basis of variable state graphic and variable set, this paper designed the variable sate graphic and lockset based dynamic data race fault detection algorithm. This algorithm reduced the occurrence of fake alarm, so that more effective detection. Given the multi-threaded program dynamic data race fault detection system framework.
     (3) Experimental verification and analysis
     Use AspectJ to complete the setting up pointcut on test program and receiving the event by pointcut, using of Java and AspectJ to achieve a multi-threaded data race fault detection system prototype. Multi-threaded access to variables (including read and write operations) as an example, the method used in this paper which is multi-threaded data race detection method through experiments that found the method compared with original lockset algorithm that a reduction of fake alarm, making detection more effective, and provided the original lockset algorithm can not provide information on the fault at the scene.
引文
[1]Robert H.B.Netzer,Timothy W.Brennan.Debugging Race Conditions in Message-Passing Programs.SPDT,1996.
    [2]Liqiang Wang,Soctt D.Stoller.Runtime Analysis of Atomicity for Multithreaded Programs.IEEE Transactions on Software Engineering Vol 32,2006.
    [3]Liqiang Wang,Soctt D.Stoller.Run-Time Analysis for Atomicity.Electronic Notes in Theoretical Computer Science,2003.
    [4]Klaus Havelund.Using Runtime Analysis to Guide Model Checking of Java Programes.QSS/Recom NASAAmes Research Center,2000.
    [5]Stefan Savage.Eraser:A Dynamic Data Race Detector for Multithreaded Programs.ACM Transactions on Computer Systems,Vol.I5,No.4,November 1997,Pages 391-411.
    [6]Willem Visser,Klaus Havelund.Model Checking Programs.Kluwer Academic Publishers,2002.
    [7]Cyrille Artho,Klaus Havelund,Armin Biere.High-Level Date Races.ACM Transactions on Programming Languages and Systems,2004.
    [8]K.Arnold and J.Gosling.The Java Programming Language.Addison-Wesley,1996.
    [9]Erie Bodden,Klaus Havelund.Racer:Effective Race Detection Using AspectJ.IEEE Transactions on Software.Engineering,2008.
    [10]Robert H.B.Netzer.Improving the Accuracy of Data Race Detection.Proc.of the Third ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming,April 1991.
    [11]Gregor Kiczales,John Lamping,Anurag Mendhekar,Chris Maeda,Cristina Videira Lopes,Jean-Marc Loingtier,John Irwin.Aspect-Oriented Programming.European Conference on Object-Oriented Programming(ECOOP),Finland.Springer-Verlag LNCS 1241.June 1997.
    [12]Jong-Deok Choi,Keunwoo Lee.Efficient and Precise Datarace Detection for Multithreaded Object-Oriented Programs.PLDI'02,June 17-19,2002.
    [13]Gregor Kiczales.Getting Started with AspectJ.CACM,2001.
    [14]Dawson Engler,Ken Ashcraft.RacerX:Effective,Static Detection of Race Conditions and Deadlocks.SOSP'03,October 19-22,2003.
    [15]Brad Richards,James R.Larus.Protocol-Based Data-Race Detection.Proceedings of the 2nd Sigmetrics Symposium on Parallel and Distributed Tools,August 1998.
    [16]Robert O'Callahan,Jong-Deok Choi.Hybrid Dynamic Data Race Detection.PPoPP'03,June 11-13,2003.
    [17]J.Harrow.Runtime checking of multithreaded applications with visual threads.SPIN Model Checking and Software Verification.Lecture Notes in Computer Science,Springer,2000,pp.331-342.
    [18]K.Havelund,G.Rosu.An overview of the runtime verifi-cation tool Java PathExplorer.Formal Methods in System Design,Vol.24,no.2,pp.189-215,2004.
    [19]S.Bensalem and K.Havelund.Reducing False Positives in Runtime Analysis of Deadlocks.Submitted for publication,January 2003.
    [20]J.Harrow.Runtime Checking of Multithreaded Applications with Visual Threads.In 7~(th) SPIN Workshop,volume 1885 of LNCS,pages 331-342.Springer,2000.
    [21]D.Lea.Concurrent Programming in Java.Addison-Wesley,1997.
    [22]Sun Microsystems.Java 2 Enterprise Edition,2002.http://java.sun.com/j2ee.
    [23]A.Kinneer,M.B.Dwyer,and G.Rothermel.Sofya:Supporting rapid development of dynamic program analyses for Java.IEEE Computer Society,2007,pp.51-52.
    [24]Dinning,A.and E.Schonberg.An Empirical Comparison of Monitoring Algorithms for Access Anomaly Detection.Proc.of Symp on Principles and Practice of Parallel Prog,Mar 1990.
    [25]Lamport,L.Time,clocks,and the ordering of eventsin a distributed system.Commun.ACM 21,July,1978,pp.558-565.
    [26]G.I.Cheng,M.Feng,C.E.Leiserson,K.H.Randall,and A.F.Stark.Detecting data races in Cilk programs that use locks.Proceedings of the Tenth Annual ACM Symposium on Parallel Algorithms and Architectures,1998.
    [27]J.-D.Choi,B.Alpern,T.Ngo,M.Sridharan,and J.Vlissides.A perturbation-free replay platform for cross-optimized multithreaded applications.Proceedings of the 15th IEEE International Parallel & Distributed Processing Symposium,April 2001.
    [28]J.-D.Choi,M.Gupta,M.Serrano,V.C.Sreedhar,and S.Midkiff.Escape analysis for Java.In ACM Conference on Object-Oriented Programming Systems,Languages, and Applications,pages 1-19,1999.
    [29]J.-D.Choi,A.Loginov,and V.Sarkar.Static data race analysis for multithreaded object-oriented programs.Technical report,IBM Research,2001.
    [30]A.Aiken and D.Gay.Barrier inference.In Proceedings of the 25th Symposium on Principles of Programming Languages(POPL),January 1998,pages 342-354.
    [31]Scott Clee.Use a consistent trace system for easier debugging.http://www.ibm.com/developerworks/java/library/j-trace1103.html
    [32]G.Ausiello,A.D'Atri,and M.Protasi.Structure preserving reductions among convex optimization problems.Journal of Computer System Sciences,Aug 1980.
    [33]D.Bacon,J.Bloch,J.Bogda,C.Click,P.Haahr,D.Lea,T.May,J.-W.Maessen,J.D.Mitchell,K.Nilsen,B.Pugh,and E.G.Sirer.The "double-checked locking is broken"declaration.http://www.cs.umd.edu/pugh/java/memoryModel/DoubleCheckedLocking.html.
    [34]B.Charron-Bost.Concerning the size of logical clocks in distributed systems.Information Processing Letters,July 1991.
    [35]M.Christiaens and K.De Bosschere.TRaDe,a topological approach to on-the-fly race detection in java programs.Proceedings of the Java Virtual Machine Research and Technology Symposium(JVM'01),April 2001.
    [36]C.Flanagan and S.N.Freund.Type-based race detection for java.In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation(PLDI),June 2000,pages 219-232.
    [37]C.v.Praun and T.Gross.Object race detection.In ACM Conference on Object-Oriented Programming Systems,Languages and Applications,2001.
    [38]Hoare,C.Monitors:An operating system structuring concept.Commun.ACM 17,10(Oct.),1974,pages 549-557.
    [39]Perkovic,D.and Keleher,P.Online data-race detection via coherency guarantees.In Proceedings of the 2nd USENIX Symposium on Operating Systems Design and Implementation,1996,pages 47-58.
    [40]AspectJ homepage:http://www.eclipse.org/aspectj/
    [41]SpringAOP homepage:http://www.springsource.org/
    [42]JBossAOP homepage:http://www.jboss.org/jbossaop/
    [43]JAC(Java Aspect Components) homepage:http://jac.ow2.org/
    [44]AspectWerkz homepage:http://aspectwerkz.codehaus.org/
    [45]AspectC++ homepage:http://www.aspectc.org/
    [46]Howard Kim.AspectC#:An AOSD implementation for C#.A dissertation submitted to the University Of Dublin.September 13,2002.
    [47]董威,王戟,齐治昌.并发程序的切片模型检验方法.计算机学报.2003年第3期.
    [48]顾庆,陈道蓄,谢立,孙钟秀.面向Java的分布式程序测试系统.软件学报.2003年第4期.
    [49]顾庆,陈道蓄,于勐,谢立,孙钟秀.基于事件约束的分布式程序正确性测试.软件学报,2000,11(8),1035-1040.
    [50]顾庆,陈道蓄,韩杰,谢立,孙钟秀.一个面向分布式程序的测试系统框架.软件学报,2000,11(8),1053-1059.
    [51]顾庆,陈道蓄,谢立.基于面向对象的分布式程序设计语言NC++的测试系统.软件学报,1997,8(6),352-356.
    [52]吴桂兰.面向方面编程的分析与研究.计算机工程与设计.2008年10月第20期.
    [53]曹东刚,梅宏.面向Aspect的程序设计——一种新的编程范型[J].计算机科学,2003,30(9),5-10.
    [54]杨军.面向Aspect编程(AOP)的研究及应用[D].武汉:湖北工业大学,2005.
    [55]徐宝文,周超洪,周天琳,等.面向方面的程序设计:概念,实现与未来[J].计算机与数字工程,2005,33(8),1-10.
    [56]王申源,董传良,刘英丹.面向方面的编程的研究与实现.计算机应用研究.2004.
    [57]陈振强,徐宝文.一种并发程序依赖性分析方法.计算机研究与发展.2002年2月.
    [58]张红英.基于AspectJ的Java程序切片系统的设计与实现:[硕士学位论文].西安:西安电子科技大学软件工程专业,2005.
    [59]高海洋,陈平.AOP综述.计算机科学.2002,29(10),41-43.
    [60]许育诚.软件测试与质量管理.北京:电子工业出版社,2004.
    [61]章隆兵,吴少刚,张福新.软件DSM系统中的动态数据竞争检测.小型微型计算机系统,2004年12期.
    [62]阎宏.JAVA与模式.电子工业出版社.2002年10月.
    [63]Erich Gamma,Richard Helm,Ralph Johnson,John Vlissides.设计模式:可复用面向对象软件的基础.机械工业出版社.2000年6月.

© 2004-2018 中国地质图书馆版权所有 京ICP备05064691号 京公网安备11010802017129号

地址:北京市海淀区学院路29号 邮编:100083

电话:办公室:(+86 10)66554848;文献借阅、咨询服务、科技查新:66554700