* gdb.base/call-signal-resume.exp, gdb.base/unwindonsignal.exp: Skip
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / watch_thread_num.c
CommitLineData
37e4754d
LM
1/* This testcase is part of GDB, the GNU debugger.
2
4c38e0a4
JB
3 Copyright 2002, 2003, 2004, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
37e4754d 5
d53a7b30
JB
6 Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003, 2007, 2008, 2009
7 Free Software Foundation, Inc.
8
37e4754d
LM
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
d53a7b30 11 the Free Software Foundation; either version 3 of the License, or
37e4754d
LM
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
d53a7b30 20 along with this program. If not, see <http://www.gnu.org/licenses/>.
37e4754d
LM
21
22 This file is copied from schedlock.c. */
23
24#include <stdio.h>
25#include <unistd.h>
26#include <stdlib.h>
27#include <pthread.h>
28
29void *thread_function (void *arg); /* Pointer to function executed by each thread */
30
31#define NUM 5
32
33static unsigned int shared_var = 1;
34
35int main () {
36 int res;
37 pthread_t threads[NUM];
38 void *thread_result;
39 long i;
40
41 for (i = 0; i < NUM; i++)
42 {
43 res = pthread_create (&threads[i],
44 NULL,
45 thread_function,
46 (void *) i);
47 }
48
49 thread_result = thread_function ((void *) i);
50
51 exit (EXIT_SUCCESS);
52}
53
54void *thread_function (void *arg) {
55 int my_number = (long) arg;
56 /* Don't run forever. Run just short of it :) */
57 while (shared_var > 0)
58 {
59 shared_var++;
60 usleep (1); /* Loop increment. */
61 }
62
63 pthread_exit (NULL);
64}
65
This page took 0.255286 seconds and 4 git commands to generate.