System Process Overview

Source: Internet
Author: User

A process is an application running in the system. A thread is the basic unit for the system to allocate processor time resources, or a unit that is executed independently within the process. For the operating system, the scheduling unit is a thread. A process includes at least one thread, which is usually called as the main thread. A process starts from the execution of the main thread and creates one or more additional threads.

What is the difference between a process and a thread?

A process is an instance of the execution program. For example, when you run the Notepad program Nodepad, you create a process to hold the code that makes up Notepad.exe and call the dynamic link library. Each process runs in a dedicated and protected address space. Therefore, if you run two copies of notepad at the same time, the data used by the program is independent of each other in the respective instances. The data opened by the second instance of the program cannot be seen in a copy of notepad.

Here I will describe the sandbox as an example. A process is like a sandbox. The thread is like a child in the sandbox. The children ran around in the sandbox, and may drag the sand into the eyes of other children. They would kick each other or bite each other. However, the difference between these sandboxes is that each sandbox is completely closed by walls and ceilings. No matter how hard the children in the sandbox are, they will not affect other children in other sandboxes. Therefore, each process is like a protected sandbox. No one can go in or out without permission.

In fact, the thread runs but the process does not run. The only way for two processes to obtain dedicated data or memory is to share the memory block through the Protocol. This is a collaboration policy. Next let's analyze the process tab in the task manager.

The process here refers to a series of processes that are identified by the executable program instances they run. This is why the ing name is given in the first column of the Process tab. Note that there is no process name column. A process does not have a ing name independent of the instance to which it belongs.

In other words, if you run five Notepad.exe copies, you will see five processes called Notepad.exe. How are they different from each other? One way is through their process ID, because each process has its unique encoding. The process ID is generated by Windows NT or Windows 2000 and can be used cyclically. Therefore, process IDs will not be larger and larger, and they can be recycled.

The third column is the percentage of CPU time occupied by the threads in the process. It is not the number of the CPU, but the percentage of CPU time occupied by the process. At this time, my system is basically idle. Although the system seems to use only a small amount of CPU time every second or so, the idle process of the system still consumes about 99% of the CPU time.

The fourth column shows the CPU time, which is the hour, minute, And seconds occupied by threads in the process. Please note that I use the word "Occupy" for threads in the process. This does not necessarily mean that it is the total CPU time consumed by the process, because, as we will see later, the NT timing method is that when a specific clock interval is triggered, no matter who happens to be in the current thread, it will be calculated within the CPU cycle. Generally, the clock runs at 10 milliseconds in most NT systems. The heart beats every 10 ms of NT. Some driver code snippets run and show who is the current thread. Let's keep the last 10 milliseconds of CPU time in its account.

Therefore, if a thread starts to run and is finished after 8 ms of continuous running, then the second thread starts to run and lasts for 2 ms, the clock is triggered, please guess which thread the entire 10 ms clock cycle is recorded in? The answer is the second thread. Therefore, there are some inherent inaccuracies in NT, and NT timing is in this way. The actual situation is also true. In most 32-bit operating systems, there is an interval-Based Timing mechanism. Remember this, because sometimes when you observe the total CPU usage of a thread, it may appear although the thread may have been running for more than 100,000 times, however, the CPU usage may be zero or very short-lived, so the above explanation is the reason. The above is the basic information column we can see in the process tab of the task manager.


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.