This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] Simply ia64-sigill.exp
- From: Yao Qi <yao at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 22 Jun 2011 18:59:44 +0800
- Subject: [patch] Simply ia64-sigill.exp
In my port, pthread_cond_signal/pthread_cond_wait don't work properly,
and some tests in ia64-sigill.exp fails.
This patch is to replace calls to pthread_cond_signal/pthread_cond_wait
with "set-and-check" on variable thread1_tid and thread2_tid, to still
keep the happen-before relationship between threads.
Test result is unchanged on x86_64-unknown-linux-gnu. OK for mainline?
--
Yao (éå)
2011-06-22 Yao Qi <yao@codesourcery.com>
gdb/testsuite/
* gdb.threads/ia64-sigill.c: Initialize thread1_tid and thread2_tid.
(thread_func): Remove calls to pthread_cond_signal.
(main): Remove calls to pthread_cond_wait. Call pthread_mutex_unlock.
---
gdb/testsuite/gdb.threads/ia64-sigill.c | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/gdb/testsuite/gdb.threads/ia64-sigill.c b/gdb/testsuite/gdb.threads/ia64-sigill.c
index ac9a4b7..5b67f38 100644
--- a/gdb/testsuite/gdb.threads/ia64-sigill.c
+++ b/gdb/testsuite/gdb.threads/ia64-sigill.c
@@ -34,11 +34,11 @@
otherwise. */
#define TIMEOUT (gettid () == getpid() ? 10 : 15)
-static pid_t thread1_tid;
+static pid_t thread1_tid = 0;
static pthread_cond_t thread1_tid_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t thread1_tid_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
-static pid_t thread2_tid;
+static pid_t thread2_tid = 0;
static pthread_cond_t thread2_tid_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t thread2_tid_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
@@ -86,8 +86,6 @@ thread_func (void *threadno_voidp)
/* THREAD1_TID_MUTEX must be already locked to avoid race. */
thread1_tid = gettid ();
- i = pthread_cond_signal (&thread1_tid_cond);
- assert (i == 0);
i = pthread_mutex_unlock (&thread1_tid_mutex);
assert (i == 0);
@@ -99,8 +97,6 @@ thread_func (void *threadno_voidp)
/* THREAD2_TID_MUTEX must be already locked to avoid race. */
thread2_tid = gettid ();
- i = pthread_cond_signal (&thread2_tid_cond);
- assert (i == 0);
i = pthread_mutex_unlock (&thread2_tid_mutex);
assert (i == 0);
@@ -314,16 +310,16 @@ main (int argc, char **argv)
printf ("Waiting till the threads initialize their TIDs.\n");
+ pthread_mutex_unlock (&thread1_tid_mutex);
+ pthread_mutex_unlock (&thread2_tid_mutex);
while (thread1_tid == 0)
{
- i = pthread_cond_wait (&thread1_tid_cond, &thread1_tid_mutex);
- assert (i == 0);
+ pthread_yield ();
}
while (thread2_tid == 0)
{
- i = pthread_cond_wait (&thread2_tid_cond, &thread2_tid_mutex);
- assert (i == 0);
+ pthread_yield ();
}
printf ("Thread 1 TID = %lu, thread 2 TID = %lu, PID = %lu.\n",
--
1.7.0.4