(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / linuxthreads / Examples / ex6.c
blob9a0266828b4d3d0f8c740d22fccde293180b6c52
1 #include <errno.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <pthread.h>
5 #include <unistd.h>
7 static void *
8 test_thread (void *v_param)
10 return NULL;
13 int
14 main (void)
16 unsigned long count;
18 setvbuf (stdout, NULL, _IONBF, 0);
20 for (count = 0; count < 2000; ++count)
22 pthread_t thread;
23 int status;
25 status = pthread_create (&thread, NULL, test_thread, NULL);
26 if (status != 0)
28 printf ("status = %d, count = %lu: %s\n", status, count,
29 strerror (errno));
30 return 1;
32 else
34 printf ("count = %lu\n", count);
36 /* pthread_detach (thread); */
37 int err = pthread_join (thread, NULL);
38 if (err != 0)
40 printf ("join failed (%s), count %lu\n", strerror (err), count);
41 return 2;
43 usleep (10);
45 return 0;