[parisc-linux] Efficient Pthread Implementation
Matthew Wilcox
matthew@wil.cx
Tue, 20 Mar 2001 04:43:48 +0000
Pthreads needs a way to find the address of the thread control structure
for the task which is currently running. If we use fixed instead of
floating stacks, and don't tell it to use a different stack (unsure
what circumstances will cause this to happen, or the advantages of
configuring pthreads to use floating stacks), then everything is fine,
we can simply take the stack pointer, mask it with the stack size and
get the answer we were looking for.
If we use a different stack, then it scans the various stacks looking
to see which stack contains this stack pointer, unless the architecture
specifies a better way to find it. x86 uses one of the segment registers,
ia64 uses a register specified in the ABI. I propose we could use %cr27.
It's readable from userspace, and we could have a 2-insn stub on the
gateway page which sets %cr27 as necessary. We then have to switch its
value across context switch, which doesn't seem like a big deal to me.
Comments? Better ideas?
--
Revolutions do not require corporate support.