]> git.corax.cc Git - corax/commitdiff
klibc/mutex: Reduce the amount of code executed in mutex_trylock() while the spinlock...
authorMatthias Kruk <m@m10k.eu>
Sat, 8 Feb 2020 15:40:35 +0000 (00:40 +0900)
committerMatthias Kruk <m@m10k.eu>
Sat, 8 Feb 2020 15:40:35 +0000 (00:40 +0900)
kernel/klibc/mutex.c

index 7e69b07464f1c7b29fa5be41fb613d7d34ffb71d..b6fd5d0ff7ec0c06ad469003f6fc9fc28e3bba6e 100644 (file)
@@ -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));