| 31 | } |
| 32 | |
| 33 | static void test_thread(void* parameter) |
| 34 | { |
| 35 | pthread_t tid; |
| 36 | |
| 37 | printf("main thread here!\n"); |
| 38 | printf("sleep 5 seconds..."); |
| 39 | sleep(5); |
| 40 | printf("done\n"); |
| 41 | |
| 42 | sem_init(&sema, 0, 0); |
| 43 | |
| 44 | /* create the "other" thread */ |
| 45 | if(pthread_create(&tid, 0, &other_thread, 0)!=0) |
| 46 | /* error */ |
| 47 | printf("pthread_create OtherThread failed.\n"); |
| 48 | else |
| 49 | printf("created OtherThread=%x\n", tid); |
| 50 | |
| 51 | /* let the other thread run */ |
| 52 | while (1) |
| 53 | { |
| 54 | printf("Main: sem_wait...\n"); |
| 55 | if(sem_wait(&sema) == -1) |
| 56 | printf("sem_wait failed\n"); |
| 57 | printf("Main back.\n\n"); |
| 58 | } |
| 59 | |
| 60 | pthread_exit(0); |
| 61 | } |
| 62 | #include <finsh.h> |
| 63 | void libc_sem() |
| 64 | { |
nothing calls this directly
no test coverage detected