1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2002-2020 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 This file is based on schedlock.c. */
27 volatile int done
= 0;
30 thread_function (void *arg
)
32 int my_number
= (long) arg
;
33 volatile int *myp
= (volatile int *) &args
[my_number
];
35 /* Don't run forever. Run just short of it :) */
36 while (*myp
> 0 && !done
)
38 (*myp
)++; /* set breakpoint here */
42 usleep (100); /* Some time to make sure we don't mask any bad
49 main (int argc
, char **argv
)
56 threads
= malloc (THREADS
* sizeof (pthread_t
));
57 args
= malloc (THREADS
* sizeof (unsigned int));
59 for (i
= 0; i
< THREADS
; i
++)
61 args
[i
] = 1; /* Init value. */
62 res
= pthread_create (&threads
[i
],
68 for (i
= 0; i
< THREADS
; i
++)
69 pthread_join (threads
[i
], &thread_result
);
This page took 0.040645 seconds and 4 git commands to generate.