Basic Components of processes

Source: Internet
Author: User

In advanced programming languages, variables and data types are directly used, and the memory processing and structure are seldom concerned. after compilation, the program will be initialized and loaded into the virtual memory at the first run, and the operating system separates the virtual memory space of each process, non-same processes are not allowed to operate on the memory data in the other process space.

 

In the plug-in design, in order to be able to control the Target Program, in addition to the window handle, the process ID is crucial for memory operations. The textbooks in this chapter will focus on the memory operation topic.

??? This section briefly describes some terms in terms of memory and surrounding terms.

When a process runs an EXE executable program, the Windows operating system initializes a process structure for running and management. A process contains a lot of information and data, and a lot of software can be run on a Windows operating system at the same time. Therefore, the structure of each process created by the system is somewhat different, in addition, every process is isolated to prevent mutual interference between processes.

 

Process ID or process ID. A process ID is used to represent a process and point to the process. You can obtain information about the process through a process ID.

 

Process Handle the operating system isolates every process. If you want to operate another process, you need to open the process ID to obtain a handle that can be operated on, that is, the process handle.

 

When a program is initialized and running, the operating system sets a permission for the process as needed, this permission is directly related to which transactions the process can perform and which transactions cannot be performed. For example, a general-permission process cannot open another high-permission process to obtain its process handle. the program software is of this common permission.

 

The thread ID process is just a structure, like a container, used to load data and some information. the real code execution function is called a thread. The thread ID or thread ID refers to this thread. similarly, a process contains at least one thread or multiple threads at the same time. Only one thread is called a single thread. If multiple threads exist in a process at the same time, they are called multithreading. In the case of multithreading, one of them is the main thread.

 

If you want to operate a thread, such as start, pause, and end a thread, you must obtain the thread handle to perform these operations.

 

Virtual Memory: After a software execution, a lot of data will be used, and the data is loaded in the virtual memory of the process space of the program. the virtual memory is actually on the hard disk. The operating system will load the required data into the physical memory based on the current requirement. After the operation, save it back to the virtual memory. In this way, you can run games or other software that exceed the physical memory on a limited physical memory computer.

 

Memory pointer when a software is initialized and running, the operating system allocates 4 GB of virtual memory space for processes of the software to store data. in such a large virtual memory, the memory pointer is used for locating. You can easily find the data needed in the virtual memory through the memory address pointed by the memory pointer.

 

Variable pointers in advanced programming languages use variables to manage the data in the memory during software runtime, rather than directly providing the location of the variable in the virtual memory. here we can use some means, obtain the location of a variable in the virtual memory. This location can be called a variable pointer.

 

Subroutine pointer a subroutine written in the program code. After the software is imported into the virtual memory, the virtual memory address of the first instruction of the subroutine is also called the subroutine pointer.

 

Module handle the module here does not refer to the plug-in workshop module. The module here refers to some files in the virtual memory, such as the execution program EXE file or some other DLL files, the memory address of these files in the virtual process is the same as the module handle.

 

Function entry function entry and subroutine pointer share the same meaning

 

Memory offset, such as offset or memory offset. offset is relative to the original memory address, one memory address + offset = another memory address, if two memory addresses are 65560 and 65800 respectively, the calculation is 65800-65560 = 240. Here, the 240 is the offset, because it is not a memory address that directly points to a memory address, it needs to be added with one memory to get another memory address, for example, 65560 + 240 = 65800, that is, the memory address + offset = another memory address or 65800-240 = 65560, that is, the memory address-offset = another memory address

 

The above (memory pointer, variable pointer, subroutine pointer, module handle, function entry) refers to somewhere in the memory, that is, the memory address, this address is a positive integer that occupies 4 bytes of length (4 bytes = 32 characters ).

 

In Memory operations, you should pay attention to the length of a data item in the memory. For common lengths, refer to the following

1 GB = 1024 MB

1 MB = 1024kb

1kb = 1024 bytes

1 byte = 8 bits

The preceding figure shows the carry length between some common data.

 

In advanced languages, we do not directly manage the data in the memory with such length, but directly use the data type for management and organization, the length of some common data types in memory can be found below

Byte = 1 byte = 8 bits

Short integer = 2 bytes = 16 digits

Integer = 4 bytes = 32 characters

Long Integer = 8 bytes = 64-bit

Double-precision decimal type = 8 bytes = 64-bit

The text type usually has no fixed length and ends with byte 0.

The byte set type usually does not have a fixed length, and the length is automatically managed by the software.

Some custom data types and the occupied length of array variables in memory are based on the data type length of each member.

Coordinate type = 8 bytes = 64-bit is composed of two integer variables, horizontal and vertical

The dynamic integer array variable will be 4 bytes of each member of the variable multiplied by the number of array members of the dynamic array.

 

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.