Platinum Partner
java,tips and tricks

How “Hello World” Gets Printed? – A Complete Life Cycle

Update(5/2/2013): The following question was posted on Stack Overflow on April 30th, it has been moved to wiki. If you think it is a good question, you can request "reopen" the question. Or you can go to my blog post  to make a point. 

I posted this question on Stack Overflow today because the complete life cycle of a simple program is interesting.

I will keep updating the post by using answers/comments to make it more complete. I surely will up vote any answer/comment that makes sense. Please up vote or post answer/comment to help. Thanks a lot!

Question link: http://stackoverflow.com/q/16311867/127859

The following is THE HelloWorld program that everybody knows.

1







It is compiled to bytecode like the following.

2

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

3









Then it gets loaded, linked and initialized in JVM.

4.








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

5









JVM makes the x86 instructions.

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

6






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

JVM is on top of gllibc, syscalls. io driver in os will be responsible for printing words in the console. io related syscalls should be implemented in io subsystem in os.

What is next in Architecture?

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

7


 

Published at DZone with permission of {{ articles[0].authors[0].realName }}, DZone MVB. (source)

Opinions expressed by DZone contributors are their own.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}