Commit | Line | Data |
---|---|---|
c35fafde PA |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
32d0add0 | 3 | Copyright 2002-2015 Free Software Foundation, Inc. |
c35fafde PA |
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 <unistd.h> | |
19 | #include <stdlib.h> | |
20 | #include <pthread.h> | |
21 | ||
22 | void *thread_function(void *arg); /* Pointer to function executed by each thread */ | |
23 | ||
24 | #define NUM 1 | |
25 | ||
26 | unsigned int args[NUM+1]; | |
27 | ||
28 | int main() { | |
29 | int res; | |
30 | pthread_t threads[NUM]; | |
31 | void *thread_result; | |
32 | long i; | |
33 | ||
34 | for (i = 1; i <= NUM; i++) | |
35 | { | |
36 | args[i] = 1; | |
e2009e98 | 37 | res = pthread_create(&threads[i - 1], |
c35fafde PA |
38 | NULL, |
39 | thread_function, | |
40 | (void *) i); | |
41 | } | |
42 | ||
43 | /* schedlock.exp: last thread start. */ | |
44 | args[0] = 1; | |
45 | thread_function ((void *) 0); | |
46 | ||
47 | exit(EXIT_SUCCESS); | |
48 | } | |
49 | ||
50 | void *thread_function(void *arg) { | |
51 | int my_number = (long) arg; | |
52 | int *myp = (int *) &args[my_number]; | |
53 | ||
54 | /* Don't run forever. Run just short of it :) */ | |
55 | while (*myp > 0) | |
56 | { | |
57 | (*myp) ++; /* insert breakpoint here */ | |
58 | } | |
59 | ||
60 | pthread_exit(NULL); | |
61 | } |