kernel/mutex: Clean up k_mutex_unlock()
Recent changes to the scheduler API means we can simplify this further: move the assignment to mutex->owner outside the if(), which removes the need to have an else clause (which just set that field to NULL when the new_owner was already NULL); and we can likewise move the irq_unlock() outside the block. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
d89249dbc5
commit
5792ee6da2
1 changed files with 4 additions and 4 deletions
|
@ -225,6 +225,8 @@ void _impl_k_mutex_unlock(struct k_mutex *mutex)
|
|||
|
||||
struct k_thread *new_owner = _unpend_first_thread(&mutex->wait_q);
|
||||
|
||||
mutex->owner = new_owner;
|
||||
|
||||
K_DEBUG("new owner of mutex %p: %p (prio: %d)\n",
|
||||
mutex, new_owner, new_owner ? new_owner->base.prio : -1000);
|
||||
|
||||
|
@ -241,14 +243,12 @@ void _impl_k_mutex_unlock(struct k_mutex *mutex)
|
|||
* waiter since the wait queue is priority-based: no need to
|
||||
* ajust its priority
|
||||
*/
|
||||
mutex->owner = new_owner;
|
||||
mutex->lock_count++;
|
||||
mutex->owner_orig_prio = new_owner->base.prio;
|
||||
} else {
|
||||
irq_unlock(key);
|
||||
mutex->owner = NULL;
|
||||
}
|
||||
|
||||
irq_unlock(key);
|
||||
|
||||
k_sched_unlock();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue