diff options
author | Christian Cunningham <cc@localhost> | 2022-02-13 17:31:22 -0700 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2022-02-13 17:31:22 -0700 |
commit | e814983a452c40734c5ecc63581df88d3925835e (patch) | |
tree | 39ea355b1e47fa0baf3acb49e2229616827f4af5 /src/util | |
parent | a0d6941b2ef689302dce37d1a864fd4213a0a559 (diff) |
Mode-aware locking
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/lock.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/util/lock.c b/src/util/lock.c index 2a7d35e..6b048f4 100644 --- a/src/util/lock.c +++ b/src/util/lock.c @@ -1,5 +1,27 @@ -#include <util/lock.h> +#include <cpu.h> +#include <cpu/atomic/swap.h> #include <lib/kmem.h> +#include <util/lock.h> + +void lock(struct Lock* l) +{ + unsigned long mode = getmode() & 0x1F; + if (mode == 0x10) { + sys1(SYS_LOCK, l); + } else { + atm_lock(CORE0_PID, (unsigned long*)l); + } +} + +void unlock(struct Lock* l) +{ + unsigned long mode = getmode() & 0x1F; + if (mode == 0x10) { + sys1(SYS_UNLOCK, l); + } else { + atm_release((unsigned long*)l); + } +} struct Lock* create_lock(void) { |