| 944 | } |
| 945 | |
| 946 | static 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 |
no test coverage detected