1 /* Copyright (C) 2002-2013 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library 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 GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
26 /* Note that this test requires more than the standard. It is
27 required that there are no spurious wakeups if only more readers
28 are added. This is a reasonable demand. */
31 static pthread_cond_t cond
= PTHREAD_COND_INITIALIZER
;
32 static pthread_mutex_t mut
= PTHREAD_MUTEX_INITIALIZER
;
41 int i
= (long int) arg
;
45 err
= pthread_mutex_lock (&mut
);
48 printf ("child %d mutex_lock failed: %s\n", i
, strerror (err
));
52 /* This call should never return. */
53 pthread_cond_wait (&cond
, &mut
);
55 /* We should never get here. */
68 for (i
= 0; i
< N
; ++i
)
74 /* Release the mutex. */
75 err
= pthread_mutex_unlock (&mut
);
78 printf ("mutex_unlock %d failed: %s\n", i
, strerror (err
));
83 err
= pthread_create (&th
, NULL
, tf
, (void *) (long int) i
);
86 printf ("create %d failed: %s\n", i
, strerror (err
));
91 err
= pthread_mutex_lock (&mut
);
94 printf ("mutex_lock %d failed: %s\n", i
, strerror (err
));
99 /* Set an alarm for 1 second. The wrapper will expect this. */
102 /* This call should never return. */
103 pthread_cond_wait (&cond
, &mut
);
105 puts ("cond_wait returned");
110 #define EXPECTED_SIGNAL SIGALRM
111 #define TEST_FUNCTION do_test ()
112 #include "../test-skeleton.c"