summaryrefslogtreecommitdiff
path: root/proc.h
diff options
context:
space:
mode:
Diffstat (limited to 'proc.h')
-rw-r--r--proc.h10
1 files changed, 10 insertions, 0 deletions
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