Implementation method of PISA manager cross-process memory mapping

By serializing and deserializing memory linked lists in the PISA protocol, cross-process memory mapping is achieved, which solves the memory allocation failure problem caused by address space randomization and ensures successful memory access between different processes.

CN114327873BActive Publication Date: 2025-10-28HUNAN GREATWALL INFORMATION FINANCIAL EQUIP +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111548654.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2021-07-15
Filing Date
2021-12-17
Publication Date
2025-10-28
Estimated Expiration
2041-12-17

AI Technical Summary

Technical Problem

In the PISA protocol, the use of address space randomization by a process can cause memory allocation failure, making cross-process memory mapping impossible and resulting in program memory allocation failure.

Method used

The message sending process serializes the linked list allocated in local memory and sends it to the PISA manager. The message receiving process deserializes the linked list through the PISA manager to generate a memory address and directly accesses the address to process the structure, thus realizing cross-process memory mapping.

Benefits of technology

In an address space randomization environment, memory mapping and access between different processes are realized, avoiding the problem of memory allocation failure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114327873B_ABST
    Figure CN114327873B_ABST
Patent Text Reader

Abstract

This invention discloses a method for implementing cross-process memory mapping in a PISA manager. The method includes: Step 1, the message sending process serializes its local memory allocation linked list to obtain a memory linked list and sends it to the PISA manager; Step 2, the message receiving process calls the PISA manager to receive the message, and the PISA manager deserializes the memory linked list to generate a memory address and sends it to the message receiving process; Step 3, the message receiving process directly accesses the memory address generated by the deserialization of the PISA manager to process the structure sent by the message sending process. This invention achieves cross-process memory space mapping without requiring shared memory addresses between the message sending and receiving processes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of financial self-service equipment technology, and in particular to a method for implementing cross-process memory mapping of the PISA protocol in the field of financial self-service equipment. Background Technology

[0002] The PISA protocol (Protocol for Intelligence Terminal Standards Architecture) requires that the memory management and allocation of the memory manager map the application layer and the device service layer to the same physical address. The device service uses the memory manager to map shared memory to the same address. In this method of allocating and appending memory to the shared memory address, the application layer and the device service layer share data through the shared memory address and send the address pointer allocated by the memory manager to the application layer via message communication. The application layer can directly access this pointer address to obtain the structure sent by the device service layer. However, this memory allocation method can lead to situations where the process fails to map to the specified address when address space randomization is used, ultimately resulting in the program being unable to map memory to the specified address, and finally, memory allocation failure. Summary of the Invention

[0003] This invention provides a method for implementing cross-process memory mapping in PISA manager, which enables cross-process memory space mapping between message sending and message receiving processes without requiring shared memory addresses.

[0004] To achieve the above technical objectives, the present invention adopts the following technical solution:

[0005] A method for implementing cross-process memory mapping in a PISA manager, comprising:

[0006] Step 1: The message sending process serializes the local memory allocation linked list to obtain a memory linked list and sends it to the PISA manager.

[0007] Step 2: The message receiving process calls the PISA manager to receive the message. The PISA manager deserializes the memory linked list, generates a memory address, and sends it to the message receiving process.

[0008] Step 3: The message receiving process directly accesses the memory address generated by the PISA manager's deserialization process to process the structure sent by the message sending process.

[0009] In a better technical solution, the local memory allocation method of the message sending process is as follows: the message sending process performs an initial memory allocation and several additional memory allocations through the PISA manager; each allocated memory includes a linked list head and a memory block for use by the message sending process, and the memory linked list of all allocated memory is used to form the memory linked list of the message sending process.

[0010] In a better technical solution, the message sending process performs the initial memory allocation through the PISA manager as follows: the message sending process calls the memory allocation interface through the PISA manager to allocate a block of memory. This memory block generates a linked list head and a memory block for the message sending process to use. The linked list head includes: the pointer address pointing to this memory block, the starting address of this memory block, the size of this memory block, and the pointer address pointing to the next linked list; wherein the pointer address pointing to this memory block corresponds to the starting address of the memory allocation by the PISA manager.

[0011] In a better technical solution, the method for the message sending process to add memory allocation through the PISA manager each time is as follows: the message sending process calls the memory append interface of the PISA manager to allocate a block of memory. This memory block generates a linked list head and the memory block appended by the message sending process. The linked list head includes: a pointer address pointing to a memory address, a pointer address pointing to this memory block address, the starting address of this memory block, the size of this memory block, and a pointer address pointing to the next linked list. The pointer address pointing to this memory block corresponds to the starting address of the memory allocation by the PISA manager. The head of the linked list is found through the append address, and the last appended memory address is added to the tail of the linked list.

