Skip to contentSkip to conversation

Efficient Pthread Implementation

parisc-linux Matthew Wilcox 1 participant 1 message Mar 20, 2001

lore
Share & tools
lore
#0 lore raw

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?

Signature · 1 line
Revolutions do not require corporate support.