Download presentation
Presentation is loading. Please wait.
Published byEmerson Worstell Modified over 10 years ago
1
Ermenegildo Tomasco University of Southampton, UK Omar Inverso University of Southampton, UK Bernd Fischer Stellenbosch University, South Africa Salvatore La Torre Università di Salerno, Italy Gennaro Parlato University of Southampton, UK MU-CSeq: Sequentialization of C Programs by Shared Memory Unwindings
2
Sequentialization of Concurrent Programs Basic Idea: convert concurrent programs into equivalent sequential programs
3
Sequentialization of Concurrent Programs Basic Idea: Mu-CSeq Approach: T ₁ ∥ T ₂ ↝ M ; T ̕₁ ; C ₁ ; T ̕₂ ; C ₂ –M makes consistent shared memory guess –checkers C ensure that threads T’ used memory consistently convert concurrent programs into equivalent sequential programs
4
Memory Unwinding xy... z “memory” 000...
5
Memory Unwinding xy... z “memory” Guess and store sequence of individual write operations: 000...
6
Memory Unwinding xy... z 1 2 3 4 N “memory” pos Guess and store sequence of individual write operations: 000 0...
7
Memory Unwinding 400 420 430 4342... 0342 xy... z 1 2 3 4 N “memory” pos Guess and store sequence of individual write operations: add N copies of shared variables (“memory”) _memory[i,v] is value of v-th variable after i-th write... 000 0
8
Memory Unwinding 400 420 430 4342... 0342 xy... z 1x 1y 2y 1z 2x var 1 2 3 4... N thr “memory”“writes” pos Guess and store sequence of individual write operations: add N copies of shared variables (“memory”) _memory[i,v] is value of v-th variable after i-th write add array to record writes (“wirtes”) i-th write is by _thr[i], which has written to _var[i]... 00000 0
9
Memory Unwinding 400 420 430 4342... 0342 xy... z 1x 1y 2y 1z 2x var... next[0] 1 2 3 4... N thr “memory”“writes” “barrier” pos Guess and store sequence of individual write operations: add N copies of shared variables (“memory”) _memory[i,v] is value of v-th variable after i-th write add array to record writes (“writes”) i-th write is by _thr[i], which has written to _var[i] add array to record validity of writes (“barrier”) next write (after i) by thread t is at _next[i,t]... 00000N+1 0... 2 4 4 1 3 next[K]... N+1 N 3 3 N... N+1
10
Basic Idea: Simulation simulate all executions compatible with guessed memory unwinding
11
Basic Idea: uses auxiliary variables – pos (current index into unwound memory) – thread (id of currently simulated thread) – end (guessed index of last write into unwound memory) Simulation simulate all executions compatible with guessed memory unwinding
12
Basic Idea: uses auxiliary variables – pos (current index into unwound memory) – thread (id of currently simulated thread) – end (guessed index of last write into unwound memory) every thread is translated into a function –simulation starts from main thread Simulation simulate all executions compatible with guessed memory unwinding
13
Basic Idea: uses auxiliary variables – pos (current index into unwound memory) – thread (id of currently simulated thread) – end (guessed index of last write into unwound memory) every thread is translated into a function –simulation starts from main thread each thread creation interrupts simulation of current thread –new thread is called with current value of pos Simulation simulate all executions compatible with guessed memory unwinding
14
Basic Idea: uses auxiliary variables – pos (current index into unwound memory) – thread (id of currently simulated thread) – end (guessed index of last write into unwound memory) every thread is translated into a function –simulation starts from main thread each thread creation interrupts simulation of current thread –new thread is called with current value of pos terminated threads must have completed their memory writes –pos > end Simulation simulate all executions compatible with guessed memory unwinding
15
Basic Idea: uses auxiliary variables – pos (current index into unwound memory) – thread (id of currently simulated thread) – end (guessed index of last write into unwound memory) every thread is translated into a function –simulation starts from main thread each thread creation interrupts simulation of current thread –new thread is called with current value of pos terminated threads must have completed their memory writes –pos > end old thread resumed with old memory position Simulation simulate all executions compatible with guessed memory unwinding
16
Basic Idea: every read / write is translated into a function –simulates valid access into unwound memory similar simulations for pthread functions Simulation simulate all executions compatible with guessed memory unwinding
17
Simulating reads and writes 400 420 430 4342... 0342 xy... z 1x 1y 2y 1z 2x var 1 2 3 4... N thr int read(uint x) { uint jmp=*; assume(jmp>=pos && jmp<next[pos,thread]); pos=jmp; if (pos>end) return; return(_memory[pos, x]); } “memory”“writes” pos... 00000 0 next[0] “barrier” N+1 2 4 4... 1 3 next[K]... N+1 N 3 3 N... N+1
18
Simulating reads and writes 400 420 430 4342... 0342 xy... z 1x 1y 2y 1z 2x var 1 2 3 4... N thr int write(uint x, int val) { pos=next[pos,thread]; if(pos>end) return; assume( _var[pos]==x && _memory[pos,x]==val); } “memory”“writes” pos... 00000 0 next[0] “barrier” N+1 2 4 4... 1 3 next[K]... N+1 N 3 3 N... N+1
19
CSeq framework Translation from P to P': constraint for the shared memory boilerplate code to simulate Read, Write and Pthread API backend-specific instrumentation sequential non- deterministic C program P'P' concurrent C program P true/false Mu-CSeq sequential BMC CBMC, ESBMC, LLBMC #writebackend#unwind
20
Thank You users.ecs.soton.ac.uk/gp4/cseq/cseq.html
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.