Page 1 of 1
JVM as a CPU
Posted: Sun Aug 05, 2007 6:53 pm
by dushara
Just curious. Are JVMs sort of CPUs?
Just for kicks, I'm wondering if I can port an RTOS kernel I've written to a JVM.
The (wacky) idea I have is to write the kernel using C (which could be translated to Java byte code using NestedVM
http://nestedvm.ibex.org) and Jamaica
http://www.judoscript.com/articles/jamaica.html.
This leads me to the question, do JVMs have some sort of interrupt mechanism or will it need to be emulated by maybe using the host OS threads?
Posted: Sun Aug 05, 2007 7:06 pm
by Alboin
Have you checked out Jnode?
PS: I don't believe translating the C will work. The C interfaces with the x86 hardware. The JVM has a different architecture.
Posted: Sun Aug 05, 2007 7:13 pm
by Kevin McGuire
I am know very little about Java, but what I do know: I can say that you will most likely end up exposing these machine features through objects using some sort of mechanism.
This makes it a pretty advanced task in which you would need to know the internals of Java quite well I would imagine.
Since C# is pretty similar to Java I could give a example where if I wrote a Just-In-Time-Compiler/(JVM) it would have to be written in such a way to marshal these interrupts into calls where in which the calls might be registered via a the creation of a object that normal C# code could interact with.
Code: Select all
namespace Vogree.System.Machine
{
public abstract unsafe class InterruptRouter
{
public static void RegisterHook(uint vector, ...Delegate..);
}
}
// normal C# code to hook a interrupt (interface with machine specific mechanisms)
Vogree.System.Machine.InterruptRouter.RegisterHook(0, ...Function Delegate..);
Not really sure much about going any deeper, but hopefully someone else can explain a way or give some insight into how to do this better than me.
Posted: Tue Aug 07, 2007 12:03 am
by dc0d32
I'm wondering if I can port an RTOS kernel I've written to a JVM.
What's the point?
Posted: Wed Aug 08, 2007 6:17 pm
by dushara
Hi,
What's the point?
Just for kicks.
I can say that you will most likely end up exposing these machine features through objects using some sort of mechanism.
What I have in mind avoids Java altogether. A C compiler (there's one called gccjvm which is not released yet), generates the byte code, maybe use Jamaica for the bits that require assembler.
The only thing that I'm not sure about is how interrupts will be generated. I'm not sure if "events" can be injected into the JVM.