In-depth understanding of computer systems (1.2)---How the Hello World program works

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.