kernel: mutex: remove unnecessary schedule locking
Removes an unnecessary schedule lock/unlock pair from k_mutex_unlock(). Rationale: Given that only the current thread (which would also be the mutex owner) will be able to modify the mutex object AND that a recursive unlock ought never trigger any reschedule (as it does not touch the pend queue), then performing a schedule lock is not needed prior to testing for a recursive unlock. Furthermore, even if it is not a recursive unlock, then a schedule lock is superfluous as the existing spinlock provides sufficient protection. Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
parent
d42b2e6bed
commit
e9b288b713
|
@ -222,8 +222,6 @@ int z_impl_k_mutex_unlock(struct k_mutex *mutex)
|
||||||
*/
|
*/
|
||||||
__ASSERT_NO_MSG(mutex->lock_count > 0U);
|
__ASSERT_NO_MSG(mutex->lock_count > 0U);
|
||||||
|
|
||||||
z_sched_lock();
|
|
||||||
|
|
||||||
LOG_DBG("mutex %p lock_count: %d", mutex, mutex->lock_count);
|
LOG_DBG("mutex %p lock_count: %d", mutex, mutex->lock_count);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -266,8 +264,6 @@ int z_impl_k_mutex_unlock(struct k_mutex *mutex)
|
||||||
k_mutex_unlock_return:
|
k_mutex_unlock_return:
|
||||||
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_mutex, unlock, mutex, 0);
|
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_mutex, unlock, mutex, 0);
|
||||||
|
|
||||||
k_sched_unlock();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue