From d855404c0176324ad2f816355a1966fdfe6b7709 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Thu, 26 Jun 2025 13:51:06 +0200 Subject: [PATCH] Revert to legacy mycpu() and cpuid() --- lib/proc.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/proc.c b/lib/proc.c index a55c8d6..66bca67 100644 --- a/lib/proc.c +++ b/lib/proc.c @@ -2,7 +2,20 @@ struct Cpu cpus[NCPU]; +/** + * Must be called with interrupts disabled, to prevent race with process being + * moved to a different CPU. + */ +int cpuid() { + int id = read_tp(); + return id; +} + /** * Return this CPU's cpu struct. Interrupts must be disabled. */ -inline struct Cpu *mycpu(void) { return &cpus[read_tp()]; } +struct Cpu *mycpu(void) { + int id = cpuid(); + struct Cpu *c = &cpus[id]; + return c; +}