OS (kernel) programmed in Java or in C

10,520

Solution 1

http://wiki.osdev.org is an extremely useful site on that matter. It tells you how to build your toolchains, which language options that are available, and has some great example code.

Yvan

Solution 2

I would humbly suggest that you truly learn a programming language before trying to build an operating system, after which you would realize in which languages you can or cannot write kernels in yourself.

Programming languages such as Java simply does not offer the low-level routines necessary to create an os. You can implement your OS in c or c++. Unless you master bootstrapping code (read assembler) and a programming language such as c, it would be a good idea to reconsider a perhaps easier task.

You could however emulate an OS by running it as a program in another OS, in which case you may experiment with any language of your choise.

Solution 3

Does it would be much harder to program than Java-based OS than C-based OS?

How would you write the hardware-level programming to handle interrupts in Java?

Solution 4

There seem to be several Java-based OSs already out there. I don't know a lot about OS-programming, but there seems to be quite an extensive literature (altough a lot of it in German) about a Java-based OS called JX, from the University of Erlangen: http://www4.informatik.uni-erlangen.de/Projects/JX/publications.html
Maybe there is something there to help.

Writing a C-based OS should be the easiest, though, simply due to there being so much more information about it.

Solution 5

You won't be able to program an OS kernel in Java unless you have access to a compiler that will compile Java into machine language. Java requires a virtual machine which interprets the byte code and executes native instructions (that rely on the kernel). You must be able to interact directly with the hardware in order to program an OS which is something you simply can't do with Java. Your only option, really, is C mixed with assembly.

Share:
10,520
Martynas
Author by

Martynas

Updated on June 24, 2022

Comments

  • Martynas
    Martynas almost 2 years

    I'm going to start building operating system and I don't know which programming language to choose for kernel. My favorite language is Java but I know that all major operating systems (Windows, Linux, Mac OS) is programmed in C, moreover Java requires virtual machine. Does it would be much harder to program than Java-based OS than C-based OS? What are the advantages and disadvantages of each of these languages?

  • Billy ONeal
    Billy ONeal about 13 years
    +1 -- oh the irony of writing a memory manager in a language where one does not manage memory.
  • Admin
    Admin about 13 years
    Obviously, the VM would have [special] instructions do that ;-) Unless the VM is run by the VM is run by the...
  • user1066101
    user1066101 about 13 years
    @pst: It's turtles, all the way down.
  • Spudd86
    Spudd86 about 13 years
    gcj does that... I don't know much about it but last time I checked it had some issues
  • Spudd86
    Spudd86 about 13 years
    Weeeeeelll you could write a JVM in Java... it'd just be useless since you need a JVM to run it. or you could compile Java to machine code, but you still need a bunch of run time junk (Garbage Collection would be the big one) and Java makes it REALLY REALLY hard to write code that works without one, so that'd be hard to do.