mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-23 19:50:13 +08:00
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-06-02 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.
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
2021-06-02 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.
|
||||||
|
|
||||||
2021-06-02 Andrew Burgess <andrew.burgess@embecosm.com>
|
2021-06-02 Andrew Burgess <andrew.burgess@embecosm.com>
|
||||||
|
|
||||||
* lib/gdb.exp (gdb_compile): Only add the -J option when using a
|
* lib/gdb.exp (gdb_compile): Only add the -J option when using a
|
||||||
|
@ -27,6 +27,7 @@ void *thread_function(void *arg); /* Pointer to function executed by each thread
|
|||||||
#define NUM 5
|
#define NUM 5
|
||||||
|
|
||||||
unsigned int args[NUM+1];
|
unsigned int args[NUM+1];
|
||||||
|
pthread_barrier_t mybarrier;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int res;
|
int res;
|
||||||
@ -35,6 +36,8 @@ int main() {
|
|||||||
void *thread_result;
|
void *thread_result;
|
||||||
long i;
|
long i;
|
||||||
|
|
||||||
|
pthread_barrier_init(&mybarrier, NULL, NUM + 1);
|
||||||
|
|
||||||
for (i = 0; i < NUM; i++)
|
for (i = 0; i < NUM; i++)
|
||||||
{
|
{
|
||||||
args[i] = 1; /* Init value. */
|
args[i] = 1; /* Init value. */
|
||||||
@ -69,12 +72,7 @@ void *thread_function(void *arg) {
|
|||||||
int my_number = (long) arg;
|
int my_number = (long) arg;
|
||||||
int *myp = (int *) &args[my_number];
|
int *myp = (int *) &args[my_number];
|
||||||
|
|
||||||
/* Don't run forever. Run just short of it :) */
|
(*myp) ++; /* Increment so parent knows child started. */
|
||||||
while (*myp > 0)
|
pthread_barrier_wait(&mybarrier);
|
||||||
{
|
|
||||||
(*myp) ++; /* Loop increment. */
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_exit(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user