1 /* A small multi-threaded test case.
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
28 cond_wait (pthread_cond_t
*cond
, pthread_mutex_t
*mut
)
30 pthread_mutex_lock(mut
);
31 pthread_cond_wait (cond
, mut
);
32 pthread_mutex_unlock (mut
);
41 pthread_mutex_init (&mut
, NULL
);
42 pthread_cond_init (&cond
, NULL
);
44 /* Wait for a condition that will never be signaled, so we effectively
45 block the thread here. */
46 cond_wait (&cond
, &mut
);
50 forever_pthread (void *unused
)
58 /* Just an anchor to help putting a breakpoint. */
65 const struct timespec ts
= { 0, 10000000 }; /* 0.01 sec */
67 pthread_create (&forever
, NULL
, forever_pthread
, NULL
);
70 nanosleep (&ts
, NULL
);