MCPcopy Index your code
hub / github.com/RT-Thread/rt-thread / test_thread

Function test_thread

examples/libc/sem.c:33–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31}
32
33static 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>
63void libc_sem()
64{

Callers

nothing calls this directly

Calls 6

sem_initFunction · 0.85
pthread_createFunction · 0.85
sem_waitFunction · 0.85
pthread_exitFunction · 0.85
sleepFunction · 0.70
printfFunction · 0.50

Tested by

no test coverage detected