Creation and death of a process

Source: Internet
Author: User

The two most widely used operating systems are linux and windows.

In program development, the concept of process and thread is essential to a good programmer. If you do not have a good understanding or application of these two concepts, it is very difficult to become a good developer.

According to the concept in the Quick Start of Hou Jie MFC, the concepts of related processes are briefly described below.

 

When an application is executed, a process is generated ).

In windows, the most direct method of program execution is to double-click an executable file icon in shell. The executed App process is actually activated by calling CreateProcess by shell. In linux, you may choose to use terminal to execute an application. Now, the perfect graphic interface of linux also supports this method in windows.

In fact, the general execution methods of the two systems can be summarized as follows:

Note: There is no major difference in linux between MFC calls and system calls in windows.

1 worker shellcalls createprocessto activate app.exe.

2. The system generates a "Process core object" and the Count value is increased by 1.

3. The system creates a 4 GB address space for this process.

The 42.16er uploads the required code to the address space, including the app.exe program and data, and the required dynamic loading function library (DLLs ).

5. The system creates a thread for this process, which is called the primary thread ). The thread is the allocation object of CPU time.

6. The system calls the Startup Code of the C runtime function library.

7. Startup Code calls the WinMain function of the App.

8. The App starts running.

9. The user closes the main App window and ends the message loop in WinMain, so WinMain ends.

10. Return to Startup Code.

11. Return to the system and call the ExitProcess technical process.

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.