From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SOkVDqJVtmCvYQAAWB0awg (envelope-from ) for ; Tue, 01 Jun 2021 11:43:30 -0400 Received: by simark.ca (Postfix, from userid 112) id 377EF1F163; Tue, 1 Jun 2021 11:43:30 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,RDNS_DYNAMIC, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E02851E01F for ; Tue, 1 Jun 2021 11:43:29 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6EA5A384403C for ; Tue, 1 Jun 2021 15:43:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6EA5A384403C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1622562209; bh=X+MwuTU6QRzws0VSgI5gNT3LTEZwxF7WVc4Sm32opYE=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=aBiW79ZuBTtXhOmc+zPXOkTIYGa/rTPjAk2IwtX3Ci8+oROE1f5UDda4hnGUCLgW1 m8UYldxj4TLA4qlyyeVNOs/hlcnh6OQuKgIL4oflA+QcbLlZbWTtRo+HTNc1FloWQD Qq140rjVwwXEE3d2CSLIaEU7G9dTm7e8ofAhtFhw= Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 1B79E384403C for ; Tue, 1 Jun 2021 15:42:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1B79E384403C Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 151FYOHK053577; Tue, 1 Jun 2021 11:42:09 -0400 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 38wqndr6p1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Jun 2021 11:42:09 -0400 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 151Fb4eh006608; Tue, 1 Jun 2021 15:42:08 GMT Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by ppma02dal.us.ibm.com with ESMTP id 38ud89ef9j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Jun 2021 15:42:08 +0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 151Fg6C140304994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 1 Jun 2021 15:42:06 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 70DD0AE05F; Tue, 1 Jun 2021 15:42:06 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 72036AE067; Tue, 1 Jun 2021 15:42:05 +0000 (GMT) Received: from li-e362e14c-2378-11b2-a85c-87d605f3c641.ibm.com (unknown [9.163.1.238]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 1 Jun 2021 15:42:05 +0000 (GMT) Message-ID: <5c776f594a2cb584423ba95d9b3d7ea1ae527def.camel@us.ibm.com> To: Simon Marchi , Pedro Franco de Carvalho , gdb-patches@sourceware.org Date: Tue, 01 Jun 2021 08:42:04 -0700 In-Reply-To: <95a322dd-8059-8a48-acf5-07b965585995@polymtl.ca> References: <87cztn7lk9.fsf@linux.ibm.com> <875yzflgzs.fsf@linux.ibm.com> <73bcfb777e72f549218cb431784e103b1831ea30.camel@us.ibm.com> <95a322dd-8059-8a48-acf5-07b965585995@polymtl.ca> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-14.el8) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: K3DEw1os5uK850ORrd71q5ITyIeNaom1 X-Proofpoint-GUID: K3DEw1os5uK850ORrd71q5ITyIeNaom1 Subject: RE: [PATCH] kill all threadapply processes at end of test X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-06-01_08:2021-06-01, 2021-06-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 impostorscore=0 mlxscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106010105 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Carl Love via Gdb-patches Reply-To: Carl Love Cc: ulrich.weigand@de.ibm.com, tom@tromey.com, rogealve@br.ibm.com Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" GDB maintainers, Simon: On Fri, 2021-05-28 at 21:48 -0400, Simon Marchi wrote: > > Hi, > > The code looks good to me, but please add a suitable commit message, > it should contain a description and explanation of the observed > problem and the chosen solution, such that somebody not familiar with > the issue can understand the rationale of the patch. > > Simon I have added a commit message describing the issue with the test and how the patch fixes the issue. Please let me know if the patch is acceptable for committing to GDB mainline. Thanks. Carl --------------------------------------------------------------------- Fix threadapply test The current test case leaves detached processes running at the end of the test. This patch changes the test to use a barrier wait to ensure all processes exit cleanly at the end of the tests. gdb/testsuite/ChangeLog: 2021-05-22 Carl Love * 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