]> pd.if.org Git - nbds/blobdiff - runtime/rcu.c
add beginings of transactional ht
[nbds] / runtime / rcu.c
index dfa49c8652ed277de7eb847716bd61d0f21e96a5..f5e3c3ca27bc53252e447fb99b086b0d863db5a4 100644 (file)
@@ -2,14 +2,15 @@
  * Written by Josh Dybnis and released to the public domain, as explained at
  * http://creativecommons.org/licenses/publicdomain
  *
- * safe memory reclemation using a simple technique from rcu
+ * safe memory reclamation using a simple technique from rcu
+ *
+ * WARNING: not robust enough for real-world use
  */
 #include <string.h>
 #include "common.h"
-#include "rcu.h"
+#include "runtime_local.h"
 #include "lwt.h"
 #include "mem.h"
-#include "nbd.h"
 #include "tls.h"
 
 #define RCU_POST_THRESHOLD 10
@@ -101,9 +102,9 @@ void nbd_defer_free (void *x) {
 }
 
 #ifdef MAKE_rcu_test
-#include <pthread.h>
 #include <errno.h>
 #include <stdio.h>
+#include "runtime.h"
 
 #define NUM_ITERATIONS 10000000
 
@@ -152,7 +153,6 @@ node_t *node_alloc (void) {
 void *worker (void *arg) {
     int id = (int)(size_t)arg;
     unsigned int rand_seed = (unsigned int)id + 1;
-    nbd_thread_init(id);
 
     // Wait for all the worker threads to be ready.
     __sync_fetch_and_add(&wait_, -1);
@@ -199,7 +199,7 @@ int main (int argc, char **argv) {
 
     pthread_t thread[num_threads];
     for (int i = 0; i < num_threads; ++i) {
-        int rc = pthread_create(thread + i, NULL, worker, (void *)(size_t)i);
+        int rc = nbd_thread_create(thread + i, i, worker, (void *)(size_t)i);
         if (rc != 0) { perror("pthread_create"); return rc; }
     }
     for (int i = 0; i < num_threads; ++i) {