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

Function _sftx_create

components/lwp/lwp_futex.c:300–335  ·  view source on GitHub ↗

* @brief Create a Shared FuTeX (sftx) * * @param[in] key Pointer to shared futex key structure * @param[in] lwp Pointer to lightweight process structure * * @return Pointer to created futex on success, NULL on failure * * @note This function: * - Allocates memory for new futex * - Creates custom object with _sftx_destroy as destructor * - Adds futex to global table *

Source from the content-addressed store, hash-verified

298 * - Initializes futex members (mutex, waiting_thread list)
299 */
300static rt_futex_t _sftx_create(struct shared_futex_key *key, struct rt_lwp *lwp)
301{
302 rt_futex_t futex = RT_NULL;
303 struct rt_object *obj = RT_NULL;
304
305 if (lwp)
306 {
307 futex = (rt_futex_t)rt_calloc(1, sizeof(struct rt_futex));
308 if (futex)
309 {
310 /* create a Shared FuTeX (sftx) */
311 obj = rt_custom_object_create("sftx", (void *)futex, _sftx_destroy);
312 if (!obj)
313 {
314 rt_free(futex);
315 futex = RT_NULL;
316 }
317 else
318 {
319 if (futex_global_table_add(key, futex))
320 {
321 rt_object_delete(obj);
322 rt_free(futex);
323 futex = RT_NULL;
324 }
325 else
326 {
327 futex->mutex = RT_NULL;
328 rt_list_init(&(futex->waiting_thread));
329 futex->custom_obj = obj;
330 }
331 }
332 }
333 }
334 return futex;
335}
336
337/**
338 * @brief Get or create a Shared FuTeX (sftx) for given user address

Callers 1

_sftx_getFunction · 0.85

Calls 6

rt_callocFunction · 0.85
rt_custom_object_createFunction · 0.85
rt_freeFunction · 0.85
futex_global_table_addFunction · 0.85
rt_object_deleteFunction · 0.85
rt_list_initFunction · 0.85

Tested by

no test coverage detected