logo资料库

Dynamic_Data_Race_Detection.pdf

第1页 / 共27页
第2页 / 共27页
第3页 / 共27页
第4页 / 共27页
第5页 / 共27页
第6页 / 共27页
第7页 / 共27页
第8页 / 共27页
资料共27页,剩余部分请下载后查看
Dynamic Data Race Detection Based Pure Locksets 杨振 2015/4/6
Data Race • “A data race occurs when two concurrent threads access a shared variable and … – at least one access is a write and – the threads use no explicit mechanism to prevent the accesses from being simultaneous” • In other words, a data race can lead to a potential violation of mutual exclusion.
Data Race Example: Threads with unsynchronized access to a shared array Thread 1 int i; … Thread 2 int i; … for (i = 1; for (i = 1; i < MAX; i < MAX; i++) i++) { { cin >> x; if (A[i] < B[i]) A[i] = 2*x; B[i] = A[i]; } … } …
Approaches to Data Race Detection • Static: performed at compile time or earlier • Dynamic: runtime analysis • Most current researches focus on dynamic detection • The environment is a single multithreaded program rather than separate programs.
Static Data Race Detection • Type-based analysis – Language type system augmented to “express common synchronization relationships”: correct typing→no data races – Difficult to do & restricts the type of synchronization primitives • Language features – e.g., use of monitors – Only works for static data – not dynamic data • Path analysis; – Doesn’t scale well – Too many false positives
Dynamic Data Race Detection • Dynamic detection: monitor programs during execution and look for problems – The program may be “instrumented” with additional instructions – The additions don’t change program functionality but are used to monitor conditions of interest - in this case, access to shared variables and synchronization operations.
Dynamic Detection • Problems: – Can only check paths that are actually executed – Adds overhead at runtime • Techniques – Happens-before – Lockset analysis ( Eraser ) – Hybrids of happen-before and lockset
Basic Idea of Eraser • Observe all instances where a shared variable is accessed by a thread. • If there is a chance that a data race can occur, be sure the shared variable is protected by a lock. – Simple algorithm – basic locks – Advanced algorithm – reader/writer locks • If variable isn’t protected, issue a warning.
分享到:
收藏