MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / thread_create

Function thread_create

libcpu/sim/posix/cpu_port.c:182–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180 pthread_exit(NULL);
181}
182static int thread_create(
183 thread_t *thread, void *task, void *parameter, void *pexit)
184{
185 int res;
186 pthread_attr_t attr;
187
188 thread->task = task;
189 thread->para = parameter;
190 thread->exit = pexit;
191
192 if (sem_init(&thread->sem, 0, 0) != 0)
193 {
194 printf("init thread->sem failed, exit \n");
195 exit(EXIT_FAILURE);
196 }
197 /* No need to join the threads. */
198 pthread_attr_init(&attr);
199 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
200
201 /* create a posix thread */
202 res = pthread_create(&thread->pthread, &attr, &thread_run, (void *)thread);
203 if (res)
204 {
205 printf("pthread create faild, <%d>\n", res);
206 exit(EXIT_FAILURE);
207 }
208
209 return 0;
210}
211
212/* resume the thread */
213static int thread_resume(thread_t *thread)

Callers 1

rt_hw_stack_initFunction · 0.85

Calls 5

sem_initFunction · 0.85
pthread_attr_initFunction · 0.85
pthread_createFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected