From: Matthias Kruk Date: Sat, 8 Feb 2020 15:40:35 +0000 (+0900) Subject: klibc/mutex: Reduce the amount of code executed in mutex_trylock() while the spinlock... X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=5e0743c59fd50780cc28e97fb3ffd18855d0ac62;p=corax klibc/mutex: Reduce the amount of code executed in mutex_trylock() while the spinlock is held --- diff --git a/kernel/klibc/mutex.c b/kernel/klibc/mutex.c index 7e69b07..b6fd5d0 100644 --- a/kernel/klibc/mutex.c +++ b/kernel/klibc/mutex.c @@ -105,14 +105,13 @@ int mutex_trylock(mutex_t *mutex) task_t *ctask; ctask = task_get_current(); + ret_val = -EAGAIN; spinlock_lock(&(mutex->mx_lock)); if(!mutex->mx_owner) { mutex->mx_owner = ctask; ret_val = 0; - } else { - ret_val = -EAGAIN; } spinlock_unlock(&(mutex->mx_lock));