X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu-defer.c;h=92635ed3cca4c1f45390bfac5348714722f56547;hp=50aa066053850be20f4ac254e81296600fad79b7;hb=0ecb3fde04135d76545ce55d80abea9aef465b54;hpb=02be55611d3b1c7bf4fdfcb3a9c98f621882d417 diff --git a/urcu-defer.c b/urcu-defer.c index 50aa066..92635ed 100644 --- a/urcu-defer.c +++ b/urcu-defer.c @@ -57,7 +57,7 @@ static struct defer_queue __thread defer_queue; static LIST_HEAD(registry); static pthread_t tid_defer; -static void internal_rcu_lock(pthread_mutex_t *mutex) +static void mutex_lock(pthread_mutex_t *mutex) { int ret; @@ -80,7 +80,7 @@ static void internal_rcu_lock(pthread_mutex_t *mutex) #endif /* #else #ifndef DISTRUST_SIGNALS_EXTREME */ } -static void internal_rcu_unlock(pthread_mutex_t *mutex) +static void mutex_unlock(pthread_mutex_t *mutex) { int ret; @@ -108,12 +108,12 @@ static unsigned long rcu_defer_num_callbacks(void) unsigned long num_items = 0, head; struct defer_queue *index; - internal_rcu_lock(&rcu_defer_mutex); + mutex_lock(&rcu_defer_mutex); list_for_each_entry(index, ®istry, list) { head = LOAD_SHARED(index->head); num_items += head - index->tail; } - internal_rcu_unlock(&rcu_defer_mutex); + mutex_unlock(&rcu_defer_mutex); return num_items; } @@ -184,9 +184,9 @@ static void _rcu_defer_barrier_thread(void) void rcu_defer_barrier_thread(void) { - internal_rcu_lock(&rcu_defer_mutex); + mutex_lock(&rcu_defer_mutex); _rcu_defer_barrier_thread(); - internal_rcu_unlock(&rcu_defer_mutex); + mutex_unlock(&rcu_defer_mutex); } /* @@ -210,7 +210,7 @@ void rcu_defer_barrier(void) if (list_empty(®istry)) return; - internal_rcu_lock(&rcu_defer_mutex); + mutex_lock(&rcu_defer_mutex); list_for_each_entry(index, ®istry, list) { index->last_head = LOAD_SHARED(index->head); num_items += index->last_head - index->tail; @@ -226,7 +226,7 @@ void rcu_defer_barrier(void) list_for_each_entry(index, ®istry, list) rcu_defer_barrier_queue(index, index->last_head); end: - internal_rcu_unlock(&rcu_defer_mutex); + mutex_unlock(&rcu_defer_mutex); } /* @@ -247,7 +247,7 @@ void _defer_rcu(void (*fct)(void *p), void *p) * If queue is full, or reached threshold. Empty queue ourself. * Worse-case: must allow 2 supplementary entries for fct pointer. */ - if (unlikely(sync || (head - tail >= DEFER_QUEUE_SIZE - 2))) { + if (unlikely(head - tail >= DEFER_QUEUE_SIZE - 2)) { assert(head - tail <= DEFER_QUEUE_SIZE); rcu_defer_barrier_thread(); assert(head - LOAD_SHARED(defer_queue.tail) == 0); @@ -347,33 +347,33 @@ void rcu_defer_register_thread(void) assert(defer_queue.q == NULL); defer_queue.q = malloc(sizeof(void *) * DEFER_QUEUE_SIZE); - internal_rcu_lock(&defer_thread_mutex); - internal_rcu_lock(&rcu_defer_mutex); + mutex_lock(&defer_thread_mutex); + mutex_lock(&rcu_defer_mutex); was_empty = list_empty(®istry); list_add(&defer_queue.list, ®istry); - internal_rcu_unlock(&rcu_defer_mutex); + mutex_unlock(&rcu_defer_mutex); if (was_empty) start_defer_thread(); - internal_rcu_unlock(&defer_thread_mutex); + mutex_unlock(&defer_thread_mutex); } void rcu_defer_unregister_thread(void) { int is_empty; - internal_rcu_lock(&defer_thread_mutex); - internal_rcu_lock(&rcu_defer_mutex); + mutex_lock(&defer_thread_mutex); + mutex_lock(&rcu_defer_mutex); list_del(&defer_queue.list); _rcu_defer_barrier_thread(); free(defer_queue.q); defer_queue.q = NULL; is_empty = list_empty(®istry); - internal_rcu_unlock(&rcu_defer_mutex); + mutex_unlock(&rcu_defer_mutex); if (is_empty) stop_defer_thread(); - internal_rcu_unlock(&defer_thread_mutex); + mutex_unlock(&defer_thread_mutex); } void rcu_defer_exit(void)