Weldon Washburn wrote:
Archie,
I can now run the below multithread Hello.java on JCHEVM using Apache
Harmony Class Library. The output toggles between clumps of "Hello
World" and clumps of "*" as WindowsXP schedules the two application
threads. This is behavior I would expect. I use System.out.write()
because System.out.println() does not work yet. A summary follows:
Mods to JCHEVM to get it to work
1)
I was not able to find the _JC_LIB_ENTRY that is intended for
read/writing files. I gave up and "borrowed"
JCNI_java_lang_VMThread_nativeSetPriority(). Instead of actually
changing thread priority, it now does a "fprintf(stdout, "%s",
&priority); fflush(stdout);" Perhaps you can tell me what native
method I should be using.
2)
I commented out some stuff in bootstrap.c that was dragging in
specific gnu classpath *.class files like "Lgnu/classpath/Pointer;"
We should discuss the best solution for this item.
Harmony Class Lib that were modified to get it to work:
Runtime.java -- expected "wrapper" code. e.g., add VMRuntime.exit() to
Runtime.exit()
Method.java, Field.java, Constructor.java -- minor mods
System.java -- added VMSystem.setOut, setErr... etc
ThreadGroup.java -- wrappers
Class.java -- wrappers
Object.java -- wrappers
String.java -- implemented a very simple intern()
Thread.java -- added a bunch of fields that JCHEVM accesses, added
code to start() to create ThreadGroup.root if it does not already
exist
Throwable.java -- wrappers
ClassLoader.java -- commented out "abstract" keyword on class
definition (too lazy to create a sub-class), added fields that JCHEVM
accesses, added code getSystemClassLoader to actually create an object
and stuff it in systemClassLoader if it does not already exist. added
a bunch of wrapper code.
OSMemory -- hacked out a bunch of stuff that was in the way
OSFileSystem -- add an ugly hack in writeImpl() to revector chars to
Thread.setPriority()
One last item. I don't know which SVN repository to place this work
in. Any suggestions?
Thanks
Weldon
##########################
class Hello extends Thread {
public static void main(String args[])
{
byte [] ba = new byte[64];
ba [0] = 'H'; ba [1] = 'e'; ba [2] = 'l'; ba [3] = 'l'; ba [4] = 'o';
ba [5] = ' '; ba [6] = 'W'; ba [7] = 'o'; ba [8] = 'r'; ba [9] =
'l'; ba[10] = 'd'; ba[11] = ' ';
Thread tr = new Hello();
tr.start();
while (true) {
for (int qq = 0; qq < 12; qq++) {
System.out.write(ba[qq]);
}
}
}
public void run() {
while(true) {
System.out.write('*');
}
}
}
--
Weldon Washburn
Intel Middleware Products Division
Hi Weldon,
Well done!
Where did you actually run the test: Cygwin, Linux, or both?
Enrico