>>>>> "Dimitris" == Dimitris Vyzovitis <[EMAIL PROTECTED]> writes:
Dimitris> On Thu, 8 Feb 2001, Joseph Shraibman wrote:
>> Is it just me or does Thread.yield() not work anymore with the
>> 2.4.0 kernel?
Dimitris> Interesting: blackdown jdk seems to indeed behave
Dimitris> incorrectly.
There's nothing wrong with Thread.yield() here. The difference you
see is the difference between interpreted and compiled code.
Dimitris> Sample execution of the test program I posted previously
Dimitris> (I am on an smp box with two processors, so the case of
Dimitris> interest is the first thread):
Dimitris> Blackdown jdk (Blackdown-1.3.0-FCS, kernel 2.4.1):
Dimitris> t1: 1 t2: 3 t3: 3
Dimitris> t1: 2 t2: 6 t3: 6
Dimitris> t1: 3 t2: 8 t3: 8
Dimitris> t1: 4 t2: 11 t3: 11
Dimitris> t1: 5 t2: 13 t3: 14
Dimitris> t1: 6 t2: 16 t3: 16
Dimitris> t1: 7 t2: 19 t3: 19
Dimitris> t1: 8 t2: 21 t3: 22
Dimitris> t1: 8 t2: 24 t3: 24
Dimitris> t1: 9 t2: 26 t3: 27
Dimitris> t1: 10 t2: 29 t3: 30
Dimitris> t1: 11 t2: 31 t3: 32
Dimitris> t1: 12 t2: 34 t3: 35
Dimitris> t1: 13 t2: 36 t3: 38
Dimitris> t1: 14 t2: 39 t3: 40
Dimitris> t1: 14 t2: 41 t3: 43
Dimitris> t1: 15 t2: 44 t3: 46
Dimitris> t1: 16 t2: 46 t3: 48
Dimitris> t1: 17 t2: 49 t3: 51
Please note that it is perfectly legal with respect to the JLS to
implement Thread.yield() as nop in JVMs based LinuxThreads. Actually
it is not only legal, it's desirable to implement it as nop on JVMs
that employ preemptive scheduling policies (especially on
multiprocessor machines).
Given the loose semantics of Thread.yield(), it is merely a pure
heuristic *hint* to the JVM. The JVM may interpret this hint in any
way it likes. The classic green threads JVM is the only one on Linux
that really needs this hint.
BTW, it's "Thread.yield()". "Thread.currentThread().yield()" has
exactly the same meaning but as Thread.yield() is a class method you
should call it directly on the class.
"Thread.currentThread().yield()" makes it look like yield() would be
an instance method.
Juergen
--
Juergen Kreileder, Blackdown Java-Linux Team
http://www.blackdown.org/java-linux.html
JVM'01: http://www.usenix.org/events/jvm01/
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]