From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 2YCZI/LGq2A3XQAAWB0awg (envelope-from ) for ; Mon, 24 May 2021 11:32:02 -0400 Received: by simark.ca (Postfix, from userid 112) id 7F9F81F11C; Mon, 24 May 2021 11:32:02 -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,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham 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 9C4C01E01F for ; Mon, 24 May 2021 11:32:01 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E4063858034; Mon, 24 May 2021 15:32:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E4063858034 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1621870321; bh=1ziZ6L6tLMGQ/fmB8zKlj1IrdCWXVkg9QA1hUwSDk/0=; h=Subject:To:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=lly/PomqdbKKp3w3hSs2jUGjsbal6NAjumeFXnzh/j6Xkuk/qrQNZac7iwQ2XZIdV AIEOBaR/C0mZH6SPGeL1TZGujpUlS8FykybFbd5fw+Gbb7d+XFfG8xNJJcm4lsQsyh v9Xva6fjGwQgqH99SASCg7os9IVreiHNBLXPW1Ew= Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id A9B783858034 for ; Mon, 24 May 2021 15:31:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A9B783858034 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14OF4Rjh059237; Mon, 24 May 2021 11:30:46 -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 38rcng4jby-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 May 2021 11:30:45 -0400 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 14OF9N15010085; Mon, 24 May 2021 15:30:45 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma02dal.us.ibm.com with ESMTP id 38psk8uxdb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 May 2021 15:30:44 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 14OFUeCk23790064 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 May 2021 15:30:40 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B55AD7805F; Mon, 24 May 2021 15:30:40 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4E7327805E; Mon, 24 May 2021 15:30:40 +0000 (GMT) Received: from li-e362e14c-2378-11b2-a85c-87d605f3c641.ibm.com (unknown [9.211.90.242]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 24 May 2021 15:30:40 +0000 (GMT) Message-ID: Subject: Re: [PATCH] kill all threadapply processes at end of test To: Pedro Franco de Carvalho , gdb-patches@sourceware.org Date: Mon, 24 May 2021 08:30:39 -0700 In-Reply-To: <73bcfb777e72f549218cb431784e103b1831ea30.camel@us.ibm.com> References: <87cztn7lk9.fsf@linux.ibm.com> <875yzflgzs.fsf@linux.ibm.com> <73bcfb777e72f549218cb431784e103b1831ea30.camel@us.ibm.com> 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: porNueH-RzLIc1IzJtAsUqi2GF3WdFRl X-Proofpoint-GUID: porNueH-RzLIc1IzJtAsUqi2GF3WdFRl X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-05-24_08:2021-05-24, 2021-05-24 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 spamscore=0 phishscore=0 impostorscore=0 bulkscore=0 suspectscore=0 mlxlogscore=787 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105240093 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@sourceware.org Sender: "Gdb-patches" 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 * 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