1/* This testcase is part of GDB, the GNU debugger. 2 3 Copyright 2017-2020 Free Software Foundation, Inc. 4 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. 9 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. 14 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/>. */ 17 18#include <pthread.h> 19 20static pthread_barrier_t barrier; 21static int dummy; 22 23static void * 24func1 (void *arg) 25{ 26 pthread_barrier_wait (&barrier); 27 dummy = 1; /* bp1 */ 28 pthread_barrier_wait (&barrier); 29 dummy = 1; 30 pthread_barrier_wait (&barrier); 31 return arg; 32} 33 34static void * 35func2 (void *arg) 36{ 37 pthread_barrier_wait (&barrier); 38 dummy = 2; 39 pthread_barrier_wait (&barrier); 40 dummy = 2; 41 pthread_barrier_wait (&barrier); /* bp2 */ 42 return arg; 43} 44 45int 46main (void) 47{ 48 pthread_t thread; 49 50 pthread_barrier_init (&barrier, NULL, 2); 51 52 pthread_create (&thread, NULL, func2, NULL); 53 func1 (NULL); 54 55 pthread_join (thread, NULL); 56 pthread_barrier_destroy (&barrier); 57 return 0; 58} 59