bit need_mb = 0; /* =1 says need reader mb, =0 for reader response. */
byte reader_progress[4];
/* Count of read-side statement executions. */
+bit reader_done = 0;
+ /* =0 says reader still running, =1 says done. */
+bit updater_done = 0;
+ /* =0 says updater still running, =1 says done. */
/* urcu definitions and variables, taken straight from the algorithm. */
do
:: need_mb == 1 ->
need_mb = 0;
- :: 1 -> skip;
+ :: !updater_done -> skip;
:: 1 -> break;
od;
reader_progress[2] +
reader_progress[3] == 0) && need_mb == 1 ->
need_mb = 0;
- :: 1 -> skip;
+ :: !updater_done -> skip;
:: 1 -> break;
od;
urcu_active_readers = tmp;
do
:: need_mb == 1 ->
need_mb = 0;
- :: 1 -> skip;
+ :: !updater_done -> skip;
:: 1 -> break;
od;
:: else -> skip;
od;
assert((tmp_free == 0) || (tmp_removed == 1));
+ /* Reader has completed. */
+ reader_done = 1;
+
/* Process any late-arriving memory-barrier requests. */
do
:: need_mb == 1 ->
need_mb = 0;
- :: 1 -> skip;
+ :: !updater_done -> skip;
:: 1 -> break;
od;
}
/* free-up step, e.g., kfree(). */
free = 1;
+
+ /*
+ * Signal updater done, ending any otherwise-infinite loops
+ * in the reading process.
+ */
+ updater_done = 1;
}
/*