summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kc/core/cpu/irq.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/kc/core/cpu/irq.c b/kc/core/cpu/irq.c
index 639aca3..e4dd29f 100644
--- a/kc/core/cpu/irq.c
+++ b/kc/core/cpu/irq.c
@@ -2,21 +2,22 @@
#include <stdatomic.h>
-static atomic_uint_fast64_t irq_lock_count = 0;
+static volatile atomic_uint_fast64_t irq_lock_count = 0;
void irq_lock(void)
{
+ irq_lock_count++;
__asm__ volatile ("cli;");
}
void irq_unlock(void)
{
- if (irq_lock_count >= 1)
+ if (atomic_load(&irq_lock_count) >= 1)
{
irq_lock_count--;
}
- if (irq_lock_count == 0)
+ if (atomic_load(&irq_lock_count) == 0)
{
__asm__ volatile ("sti;");
}