Major restructure
This commit is contained in:
parent
0562c2fe5a
commit
c52e19de83
25 changed files with 574 additions and 188 deletions
21
kern/libkern/proc.c
Normal file
21
kern/libkern/proc.c
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue