5

I took compiler, operating system, computer architecture course in graduate school. But I want to see those concepts in a simple but real example (not too theoretical). HelloWorld is a good choice for simple example.

Not only the life cycle of this little program is interesting, but also knowing how JVM, OS and Architecture works can help us to become a better programmer.

In short, my question is: do I describe the steps correctly and completely?

In detail, I need your help with the following:

  1. Point out any part that I am wrong
  2. I'm sure I miss a lot of valuable points, so please add any point that makes sense in the life cycle.

What I want to know is how HelloWorld goes through each layer, and then come back from it. Assume this program runs on an Intel CPU with Ubuntu.

I will keep this post updated by combining good answers until one answer is finally accepted.

The following is THE HelloWorld program that everybody knows.

enter image description here

It is compiled to bytecode like the following.

enter image description here

The bytecode is not readable, but we can use javap -classpath . -c HelloWorld to see mnemonics like the following.

enter image description here

Then it gets loaded, linked and initialized in JVM.

enter image description here

Since it has only one thread, let's assume it is the the left thread in the following JVM run-time data area.

enter image description here

JVM threads are user-level threads, so it will be mapped to kernel. In Ubuntu, it is one-to-one mapping like the following:

enter image description here

Now JVM makes the x86 instructions? (update)

What is operating system's role for this particular program?

What is next in Architecture?

Fetch instruction, decode, execute, memory access, write back in 5-steps MIPS.

enter image description here

References:

  1. OS basics
  2. Diagrams

This could be an extremely difficult question. Unlike questions of how to use a certain API, this requires understanding of almost everything.

Ryan
  • 2,825
  • 9
  • 36
  • 58

1 Answers1

3

A Java virtual machine (JVM) is a virtual machine that can execute Java bytecode. It is the code execution component of the Java platform.

http://en.wikipedia.org/wiki/Java_virtual_machine

Image courtesy of wikipedia:

enter image description here

durron597
  • 31,968
  • 17
  • 99
  • 158