Race Directed Random Testing of Concurrent Programs KOUSHIK SEN - UNIVERSITY OF CALIFORNIA, BERKELEY PRESENTED BY – ARTHUR KIYANOVSKI – TECHNION, ISRAEL

Embed Size (px)

Citation preview

  • Slide 1

Race Directed Random Testing of Concurrent Programs KOUSHIK SEN - UNIVERSITY OF CALIFORNIA, BERKELEY PRESENTED BY ARTHUR KIYANOVSKI TECHNION, ISRAEL Slide 2 Goal Verify Data Races Automatically Efficiently No false alarms Being able to reproduce races Slide 3 Background Slide 4 Data Race - Definition Two or more threads access the same memory location concurrently At least one of the accesses is for writing x=1 if (x==1) Temporally next to each other Slide 5 Data Race Another Example Thread 2: X=X+1; Thread 1: X=X+1; What actually happens in x=x+1? 1.Read x to tmp 2.Add 1 to tmp 3.Write tmp to X Slide 6 Not a Data Race! Thread 2: Lock(L); X=X+1; Unlock(L); Thread 1: Lock(L); X=X+1; Unlock(L); Slide 7 Multithreaded Testing On One CPU Lets say we have 2 threads blue and red. There is a data race between red 3 and blue 3. Lets show a way of running them on 1 CPU that can find the same Data Races that running them on 2 CPUs can. 1 2 3 1 2 3 Data Race Slide 8 Once upon a time Testing concurrent programs Slide 9 The Simple Traditional Way Repeatedly execute the program with the hope that different test executions will result in different interleavings. Slide 10 Advantages Of The Traditional Way Inexpensive compared to sophisticated techniques such as model checking and verification Slide 11 Problems With The Traditional Way Outcome highly dependent on the test environment. Some interleavings may only occur on heavily-loaded test systems. Depends on the underlying operating system for thread scheduling Often ends up executing the same interleaving many times. Slide 12 Simple Randomized Algorithm Simple Scheduler At every state during a concurrent execution Pick a thread randomly Execute the next instruction of the thread Slide taken and adapted from the original slides of Koushik Sen for PLDI08 Slide 13 Simple Randomized Algorithm Simple Scheduler At every state during a concurrent execution Pick a thread randomly Execute the next instruction of the thread Slide taken and adapted from the original slides of Koushik Sen for PLDI08 Slide 14 Simple Randomized Algorithm Simple Scheduler At every state during a concurrent execution Pick a thread randomly Execute the next instruction of the thread Slide taken and adapted from the original slides of Koushik Sen for PLDI08 Slide 15 Simple Randomized Algorithm Simple Scheduler At every state during a concurrent execution Pick a thread randomly Execute the next instruction of the thread Slide taken and adapted from the original slides of Koushik Sen for PLDI08 Slide 16 Simple Randomized Algorithm Simple Scheduler At every state during a concurrent execution Pick a thread randomly Execute the next instruction of the thread Slide taken and adapted from the original slides of Koushik Sen for PLDI08 Slide 17 Simple Randomized Algorithm Simple Scheduler At every state during a concurrent execution Pick a thread randomly Execute the next instruction of the thread Slide taken and adapted from the original slides of Koushik Sen for PLDI08 Slide 18 Problems With Randomized Algorithm Everything is left to chance Randomized is not good enough for some code structures What are the chances that we randomly stumble upon the data race here? thread2 { x = x+1; } thread1 { for (i=0; i