Back to index

glibc  2.9
joinrace.c
Go to the documentation of this file.
00001 /* Test case by Permaine Cheung <pcheung@cygnus.com>.  */
00002 
00003 #include <errno.h>
00004 #include <pthread.h>
00005 #include <stdio.h>
00006 #include <stdlib.h>
00007 
00008 static void *
00009 sub1 (void *arg)
00010 {
00011   /* Nothing.  */
00012   return NULL;
00013 }
00014 
00015 int
00016 main (void)
00017 {
00018   int istatus;
00019   int policy;
00020   int cnt;
00021   pthread_t thread1;
00022   struct sched_param spresult1, sp1;
00023 
00024   for (cnt = 0; cnt < 100; ++cnt)
00025     {
00026       printf ("Round %d\n", cnt);
00027 
00028       pthread_create (&thread1, NULL, &sub1, NULL);
00029       pthread_join (thread1, NULL);
00030 
00031       istatus = pthread_getschedparam (thread1, &policy, &spresult1);
00032       if (istatus != ESRCH)
00033        {
00034          printf ("pthread_getschedparam returns: %d\n", istatus);
00035          return 1;
00036        }
00037 
00038       sp1.sched_priority = 0;
00039       istatus = pthread_setschedparam (thread1, SCHED_OTHER, &sp1);
00040       if (istatus != ESRCH)
00041        {
00042          printf ("pthread_setschedparam returns: %d\n", istatus);
00043          return 2;
00044        }
00045     }
00046 
00047   return 0;
00048 }