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

Function rt_mutex_create

src/ipc.c:1234–1262  ·  view source on GitHub ↗

* @brief This function will create a mutex object. * * @note For the mutex object, its memory space is automatically allocated. * By contrast, the rt_mutex_init() function will initialize a static mutex object. * * @see rt_mutex_init() * * @param name is a pointer to the name that given to the mutex. * * @param flag is the mutex flag, which determines the queui

Source from the content-addressed store, hash-verified

1232 * @warning This function can ONLY be called from threads.
1233 */
1234rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag)
1235{
1236 struct rt_mutex *mutex;
1237
1238 /* flag parameter has been obsoleted */
1239 RT_UNUSED(flag);
1240
1241 RT_DEBUG_NOT_IN_INTERRUPT;
1242
1243 /* allocate object */
1244 mutex = (rt_mutex_t)rt_object_allocate(RT_Object_Class_Mutex, name);
1245 if (mutex == RT_NULL)
1246 return mutex;
1247
1248 /* initialize ipc object */
1249 _ipc_object_init(&(mutex->parent));
1250
1251 mutex->owner = RT_NULL;
1252 mutex->priority = 0xFF;
1253 mutex->hold = 0;
1254 mutex->ceiling_priority = 0xFF;
1255 rt_list_init(&(mutex->taken_list));
1256
1257 /* flag can only be RT_IPC_FLAG_PRIO. RT_IPC_FLAG_FIFO cannot solve the unbounded priority inversion problem */
1258 mutex->parent.parent.flag = RT_IPC_FLAG_PRIO;
1259 rt_spin_lock_init(&(mutex->spinlock));
1260
1261 return mutex;
1262}
1263RTM_EXPORT(rt_mutex_create);
1264
1265

Callers 15

_futex_lock_piFunction · 0.85
rt_mm_lockFunction · 0.85
sys_mutex_createFunction · 0.85
rt_serial_bypass_initFunction · 0.85
rt_hw_sensor_registerFunction · 0.85
rt_hw_sensor_registerFunction · 0.85
usb_osal_mutex_createFunction · 0.85
check_createFunction · 0.85
arm_tpl_cvMethod · 0.85
sys_mutex_newFunction · 0.85
free_socketFunction · 0.85
alloc_socket_by_deviceFunction · 0.85

Calls 4

rt_object_allocateFunction · 0.85
_ipc_object_initFunction · 0.85
rt_list_initFunction · 0.85
rt_spin_lock_initFunction · 0.70

Tested by 11

task_registrationFunction · 0.68
task_registrationFunction · 0.68
task_registrationFunction · 0.68
_ic_test_openFunction · 0.68
can_sampleFunction · 0.68
test_dynamic_mutex_takeFunction · 0.68
test_dynamic_pri_reverseFunction · 0.68