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.
It is compiled to bytecode like the following.
The bytecode is not readable, but we can use javap -classpath . -c HelloWorld to see mnemonics like the following.
Then it gets loaded, linked and initialized in JVM.
Since it has only one thread, let’s assume it is the the left thread in the following JVM run-time data area.
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:
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.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)