diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-09-29 10:56:18 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-09-29 10:56:18 -0600 |
commit | 7b34cb7741c683dc623ece652032f1bf09d34140 (patch) | |
tree | e131e4973f47bcfc93131c9eed7c78d4c614a4be /libcr_ipc/mutex.c | |
parent | f54d6bfcc488b644926b962c230f8f12d0d65646 (diff) |
wip fixes
Diffstat (limited to 'libcr_ipc/mutex.c')
-rw-r--r-- | libcr_ipc/mutex.c | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/libcr_ipc/mutex.c b/libcr_ipc/mutex.c deleted file mode 100644 index 198c738..0000000 --- a/libcr_ipc/mutex.c +++ /dev/null @@ -1,39 +0,0 @@ -/* libcr_ipc/mutex.c - Simple mutexes for libcr (implementation file) - * - * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> - * SPDX-Licence-Identifier: AGPL-3.0-or-later - */ - -#include <assert.h> - -#include <libcr_ipc/mutex.h> - -void cr_mutex_lock(cr_mutex_t *mu) { - assert(mu); - if (!mu->tail) - mu->tail = &mu->head; - if (!mu->locked) { - mu->locked = true; - return; - } - struct _cr_ipc_cid_list self = { - .val = cr_getcid(), - .next = NULL, - }; - *(mu->tail) = &self; - mu->tail = &(self.next); - cr_pause_and_yield(); -} - -void cr_mutex_unlock(cr_mutex_t *mu) { - assert(mu); - assert(mu->tail); - assert(mu->locked); - if (mu->head) { - cr_unpause(mu->head->val); - mu->head = mu->head->next; - if (!mu->head) - mu->tail = &mu->head; - } else - mu->locked = false; -} |