Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Carl Love via Gdb-patches <gdb-patches@sourceware.org>
To: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>,
	gdb-patches@sourceware.org
Cc: ulrich.weigand@de.ibm.com, tom@tromey.com, rogealve@br.ibm.com
Subject: Re: [PATCH] kill all threadapply processes at end of test
Date: Mon, 24 May 2021 08:30:39 -0700	[thread overview]
Message-ID: <f37e1b270c998c5b70c73b948bff45c1e3438185.camel@us.ibm.com> (raw)
In-Reply-To: <73bcfb777e72f549218cb431784e103b1831ea30.camel@us.ibm.com>

Simon, Tom, Pedro, GCC maintainers:

I have implemented the test changes to use pthread barrier rather then
the spin loop.  The changes only require changing the test with no
changes to the expect scripts.  

The threadsapply test runs fine with no errors and no processes running
after the test with just the changes to threadapply.c.  This approach
seems to work well and would be better then the previous patches to
kill the processes in the expect script.  

The patch has been tested on Power.  Please let me know if you have any
additional comments or concern. Thanks.

                         Carl Love
----------------------------------------------------------------------
Change test to use barrier wait

gdb/testsuite/ChangeLog:

2021-05-22  Carl Love  <cel@us.ibm.com>

	* gdb.threads/threadapply.c: Add global mybarrier.
	(main): Add pthread_barrier_init.
	(thread_function): Replace while loop with myp increment and
	pthread_barrier_wait.
---
 gdb/testsuite/gdb.threads/threadapply.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/gdb.threads/threadapply.c b/gdb/testsuite/gdb.threads/threadapply.c
index 93a3fc8e82d..1ac99b07fc1 100644
--- a/gdb/testsuite/gdb.threads/threadapply.c
+++ b/gdb/testsuite/gdb.threads/threadapply.c
@@ -27,6 +27,7 @@ void *thread_function(void *arg); /* Pointer to function executed by each thread
 #define NUM 5
 
 unsigned int args[NUM+1];
+pthread_barrier_t mybarrier;
 
 int main() {
     int res;
@@ -35,6 +36,8 @@ int main() {
     void *thread_result;
     long i;
 
+    pthread_barrier_init(&mybarrier, NULL, NUM + 1);
+
     for (i = 0; i < NUM; i++)
       {
 	args[i] = 1; /* Init value.  */
@@ -69,12 +72,7 @@ void *thread_function(void *arg) {
     int my_number =  (long) arg;
     int *myp = (int *) &args[my_number];
 
-    /* Don't run forever.  Run just short of it :)  */
-    while (*myp > 0)
-      {
-	(*myp) ++;  /* Loop increment.  */
-      }
-
-    pthread_exit(NULL);
+    (*myp) ++;  /* Increment so parent knows child started.  */
+    pthread_barrier_wait(&mybarrier);
 }
 
-- 
2.27.0



  reply	other threads:[~2021-05-24 15:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12 16:36 Carl Love via Gdb-patches
2021-05-13 14:30 ` Simon Marchi via Gdb-patches
2021-05-13 15:44 ` Tom Tromey
2021-05-13 18:10   ` Carl Love via Gdb-patches
2021-05-18 15:29     ` Carl Love via Gdb-patches
2021-05-18 21:56       ` Pedro Franco de Carvalho via Gdb-patches
2021-05-19  0:11         ` Pedro Franco de Carvalho via Gdb-patches
2021-05-20 15:42           ` Carl Love via Gdb-patches
2021-05-20 16:01           ` Carl Love via Gdb-patches
2021-05-24 15:30             ` Carl Love via Gdb-patches [this message]
2021-05-29  1:48               ` Simon Marchi via Gdb-patches
2021-06-01 15:42                 ` Carl Love via Gdb-patches
2021-06-01 16:08                   ` Simon Marchi via Gdb-patches
2021-06-02 15:08                     ` Carl Love via Gdb-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f37e1b270c998c5b70c73b948bff45c1e3438185.camel@us.ibm.com \
    --to=gdb-patches@sourceware.org \
    --cc=cel@us.ibm.com \
    --cc=pedromfc@linux.ibm.com \
    --cc=rogealve@br.ibm.com \
    --cc=tom@tromey.com \
    --cc=ulrich.weigand@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox