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

Function rt_mutex_setprioceiling

src/ipc.c:1152–1184  ·  view source on GitHub ↗

* @brief set the prioceiling attribute of the mutex. * * @param mutex is a pointer to a mutex object. * @param priority is the priority should be set to mutex. * * @return return the old priority ceiling */

Source from the content-addressed store, hash-verified

1150 * @return return the old priority ceiling
1151 */
1152rt_uint8_t rt_mutex_setprioceiling(rt_mutex_t mutex, rt_uint8_t priority)
1153{
1154 rt_uint8_t ret_priority = 0xFF;
1155 rt_uint8_t highest_prio;
1156 rt_sched_lock_level_t slvl;
1157
1158 RT_DEBUG_IN_THREAD_CONTEXT;
1159
1160 if ((mutex) && (priority < RT_THREAD_PRIORITY_MAX))
1161 {
1162 /* critical section here if multiple updates to one mutex happen */
1163 rt_spin_lock(&(mutex->spinlock));
1164 ret_priority = mutex->ceiling_priority;
1165 mutex->ceiling_priority = priority;
1166 if (mutex->owner)
1167 {
1168 rt_sched_lock(&slvl);
1169 highest_prio = _thread_get_mutex_priority(mutex->owner);
1170 if (highest_prio != rt_sched_thread_get_curr_prio(mutex->owner))
1171 {
1172 _thread_update_priority(mutex->owner, highest_prio, RT_UNINTERRUPTIBLE);
1173 }
1174 rt_sched_unlock(slvl);
1175 }
1176 rt_spin_unlock(&(mutex->spinlock));
1177 }
1178 else
1179 {
1180 rt_set_errno(-RT_EINVAL);
1181 }
1182
1183 return ret_priority;
1184}
1185RTM_EXPORT(rt_mutex_setprioceiling);
1186
1187

Callers

nothing calls this directly

Calls 8

_thread_update_priorityFunction · 0.85
rt_set_errnoFunction · 0.85
rt_spin_lockFunction · 0.70
rt_sched_lockFunction · 0.70
rt_sched_unlockFunction · 0.70
rt_spin_unlockFunction · 0.70

Tested by

no test coverage detected