summaryrefslogtreecommitdiff
path: root/sys/kern/spinlock.c
diff options
context:
space:
mode:
authorstefan <stefan@s00.xyz>2023-04-19 20:50:10 -0400
committerstefan <stefan@s00.xyz>2023-04-19 20:50:10 -0400
commit83e17e29456ec9b6d45f4d9f2634eb280c6f414f (patch)
tree004a9b2a7cd3f0c7bb4224b59204680bd5d79681 /sys/kern/spinlock.c
parentaf1ce4b2e637ceb418ea72d51c49a3eee276a938 (diff)
downloadsv-83e17e29456ec9b6d45f4d9f2634eb280c6f414f.tar.gz
ticket locks
Diffstat (limited to 'sys/kern/spinlock.c')
-rw-r--r--sys/kern/spinlock.c38
1 files changed, 0 insertions, 38 deletions
diff --git a/sys/kern/spinlock.c b/sys/kern/spinlock.c
deleted file mode 100644
index ade270f..0000000
--- a/sys/kern/spinlock.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <asm.h>
-#include <spinlock.h>
-
-void
-initlock(struct spinlock *l)
-{
- l->locked = 0;
-}
-
-void
-acquire(struct spinlock *l)
-{
- sie_disable();
-
- if (l->locked)
- return;
-
- while (__sync_lock_test_and_set(&l->locked, 1))
- ;
-
- __sync_synchronize();
-}
-
-void
-release(struct spinlock *l)
-{
- sie_disable(); // avoid deadlock
-
- if (l->locked)
- return; // interrupts are still disabled, what to do here?
-
- /* fence */
- __sync_synchronize();
-
- __sync_lock_release(&l->locked);
-
- sie_enable();
-}