MCPcopy Index your code
hub / github.com/RT-Thread/rt-thread / rt_mutex_init

Function rt_mutex_init

src/ipc.c:1008–1033  ·  view source on GitHub ↗

* @brief Initialize a static mutex object. * * @note For the static mutex object, its memory space is allocated by the compiler during compiling, * and shall placed on the read-write data segment or on the uninitialized data segment. * By contrast, the rt_mutex_create() function will automatically allocate memory space * and initialize the mutex. * * @se

Source from the content-addressed store, hash-verified

1006 * @warning This function can ONLY be called from threads.
1007 */
1008rt_err_t rt_mutex_init(rt_mutex_t mutex, const char *name, rt_uint8_t flag)
1009{
1010 /* flag parameter has been obsoleted */
1011 RT_UNUSED(flag);
1012
1013 /* parameter check */
1014 RT_ASSERT(mutex != RT_NULL);
1015
1016 /* initialize object */
1017 rt_object_init(&(mutex->parent.parent), RT_Object_Class_Mutex, name);
1018
1019 /* initialize ipc object */
1020 _ipc_object_init(&(mutex->parent));
1021
1022 mutex->owner = RT_NULL;
1023 mutex->priority = 0xFF;
1024 mutex->hold = 0;
1025 mutex->ceiling_priority = 0xFF;
1026 rt_list_init(&(mutex->taken_list));
1027
1028 /* flag can only be RT_IPC_FLAG_PRIO. RT_IPC_FLAG_FIFO cannot solve the unbounded priority inversion problem */
1029 mutex->parent.parent.flag = RT_IPC_FLAG_PRIO;
1030 rt_spin_lock_init(&(mutex->spinlock));
1031
1032 return RT_EOK;
1033}
1034RTM_EXPORT(rt_mutex_init);
1035
1036

Callers 15

lwp_pid_initFunction · 0.85
lwp_createFunction · 0.85
lwp_futex_initFunction · 0.85
lwp_tid_initFunction · 0.85
lwp_session_createFunction · 0.85
lwp_pgrp_createFunction · 0.85
lwp_tty_create_extFunction · 0.85
rt_virtio_gpu_initFunction · 0.85
rt_virtio_input_initFunction · 0.85
rt_pci_ep_registerFunction · 0.85

Calls 4

rt_object_initFunction · 0.85
_ipc_object_initFunction · 0.85
rt_list_initFunction · 0.85
rt_spin_lock_initFunction · 0.70

Tested by 10

test_static_mutex_initFunction · 0.68
test_static_mutex_takeFunction · 0.68
test_static_pri_reverseFunction · 0.68
test_recurse_lockFunction · 0.68
test_mutex_piFunction · 0.68
test_mutex_pi_timeoutFunction · 0.68