- fifo_enqueue(pending_[tid_], x);
- TRACE("r0", "nbd_defer_free: put %p on queue at position %llu", x, pending_[tid_]->head);
- rcu_post(pending_[tid_]->head);
+ 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", "rcu_defer_free: put %p on queue at position %llu", x, q->head);
+ q->head++;
+
+ if (pending_[tid_]->head - rcu_last_posted_[tid_][tid_] >= RCU_POST_THRESHOLD) {
+ 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;
+ }