diff options
author | Agustina Arzille <avarzille@riseup.net> | 2017-07-21 00:49:39 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-07-21 00:49:48 +0200 |
commit | 4278f99adcbcfbd52904c0d8809184afe091c958 (patch) | |
tree | 745aed92ca63047495bcecc3f8007dd48818405b /kern/mutex.c | |
parent | 4eaa58c85eec654eb8bf8e002b3f3a419f5ce16b (diff) |
Rework mutex implementation selection
Diffstat (limited to 'kern/mutex.c')
-rw-r--r-- | kern/mutex.c | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/kern/mutex.c b/kern/mutex.c deleted file mode 100644 index 7899bef9..00000000 --- a/kern/mutex.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2013-2017 Richard Braun. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef X15_MUTEX_PI - -#include <stdbool.h> -#include <stddef.h> - -#include <kern/mutex.h> -#include <kern/mutex_i.h> -#include <kern/sleepq.h> - -void -mutex_lock_slow(struct mutex *mutex) -{ - struct sleepq *sleepq; - unsigned long flags; - unsigned int state; - - sleepq = sleepq_lend(mutex, false, &flags); - - for (;;) { - state = atomic_swap_acquire(&mutex->state, MUTEX_CONTENDED); - - if (state == MUTEX_UNLOCKED) { - break; - } - - sleepq_wait(sleepq, "mutex"); - } - - if (sleepq_empty(sleepq)) { - state = atomic_swap_acquire(&mutex->state, MUTEX_LOCKED); - assert(state == MUTEX_CONTENDED); - } - - sleepq_return(sleepq, flags); -} - -void -mutex_unlock_slow(struct mutex *mutex) -{ - struct sleepq *sleepq; - unsigned long flags; - - sleepq = sleepq_acquire(mutex, false, &flags); - - if (sleepq == NULL) { - return; - } - - sleepq_signal(sleepq); - - sleepq_release(sleepq, flags); -} - -#endif /* X15_MUTEX_PI */ |