summaryrefslogtreecommitdiff
path: root/proc.h
diff options
context:
space:
mode:
authorrsc <rsc>2007-08-10 16:37:27 +0000
committerrsc <rsc>2007-08-10 16:37:27 +0000
commitb6095304b7ee2b69d2ee4a9a7265999d1a2b9675 (patch)
tree3193df85e9fc228f512010d4bddf3aeb31e9993e /proc.h
parent3bbbaca14db70c6f255139c66a62b4cd5191462c (diff)
downloadxv6-labs-b6095304b7ee2b69d2ee4a9a7265999d1a2b9675.tar.gz
xv6-labs-b6095304b7ee2b69d2ee4a9a7265999d1a2b9675.tar.bz2
xv6-labs-b6095304b7ee2b69d2ee4a9a7265999d1a2b9675.zip
Make cp a magic symbol.
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