summaryrefslogtreecommitdiff
path: root/proc.h
diff options
context:
space:
mode:
authorRuss Cox <rsc@x40.(none)>2009-09-02 10:07:59 -0700
committerRuss Cox <rsc@x40.(none)>2009-09-02 10:07:59 -0700
commit7e0cc8e36ea91d0299f375f3b3476ab58ab71dde (patch)
tree0b02d5f1c1708ffeeb26ae84a4545cbc9a4c4265 /proc.h
parent374362c55c7e1268ce6c52b029458ef22144c114 (diff)
downloadxv6-labs-7e0cc8e36ea91d0299f375f3b3476ab58ab71dde.tar.gz
xv6-labs-7e0cc8e36ea91d0299f375f3b3476ab58ab71dde.tar.bz2
xv6-labs-7e0cc8e36ea91d0299f375f3b3476ab58ab71dde.zip
another attempt at cpu-local variables.
this time do it ourselves instead of piggybacking on TLS. add -fno-pic to Makefile; pic code breaks our fake TLS.
Diffstat (limited to 'proc.h')
-rw-r--r--proc.h17
1 files changed, 9 insertions, 8 deletions
diff --git a/proc.h b/proc.h
index f20f67e..192f8ff 100644
--- a/proc.h
+++ b/proc.h
@@ -59,10 +59,9 @@ struct cpu {
int ncli; // Depth of pushcli nesting.
int intena; // Were interrupts enabled before pushcli?
- // "Thread"-local storage variables
+ // Cpu-local storage variables; see below
struct cpu *cpu;
struct proc *proc;
- void *tlsstruct;
};
extern struct cpu cpus[NCPU];
@@ -70,9 +69,11 @@ extern int ncpu;
// Per-CPU variables, holding pointers to the
// current cpu and to the current process.
-// The __thread prefix tells gcc to refer to them in the segment
-// pointed at by gs; the name __thread derives from the use
-// of the same mechanism to provide per-thread storage in
-// multithreaded user programs.
-extern __thread struct cpu *cpu; // This cpu.
-extern __thread struct proc *proc; // Current process on this cpu.
+// The asm suffix tells gcc to use "%gs:0" to refer to cpu
+// and "%gs:4" to refer to proc. ksegment sets up the
+// %gs segment register so that %gs refers to the memory
+// holding those two variables in the local cpu's struct cpu.
+// This is similar to how thread-local variables are implemented
+// in thread libraries such as Linux pthreads.
+extern struct cpu *cpu asm("%gs:0"); // This cpu.
+extern struct proc *proc asm("%gs:4"); // Current proc on this cpu.