SharC: Checking data sharing strategies for multithreaded C

被引:5
作者
Anderson, Zachary [1 ]
Gay, David [2 ]
Ennals, Rob [2 ]
Brewer, Eric [1 ]
机构
[1] Univ Calif Berkeley, Berkeley, CA 94720 USA
[2] Intel Res, Berkeley, CA USA
关键词
languages;
D O I
10.1145/1379022.1375600
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Unintended or unmediated data sharing is a frequent cause of insidious bugs in multithreaded programs. We present a tool called SharC ( short for Sharing Checker) that allows a user to write lightweight annotations to declare how they believe objects are being shared between threads in their program. SharC uses a combination of static and dynamic analyses to check that the program conforms to this specification. SharC allows any type to have one of five "sharing modes" private to the current thread, read-only, shared under the control of a specified lock, intentionally racy, or checked dynamically. The dynamic mode uses run-time checking to verify that objects are either read-only, or only accessed by one thread. This allows us to check programs that would be difficult to check with a purely static system. If the user does not give a type an explicit annotation, then SharC uses a static type-qualifier analysis to infer that it is either private or should be checked dynamically. SharC allows objects to move between different sharing modes at runtime by using reference counting to check that there are no other references to the objects when they change mode. SharC's baseline dynamic analysis can check any C program, but is slow, and will generate false warnings about intentional data sharing. As the user adds more annotations, false warnings are reduced, and performance improves. We have found in practice that very few annotations are needed to describe all sharing and give reasonable performance. We ran SharC on 6 legacy C programs, summing to over 600k lines of code, and found that a total of only 60 simple annotations were needed to remove all false positives and to reduce performance overhead to only 2-14%.
引用
收藏
页码:149 / 158
页数:10
相关论文
共 26 条
[1]  
AGARWAL R, ASE 05
[2]  
ANDERSON ZR, 2008, UCBEECS200825
[3]  
BOYAPATI C, OOPSLA 02, P211
[4]  
CHENG GI, SPAA 98, P298
[5]  
CHOI JD, PLDI 02, P258
[6]  
CONDIT J, ESOP 07
[7]  
ELMAS T, PLDI 07, P245
[8]  
ENGLER D, SOSP 03, P237
[9]  
FLANAGAN C, POPL 04, P256
[10]  
FOSTER JS, PLDI 99, P192