1 /* This test program is part of GDB, The GNU debugger.
3 Copyright 2004-2014 Free Software Foundation, Inc.
5 Originally written by Jeff Johnston <jjohnstn@redhat.com>,
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 #include <semaphore.h>
36 thread_function (void *arg
)
41 while (sem_wait (&semaphore
) != 0)
45 perror ("thread_function");
49 printf ("Thread executing\n"); /* tlsvar-is-set */
54 main (int argc
, char **argv
)
58 pthread_attr_init (&attr
);
59 pthread_attr_setstacksize (&attr
, PTHREAD_STACK_MIN
);
61 if (sem_init (&semaphore
, 0, 0) == -1)
71 /* Create a thread, wait for it to complete. */
74 pthread_create (&thread
, &attr
, thread_function
, NULL
);
75 sem_post (&semaphore
);
76 pthread_join (thread
, NULL
);
79 pthread_attr_destroy (&attr
);
This page took 0.031766 seconds and 4 git commands to generate.