xref: /linux/tools/memory-model/litmus-tests/MP+poonceonces.litmus (revision 26fbb4c8c7c3ee9a4c3b4de555a8587b5a19154e)
1C MP+poonceonces
2
3(*
4 * Result: Sometimes
5 *
6 * Can the counter-intuitive message-passing outcome be prevented with
7 * no ordering at all?
8 *)
9
10{
11	int buf;
12	int flag;
13}
14
15P0(int *buf, int *flag) // Producer
16{
17	WRITE_ONCE(*buf, 1);
18	WRITE_ONCE(*flag, 1);
19}
20
21P1(int *buf, int *flag) // Consumer
22{
23	int r0;
24	int r1;
25
26	r0 = READ_ONCE(*flag);
27	r1 = READ_ONCE(*buf);
28}
29
30exists (1:r0=1 /\ 1:r1=0) (* Bad outcome. *)
31