[0012] In a better technical solution, step 1 is as follows: The PISA manager receives the sending event message from the message sending process, finds the corresponding memory linked list according to the memory address allocated by the message sending process, and serializes the memory linked list to form a data block of multiple memory blocks; the PISA manager sends the event type and multiple memory blocks to the message receiving process according to the event receiver.

[0013] In a better technical solution, step 3 includes:

[0014] Step 3.1: The message receiving process calls the PISA manager sequentially according to the number of memory blocks to perform the initial memory allocation and the append memory allocation, and restores the memory allocated each time.

[0015] Step 3.2: The message receiving process receives a message callback or directly obtains a new event, and obtains the message event type and the memory address pointing to deserialization;

[0016] Step 3.3: The message receiving process directly accesses the data in the memory address and calls the release interface of the PISA release manager to release the memory address.

[0017] In the superior technical solution, the specific process of step 3.1 is as follows:

[0018] Step 3.1.1: Call the PISA manager's memory restoration interface according to the data block of the first memory block. First, restore the head data of the linked list of the corresponding memory block. The head of the linked list includes: the pointer address pointing to this memory address, the starting address of this memory address, the size of this memory block, and the pointer address pointing to the next linked list. The pointer address pointing to this memory block corresponds to the starting address of the memory allocation by the PISA manager. Then, copy the data part of the memory block to the data of the restored memory block. Record the correspondence between the starting address of the original memory block and the starting address of the new memory block and save it to the list. If there are still memory blocks that have not been restored, proceed to step 3.1.2; otherwise, skip step 3.1 and execute step 3.2.

[0019] Step 3.1.2: Call the PISA Manager's memory append and restore interface. First, allocate memory space of the corresponding size in the receiving process according to the size of the memory block to be restored. Then, restore the head data of the linked list of the corresponding memory block. The pointer address pointing to the memory address in the head of the linked list corresponds to the starting address of the PISA Manager's memory allocation, the pointer address pointing to this memory address, the starting address of this memory address, the size of this memory block, and the pointer address pointing to the next linked list. Then, find the head of the linked list through the append address and add the last appended memory address to the tail of the linked list. Copy the data from the original memory block to the new memory address corresponding to the starting address of the original memory block, as found in the mapping between the starting addresses of the original memory block and the starting addresses of the new memory block; add the new memory address to the difference between the originally allocated starting address and the pointer address of the original memory address, and assign this address to point to the new memory address; append the mapping between the starting address of the new memory allocation and the original memory address to the mapping list; if there are still unrestored memory blocks, proceed to step 3.1.2, otherwise skip step 3.1 and execute step 3.2.

[0020] In a more favorable technical solution, the message sending process is a device service process, and the message process is an application processing process.

[0021] Beneficial effects

[0022] Based on the PISA protocol framework, this invention provides a cross-process memory mapping method. The technical advantages are as follows: when the process uses address space randomization, this invention will not cause memory allocation failure due to the inability to map memory to the same address. Memory mapping and access can also be completed by different processes calling the PISA manager through different physical machines. Attached Figure Description

[0023] Figure 1 This is a diagram showing the relationship between the application service process, the message service process, and the device service process in this embodiment of the application.

[0024] Figure 2 This is a flowchart illustrating the initial memory allocation process of the application service process in this embodiment of the application.

[0025] Figure 3 This is a flowchart illustrating the process of additional memory allocation for the application service process in this embodiment of the application.

[0026] Figure 4 This is a flowchart illustrating the steps of the linked list deserialization process to obtain memory block one in an embodiment of this application.

[0027] Figure 5 This is the step in the linked list deserialization process to obtain memory block two in the embodiments of this application. Figure 1 ;

[0028] Figure 6 This is the step in the linked list deserialization process to obtain memory block two in the embodiments of this application. Figure 2 ;

[0029] Figure 7 This is the step in the linked list deserialization process to obtain memory block two in the embodiments of this application. Figure 3 . Detailed Implementation

[0030] The embodiments of the present invention will be described in detail below. These embodiments are based on the technical solutions of the present invention and provide detailed implementation methods and specific operation processes to further explain the technical solutions of the present invention.

[0031] This invention provides a method for implementing cross-process memory mapping using the PISA manager. It is applicable to all memory allocations and message sending / receiving processes implemented through the PISA manager. The key process is as follows: the message sender serializes and sends a linked list of local memory allocations to the PISA manager; the message receiver calls the PISA manager to receive the message; the PISA manager deserializes the linked list of memory allocations, generating a memory address for the message receiver. The message receiver directly accesses the memory address generated by the deserialization process of the PISA manager to process the structure sent by the message sender.

