aboutsummaryrefslogtreecommitdiff
path: root/src/util/mutex.c
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-01-03 20:10:10 -0800
committerChristian Cunningham <cc@localhost>2022-01-03 20:10:10 -0800
commit1b180d2f15e9b726e6e9dde5601f41fa48c1c044 (patch)
tree837de56031b3c26b62e8773d2bc671b38da12e53 /src/util/mutex.c
parent3448a072fab683b97c93922b2d150e530a22b5a3 (diff)
Ensured Aligned Mutexes
Diffstat (limited to 'src/util/mutex.c')
-rw-r--r--src/util/mutex.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/util/mutex.c b/src/util/mutex.c
index 2637a6c..1763de2 100644
--- a/src/util/mutex.c
+++ b/src/util/mutex.c
@@ -1,4 +1,5 @@
#include "../cpu/atomic/swap.h"
+#include "../lib/mem.h"
#include "../util/mutex.h"
unsigned char lock_mutex(struct Mutex* m, unsigned long pid)
@@ -21,3 +22,11 @@ unsigned char release_mutex(struct Mutex* m, unsigned long pid)
}
return 1;
}
+
+struct Mutex* create_mutex(void* addr)
+{
+ // Ensure aligned to word - Important for Atomic Swap
+ struct Mutex* m = (struct Mutex*)malloca(sizeof(struct Mutex), 4);
+ m->addr = addr;
+ return m;
+}