Page 1 of 1
Java-like VM for OSes
Posted: Thu Dec 01, 2011 7:08 am
by amd64pager
I just thought if you could write your OS in bytecode,you could have a OS library(remember the java library anyone?) and a VM like the one java gives,you could add features like just in time compilation and other fancy features.
Would this be a good idea?And if it is,does anyone know some more ideas for it?
Re: Java-like VM for OSes
Posted: Thu Dec 01, 2011 10:56 pm
by ACcurrent
Long Live AOT compilers. My OS does this. (this may actually one place where EFI helps over BIOS)
Re: Java-like VM for OSes
Posted: Fri Dec 02, 2011 1:14 am
by Tosi
There are quite a few kernels that have been written in mostly Java; there is always a machine-dependent part that will need to be written in C or assembly however. And unless you are on a processor which can run the bytecode natively, there is an amount of overhead introduced by the interpretation or JIT.
For an example, see
JavaOS, which also has links to several other Java OSes.
In short, there are some minor difficulties, but writing an OS in a language which is compiled to bytecode instead of machine code is definitely possible.
Re: Java-like VM for OSes
Posted: Mon Dec 05, 2011 6:04 am
by amd64pager
This is how it works:
It is made of different parts:
OSVM kernel
OSVM script parser
OSVM compiled executable parser
OSVM executable utilities
This is how the startup sequence goes:
-The bootloader loads the OSVM kernel
-The OSVM kernel loads the rest of the OSVM.
-Then the startup script is called
-The startup script can do things like print version,display a image etc.
-Then using the OSVM executable utilities,the script can link different parts of the kernel
-Then the scripts destroys itself and says the OSVM executable parser to run the kernel
Can you please suggest new ideas?
Re: Java-like VM for OSes
Posted: Mon Dec 05, 2011 6:31 am
by bluemoon
So, you are describing a scripting engine or virtual machine?
Re: Java-like VM for OSes
Posted: Mon Dec 05, 2011 7:12 am
by Solar
@bluemoon:
The difference tends to blur a bit there.
@ amd64pager:
You are aware that this will not make your OS any simpler to develop? Your VM would have to handle memory management, hardware management and abstraction, I/O handling, i.e. all the stuff that a common OS kernel has to do.
What this approach does give you are the advantages of a virtualized environment - but that is an advantage that becomes tangible only after you're done with the VM.
I am not discouraging you from doing it. I just want you to avoid a common conceptual mistake - thinking that, by going this road, you could write your "OS" in an "easier" environment. As I said, you will still have to face the nitty-gritty of ring 0 kernel work; the benefits are mostly for later stages of development.
Re: Java-like VM for OSes
Posted: Mon Dec 05, 2011 7:33 am
by rdos
To me it would be interesting to know if there is a (real) Java VM that can be compiled with Open Watcom and that provide a well-documented OS layer (like ACPICA has)? I'm not interested in designs that assume GCC, or that assume Linux-type functionality to be present (Dalvik).
I wouldn't want to write any OS-functionality in Java, just the ability to run Java-bytecode applications.
So, is there?
Re: Java-like VM for OSes
Posted: Mon Dec 05, 2011 8:57 am
by amd64pager
bluemoon wrote:So, you are describing a scripting engine or virtual machine?
The scripting engine runs the scripts,the VM runs bytecode executables.
Solar wrote:
@ amd64pager:
You are aware that this will not make your OS any simpler to develop? Your VM would have to handle memory management, hardware management and abstraction, I/O handling, i.e. all the stuff that a common OS kernel has to do.
What this approach does give you are the advantages of a virtualized environment - but that is an advantage that becomes tangible only after you're done with the VM.
The VM is like a CISC machine.It has it's own LDT,GDT etc.
And interrupt handling(you need to use IRQs,right?) is a special exception:the LIDT contains the handlers for inside-VM interrupts,and the GIDT contains handlers for interrupts that happen in the CPU(like int 19).The GIDT works like this:The OSVM kernel gets an interrupt.After it checks the interrupt(whether it is not an OSVM exception) and then calls the function at the address of the GIDT.
Solar wrote:
Your VM would have to handle memory management, hardware management and abstraction, I/O handling, i.e. all the stuff that a common OS kernel has to do.
And as I said before in this post,it is just a VM.The OSVM-based Kernel Framework Class Library(OSVMBKFCL)implements some of the functions that you put there,but not managers and other stuff.I also have the concept of rings and IOPL in my VM.A thread with a CPL lower than the IOPL can do I\O access directly to the hardware.
Re: Java-like VM for OSes
Posted: Mon Dec 05, 2011 9:45 am
by Solar
/me confused... what are you virtualizing then?
Re: Java-like VM for OSes
Posted: Tue Dec 06, 2011 5:31 am
by narke
Hello, the next step for my OS is to have a VM, I chose NekoVM, it's simple and elegant.
I'm writing transcompilers for python and Standard ML (both are far to be complete by now but you can help):
http://github.com/narke.