[ltt-dev] [PATCH 2/7] urcu, defer_rcu: fix missing respond to a cancellation request
Lai Jiangshan
laijs at cn.fujitsu.com
Wed Sep 28 04:34:28 EDT 2011
thread1: thread2
thr_defer()
pthread_testcancel();
stop_defer_thread() .
pthread_cancel(tid_defer); .
wake_up_defer(); .
wait_defer();
pthread_join(tid_defer)
thread2 missing respond to the cancellation request from thread1
and wait callback forever.
thread1 wait thread2 forver by pthread_join():
Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
---
urcu-defer-impl.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/urcu-defer-impl.h b/urcu-defer-impl.h
index d1ab046..6339747 100644
--- a/urcu-defer-impl.h
+++ b/urcu-defer-impl.h
@@ -187,6 +187,7 @@ static void wait_defer(void)
{
uatomic_dec(&defer_thread_futex);
cmm_smp_mb(); /* Write futex before read queue */
+ pthread_testcancel();
if (rcu_defer_num_callbacks()) {
cmm_smp_mb(); /* Read queue before write futex */
/* Callbacks are queued, don't wait. */
@@ -359,7 +360,6 @@ void _defer_rcu(void (*fct)(void *p), void *p)
void *thr_defer(void *args)
{
for (;;) {
- pthread_testcancel();
/*
* "Be green". Don't wake up the CPU if there is no RCU work
* to perform whatsoever. Aims at saving laptop battery life by
@@ -387,6 +387,7 @@ static void start_defer_thread(void)
{
int ret;
+ uatomic_set(&defer_thread_futex, 0);
ret = pthread_create(&tid_defer, NULL, thr_defer, NULL);
assert(!ret);
}
--
1.7.4.4
More information about the lttng-dev
mailing list