From bccc0b5200fe063760f45cd53c21abed37ec334a Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Thu, 26 Jun 2025 14:45:45 +0200 Subject: [PATCH] Nasty unfixed bug related to spinlock panics --- lib/spinlock.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/spinlock.c b/lib/spinlock.c index 5277a8b..6b1d89f 100644 --- a/lib/spinlock.c +++ b/lib/spinlock.c @@ -4,10 +4,12 @@ */ // #include +#include "string.h" #include #include #include #include +#include /** * The aquire() and release() functions control ownership of the lock. @@ -99,6 +101,7 @@ void push_off(void) { intr_off(); if (mycpu()->noff == 0) mycpu()->intena = old; + mycpu()->noff += 1; } @@ -106,8 +109,15 @@ void pop_off(void) { struct Cpu *c = mycpu(); if (intr_get()) panic("pop_off - interruptible"); - if (c->noff < 1) + if (c->noff < 1) { + { + // TODO: Remove this block when fixed + char amt[100]; + itoa(c->noff, amt, 10); + uart_puts(amt); + } panic("pop_off"); + } c->noff -= 1; if (c->noff == 0 && c->intena) intr_on();