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

Function _pthread_get_data

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

* @brief Retrieves the private data structure of a specified thread * * This function locates and validates the thread-private data structure associated with the given thread ID. * It uses a spinlock to synchronize access to the global thread table, ensuring data consistency in multithreaded environments. * A magic number validation is performed before returning to guarantee structural integ

Source from the content-addressed store, hash-verified

40 * - Internal interface typically used by other POSIX thread library functions
41 */
42_pthread_data_t *_pthread_get_data(pthread_t thread)
43{
44 _pthread_data_t *ptd;
45
46 if (thread >= PTHREAD_NUM_MAX) return NULL;
47
48 rt_hw_spin_lock(&pth_lock);
49 ptd = pth_table[thread];
50 rt_hw_spin_unlock(&pth_lock);
51
52 if (ptd && ptd->magic == PTHREAD_MAGIC) return ptd;
53
54 return NULL;
55}
56
57/**
58 * @brief Get the index position of a thread data in the global thread table

Callers 9

pthread_createFunction · 0.85
pthread_detachFunction · 0.85
pthread_joinFunction · 0.85
pthread_getcpuclockidFunction · 0.85
pthread_getschedparamFunction · 0.85
pthread_setschedparamFunction · 0.85
pthread_setschedprioFunction · 0.85
pthread_killFunction · 0.85
pthread_cancelFunction · 0.85

Calls 2

rt_hw_spin_lockFunction · 0.50
rt_hw_spin_unlockFunction · 0.50

Tested by

no test coverage detected