diff options
| author | [email protected] <[email protected]> | 2010-11-18 11:31:54 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2010-11-18 11:31:54 +0000 |
| commit | d9cb84f4840c49993cfbcc80057488c50eae60cb (patch) | |
| tree | 9077055207bb6faa59cd565d37a77aa12e39b53c /examples/libc/ex6.c | |
| parent | 019b6542012115190cfbde415532c8940cc47500 (diff) | |
add libc testcase.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1061 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'examples/libc/ex6.c')
| -rw-r--r-- | examples/libc/ex6.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/examples/libc/ex6.c b/examples/libc/ex6.c new file mode 100644 index 0000000000..dea6ead8cb --- /dev/null +++ b/examples/libc/ex6.c @@ -0,0 +1,37 @@ +#include <errno.h> +#include <stdio.h> +#include <string.h> +#include <pthread.h> +#include <unistd.h> + +#define usleep rt_thread_sleep + +static void *test_thread(void *v_param) { + return NULL; +} + +int libc_ex6(void) { + unsigned long count; + + setvbuf(stdout, NULL, _IONBF, 0); + + 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(10); + } + return 0; +} +#include <finsh.h> +FINSH_FUNCTION_EXPORT(libc_ex6, example 6 for libc); |
