exit(1);
}
+ rcu_register_thread();
+ rcu_read_lock();
/* Insert items looked up by readers */
for (i = 0; i < global_items; i++) {
node = rbtree_alloc();
node->key = global_key[i];
rcu_rbtree_insert(&rbtree, node);
}
+ rcu_read_unlock();
cmm_smp_mb();
tot_writes += count_writer[i];
}
+ rcu_read_lock();
for (i = 0; i < global_items; i++) {
node = rcu_rbtree_search(&rbtree, rbtree.root, global_key[i]);
assert(!rcu_rbtree_is_nil(node));
rcu_rbtree_remove(&rbtree, node);
call_rcu(&node->head, rbtree_free);
}
+ rcu_read_unlock();
+ rcu_unregister_thread();
printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
tot_writes);
v->p = u->p;
cmm_smp_wmb(); /* write into node before publish */
_CMM_STORE_SHARED(rbtree->root, v);
- } else if (u == u->p->left) {
- v->pos = IS_LEFT;
- v->p = u->p;
- cmm_smp_wmb(); /* write into node before publish */
- _CMM_STORE_SHARED(u->p->left, v);
} else {
- v->pos = IS_RIGHT;
+ v->pos = u->pos;
v->p = u->p;
cmm_smp_wmb(); /* write into node before publish */
- _CMM_STORE_SHARED(u->p->right, v);
+ if (u->pos == IS_LEFT)
+ _CMM_STORE_SHARED(u->p->left, v);
+ else
+ _CMM_STORE_SHARED(u->p->right, v);
}
+
/* Point children to new copy (parent only used by updates/next/prev) */
if (!rcu_rbtree_is_nil(v)) {
v->right->p = get_decay(v->right->p);