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
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 @@
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 @@
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_;