19 lines
375 B
C
19 lines
375 B
C
#include <proc.h>
|
|
|
|
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 = r_tp();
|
|
return id;
|
|
}
|
|
|
|
// Return this CPU's cpu struct.
|
|
// Interrupts must be disabled.
|
|
struct Cpu *mycpu(void) {
|
|
int id = cpuid();
|
|
struct Cpu *c = &cpus[id];
|
|
return c;
|
|
}
|