xref: /kernel/linux/linux-6.6/tools/memory-model/litmus-tests/MP+poonceonces.litmus (revision 62306a36)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /kernel/linux/linux-6.6/tools/memory-model/litmus-tests/
162306a36Sopenharmony_ciC MP+poonceonces
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci(*
462306a36Sopenharmony_ci * Result: Sometimes
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Can the counter-intuitive message-passing outcome be prevented with
762306a36Sopenharmony_ci * no ordering at all?
862306a36Sopenharmony_ci *)
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci{}
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ciP0(int *buf, int *flag) // Producer
1362306a36Sopenharmony_ci{
1462306a36Sopenharmony_ci	WRITE_ONCE(*buf, 1);
1562306a36Sopenharmony_ci	WRITE_ONCE(*flag, 1);
1662306a36Sopenharmony_ci}
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ciP1(int *buf, int *flag) // Consumer
1962306a36Sopenharmony_ci{
2062306a36Sopenharmony_ci	int r0;
2162306a36Sopenharmony_ci	int r1;
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci	r0 = READ_ONCE(*flag);
2462306a36Sopenharmony_ci	r1 = READ_ONCE(*buf);
2562306a36Sopenharmony_ci}
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ciexists (1:r0=1 /\ 1:r1=0) (* Bad outcome. *)
28

Indexes created Thu Nov 07 10:32:03 CST 2024