File tree Expand file tree Collapse file tree 3 files changed +19
-11
lines changed
tests/regression/82-barrier Expand file tree Collapse file tree 3 files changed +19
-11
lines changed Original file line number Diff line number Diff line change 2222 module V = VarinfoV
2323
2424 module TID = ThreadIdDomain. Thread
25- module Waiters = SetDomain. ToppedSet (TID ) (struct let topname = " All MHP" end )
25+ module Waiters = SetDomain. ToppedSet (MHP ) (struct let topname = " All MHP" end )
2626 module G = Lattice. Prod (Capacity ) (Waiters )
2727
2828 let name () = " pthreadBarriers"
@@ -40,17 +40,14 @@ struct
4040 let ask = Analyses. ask_of_man man in
4141 let may, must = man.local in
4242 let barriers = possible_vinfos ask barrier in
43- let tid = match ThreadId. get_current ask with
44- | `Lifted tid -> Waiters. singleton tid
45- | _ -> Waiters. top ()
46- in
43+ let mhp = MHP. current ask in
4744 let handle_one b =
48- man.sideg b (Capacity. bot () , tid );
45+ man.sideg b (Capacity. bot () , Waiters. singleton mhp );
4946 let addr = ValueDomain.Addr. of_var b in
5047 let (capacity, waiters) = man.global b in
51- let relevant_waiters = Waiters. filter (fun tid -> true ) waiters in
48+ let relevant_waiters = Waiters. filter (fun other -> MHP. may_happen_in_parallel mhp other ) waiters in
5249 let may_run =
53- if Waiters. exists ( fun tid -> not @@ TID. is_unique tid) relevant_waiters then
50+ if Waiters. exists MHP. may_be_non_unique_thread relevant_waiters then
5451 true
5552 else
5653 let count = Waiters. cardinal relevant_waiters in
Original file line number Diff line number Diff line change @@ -92,3 +92,8 @@ let may_happen_in_parallel one two =
9292 else
9393 true
9494 | _ -> true
95+
96+ let may_be_non_unique_thread mhp =
97+ match mhp.tid with
98+ | `Lifted tid -> not (TID. is_unique tid)
99+ | _ -> true
Original file line number Diff line number Diff line change 88pthread_barrier_t barrier ;
99
1010void * f2 (void * ptr ) {
11+ pthread_barrier_wait (& barrier );
1112 return NULL ;
1213}
1314
1415void * f1 (void * ptr ) {
1516 pthread_barrier_wait (& barrier );
1617
18+ // This is past the barrier, so it will not be reached
1719 pthread_t t2 ;
1820 pthread_create (& t2 ,NULL ,f2 ,NULL );
1921
@@ -26,18 +28,22 @@ int main(int argc, char const *argv[])
2628 int i = 0 ;
2729
2830 pthread_barrier_init (& barrier , NULL , 3 );
31+
32+ pthread_t t1 ;
33+ pthread_create (& t1 ,NULL ,f1 ,NULL );
2934
3035 if (top ) {
3136 pthread_barrier_wait (& barrier );
3237 // Unreachable
3338 i = 1 ;
3439 }
3540
36- __goblint_check (i == 0 );
37- pthread_t t1 ;
41+ // Created too late to have any effect
42+ pthread_t t2 ;
43+ pthread_create (& t2 ,NULL ,f1 ,NULL );
3844
45+ __goblint_check (i == 0 );
3946
40- pthread_create (& t1 ,NULL ,f1 ,NULL );
4147
4248 return 0 ;
4349}
You can’t perform that action at this time.
0 commit comments