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

Function pthread_entry_stub

components/libc/posix/pthreads/pthread.c:328–350  ·  view source on GitHub ↗

* @brief Thread entry point stub that manages thread execution and resource cleanup * * This function serves as the entry point for POSIX threads, executing the thread's main * function and handling post-exit resource management based on the thread's detach state. * * @param parameter Thread parameter containing the _pthread_data_t structure pointer * * @note * - Executes thread's main f

Source from the content-addressed store, hash-verified

326 * - Integrates with pthread lifecycle management system for complete resource recovery
327 */
328static void pthread_entry_stub(void *parameter)
329{
330 void *value;
331 _pthread_data_t *ptd;
332
333 ptd = (_pthread_data_t *)parameter;
334
335 /* execute pthread entry */
336 value = ptd->thread_entry(ptd->thread_parameter);
337
338 /* According to "detachstate" to whether or not to recycle resource immediately */
339 if (ptd->attr.detachstate == PTHREAD_CREATE_JOINABLE)
340 {
341 /* set value */
342 ptd->return_value = value;
343 rt_sem_release(ptd->joinable_sem);
344 }
345 else
346 {
347 /* release pthread resource */
348 _pthread_data_destroy(ptd);
349 }
350}
351
352/**
353 * @brief Creates a new thread in a POSIX-compliant system.

Callers

nothing calls this directly

Calls 2

rt_sem_releaseFunction · 0.85
_pthread_data_destroyFunction · 0.85

Tested by

no test coverage detected