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

Function _mutex_before_delete_detach

src/ipc.c:946–977  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

944}
945
946static void _mutex_before_delete_detach(rt_mutex_t mutex)
947{
948 rt_sched_lock_level_t slvl;
949 rt_bool_t need_schedule = RT_FALSE;
950
951 rt_spin_lock(&(mutex->spinlock));
952 /* wakeup all suspended threads */
953 rt_susp_list_resume_all(&(mutex->parent.suspend_thread), RT_ERROR);
954
955 rt_sched_lock(&slvl);
956
957 /* remove mutex from thread's taken list */
958 rt_list_remove(&mutex->taken_list);
959
960 /* whether change the thread priority */
961 if (mutex->owner)
962 {
963 need_schedule = _check_and_update_prio(mutex->owner, mutex);
964 }
965
966 if (need_schedule)
967 {
968 rt_sched_unlock_n_resched(slvl);
969 }
970 else
971 {
972 rt_sched_unlock(slvl);
973 }
974
975 /* unlock and do necessary reschedule if required */
976 rt_spin_unlock(&(mutex->spinlock));
977}
978
979/**
980 * @addtogroup group_mutex Mutex

Callers 2

rt_mutex_detachFunction · 0.85
rt_mutex_deleteFunction · 0.85

Calls 8

rt_susp_list_resume_allFunction · 0.85
rt_list_removeFunction · 0.85
_check_and_update_prioFunction · 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