This article reprinted address : http://www.cnblogs.com/zuoxiaolong/p/computer2.html
the execution of Hello world
As an example of a Linux system, when we execute a simple C program that prints a string, we need to enter the./hello in the command line and the carriage return to execute the program. Throughout the execution of the process, the computer has done three things, or went through three stages to complete the operation of the program.
one, the Linux shell scans the characters entered by the user
When we enter./hello on the keyboard, the Linux shell (that is, the command line) scans the characters we enter, reads the characters into the register, and then one by one into main memory. In other words,./hello These characters are passed through the registers in the CPU to reach the main memory. Below the LZ will draw the diagram of this process.
loading the code of Hello file and data into main memory
The trigger of this process is the moment we press ENTER, the system will load the hello file stored on disk into main memory, and this process will take advantage of a technology called memory access, so that data does not go through the register directly to main memory. is an illustration of this process.
third, according to the code in main memory instruction execution program
After the code and the data required by the program are loaded into main memory, the CPU begins to execute the instructions in the code, starting at the start of the function. Since our code simply outputs a string such as "Hello World", the system simply loads the string into the register and then transmits it to the display terminal. This process is like.
Summary of this chapter
This chapter simply introduces the implementation of the Hello program, we can simply understand that the execution of the Hello program is actually to load the data and code into main memory, and the CPU from main memory to obtain instructions to execute the process.
In-depth understanding of computer systems (1.2)---How the Hello World program works