From 0302fece014004a2df366dacc2b8e9416264a978 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 7 Jul 1998 15:23:31 +0000 Subject: Update. * sysdeps/unix/sysv/linux/sparc/sparc64/bits/types.h: Add __ino64_t definition. --- linuxthreads/Examples/ex1.c | 7 +++---- linuxthreads/Examples/ex2.c | 5 +---- linuxthreads/Examples/ex3.c | 24 +++++++++++------------- linuxthreads/Examples/ex4.c | 6 +++--- linuxthreads/Examples/ex5.c | 2 +- linuxthreads/Examples/ex6.c | 38 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 57 insertions(+), 25 deletions(-) create mode 100644 linuxthreads/Examples/ex6.c (limited to 'linuxthreads/Examples') diff --git a/linuxthreads/Examples/ex1.c b/linuxthreads/Examples/ex1.c index c399fab..f455ecf 100644 --- a/linuxthreads/Examples/ex1.c +++ b/linuxthreads/Examples/ex1.c @@ -17,15 +17,15 @@ void * process(void * arg) return NULL; } -int main() +int main(void) { int retcode; pthread_t th_a, th_b; void * retval; - retcode = pthread_create(&th_a, NULL, process, "a"); + retcode = pthread_create(&th_a, NULL, process, (void *) "a"); if (retcode != 0) fprintf(stderr, "create a failed %d\n", retcode); - retcode = pthread_create(&th_b, NULL, process, "b"); + retcode = pthread_create(&th_b, NULL, process, (void *) "b"); if (retcode != 0) fprintf(stderr, "create b failed %d\n", retcode); retcode = pthread_join(th_a, &retval); if (retcode != 0) fprintf(stderr, "join a failed %d\n", retcode); @@ -33,4 +33,3 @@ int main() if (retcode != 0) fprintf(stderr, "join b failed %d\n", retcode); return 0; } - diff --git a/linuxthreads/Examples/ex2.c b/linuxthreads/Examples/ex2.c index 3f7f115..70cb6b3 100644 --- a/linuxthreads/Examples/ex2.c +++ b/linuxthreads/Examples/ex2.c @@ -97,7 +97,7 @@ void * consumer(void * data) return NULL; } -int main() +int main(void) { pthread_t th_a, th_b; void * retval; @@ -111,6 +111,3 @@ int main() pthread_join(th_b, &retval); return 0; } - - - diff --git a/linuxthreads/Examples/ex3.c b/linuxthreads/Examples/ex3.c index 002bc90..7557cc7 100644 --- a/linuxthreads/Examples/ex3.c +++ b/linuxthreads/Examples/ex3.c @@ -1,6 +1,7 @@ /* Multi-thread searching. Illustrates: thread cancellation, cleanup handlers. */ +#include #include #include #include @@ -19,9 +20,7 @@ pthread_t threads[NUM_THREADS]; pthread_mutex_t lock; int tries; -int main(argc, argv) - int argc; - char ** argv; +int main(int argc, char ** argv) { int i; int pid; @@ -31,14 +30,14 @@ int main(argc, argv) printf("Searching for the number = %d...\n", pid); /* Initialize the mutex lock */ - pthread_mutex_init(&lock, NULL); + pthread_mutex_init(&lock, NULL); /* Create the searching threads */ for (i=0; i +#include +#include +#include + +void * +test_thread (void *v_param) +{ + return NULL; +} + +int +main (void) +{ + unsigned long count; + + for (count = 0; count < 2000; ++count) + { + pthread_t thread; + int status; + + status = pthread_create (&thread, NULL, test_thread, NULL); + if (status != 0) + { + printf ("status = %d, count = %lu: %s\n", status, count, + strerror (errno)); + return 1; + } + else + { + printf ("count = %lu\n", count); + } + /* pthread_detach (thread); */ + pthread_join (thread, NULL); + usleep (50); + } + return 0; +} -- cgit v1.1