chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / linuxthreads / joinrace.c
1 /* Test case by Permaine Cheung <pcheung@cygnus.com>.  */
2
3 #include <errno.h>
4 #include <pthread.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7
8 static void *
9 sub1 (void *arg)
10 {
11   /* Nothing.  */
12   return NULL;
13 }
14
15 int
16 main (void)
17 {
18   int istatus;
19   int policy;
20   int cnt;
21   pthread_t thread1;
22   struct sched_param spresult1, sp1;
23
24   for (cnt = 0; cnt < 100; ++cnt)
25     {
26       printf ("Round %d\n", cnt);
27
28       pthread_create (&thread1, NULL, &sub1, NULL);
29       pthread_join (thread1, NULL);
30
31       istatus = pthread_getschedparam (thread1, &policy, &spresult1);
32       if (istatus != ESRCH)
33         {
34           printf ("pthread_getschedparam returns: %d\n", istatus);
35           return 1;
36         }
37
38       sp1.sched_priority = 0;
39       istatus = pthread_setschedparam (thread1, SCHED_OTHER, &sp1);
40       if (istatus != ESRCH)
41         {
42           printf ("pthread_setschedparam returns: %d\n", istatus);
43           return 2;
44         }
45     }
46
47   return 0;
48 }