From 1767d390fbf3d0c65389de46caf0b6d43ef3b6ad Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Fri, 10 Jul 2026 11:24:56 +0800 Subject: feat: establish bootable new architecture checkpoint Replace the compressed boot path with a relocatable higher-half RISC-V entry, expand memory and SMP support, and add the driver, TTY, VFS, exec, signal, syscall, initramfs, and self-test infrastructure needed for a bootable kernel checkpoint. --- na/kernel/sync/spinlock.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'na/kernel/sync/spinlock.cc') diff --git a/na/kernel/sync/spinlock.cc b/na/kernel/sync/spinlock.cc index bca4684..f649fe7 100644 --- a/na/kernel/sync/spinlock.cc +++ b/na/kernel/sync/spinlock.cc @@ -17,6 +17,7 @@ #include "cpu_state.h" #include #include +#include // ============================================================ // Per-CPU sync state (BSS zero-initialized) @@ -88,6 +89,10 @@ void Spinlock::acquire() { // Step 4: record owner cpu_id_ = arch::cpu::id(); + + // Step 5: bump preempt_count — prevents schedule() from preempting + TaskControlBlock* curr = current_task(); + if (curr) curr->preempt_count++; } void Spinlock::release() { @@ -102,7 +107,11 @@ void Spinlock::release() { // Step 3: release the lock with release semantics locked_.store(0, __ATOMIC_RELEASE); - // Step 4: restore interrupt state if this was the last lock + // Step 4: drop preempt_count + TaskControlBlock* curr = current_task(); + if (curr) curr->preempt_count--; + + // Step 5: restore interrupt state if this was the last lock sync::pop_intr(); } -- cgit v1.2.3