Add reader nesting test
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Thu, 26 Feb 2009 23:01:12 +0000 (18:01 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Thu, 26 Feb 2009 23:01:12 +0000 (18:01 -0500)
Add readers with configurable nesting level.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
formal-model/urcu/DEFINES
formal-model/urcu/Makefile
formal-model/urcu/urcu.spin

index 855dbd5eeae61df5de77a19919bf422988d410c2..4224b3238c2b0832e9072f553384ce7ea0c4ee7f 100644 (file)
@@ -3,3 +3,7 @@
 
 #define read_free_race (read_generation == last_free_gen)
 #define read_free      (free_done && data_access)
+
+#ifndef READER_NEST_LEVEL
+#define READER_NEST_LEVEL 1
+#endif
index c52c4badaf93e2dcbcbd96ae1b22e014e4fcaf09..498241b2e0ed64e8071dfeea2d274ecbb0b29e27 100644 (file)
@@ -23,6 +23,7 @@ SPINFILE=urcu.spin
 
 default:
        make urcu_free | tee urcu_free.log
+       make urcu_free_nested | tee urcu_free_nested.log
        make urcu_free_no_rmb | tee urcu_free_no_rmb.log
        make urcu_free_no_wmb | tee urcu_free_no_wmb.log
        make urcu_free_no_mb | tee urcu_free_no_mb.log
@@ -55,6 +56,13 @@ urcu_free: clean urcu_free_ltl run
        cp .input.spin $@.spin.input
        -cp .input.spin.trail $@.spin.input.trail
 
+urcu_free_nested: clean urcu_free_ltl urcu_free_nested_define run
+       cp .input.spin $@.spin.input
+       -cp .input.spin.trail $@.spin.input.trail
+
+urcu_free_nested_define:
+       cp urcu_free_nested.define .input.define
+
 urcu_free_no_rmb: clean urcu_free_ltl urcu_free_no_rmb_define run
        cp .input.spin $@.spin.input
        -cp .input.spin.trail $@.spin.input.trail
@@ -129,8 +137,8 @@ urcu_progress_writer_error_define:
 
 urcu_progress_writer_error_ltl:
        touch .input.define
-       cat DEFINES > pan.ltl
        cat .input.define >> pan.ltl
+       cat DEFINES > pan.ltl
        spin -f "!(`cat urcu_progress.ltl | grep -v ^//`)" >> pan.ltl
 
 
@@ -144,8 +152,8 @@ pan: pan.c
        gcc -w ${CFLAGS} -o pan pan.c
 
 pan.c: pan.ltl ${SPINFILE}
-       cat DEFINES > .input.spin
        cat .input.define >> .input.spin
+       cat DEFINES > .input.spin
        cat ${SPINFILE} >> .input.spin
        rm -f .input.spin.trail
        spin -a -X -N pan.ltl .input.spin
index e9271f82bb58e3acdef1db13aa7226e011d48200..17c6612c8c23880961be2fa63d99b08cfb09e030 100644 (file)
@@ -178,7 +178,7 @@ inline wait_for_quiescent_state(tmp, i, j)
 
 active [NR_READERS] proctype urcu_reader()
 {
-       byte i;
+       byte i, nest_i;
        byte tmp, tmp2;
 
        assert(get_pid() < NR_PROCS);
@@ -196,33 +196,47 @@ end_reader:
 #ifdef READER_PROGRESS
 progress_reader:
 #endif
-               ooo_mem(i);
-               tmp = READ_CACHED_VAR(urcu_active_readers_one);
-               ooo_mem(i);
-               if
-               :: (!(tmp & RCU_GP_CTR_NEST_MASK))
-                       ->
-                       tmp2 = READ_CACHED_VAR(urcu_gp_ctr);
+               nest_i = 0;
+               do
+               :: nest_i < READER_NEST_LEVEL ->
                        ooo_mem(i);
-                       WRITE_CACHED_VAR(urcu_active_readers_one, tmp2);
-               :: else ->
-                       WRITE_CACHED_VAR(urcu_active_readers_one, tmp + 1);
-               fi;
+                       tmp = READ_CACHED_VAR(urcu_active_readers_one);
+                       ooo_mem(i);
+                       if
+                       :: (!(tmp & RCU_GP_CTR_NEST_MASK))
+                               ->
+                               tmp2 = READ_CACHED_VAR(urcu_gp_ctr);
+                               ooo_mem(i);
+                               WRITE_CACHED_VAR(urcu_active_readers_one, tmp2);
+                       :: else ->
+                               WRITE_CACHED_VAR(urcu_active_readers_one, tmp + 1);
+                       fi;
+                       ooo_mem(i);
+                       smp_mb(i);
+                       nest_i++;
+               :: nest_i >= READER_NEST_LEVEL -> break;
+               od;
+
                ooo_mem(i);
-               smp_mb(i);
                read_generation = READ_CACHED_VAR(generation_ptr);
                ooo_mem(i);
                data_access = 1;
                ooo_mem(i);
                data_access = 0;
+
+               nest_i = 0;
+               do
+               :: nest_i < READER_NEST_LEVEL ->
+                       ooo_mem(i);
+                       smp_mb(i);
+                       ooo_mem(i);
+                       tmp2 = READ_CACHED_VAR(urcu_active_readers_one);
+                       ooo_mem(i);
+                       WRITE_CACHED_VAR(urcu_active_readers_one, tmp2 - 1);
+                       nest_i++;
+               :: nest_i >= READER_NEST_LEVEL -> break;
+               od;
                ooo_mem(i);
-               smp_mb(i);
-               ooo_mem(i);
-               tmp2 = READ_CACHED_VAR(urcu_active_readers_one);
-               ooo_mem(i);
-               WRITE_CACHED_VAR(urcu_active_readers_one, tmp2 - 1);
-               ooo_mem(i);
-               //wakeup_all(i);
                //smp_mc(i);    /* added */
        od;
 }
This page took 0.028395 seconds and 4 git commands to generate.