[0032] One of the key processes in this invention is the serialization and deserialization of the memory allocation list. The difficulty lies in the fact that the structure of the PISA message response is a series of non-contiguous memory blocks, and pointers within the structures of already allocated memory blocks can point to new memory blocks. Figure 1 As shown, it includes the following three parts:

[0033] Part 1: Application processing process, the interface layer for receiving messages from the PISA manager.

[0034] Part 2: PISA Manager, which includes message processing services, memory allocation and appending, and memory serialization and deserialization functions.

[0035] Part 3: Device service process, the interface layer for sending messages through the PISA manager.

[0036] The specific process of cross-process memory mapping is described as follows:

[0037] Step 1: The device service process allocates a block of memory through the PISA manager's memory allocation interface. This memory allocation generates a linked list head and a memory block for the device service process. The linked list head includes: a pointer to the memory address (this pointer corresponds to the starting address of the PISA manager's memory allocation; this address is NULL when allocating memory), a pointer to this memory address, the starting address of this memory block, the size of this memory block, and a pointer to the next item in the linked list (which is NULL). Figure 2 As shown.

[0038] Step 2: The device service process calls the PISA manager's memory append interface to allocate a block of memory. This memory allocation generates a linked list head and the memory block appended by the device service process. The linked list head includes: a pointer to the memory address (corresponding to the starting address of the PISA manager's memory allocation; the starting address of the linked list is found through the append address), a pointer to this memory address, the starting address of this memory block, the size of this memory block, and a pointer to the next linked list (which is NULL). The head of the linked list is found through the append address, and the last appended memory address is added to the tail of the linked list. For example... Figure 3As shown.

[0039] Step 3: Add memory. Add memory to the end of the linked list as in Step 2.

[0040] Step 4: The device service process sends event messages through the PISA Manager's message sending interface. The PISA Manager locates the entire memory list containing the memory address allocated by the device service process, deserializes the entire memory list, and forms multiple memory blocks. The event receiver, event type, and multiple memory blocks are then sent to the PISA Manager's message receiving service.

[0041] Step 5: The PISA Manager message receiving service receives the message sent by the device service process and forwards it to the event receiver based on the event receiver's name. The PISA Manager loaded by the event receiver will deserialize the event type and the data blocks of multiple memory blocks. Based on the number of memory blocks, it sequentially calls the PISA Manager's memory allocation (Step 6) and memory append (Step 7). For example... Figure 4-7 As shown.

[0042] Step 6: Call the PISA Manager's memory restore interface according to the data block of the first memory block. First, restore the head data of the linked list corresponding to the memory block. The head of the linked list includes: the pointer address to the memory address (corresponding to the starting address of the memory allocation in PISA Manager, the address is NULL), the pointer address to this memory address (NULL), the starting address of this memory address, the size of this memory block, and the pointer address to the next linked list (NULL). Then, copy the data part of the memory block to the data of the restored memory block. Record the correspondence between the starting address of the original memory block and the starting address of the new memory block, and save it to a list. If there are still memory blocks that have not been restored, proceed to Step 7; otherwise, proceed to Step 8.

[0043] Step 7: Call the PISA Manager's memory append and restore interface. First, allocate memory space of the corresponding size in the receiving process according to the size of the memory block to be restored. Then, restore the head data of the linked list for the corresponding memory block. The head of the linked list contains the pointer address to the memory address (corresponding to the starting address of the PISA Manager's memory allocation, found by appending the address), the pointer address to this memory address, the starting address of this memory address, the size of this memory block, and the pointer address to the next linked list (NULL). Find the head of the linked list by appending the address and add the last appended memory address to the tail of the linked list. Copy the data in the original memory block to the new memory address corresponding to the starting address of this original memory block, found according to the correspondence between the starting address of the original memory block and the starting address of the new memory address. Then, add the new memory address to the difference between the originally allocated starting address and the pointer address of the original memory address. Assign this address to the new memory address. In this way, the new memory pointer relationship is restored to normal. Append the correspondence between the starting address of the new memory allocation and the original memory address to the correspondence list. If there are still unrestored memory blocks, proceed to step 7; otherwise, proceed to step 8.

[0044] Step 8: The message receiving process receives a message callback or directly obtains a new event, gets the message event type, and points to the deserialization memory address.

[0045] Step 9: The message receiving process directly accesses the data in the memory address and calls the release interface of the PISA release manager to release the memory address.

[0046] In this way, the memory addresses allocated and appended by process A are mapped to process B through memory mapping. When B directly accesses the memory address of process B, the data content is the same as that assigned by process A. The only difference is that the value of the pointer pointing to the address in the memory address is different, and the memory addresses pointed to by processes A and B are also different.

