diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-02-27 21:17:21 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-02-27 21:17:21 +0000 |
commit | 148cde5e982950ad5836fa96baa466de842e1c14 (patch) | |
tree | bf737b367b91c5da81345eb21016b07400d7a72f /nuttx/examples/ostest/mutex.c | |
parent | f6b81a790c28d7d36d9de33810df5270c1ebbfd7 (diff) | |
download | px4-nuttx-148cde5e982950ad5836fa96baa466de842e1c14.tar.gz px4-nuttx-148cde5e982950ad5836fa96baa466de842e1c14.tar.bz2 px4-nuttx-148cde5e982950ad5836fa96baa466de842e1c14.zip |
Finally, a clean SDCC compile
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@20 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/ostest/mutex.c')
-rw-r--r-- | nuttx/examples/ostest/mutex.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/nuttx/examples/ostest/mutex.c b/nuttx/examples/ostest/mutex.c index cb8996053..5edf60dba 100644 --- a/nuttx/examples/ostest/mutex.c +++ b/nuttx/examples/ostest/mutex.c @@ -91,6 +91,11 @@ static void *thread_func(void *parameter) void mutex_test(void) { pthread_t thread1, thread2; +#ifdef SDCC + pthread_addr_t result1, result2; + pthread_attr_t attr; +#endif + int status; /* Initialize the mutex */ @@ -100,19 +105,35 @@ void mutex_test(void) /* Start two thread instances */ printf("Starting thread 1\n"); - if ((pthread_create(&thread1, NULL, thread_func, (void*)1)) != 0) +#ifdef SDCC + (void)pthread_attr_init(&attr); + status = pthread_create(&thread1, &attr, thread_func, (pthread_addr_t)1); +#else + status = pthread_create(&thread1, NULL, thread_func, (pthread_addr_t)1); +#endif + if (status != 0) { printf("Error in thread#1 creation\n"); } printf("Starting thread 2\n"); - if ((pthread_create(&thread2, NULL, thread_func, (void*)2)) != 0) +#ifdef SDCC + status = pthread_create(&thread2, &attr, thread_func, (pthread_addr_t)2); +#else + status = pthread_create(&thread2, NULL, thread_func, (pthread_addr_t)2); +#endif + if (status != 0) { printf("Error in thread#2 creation\n"); } +#ifdef SDCC + pthread_join(thread1, &result1); + pthread_join(thread2, &result2); +#else pthread_join(thread1, NULL); pthread_join(thread2, NULL); +#endif printf("\t\tThread1\tThread2\n"); printf("\tLoops\t%ld\t%ld\n", nloops[0], nloops[1]); |