diff options
author | Christian Cunningham <cc@localhost> | 2021-12-19 21:06:09 -0800 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2021-12-19 21:06:09 -0800 |
commit | 0924065511087d9ef3cf84183029ce8e834ff84a (patch) | |
tree | 63b1236a636f6315bc0d2bef4fcc599456479a18 /src/util/mutex.c | |
parent | 43db8c57ebe496bea03d66e2ddd0aa6bc298738c (diff) |
Configured atomic swap
Diffstat (limited to 'src/util/mutex.c')
-rw-r--r-- | src/util/mutex.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/util/mutex.c b/src/util/mutex.c index 86ffcf5..98dc849 100644 --- a/src/util/mutex.c +++ b/src/util/mutex.c @@ -1,8 +1,10 @@ #include "../util/mutex.h" +#include "../cpu/atomic/swap.a.h" unsigned char lock_mutex(struct Mutex* m, unsigned long pid) { if (m->pid == NULL_PID) { - m->pid = pid; + //m->pid = pid; + atm_lock(pid, &m->pid); return 0; } return 1; @@ -13,7 +15,8 @@ unsigned char lock_mutex(struct Mutex* m, unsigned long pid) { // mutex's pid lock unsigned char release_mutex(struct Mutex* m, unsigned long pid) { if (m->pid == pid) { - m->pid = NULL_PID; + //m->pid = NULL_PID; + atm_release(&m->pid); return 0; } return 1; |