Nasty unfixed bug related to spinlock panics

This commit is contained in:
Imbus 2025-06-26 14:45:45 +02:00
parent d9896b4229
commit bccc0b5200

View file

@ -4,10 +4,12 @@
*/ */
// #include <lib/stdio.h> // #include <lib/stdio.h>
#include "string.h"
#include <panic.h> #include <panic.h>
#include <proc.h> #include <proc.h>
#include <riscv.h> #include <riscv.h>
#include <spinlock.h> #include <spinlock.h>
#include <uart.h>
/** /**
* The aquire() and release() functions control ownership of the lock. * The aquire() and release() functions control ownership of the lock.
@ -99,6 +101,7 @@ void push_off(void) {
intr_off(); intr_off();
if (mycpu()->noff == 0) if (mycpu()->noff == 0)
mycpu()->intena = old; mycpu()->intena = old;
mycpu()->noff += 1; mycpu()->noff += 1;
} }
@ -106,8 +109,15 @@ void pop_off(void) {
struct Cpu *c = mycpu(); struct Cpu *c = mycpu();
if (intr_get()) if (intr_get())
panic("pop_off - interruptible"); 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"); panic("pop_off");
}
c->noff -= 1; c->noff -= 1;
if (c->noff == 0 && c->intena) if (c->noff == 0 && c->intena)
intr_on(); intr_on();