From b6095304b7ee2b69d2ee4a9a7265999d1a2b9675 Mon Sep 17 00:00:00 2001 From: rsc Date: Fri, 10 Aug 2007 16:37:27 +0000 Subject: Make cp a magic symbol. --- proc.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'proc.h') diff --git a/proc.h b/proc.h index 2848ecd..7a04cd5 100644 --- a/proc.h +++ b/proc.h @@ -50,7 +50,17 @@ struct proc { // expandable heap extern struct proc proc[]; + +// If xv6 was only for uniprocessors, this could be +// struct proc *cp; +// Instead we have an array curproc, one per +// processor, and #define cp to the right element +// in the array. In general such preprocessor +// subterfuge is to be avoided, but cp is used +// so often that having the shorthand is worth the ugliness. extern struct proc *curproc[NCPU]; // Current (running) process per CPU +#define cp (curproc[cpu()]) // Current process on this CPU + #define MPSTACK 512 -- cgit v1.2.3