]> pd.if.org Git - nbds/blobdiff - runtime/rcu.c
add hazard pointer implementation. buggy
[nbds] / runtime / rcu.c
index 5ae851be58f5ef7021a10a78aeda6142e01e181e..50205e8670173c2d2ab55089ae1cac4b4bb80901 100644 (file)
@@ -12,6 +12,7 @@
 #include "lwt.h"
 #include "mem.h"
 #include "tls.h"
+#include "rcu.h"
 
 #define RCU_POST_THRESHOLD 10
 #define RCU_QUEUE_SCALE 20
@@ -71,17 +72,18 @@ void rcu_update (void) {
     }
 }
 
-void nbd_defer_free (void *x) {
+void rcu_defer_free (void *x) {
+    assert(x);
     LOCALIZE_THREAD_LOCAL(tid_, int);
     fifo_t *q = pending_[tid_];
     assert(MOD_SCALE(q->head + 1, q->scale) != MOD_SCALE(q->tail, q->scale));
     uint32_t i = MOD_SCALE(q->head++, q->scale);
     q->x[i] = x;
-    TRACE("r0", "nbd_defer_free: put %p on queue at position %llu", x, pending_[tid_]->head);
+    TRACE("r0", "rcu_defer_free: put %p on queue at position %llu", x, pending_[tid_]->head);
 
     if (pending_[tid_]->head - rcu_last_posted_[tid_][tid_] < RCU_POST_THRESHOLD)
         return;
-    TRACE("r0", "nbd_defer_free: posting %llu", pending_[tid_]->head, 0);
+    TRACE("r0", "rcu_defer_free: posting %llu", pending_[tid_]->head, 0);
     int next_thread_id = (tid_ + 1) % num_threads_;
     rcu_[next_thread_id][tid_] = rcu_last_posted_[tid_][tid_] = pending_[tid_]->head;
 }