Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

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

DZone's Guide to

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

· Java Zone
Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

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


 

Download Modern Java EE Design Patterns: Building Scalable Architecture for Sustainable Enterprise Development.  Brought to you in partnership with Red Hat

Topics:

Published at DZone with permission of Ryan Wang. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}