21 lines
388 B
C
21 lines
388 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 = read_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;
|
|
}
|