thin locks (was Re: libgcj/117:)

Godmar Back gback@cs.utah.edu
Fri Dec 10 13:24:00 GMT 1999


pthread_self() can be optimized and inlined in application code;
in compiled code, I think it would incur at least a function call.

What version of libpthread are you referring to?
Linux-threads 0.71 uses a non-generic implementation only for 
the alpha.  The generic implementation takes two branches in the
common case.  I assume you're referring to a newer version.

Maybe I was a bit too strong in saying "would eliminate any advantage".
It would of course be a lot faster than the current way.  I think it 
depends on how high you're aiming.

	- Godmar

> 
> Godmar Back wrote:
> [snip]
> > Clearly, getting a thread id by using pthread_self() or the like would 
> > eliminate any advantage you hope to see from thin locks.
> 
> This isn't clear to me... what evidence do you have that pthread_self()
> is expensive?  Libpthread uses platform-dependent techniques whenever
> available, falling back on the stack pointer.
> 
> On Alpha/Linux for example, pthread_self() calls PALcode to get the
> unique thread descriptor.  SPARC uses a reserved register.  I believe
> Intel uses the LDT...
> 




More information about the Java mailing list