hash table comment fix.
[urcu.git] / formal-model / ooomem-two-writes / mem.spin
index cb206d2596ef0a24b5b1d29aafba953e0dd1b356..304c3f80f534aeba276c7ef7dc1efa3706a04fc9 100644 (file)
@@ -1,5 +1,21 @@
 /*
- * mem.spin: Promela code to validate memory barriers with OOO memory.
+ * mem.spin: Promela code to validate memory barriers with out-of-order memory
+ * and out-of-order instruction scheduling.
+ *
+ * Algorithm verified :
+ *
+ * alpha = 0;
+ * beta = 0;
+ * x = 1;
+ * y = 1;
+ *
+ * Process A                  Process B
+ * alpha = 1;                 beta = 1;
+ * mb();                      mb();
+ * x = beta;                  y = alpha;
+ *
+ * if x = 0, then y != 0
+ * if y = 0, then x != 0
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 /* Promela validation variables. */
 
 /*
- * Produced process data flow. Updated after each instruction to show which
- * variables are ready. Assigned using SSA (static single assignment) (defuse
- * analysis must be done on the program to map "real" variables to single define
- * followed by use). Using one-hot bit encoding per variable to save state
- * space.  Used as triggers to execute the instructions having those variables
- * as input.
+ * Produced process control and data flow. Updated after each instruction to
+ * show which variables are ready. Using one-hot bit encoding per variable to
+ * save state space. Used as triggers to execute the instructions having those
+ * variables as input. Leaving bits active to inhibit instruction execution.
+ * Scheme used to make instruction disabling and automatic dependency fall-back
+ * automatic.
  */
 
-#define PRODUCE_TOKENS(state, bits)    \
-       state = (state) | (bits)
+#define CONSUME_TOKENS(state, bits, notbits)                   \
+       ((!(state & (notbits))) && (state & (bits)) == (bits))
 
-/* All bits must be active to consume. All notbits must be inactive. */
-/* Consuming a token does not clear it, it just waits for it. */
-#define CONSUME_TOKENS(state, bits, notbits)                           \
-       ((!((state) & (notbits))) && ((state) & (bits)) == (bits))
+#define PRODUCE_TOKENS(state, bits)                            \
+       state = state | (bits);
 
-#define CLEAR_TOKENS(state, bits)      \
-       state = (state) & ~(bits)
+#define CLEAR_TOKENS(state, bits)                              \
+       state = state & ~(bits)
 
 #define NR_PROCS 2
 
@@ -144,9 +158,8 @@ inline smp_mb()
 DECLARE_CACHED_VAR(byte, alpha, 0);
 DECLARE_CACHED_VAR(byte, beta, 0);
 
-/* value 2 is uninitialized */
-byte read_one = 2;
-byte read_two = 2;
+byte read_one = 1;
+byte read_two = 1;
 
 /*
  * Bit encoding, proc_one_produced :
This page took 0.024201 seconds and 4 git commands to generate.