summaryrefslogtreecommitdiff
path: root/examples/libc/sem.c
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2013-01-08 05:05:02 -0800
committerBernard Xiong <[email protected]>2013-01-08 05:05:02 -0800
commit72782e920325808bbc58fc2344fc52033479b627 (patch)
tree45badbfa9818b8d1722463949beba0f88d1cbd9f /examples/libc/sem.c
parentb3cf278502e605fa03861a2da5685b4c8d72879e (diff)
convert end of line
Diffstat (limited to 'examples/libc/sem.c')
-rw-r--r--examples/libc/sem.c130
1 files changed, 65 insertions, 65 deletions
diff --git a/examples/libc/sem.c b/examples/libc/sem.c
index 9686119059..d081d246e9 100644
--- a/examples/libc/sem.c
+++ b/examples/libc/sem.c
@@ -1,65 +1,65 @@
-#include <pthread.h>
-#include <semaphore.h>
-#include <stdio.h>
-
-static sem_t sema;
-static void* other_thread()
-{
- printf("other_thread here!\n");
-
- sleep(1);
-
- while (1)
- {
- printf("other_thread: sem_post...\n");
- if(sem_post(&sema) == -1)
- printf("sem_post failed\n");
- sleep(1);
- }
-
- printf("other_thread dies!\n");
- pthread_exit(0);
-}
-
-static void test_thread(void* parameter)
-{
- pthread_t tid;
-
- printf("main thread here!\n");
- printf("sleep 5 seconds...");
- sleep(5);
- printf("done\n");
-
- sem_init(&sema, 0, 0);
-
- /* create the "other" thread */
- if(pthread_create(&tid, 0, &other_thread, 0)!=0)
- /* error */
- printf("pthread_create OtherThread failed.\n");
- else
- printf("created OtherThread=%x\n", tid);
-
- /* let the other thread run */
- while (1)
- {
- printf("Main: sem_wait...\n");
- if(sem_wait(&sema) == -1)
- printf("sem_wait failed\n");
- printf("Main back.\n\n");
- }
-
- pthread_exit(0);
-}
-#include <finsh.h>
-void libc_sem()
-{
- rt_thread_t tid;
-
- tid = rt_thread_create("semtest", test_thread, RT_NULL,
- 2048, 20, 5);
- if (tid != RT_NULL)
- {
- rt_thread_startup(tid);
- }
-}
-FINSH_FUNCTION_EXPORT(libc_sem, posix semaphore test);
+#include <pthread.h>
+#include <semaphore.h>
+#include <stdio.h>
+
+static sem_t sema;
+static void* other_thread()
+{
+ printf("other_thread here!\n");
+
+ sleep(1);
+
+ while (1)
+ {
+ printf("other_thread: sem_post...\n");
+ if(sem_post(&sema) == -1)
+ printf("sem_post failed\n");
+ sleep(1);
+ }
+
+ printf("other_thread dies!\n");
+ pthread_exit(0);
+}
+
+static void test_thread(void* parameter)
+{
+ pthread_t tid;
+
+ printf("main thread here!\n");
+ printf("sleep 5 seconds...");
+ sleep(5);
+ printf("done\n");
+
+ sem_init(&sema, 0, 0);
+
+ /* create the "other" thread */
+ if(pthread_create(&tid, 0, &other_thread, 0)!=0)
+ /* error */
+ printf("pthread_create OtherThread failed.\n");
+ else
+ printf("created OtherThread=%x\n", tid);
+
+ /* let the other thread run */
+ while (1)
+ {
+ printf("Main: sem_wait...\n");
+ if(sem_wait(&sema) == -1)
+ printf("sem_wait failed\n");
+ printf("Main back.\n\n");
+ }
+
+ pthread_exit(0);
+}
+#include <finsh.h>
+void libc_sem()
+{
+ rt_thread_t tid;
+
+ tid = rt_thread_create("semtest", test_thread, RT_NULL,
+ 2048, 20, 5);
+ if (tid != RT_NULL)
+ {
+ rt_thread_startup(tid);
+ }
+}
+FINSH_FUNCTION_EXPORT(libc_sem, posix semaphore test);