From 0924065511087d9ef3cf84183029ce8e834ff84a Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Sun, 19 Dec 2021 21:06:09 -0800 Subject: Configured atomic swap --- src/util/mutex.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/util') 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; -- cgit v1.2.1