[0047] The above embodiments are preferred embodiments of this application. Those skilled in the art can make various changes or improvements based on them. Without departing from the overall concept of this application, these changes or improvements should fall within the scope of protection claimed in this application.

Claims

1. A cross-process memory mapping method for a PISA manager, characterized in that, include: Step 1: The message sending process serializes the local memory allocation linked list to obtain a memory linked list and sends it to the PISA manager. Step 2: The message receiving process calls the PISA manager to receive the message. The PISA manager deserializes the memory linked list, generates a memory address, and sends it to the message receiving process. Step 3: The message receiving process directly accesses the memory address generated by the PISA manager's deserialization process to process the structure sent by the message sending process. The local memory allocation method of the message sending process is as follows: the message sending process performs the initial memory allocation and several additional memory allocations through the PISA manager; each allocated memory includes a linked list head and a memory block for use by the message sending process, and the memory linked list of all allocated memory is used to form the memory linked list of the message sending process. The message sending process adds memory allocations through the PISA manager each time as follows: The message sending process calls the PISA manager's memory append interface to allocate a block of memory. This memory block generates a linked list head and the memory block appended by the message sending process. The linked list head includes: a pointer address pointing to a memory address, a pointer address pointing to this memory block address, the starting address of this memory block, the size of this memory block, and a pointer address pointing to the next linked list. The pointer address pointing to this memory block address corresponds to the starting address of the memory allocation by the PISA manager. The head of the linked list is found through the append address, and the last appended memory address is added to the tail of the linked list.

2. The method according to claim 1, characterized in that, The method by which the message sending process performs the initial memory allocation through the PISA manager is as follows: The message sending process calls the memory allocation interface through the PISA manager to allocate a block of memory. This memory block generates a linked list head and a memory block for use by the message sending process. The linked list head includes: the pointer address pointing to this memory block, the starting address of this memory block, the size of this memory block, and the pointer address pointing to the next linked list; wherein the pointer address pointing to this memory block corresponds to the starting address of the memory allocation by the PISA manager.

3. The method according to claim 1, characterized in that, Step 1 is as follows: The PISA manager receives the sending event message from the message sending process, finds the corresponding memory linked list according to the memory address allocated by the message sending process, and serializes the memory linked list to form a data block of multiple memory blocks; The PISA manager sends the event type and multiple memory blocks to the message receiving process based on the event receiver.

4. The method according to claim 1, characterized in that, Step 3 includes: Step 3.1: The message receiving process calls the PISA manager sequentially according to the number of memory blocks to perform the initial memory allocation and the append memory allocation, and restores the memory allocated each time. Step 3.2: The message receiving process receives a message callback or directly obtains a new event, and obtains the message event type and the memory address pointing to deserialization; Step 3.3: The message receiving process directly accesses the data in the memory address and calls the release interface of the PISA release manager to release the memory address.

5. The method according to claim 4, characterized in that, The specific process of step 3.1 is as follows: Step 3.1.1: According to the data block of the first memory block, call the memory restoration interface of PISA Manager to restore the head data of the linked list of the corresponding memory block. The head of the linked list includes: the pointer address pointing to this memory address, the starting address of this memory address, the size of this memory block, and the pointer address pointing to the next linked list. The pointer address pointing to this memory address corresponds to the starting address of the memory allocation by PISA Manager. Then, copy the data of the memory block to the restored memory block. Record the correspondence between the starting address of the original memory block and the starting address of the new memory block and save it to the list. If there are still memory blocks that have not been restored, proceed to step 3.1.2; otherwise, skip step 3.1 and execute step 3.

2. Step 3.1.2: Call the PISA Manager's memory append and restore interface. First, allocate memory space of the corresponding size in the receiving process according to the size of the memory block to be restored. Then, restore the head data of the linked list of the corresponding memory block. The head of the linked list contains the pointer address to the memory address, the pointer address to this memory block, the starting address of this memory block, the size of this memory block, and the pointer address to the next linked list. Find the head of the linked list by appending the address and add the last appended memory address to the tail of the linked list. Copy the data in the original memory block to the new memory address corresponding to the starting address of the original memory block, based on the correspondence between the starting address of the original memory block and the starting address of the new memory block. Add the new memory address to the difference between the originally allocated starting address and the pointer address of the original memory address, and assign this address to the new memory address. Append the correspondence between the starting address of the new memory allocation and the original memory address to the correspondence list. If there are still unrestored memory blocks, proceed to step 3.1.2; otherwise, skip step 3.1 and execute step 3.

2.

6. The method according to claim 1, characterized in that, The message sending process is a device service process, and the message receiving process is an application processing process.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Implementation mode of PISA manager under Linux system

    CN112612622A

  • Data structure transmission method

    CN1924817A