This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
Re: Why is Linux thread locking so slow?
>>>>> "Tom" == Tom Tromey <tromey@cygnus.com> writes:
Matt> However, I can't seem to duplicate the same problem when writing
Matt> a simple pthreads program in C -- the C program performance
Matt> doesn't decrease anywhere near as badly as Java. I believe I am
Matt> using the same locking mechanisms in C as are used in GCJ.
Tom> Someone (I don't remember who) has said here that Linux Threads
Tom> uses spin locks for mutexes -- apparently it doesn't yield when
Tom> trying to acquire a lock. I haven't looked at the source to see
Tom> if this is the case, but if it is then it would seem to explain
Tom> your problem.
Except, of course, why you don't see it with C :-(
One difference between the Java code and the C code you posted is the
GC. You could try disabling the GC to see if that has any effect. I
don't know whether it will or not, since now I don't really have a
theory about this problem.
T