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

Function _pftx_get

components/lwp/lwp_futex.c:219–252  ·  view source on GitHub ↗

* @brief Gets or creates a private futex for the given user address * * @param[in] uaddr User-space address used as futex key * @param[in] lwp Pointer to the lightweight process structure * @param[in] op Operation flags (unused in current implementation) * @param[out] rc Pointer to store the operation result code * * @return rt_futex_t Returns pointer to existing or newly created futex on s

Source from the content-addressed store, hash-verified

217 * @note If the futex doesn't exist, it creates a new one using _pftx_create_locked.
218 */
219static rt_futex_t _pftx_get(void *uaddr, struct rt_lwp *lwp, int op,
220 rt_err_t *rc)
221{
222 struct lwp_avl_struct *node = RT_NULL;
223 rt_futex_t futex = RT_NULL;
224 rt_err_t error = -1;
225
226 LWP_LOCK(lwp);
227
228 /**
229 * Note: Critical Section
230 * protect lwp address_search_head (READ)
231 */
232 node = lwp_avl_find((avl_key_t)uaddr, lwp->address_search_head);
233 if (node)
234 {
235 futex = rt_container_of(node, struct rt_futex, node);
236 error = 0;
237 }
238 else
239 {
240 /* create a futex according to this uaddr */
241 futex = _pftx_create_locked(uaddr, lwp);
242
243 if (!futex)
244 error = -ENOMEM;
245 else
246 error = 0;
247 }
248 LWP_UNLOCK(lwp);
249
250 *rc = error;
251 return futex;
252}
253
254/**
255 * @brief Destroy a Shared FuTeX (sftx)

Callers 1

_futex_getFunction · 0.85

Calls 2

lwp_avl_findFunction · 0.85
_pftx_create_lockedFunction · 0.85

Tested by

no test coverage detected