From 5e0743c59fd50780cc28e97fb3ffd18855d0ac62 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Sun, 9 Feb 2020 00:40:35 +0900 Subject: [PATCH] klibc/mutex: Reduce the amount of code executed in mutex_trylock() while the spinlock is held --- kernel/klibc/mutex.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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)); -- 2.47.3