-
Notifications
You must be signed in to change notification settings - Fork 2
/
testTerms.rkt
1257 lines (1116 loc) · 31.2 KB
/
testTerms.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#lang at-exp racket
(require redex/reduction-semantics)
(provide (all-defined-out))
(require racket/string)
(require "../core/parser.rkt")
(define (concretize generator parameterString)
(apply generator (string-split parameterString)))
#|
ret 5 || ret 239
|#
(define testTerm-1 (term (spw (ret 5) (ret 239))))
#|
x_imod0 = 0; y_imod1 = 0
x_mod0 = 1 || y_mod2 = 1
R1 = y_mod1 || R2 = x_mod3
|#
(define (term_SB_abst imod0 imod1 mod0 mod1 mod2 mod3)
@prog{x_@imod0 := 0;
y_@imod1 := 0;
spw
{{{ x_@mod0 := 1;
r1 := y_@mod1;
ret r1
||| y_@mod2 := 1;
r2 := x_@mod3;
ret r2 }}} })
#|
x_rlx = 0; y_rlx = 0
x_rlx = 1 || y_rlx = 1
R1 = y_rlx || R2 = x_rlx
Can lead to R1 = R2 = 0.
|#
(define term_WrlxRrlx_WrlxRrlx (concretize term_SB_abst "rlx rlx rlx rlx rlx rlx"))
#|
x_rel = 0; y_rel = 0
x_rel = 1 || y_rel = 1
R1 = y_acq || R2 = x_acq
Can lead to R1 = R2 = 0.
|#
(define term_WrelRacq_WrelRacq (concretize term_SB_abst "rel rel rel acq rel acq"))
#|
x_rel = 0; y_rel = 0
x_sc = 1 || y_sc = 1
r1 = y_sc || r2 = x_sc
ret r1 r2
|#
(define term_WscRsc_WscRsc (concretize term_SB_abst "rel rel sc sc sc sc"))
#|
x_rel = 0; y_rel = 0
x_{sc,rel} = 1 || y_{sc,rel} = 1
r1 = y_{sc,rel} || r2 = x_{sc,rel}
ret r1 r2
|#
(define term_WrelRsc_WscRsc (concretize term_SB_abst "rel rel rel sc sc sc"))
(define term_WscRacq_WscRsc (concretize term_SB_abst "rel rel sc acq sc sc"))
(define term_WscRsc_WrelRsc (concretize term_SB_abst "rel rel sc sc rel sc"))
(define term_WscRsc_WscRacq (concretize term_SB_abst "rel rel sc sc sc acq"))
#|
x_rlx = 0; y_rlx = 0
R1 = x_mod0 || R2 = y_mod2
y_mod1 = 1 || x_mod3 = 1
|#
(define (term_LB_abst mod0 mod1 mod2 mod3)
@prog{x_rlx := 0;
y_rlx := 0;
spw
{{{ r1 := x_@mod0;
y_@mod1 := 1;
ret r1
||| r2 := y_@mod2;
x_@mod3 := 1;
ret r2 }}} })
#|
R1 = x_rlx || R2 = y_rlx
y_rlx = 1 || x_rlx = 1
With postponed reads it should be able to lead to R1 = R2 = 1.
|#
(define term_RrlxWrlx_RrlxWrlx (concretize term_LB_abst "rlx rlx rlx rlx"))
#|
R1 = x_rlx || R2 = y_rlx
y_rel = 1 || x_rel = 1
With postponed reads it should be able to lead to R1 = R2 = 1.
Rel modificators solve nothing here.
|#
(define term_RrlxWrel_RrlxWrel (concretize term_LB_abst "rlx rel rlx rel"))
#|
R1 = x_acq || R2 = y_acq
y_rlx = 1 || x_rlx = 1
With postponed reads it should be able to lead to R1 = R2 = 1.
Acq modificators solve nothing here.
|#
(define term_RacqWrlx_RacqWrlx (concretize term_LB_abst "acq rlx acq rlx"))
#|
R1 = x_rlx || R2 = y_rlx
y_sc = 1 || x_sc = 1
With postponed reads it should be able to lead to R1 = R2 = 1.
SC modificators solve nothing here.
|#
(define term_RrlxWsc_RrlxWsc (concretize term_LB_abst "rlx sc rlx sc"))
#|
R1 = x_con || R2 = y_con
y_rlx = 1 || x_rlx = 1
With postponed reads it should be able to lead to R1 = R2 = 1.
|#
(define term_RconWrlx_RconWrlx (concretize term_LB_abst "con rlx con rlx"))
#|
R1 = x_con || R2 = y_con
y_rel = 1 || x_rel = 1
With postponed reads it should be able to lead to R1 = R2 = 1.
Rel modificators solve nothing here,
because consume (con) doesn't provide synchronization.
|#
(define term_RconWrel_RconWrel (concretize term_LB_abst "con rel con rel"))
#|
R1 = x_con || R2 = y_con
y_sc = 1 || x_sc = 1
With postponed reads it should be able to lead to R1 = R2 = 1.
SC modificators solve nothing here,
because consume (con) doesn't provide synchronization.
|#
(define term_RconWsc_RconWsc (concretize term_LB_abst "con sc con sc"))
#|
R1 = x_acq || R2 = y_rlx
y_rel = 1 || x_rel = 1
It's impossible to get R1 = R2 = 1.
|#
(define term_RacqWrel_RrlxWrel (concretize term_LB_abst "acq rel rlx rel"))
#|
R1 = x_rlx || R2 = y_acq
y_rel = 1 || x_rel = 1
It's impossible to get R1 = R2 = 1.
|#
(define term_RrlxWrel_RacqWrel (concretize term_LB_abst "rlx rel acq rel"))
#|
R1 = x_acq || R2 = y_acq
y_rel = 1 || x_rel = 1
It's impossible to get R1 = R2 = 1.
|#
(define term_RacqWrel_RacqWrel (concretize term_LB_abst "acq rel acq rel"))
#|
x_rlx = 0; y_rlx = 0
R1 = x_mod0; || R2 = y_mod2;
R1' = R1 + 1; || R2' = R2 + 1;
y_mod1 = 1; || x_mod3 = 1;
ret R1' || ret R2'
|#
(define (term_LB_abst_let mod0 mod1 mod2 mod3)
@prog{x_rlx := 0;
y_rlx := 0;
spw
{{{ r1 := x_@mod0;
r11 := ret (r1 + 1);
y_@mod1 := 1;
ret r11
||| r2 := y_@mod2;
r21 := ret (r2 + 1);
x_@mod3 := 1;
ret r21 }}} })
(define term_RrlxWrlx_RrlxWrlx_let (concretize term_LB_abst_let "rlx rlx rlx rlx"))
(define term_RrlxWrel_RrlxWrel_let (concretize term_LB_abst_let "rlx rel rlx rel"))
(define term_RrlxWsc_RrlxWsc_let (concretize term_LB_abst_let "rlx sc rlx sc" ))
(define term_RconWrlx_RconWrlx_let (concretize term_LB_abst_let "con rlx con rlx"))
(define term_RconWrel_RconWrel_let (concretize term_LB_abst_let "con rel con rel"))
(define term_RconWsc_RconWsc_let (concretize term_LB_abst_let "con sc con sc" ))
(define term_RacqWrel_RrlxWrel_let (concretize term_LB_abst_let "acq rel rlx rel"))
(define term_RrlxWrel_RacqWrel_let (concretize term_LB_abst_let "rlx rel acq rel"))
(define term_RacqWrel_RacqWrel_let (concretize term_LB_abst_let "acq rel acq rel"))
#|
x_rlx = 0; y_rlx = 0
R1 = x_mod0; || R2 = y_mod2;
z1_rlx = R1; || z2_rlx = R2;
y_mod1 = 1; || x_mod3 = 1;
r1 = z1_mod0; r2 = z2_mod0
ret (r1 r2)
|#
(define (term_LB_abst_use mod0 mod1 mod2 mod3)
@prog{x_rlx := 0;
y_rlx := 0;
spw
{{{ r1 := x_@mod0;
z1_rlx := r1;
y_@mod1 := 1;
ret r1
||| r2 := y_@mod2;
z2_rlx := r2;
x_@mod3 := 1;
ret r2 }}};
r1 := z1_@mod0;
r2 := z2_@mod0;
ret [r1 r2] })
(define term_RrlxWrlx_RrlxWrlx_use (concretize term_LB_abst_use "rlx rlx rlx rlx"))
(define term_RrlxWrel_RrlxWrel_use (concretize term_LB_abst_use "rlx rel rlx rel"))
(define term_RrlxWsc_RrlxWsc_use (concretize term_LB_abst_use "rlx sc rlx sc" ))
(define term_RconWrlx_RconWrlx_use (concretize term_LB_abst_use "con rlx con rlx"))
(define term_RconWrel_RconWrel_use (concretize term_LB_abst_use "con rel con rel"))
(define term_RconWsc_RconWsc_use (concretize term_LB_abst_use "con sc con sc" ))
(define term_RacqWrel_RrlxWrel_use (concretize term_LB_abst_use "acq rel rlx rel"))
(define term_RrlxWrel_RacqWrel_use (concretize term_LB_abst_use "rlx rel acq rel"))
(define term_RacqWrel_RacqWrel_use (concretize term_LB_abst_use "acq rel acq rel"))
#|
x_mod0 = 0; y_mod0 = 0
x_mod1 = 1; || y_mod3 = 1;
y_mod2 = 2; || x_mod4 = 2;
r1 = x_mod5; r2 = z2_mod5
ret (r1 r2)
It should be possible to get r1 = r2 = 1, if there is no thread with
both release accesses.
|#
(define (term_2+2W_abst mod0 mod1 mod2 mod3 mod4 mod5)
@prog{x_@mod0 := 0;
y_@mod0 := 0;
spw
{{{ x_@mod1 := 1;
y_@mod2 := 2;
ret 0
||| y_@mod3 := 1;
x_@mod4 := 2;
ret 0 }}};
r1 := x_@mod5;
r2 := y_@mod5;
ret [r1 r2] })
(define term_2+2W_rlx (concretize term_2+2W_abst "rlx rlx rlx rlx rlx rlx"))
(define term_2+2W_rel_acq (concretize term_2+2W_abst "rel rel rel rel rel acq"))
(define term_2+2W_rel1_rlx (concretize term_2+2W_abst "rlx rel rlx rel rlx rlx"))
(define term_2+2W_rel2_rlx (concretize term_2+2W_abst "rlx rlx rel rlx rel rlx"))
(define term_2+2W_rel3_rlx (concretize term_2+2W_abst "rlx rlx rel rel rlx rlx"))
#|
x_na = 1 || x_na = 2
It should get `stuck`.
|#
(define testTerm2
@prog{spw
{{{ x_na := 1
||| x_na := 2 }}} })
#|
c_rel = 0
a_na = 7 || repeat (c_acq) end
c_rel = 1 || a_na = a_na + 1
ret a_na
Example from: Vafeiadis-Narayan:OOPSLA13
"Relaxed Separation Logic: A Program Logic for C11 Concurrency".
It shouldn't get `stuck`.
|#
(define testMP+rel+acq ; testTerm3
@prog{c_rel := 0;
spw
{{{ a_na := 7;
c_rel := 1
||| repeat c_acq end;
r1 := a_na;
a_na := r1 + 1 }}};
r0 := a_na;
ret r0 })
#|
c_rel = 0
a_na = 7 || repeat (c_rlx) end
c_rel = 1 || fence acq
|| a_na = a_na + 1
ret a_na
Example from: Vafeiadis-Narayan:OOPSLA13
"Relaxed Separation Logic: A Program Logic for C11 Concurrency".
It shouldn't get `stuck`.
|#
(define testMP+rel+rlx+fence
@prog{c_rel := 0;
spw
{{{ a_na := 7;
c_rel := 1
||| repeat c_rlx end;
fence acq;
r1 := a_na;
a_na := r1 + 1 }}};
r0 := a_na;
ret r0 })
#|
c_rel = 0
a_na = 7 || repeat (c_rlx) end
fence rel || fence acq
c_rlx = 1 || a_na = a_na + 1
ret a_na
Example from: Vafeiadis-Narayan:OOPSLA13
"Relaxed Separation Logic: A Program Logic for C11 Concurrency".
It shouldn't get `stuck`.
|#
(define testMP+rlx+fence
@prog{c_rel := 0;
spw
{{{ a_na := 7;
fence rel;
c_rlx := 1
||| repeat c_rlx end;
fence acq;
r1 := a_na;
a_na := r1 + 1 }}};
r0 := a_na;
ret r0 })
#|
c_rlx = 0
a_na = 7 || repeat (c_rlx) end
c_rlx = 1 || a_na = a_na + 1
ret a_na
Example from: Vafeiadis-Narayan:OOPSLA13
"Relaxed Separation Logic: A Program Logic for C11 Concurrency".
It uses rlx writes and reads instead of rel/acq, and it leads to `stuck`.
|#
(define testMP+rlx ; testTerm3-0
@prog{c_rlx := 0;
spw
{{{ a_na := 7;
c_rlx := 1
||| repeat c_rlx end;
r1 := a_na;
a_na := r1 + 1 }}};
r0 := a_na;
ret r0 })
#|
c_rlx = 0
r1 = a_na || repeat (c_rlx) end
c_rlx = 1 || a_na = 5
ret a_na
|#
(define testMP+read+rlx
@prog{c_rlx := 0;
a_na := 0;
spw
{{{ r2 := a_na;
c_rlx := 1
||| repeat c_rlx end;
a_na := 5 }}};
ret 0 })
#|
c_rlx = 0
r1 = a_na || repeat (c_rlx) end
c_rel = 1 || a_na = 5
ret a_na
|#
(define testMP+read+rel
@prog{c_rlx := 0;
a_na := 0;
spw
{{{ r2 := a_na;
c_rel := 1
||| repeat c_rlx end;
a_na := 5 }}};
ret 0 })
#|
c_rlx = 0
a_rlx = 7 || if (c_acq)
c_rel = 1 || a_rlx = a_rlx + 1
ret a_rlx
|#
(define testMP-If+rel+acq ; testTerm3-1
@prog{c_rlx := 0;
spw
{{{ a_rlx := 7;
c_rel := 1
||| r2 := c_acq;
if r2
then r1 := a_rlx;
a_rlx := r1 + 1
else ret 0
fi }}};
r0 := a_rlx;
ret r0 })
#|
c_sc = 0
a_na = 7 || repeat (c_sc) end
c_sc = 1 || a_na = a_na + 1
ret a_na
Version with SC modifiers instead of Rel/Acq.
Example from: VafeiadisNarayan:OOPSLA13
"Relaxed Separation Logic: A Program Logic for C11 Concurrency".
It shouldn't get `stuck`.
|#
(define testMP+sc ; testTerm3-2
@prog{c_sc := 0;
spw
{{{ a_na := 7;
c_sc := 1
||| repeat c_sc end;
r1 := a_na;
a_na := r1 + 1 }}};
r0 := a_na;
ret r0 })
#|
Dekker's lock doesn't work in weak memory settings (and in our model).
x_rel = 0
y_rel = 0
x_rel = 1 || y_rel = 1
if y_acq == 0 then || if x_acq == 0 then
a_na = 239 a_na = 30
It should get `stuck` because of concurrent non-atomic writes.
|#
(define testTerm4
@prog{x_rel := 0;
y_rel := 0;
spw
{{{ x_rel := 1;
r0 := y_acq;
if r0 == 0
then a_na := 239
else ret 0
fi
||| y_rel := 1;
r1 := x_acq;
if r1 == 0
then a_na := 30
else ret 0
fi }}} })
#|
Ernie Cohen's lock should work in weak memory settings.
Described in Turon-al:OOPSLA14.
x_rel = 0
y_rel = 0
x_rel = choice(1, 2) || y_rel = choice(1, 2)
repeat y_acq end || repeat x_acq end
if x_acq == y_acq then || if x_acq != y_acq then
a_na = 239 || a_na = 239
|#
(define testTerm5
@prog{x_rel := 0;
y_rel := 0;
spw
{{{ x_rel := choice 1 2;
repeat y_acq end;
r0 := x_acq;
r1 := y_acq;
if r0 == r1
then a_na := 239
else ret 0
fi
||| y_rel := choice 1 2;
repeat x_acq end;
r2 := x_acq;
r3 := y_acq;
if r2 != r3
then a_na := 239
else ret 0
fi }}} })
#| CoRR_rlx (Coherence of Read-Read)
x_rlx = 0
x_rlx = 1 || x_rlx = 2 || a = x_rlx || c = x_rlx
|| || b = x_rlx || d = x_rlx
The execution a = d = 1 and b = c = 2 should be invalid.
|#
(define testTerm6
@prog{x_rlx := 0;
rABCD := spw
{{{ spw
{{{ x_rlx := 1
||| x_rlx := 2 }}}
||| spw
{{{ rA := x_rlx;
rB := x_rlx;
ret [rA rB]
||| rC := x_rlx;
rD := x_rlx;
ret [rC rD] }}} }}};
ret rABCD_2})
#| CoRR_rel+acq (Coherence of Read-Read)
x_rel = 0
x_rel = 1 || x_rel = 2 || a = x_acq || c = x_acq
|| || b = x_acq || d = x_acq
The execution a = d = 1 and b = c = 2 should be invalid.
|#
(define test_CoRR_rel+acq
@prog{x_rel := 0;
rABCD := spw
{{{ spw
{{{ x_rel := 1
||| x_rel := 2 }}}
||| spw
{{{ rA := x_acq;
rB := x_acq;
ret [rA rB]
||| rC := x_acq;
rD := x_acq;
ret [rC rD] }}} }}};
ret rABCD_2})
#|
IRIW. Anti-TSO example.
x_rlx = 0
y_rlx = 0
x_rlx = 1 || y_rlx = 1 || a = x_rlx || c = y_rlx
|| || b = y_rlx || d = x_rlx
The `ret ((1 0) (0 1))` shows that our model is more relaxed
than x86-TSO [Sewell-al:CACM10].
|#
(define testTerm65
@prog{x_rlx := 0;
y_rlx := 0;
rABCD := spw
{{{ spw
{{{ x_rlx := 1
||| y_rlx := 1 }}}
||| spw
{{{ rA := x_rlx;
rB := y_rlx;
ret [rA rB]
||| rC := y_rlx;
rD := x_rlx;
ret [rC rD] }}} }}};
ret rABCD_2})
#|
IRIW. Anti-TSO example. (Release+Acquire)
x_rel = 0
y_rel = 0
x_rel = 1 || y_rel = 1 || a = x_acq || c = y_rel
|| || b = y_acq || d = x_rel
The `ret ((1 0) (0 1))` shows that our model is more relaxed
than x86-TSO [Sewell-al:CACM10].
|#
(define testTerm67
@prog{x_rel := 0;
y_rel := 0;
rABCD := spw
{{{ spw
{{{ x_rel := 1
||| y_rel := 1 }}}
||| spw
{{{ rA := x_acq;
rB := y_acq;
ret [rA rB]
||| rC := y_acq;
rD := x_acq;
ret [rC rD] }}} }}};
ret rABCD_2})
#|
Anti-TSO example.
It shows why our model isn't TSO.
x_rlx = 0; y_rlx = 0
x_rlx = 1 || a = y_rlx
y_rlx = 1 || b = x_rlx
In TSO a = 1 and b = 0 is forbidden outcome. But not in our semantics.
|#
(define testTerm7
@prog{x_rlx := 0;
y_rlx := 0;
rAB := spw
{{{ x_rlx := 1;
y_rlx := 1
||| rA := y_rlx;
rB := x_rlx;
ret [rA rB] }}};
ret rAB_2})
#|
cas rlx sc "x" 1 0
Leads to `stuck` state, because Compare-and-Set (Read-Modify-Write) operations in C11 are
undefined if success modifier is weaker than fail modifier.
|#
(define testTerm8
@prog{cas_rlx_sc(x, 1, 0)})
#|
An example from VafeiadisNarayan:OOPSLA13. It shouldn't get `stuck`.
lock = 1
a_na = 2 || if ((cas_acq_rlx lock 0 1) || if ((cas_acq_rlx lock 0 1)
lock_rel = 0 || == 0) || == 0)
|| then ||
|| a_na = 3 || a_na = 2
|| else (ret -1) || else (ret -1)
|#
(define testTerm9
@prog{lock_rel := 1;
r2 := spw
{{{ a_na := 2;
lock_rel := 0
||| spw
{{{ r0 := cas_acq_rlx(lock, 0, 1);
if r0 == 0
then a_na := 3
else ret 0 - 1
fi
||| r1 := cas_acq_rlx(lock, 0, 1);
if r1 == 0
then a_na := 2
else ret 0 - 1
fi }}} }}};
ret r2_2})
#|
x_rel = 0; y_rel = 0
x_rel = 5 || y_rel = 5
a_sc = 0 || b_sc = 0
r1 = y_acq || r2 = x_acq
ret r1 r2
In Batty-al:POPL11 it's possible to get r1 = 0 /\ r2 = 0.
|#
(define testTerm10
@prog{x_rel := 0;
y_rel := 0;
r0 := spw
{{{ x_rel := 5;
a_sc := 0;
r1 := y_acq;
ret r1
||| y_rel := 5;
b_sc := 0;
r2 := x_acq;
ret r2 }}};
ret r0})
#|
x_rlx = 0; y_rlx = 0
y_rlx = 1 || if (x_acq == 2) {
x_rel = 1 || r1 = y_rlx
x_rlx = 2 || ret 0 || } else {
|| r1 = 0 }
According to Batty-al:POPL11 it's possible to get r1 = 0, because
there is no release sequence between x_rel = 1 and x_rlx = 2.
|#
(define term_Wrel_Wrlx_Racq
@prog{x_rlx := 0;
y_rlx := 0;
r0 := spw
{{{ y_rlx := 1;
x_rel := 1;
spw
{{{ x_rlx := 2
||| ret 0 }}}
||| r2 := x_acq;
if r2 == 2
then y_rlx
else ret 0
fi }}};
ret r0_2 })
#|
x_rel = 0
x_rel = 1 || r = x_acq
x_na = 2 ||
Should lead to `stuck` because of VafeiadisNarayan:OOPSLA (ConsistentRFna) ---
`x_na = 2` and `r = x_acq` aren't happens-before ordered.
|#
(define term_WrelWna_Racq
@prog{x_rel := 0;
spw
{{{ x_rel := 1;
x_na := 2
||| r0 := x_acq;
ret r0 }}} })
#|
x_rlx = 0; y_rlx = 0
R1 = x_mod0 || R2 = y_mod2
y_mod1 = 1 || x_mod3 = 1
|| x_mod4 = 2
|#
(define (abst_RW_RWW mod0 mod1 mod2 mod3 mod4)
@prog{x_rlx := 0;
y_rlx := 0;
spw
{{{ r1 := x_@mod0;
y_@mod1 := 1;
ret r1
||| r2 := y_@mod2;
x_@mod3 := 1;
x_@mod4 := 2;
ret r2 }}} })
#|
x_rlx = 0; y_rlx = 0
R1 = x_rlx || R2 = y_rlx
y_rlx = 1 || x_rlx = 1
|| x_rlx = 2
With postponed reads it should be able to lead to R1 = 2; R1 = 1.
|#
(define term_RrlxWrlx_RrlxWrlxWrlx (concretize abst_RW_RWW "rlx rlx rlx rlx rlx"))
#|
x_rlx = 0; y_rlx = 0
R1 = x_acq || R2 = y_rlx
y_rlx = 1 || x_rel = 1
|| x_rlx = 2
With postponed reads it shouldn't lead to R1 = 2; R1 = 1.
|#
(define term_RacqWrlx_RrlxWrelWrlx (concretize abst_RW_RWW "acq rlx rlx rel rlx"))
#|
x_rlx = 0; y_rlx = 0
R1 = y_mod0 || ret 0 || R2 = x_mod2 || ret 0
x_mod1 = 1 || y_mod3 = 1
ret (R1 R2)
|#
(define (abst_R-W_R-W mod0 mod1 mod2 mod3)
@prog{x_rlx := 0;
y_rlx := 0;
spw
{{{ r10 := spw
{{{ r1 := y_@mod0;
ret r1
||| ret 0 }}};
x_@mod1 := 1;
ret r10_1
||| r20 := spw
{{{ r2 := x_@mod2;
ret r2
||| ret 0 }}};
y_@mod3 := 1;
ret r20_1 }}} })
#|
x_rlx = 0; y_rlx = 0
R1 = y_rlx || ret 0 || R2 = x_rlx || ret 0
x_rlx = 1 || y_rlx = 1
ret (R1 R2)
|#
(define term_Rrlx-Wrlx_Rrlx-Wrlx (concretize abst_R-W_R-W "rlx rlx rlx rlx"))
#|
x_rlx = 0; y_rlx = 0
R1 = y_acq || ret 0 || R2 = x_acq || ret 0
x_rlx = 1 || y_rlx = 1
ret (R1 R2)
|#
(define term_Racq-Wrlx_Racq-Wrlx (concretize abst_R-W_R-W "acq rlx acq rlx"))
#|
x_rlx = 0; y_rlx = 0
R1 = y_rlx || ret 0 || R2 = x_rlx || ret 0
x_rel = 1 || y_rel = 1
ret (R1 R2)
|#
(define term_Rrlx-Wrel_Rrlx-Wrel (concretize abst_R-W_R-W "rlx rel rlx rel"))
#|
x_rlx = 0; y_rlx = 0
R1 = y_rlx || ret 0 || R2 = x_acq || ret 0
x_rel = 1 || y_rel = 1
ret (R1 R2)
|#
(define term_Rrlx-Wrel_Racq-Wrel (concretize abst_R-W_R-W "rlx rel acq rel"))
#|
x_rlx = 0; y_rlx = 0
y_rlx = 1 || cas_rlx,rlx(x, 1, 2) || r1 = x_acq
x_rel = 1 || || r2 = y_rlx
It's impossible to get r1 = 2; r2 = 0, due to synchronization through
RMW (cas) operation.
|#
(define term_WrlxWrel_RMWrlxrlx_RacqRrlx
@prog{x_rlx := 0;
y_rlx := 0;
r012 := spw
{{{ spw
{{{ y_rlx := 1;
x_rel := 1
||| cas_rlx_rlx(x, 1, 2)
}}}
||| r1 := x_acq;
r2 := y_rlx;
ret [r1 r2] }}};
ret r012_2 })
#|
x_rel = 0; y_rel = 1
x_mod0 = 1 || y_mod2 = 2
r1 = y_mod1 || r2 = x_mod3
ret (r1 r2)
|#
(define (abst_W1R_W2R mod0 mod1 mod2 mod3)
@prog{x_rel := 0;
y_rel := 1;
spw
{{{ x_@mod0 := 1;
r1 := y_@mod1;
ret r1
||| y_@mod2 := 2;
r2 := x_@mod3;
ret r2 }}} })
(define term_W1rlxRrlx_W2rlxRrlx (concretize abst_W1R_W2R "rlx rlx rlx rlx"))
(define term_W1relRrlx_W2relRrlx (concretize abst_W1R_W2R "rel rlx rel rlx"))
(define term_W1relRacq_W2relRacq (concretize abst_W1R_W2R "rel acq rel acq"))
(define term_W1scRsc_W2relRacq (concretize abst_W1R_W2R "sc sc rel acq"))
(define term_W1scRsc_W2scRacq (concretize abst_W1R_W2R "sc sc sc acq"))
(define term_W1scRsc_W2scRsc (concretize abst_W1R_W2R "sc sc sc sc "))
#|
data_na = 0
dataP_na = 0
p_rel = 0
data_na = 5 || r1 = p_con
dataP_na = &data ||
p_rel = &dataP || if (r1 != 0) {
|| r3 = r1_na
|| r2 = r3_na
|| else
|| r2 = 1
Possible outcomes for r2 are 1 and 5.
|#
(define term_MP_pointer_consume
@prog{data_na := 0;
dataP_na := 0;
p_rel := 0;
r0 := spw
{{{ data_na := 5;
dataP_na := data;
p_rel := dataP
||| r1 := p_con;
if r1 != 0
then r3 := r1_na;
r3_na
else ret 1
fi }}};
ret r0_2 })
#|
WRC_rel+acq
x_rel = 0; y_rel = 0
x_rel = 1 || r1 = x_acq || r2 = y_acq
|| y_rel = r1 || r3 = x_acq
Impossible outcome: r2 = 1 /\ r3 = 0.
|#
(define term_WRC_rel+acq
@prog{x_rel := 0;
y_rel := 0;
r0 := spw
{{{ spw
{{{ x_rel := 1
||| r1 := x_acq;
y_rel := r1 }}}
||| r2 := y_acq;
r3 := x_acq;
ret [r2 r3] }}};
ret r0_2})
#|
WRC_rlx
x_rlx = 0; y_rlx = 0
x_rlx = 1 || r1 = x_rlx || r2 = y_rlx
|| y_rlx = r1 || r3 = x_rlx
Possible outcome: r2 = 1 /\ r3 = 0.
|#
(define term_WRC_rlx
@prog{x_rlx := 0;
y_rlx := 0;
r0 := spw
{{{ spw
{{{ x_rlx := 1
||| r1 := x_rlx;
y_rlx := r1 }}}
||| r2 := y_rlx;
r3 := x_rlx;
ret [r2 r3] }}};
ret r0_2})
#|
x_rlx = 0; y_rlx = 0; z_rlx = 0;
if (x_mod1) { || if (y_mod3) {
z_rlx = 1 || x_mod4 = 1
y_mod2 = 1 || }
} else { ||
y_mod2 = 1 ||
} ||
r = z_rlx
Possible outcome: r = 1
|#
(define (term_nOTA_abst mod0 mod1 mod2 mod3 mod4)
@prog{x_rlx := 0;
y_rlx := 0;
z_rlx := 0;
spw
{{{ r1 := x_@mod0;
if r1
then z_rlx := 1;
y_@mod2 := 1
else y_@mod2 := 1
fi
||| r2 := y_@mod0;
if r2
then x_@mod2 := 1
else ret 0
fi }}};
z_rlx })
(define term_nOTA_rlx (concretize term_nOTA_abst "rlx rlx rlx rlx rlx"))
#|
x_rlx = 0; y_rlx = 0;
z_rlx = 0; f_rlx = 0;
if (x_mod1) { || if (y_mod3) {
if (f_rlx) { || f_rlx = 1
z_rlx = 1 || x_mod4 = 1
y_mod2 = 1 || }
} else { ||
y_mod2 = 1 ||
} ||
} else { ||
y_mod2 = 1 ||
} ||
r = z_rlx
Possible outcome: r = 1
|#
(define (term_nOTA_nestIf_abst mod0 mod1 mod2 mod3 mod4)
@prog{x_rlx := 0;
y_rlx := 0;
z_rlx := 0;
f_rlx := 0;
spw
{{{ r1 := x_@mod0;
if r1
then r2 := f_rlx;
if r2
then z_rlx := 1;
y_@mod2 := 1
else y_@mod2 := 1
fi
else y_@mod2 := 1