Differences between hosted and non-hosted programs

Source: Internet
Author: User

Today I read several blog posts from my predecessors, but I have never paid attention to this concept. I will sort them out today:

Reference blog: http://www.cnblogs.com/wuchang/archive/2006/12/07/584997.html

Http://www.cnblogs.com/springcsc/archive/2008/12/25/1362515.html

Generally, an executable file contains a PE Header. The system finds the entry function based on the PE information and executes the executable program by executing the code in the entry function. The hosted program file also contains a CLR header file and other information required by CLR compared to the unmanaged program.

(1) Execution Process of unmanaged programs
In an unmanaged program, the executable program saves the machine code, and the CPU can be directly loaded and executed. After the system loads the executable program, the system adds an offset address to the base address of the executable file to form the actual physical address and directly loads it into the memory for running.

(2) the execution process of the hosting program

The executable file of the managed program contains the intermediate language and metadata. Of course, it cannot be run directly. The CLR must be started, and the CLR can instantly compile the intermediate language into machine code, and load it into the memory for execution (specific process: the program jumps to MSCoree before entering the entry function. dll, call its code to start CLR and complete some initialization work ). Of course, the method in IL is not compiled every time it is called, but compiled only when it is called for the first time, the instant compiler stores the method name and corresponding entry address in the ing table. When this method is called next time, the ing table is directly used instead of being compiled again.

Because the compiler must compile the managed program into executable code before it runs, the efficiency will decrease, but the actual decrease will be much lower. Let's take a look at the experiment below.

 

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.