From 3cdbfdce6a38cd23968d27d6e9e8d3ee65c3cf98 Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Sat, 8 Nov 2014 15:57:11 -0800 Subject: Convert futex to cond wait. Switch to the better supported pthread_cond to handle the Wait/Wake functions. Also, increase the number of simultaneous threads in the thread tests. Bug: 18381207 (cherry picked from commit db44538387b08f367fc2419653639866f4c2fbd6) Change-Id: Id326a7a7b92cb61573def3f761597c40f3ef2f4b --- libbacktrace/BacktraceThread.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'libbacktrace/BacktraceThread.h') diff --git a/libbacktrace/BacktraceThread.h b/libbacktrace/BacktraceThread.h index ff3e9f3..99a8638 100644 --- a/libbacktrace/BacktraceThread.h +++ b/libbacktrace/BacktraceThread.h @@ -48,8 +48,10 @@ public: inline void Lock() { pthread_mutex_lock(&mutex_); - // Reset the futex value in case of multiple unwinds of the same thread. - futex_ = 0; + + // Always reset the wait value since this could be the first or nth + // time this entry is locked. + wait_value_ = 0; } inline void Unlock() { @@ -66,9 +68,11 @@ private: pid_t pid_; pid_t tid_; - int futex_; int ref_count_; pthread_mutex_t mutex_; + pthread_mutex_t wait_mutex_; + pthread_cond_t wait_cond_; + int wait_value_; ThreadEntry* next_; ThreadEntry* prev_; ucontext_t ucontext_; -- cgit v1.1