Inter-process communication method and device based on shared memory, electronic equipment and medium

By copying the ROM area file to the RAM area in the inter-process communication method of shared memory, and reading and writing data through global pointer variables, the problem of low inter-process communication performance in the prior art is solved, and efficient inter-process data communication is achieved.

CN119668897APending Publication Date: 2025-03-21HUALI ISMARTWAYS TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411769038.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-03-21

AI Technical Summary

Technical Problem

In the prior art, inter-process communication performance is low, especially the inter-process communication method of shared memory lacks efficient implementation.

Method used

Through the inter-process communication method based on shared memory, the shared attribute management process copies the file in the ROM area to the RAM area, the target process maps the file to its address space, and reads and writes the cache data through a global pointer variable to update the data in the file.

Benefits of technology

It realizes efficient inter-process communication, and each process reads and writes data to each other through global pointer variables, without interfering with each other, solving the problems of inconvenient inter-process communication and high performance overhead.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119668897A_ABST
    Figure CN119668897A_ABST
Patent Text Reader

Abstract

The invention relates to an inter-process communication method and device based on a shared memory, electronic equipment and a medium, and belongs to the technical field of computers.The method comprises the steps that a special. Bin file format is set to manage data, and a first file in an ROM area is copied to an RAM area based on a shared attribute management process to obtain a second file; mapping the second file to an address space of the target process based on the target process to obtain a mapped address space; obtaining a global pointer variable based on the mapped address space; reading and writing the cached data of the mapped address space based on the target process in combination with the global pointer variable to obtain temporary data; and the target process updates the temporary data into the second file. The cache data in the specific format in the process address space is read and written through the global pointer variable, inter-process communication is achieved through the shared file, read-write data of the processes are communicated and do not interfere with one another, and the problems that inter-process communication is inconvenient and performance overhead is high are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method, device, electronic device and medium for inter-process communication based on shared memory. Background Art

[0002] Inter-Process Communication (IPC) refers to the process of exchanging data and information between two or more processes in an operating system. IPC is a set of programming interfaces provided by the operating system.

[0003] In the prior art, notifications between processes usually adopt the socket method, the file system function read+write method and the cat | grep pipe filtering method. When using the socket method, it is necessary to maintain the socket connection, perform data packet verification and analysis, error handling, etc., and the socket is a point-to-point communication. Adding one more process requires maintaining one more connection, which increases the complexity of the software; when using the file system function read+write method, due to the buffering of the file, old data may be read, resulting in inconsistent data between different processes, and a single file can only be accessed by one process at the same time, and a synchronization mechanism is required to prevent multiple processes from accessing the same file at the same time; and file system operations involve disk I / O, and the delay will be much higher than memory; when using the cat | grep pipe filtering method, each pipe command will create a new child process, which will increase system overhead.

[0004] In summary, the prior art lacks a shared memory inter-process communication method to solve the problem of low inter-process communication performance. Summary of the invention

[0005] In view of this, it is necessary to provide an inter-process communication method, device, electronic device and medium based on shared memory to solve the problem of high performance overhead of inter-process communication.

[0006] In order to solve the above problems, the present invention provides an inter-process communication method based on shared memory, comprising: Based on the shared attribute management process, the first file in the ROM area is copied to the RAM area to obtain a second file; Mapping the second file to the address space of the target process based on the target process to obtain a mapped address space; Get the global pointer variable based on the mapped address space; Based on the target process and in combination with the global pointer variable, cache data of the mapped address space is read and written to obtain temporary data; The target process updates the temporary data into the second file.

[0007] In a possible implementation, the first file and the second file are both binary files. In a possible implementation, mapping the second file to the address space of the target process based on the target process to obtain the mapped address space includes: Based on the target process and in combination with mmap technology, the second file is mapped to the address space of the target process to obtain the mapped address space.

[0008] In a possible implementation, the step of reading and writing cache data of the mapped address space based on the target process and in combination with the global pointer variable to obtain temporary data includes: When the target process needs to modify the data in the second file, obtaining the data type of the data to be written in the cache data; Determine the bitmap ID of the data to be written based on the data type; Obtaining a relative address and a fixed offset of data to be written based on the bitmap ID; According to the global pointer variable combined with the relative address and fixed offset, the temporary data of the process address space is obtained.

[0009] In a possible implementation, the method further includes: When the target process needs to read the data in the second file, when it is determined that the shared attribute write mark of the global pointer variable is readable, temporary data is obtained based on the global pointer variable.

[0010] In a possible implementation, the memory allocation format of the second file includes: a first relative address, a second relative address, a third relative address, a fourth relative address, a fifth relative address, a sixth relative address, a seventh relative address, an eighth relative address, a ninth relative address, and a tenth relative address: The first relative address is used to represent the shared attribute information header, the second relative address is used to represent the shared attribute write mark, the third relative address is used to represent the bool type data interval, the fourth relative address is used to represent the char type data interval, the fifth relative address is used to represent the short type data interval, the sixth relative address is used to represent the int type data interval, the seventh relative address is used to represent the float type data interval, the eighth relative address is used to represent the double type data interval, the ninth relative address is used to represent the string type data interval, and the tenth relative address is used to represent the check value.

[0011] In a possible implementation, the method further includes: The shared attribute management process writes the second file into the first file in a timing or triggering manner.

[0012] In a possible implementation, the method further includes: The temporary data in the second file is read based on a third-party tool to monitor the communication status between the target processes.

[0013] On the other hand, the present invention also provides an inter-process communication device based on shared memory, comprising: A shared file acquisition module, used for copying a first file in the ROM area to a RAM area to obtain a second file based on a shared attribute management process; A mapped address space acquisition module, used for mapping the second file to the address space of the target process based on the target process to obtain the mapped address space; A global pointer variable acquisition module is used to obtain a global pointer variable based on the mapped address space; A temporary data acquisition module, used for reading and writing cache data of the mapped address space based on the target process and in combination with the global pointer variable to obtain temporary data; An updating module is used for the target process to update temporary data into the second file.

[0014] On the other hand, the present invention also provides an electronic device, including a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in a method for forwarding a remote server interface described in any one of the above implementations.

[0015] The beneficial effects of the present invention are as follows: the present invention provides a method for inter-process communication based on shared memory, based on a shared attribute management process, a first file in a ROM area is copied to a RAM area to obtain a second file, the second file is used to manage data, based on a target process, the second file is mapped to the address space of the target process to obtain a mapped address space, a global pointer variable is obtained based on the mapped address space, based on the target process and in combination with the global pointer variable, cache data in the mapped address space is read and written to obtain temporary data, different processes read and write data in the second file through the global pointer variable, and the target process updates the temporary data to the second file. The present invention reads and writes cache data in a specific format in the process address space through a global pointer variable, and uses a shared file to realize inter-process communication, so that the reading and writing data between various processes are interoperable and do not interfere with each other, thereby solving the problems of inconvenient inter-process communication and high performance overhead. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1A method flow chart of an embodiment of an inter-process communication method based on shared memory provided by the present invention; Figure 2 A data synchronization structure diagram of an embodiment of an inter-process communication method based on shared memory provided by the present invention; Figure 3 A data synchronization flow chart of an embodiment of an inter-process communication method based on shared memory provided by the present invention; Figure 4 For the present invention Figure 1 A schematic flow chart of an embodiment of S104; Figure 5 A schematic flow chart of an embodiment of an inter-process communication device based on shared memory provided by the present invention; Figure 6 A schematic structural diagram of an embodiment of an electronic device provided by the present invention. DETAILED DESCRIPTION

[0017] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.

[0018] Before presenting the embodiments, the following terms are explained.

[0019] ROM (Read-Only Memory) is a read-only memory (including some memories that can be erased and written repeatedly) used to store fixed program instructions and data. The data in ROM will not be lost when the computer is powered off, so it is called non-volatile memory.

[0020] RAM (Random Access Memory) is a temporary memory used to store programs and data that the computer is running. It has the characteristics of fast read and write speed and random access.

[0021] Mmap technology is a technology that maps files or other objects to memory. This technology allows user programs (user space) to directly access device memory (kernel space), which is more efficient than copying data between user space and kernel space.

[0022] The present invention provides a method, device, electronic device and medium for inter-process communication based on shared memory, which are respectively described below.

[0023] Figure 1 A flow chart of an embodiment of the inter-process communication method based on shared memory provided by the present invention is as follows: Figure 1 As shown, the inter-process communication method based on shared memory includes: S101, based on the shared attribute management process, copy the first file in the ROM area to the RAM area to obtain a second file; S102, mapping the second file to the address space of the target process based on the target process to obtain a mapped address space; S103, obtaining a global pointer variable based on the mapped address space; S104, based on the target process and in combination with the global pointer variable, read and write the cache data of the mapped address space to obtain temporary data; S105: The target process updates the temporary data into the second file.

[0024] Compared with the prior art, the present embodiment provides a method for inter-process communication based on shared memory, which copies a first file in a ROM area to a RAM area based on a shared attribute management process to obtain a second file, maps the second file to the address space of the target process based on a target process to obtain a mapped address space, obtains a global pointer variable based on the mapped address space, reads and writes cached data in the mapped address space based on the target process and in combination with the global pointer variable to obtain temporary data, and different processes read and write data in the second file through the global pointer variable, and the target process updates the temporary data to the second file. The present invention reads and writes cached data in a specific format in the process address space through a global pointer variable, and uses shared files to realize inter-process communication. The read and write data between various processes are interoperable and do not interfere with each other, thereby solving the problems of inconvenient inter-process communication and high performance overhead.

[0025] It should be noted that the method of the present invention is performed on a computer in a Linux environment or an MCU single-chip environment.

[0026] In a specific embodiment of the present invention, Figure 2 As shown, it is a data synchronization structure diagram of the present invention. For the convenience of understanding, only process 1 and process 2 are identified in the figure. It can be understood that this embodiment can have multiple processes, and the reading and writing of data by the processes do not affect each other.

[0027] In order to better illustrate this embodiment, Figure 3 The data synchronization flow chart of the present invention is as follows: Step 1: The device starts self-test; Step 2: The shared attribute management process copies the ROM area file rom.bin to the RAM area as ram.bin; Step 3: Use mmap technology to map ram.bin to the cache of process 1; Step 4: Process 1 interval sets or reads cache data; Step 5: Process 1 automatically, timed or triggered, synchronizes the cache data with ram.bin; Step 6: Shared property management process timing or trigger mode, write ram.bin back rom.bin file.

[0028] In a specific embodiment of the present invention, before step S101, the device is also powered on and initialized to complete a self-check of the ROM area and the RAM area.

[0029] In some embodiments of the present invention, the first file and the second file are both binary files. Specifically, the first file is a rom.bin file, and the second file is a ram.bin file. The .bin file format is used to manage data.

[0030] It should be noted that in the Linux environment or MCU environment, the memory address is represented by 32 bits (for the convenience of description, the problem of inconsistent address bit length caused by the hardware system is not considered for the time being), and the shared attribute ID is also represented by 32 bits; when mmap is used to map ram.bin to the process cache area represented by the pointer g_ptr, address 0 is the starting address of the g_ptr pointer, and address 1 to address 9 are fixed offset length addresses relative to address 0, and the length of each relative address interval is fixed; in the single data type 0x00010000, the parameter sequence number represents the base address of relative address 3 + fixed offset 0x0000.

[0031] In some embodiments of the present invention, the memory allocation format of the second file includes: relative address 0 in the first relative address correspondence table 1, relative address 1 in the second relative address correspondence table 1, relative address 2 in the third relative address correspondence table 1, relative address 3 in the fourth relative address correspondence table 1, relative address 4 in the fifth relative address correspondence table 1, relative address 5 in the sixth relative address correspondence table 1, relative address 6 in the seventh relative address correspondence table 1, relative address 7 in the eighth relative address correspondence table 1, relative address 8 in the ninth relative address correspondence table 1, and relative address 9 in the tenth relative address correspondence table 1: The first relative address is used to represent the shared attribute information header, the second relative address is used to represent the shared attribute write mark, the third relative address is used to represent the bool type data interval, the fourth relative address is used to represent the char type data interval, the fifth relative address is used to represent the short type data interval, the sixth relative address is used to represent the int type data interval, the seventh relative address is used to represent the float type data interval, the eighth relative address is used to represent the double type data interval, the ninth relative address is used to represent the string type data interval, and the tenth relative address is used to represent the check value.

[0032] In some embodiments of the present invention, mapping the second file to the address space of the target process based on the target process to obtain the mapped address space includes: Based on the target process and in combination with mmap technology, the second file is mapped to the address space of the target process to obtain the mapped address space.

[0033] It should be noted that this embodiment uses mmap technology to map files, and the data processing part is processed through cache and global pointer variables.

[0034] In step S102, the second file ram.bin uses a fixed format to store data. The specific format is shown in the following table: Table 1: Data format in ram.bin file

[0035] In Table 1, each relative address corresponds to a fixed offset of a data type. Taking char data as an example, a breakdown of char data is shown in Table 2 below, and a bitmap of char data is shown in Table 3 below.

[0036] Table 2: Example of char data segmentation

[0037] Table 3: char data bitmap

[0038] The relative address 1 in Table 1: the shared attribute write mark bitmap is detailed as shown in Table 4 below: Table 4: Shared attribute write flag bitmap detailed description

[0039] In summary, when this embodiment uses mmap to map the ram.bin file, the memory allocation is divided into fixed formats, and the parameter ID and the memory allocation are associated together, and the data partitions are divided according to different data addresses and bits, so that one ram.bin file manages all types of data structures.

[0040] In some embodiments of the present invention, Figure 4 As shown, in step S104, the cache data of the mapped address space is read and written based on the target process and in combination with the global pointer variable to obtain temporary data, including: S401, when the target process needs to modify the data in the second file, obtaining the data type of the data to be written in the cache data; S402, determining the bitmap ID of the data to be written based on the data type; S403, obtaining a relative address and a fixed offset of the data to be written based on the bitmap ID; S404. Obtain temporary data of the process address space according to the global pointer variable combined with the relative address and the fixed offset.

[0041] In some embodiments of the present invention, it further comprises: When the target process needs to read the data in the second file, when it is determined that the shared attribute write mark of the global pointer variable is readable, temporary data is obtained based on the global pointer variable.

[0042] In a specific embodiment of the present invention, the target process modifies the data in the second file including the following steps: The target process sets the instruction set_share_value, indicating that the target process needs to write the cache data of the mapped address space into the second file ram.bin through the global pointer variable g_ptr. For example, assume that the char type "H" in the cache data needs to be written into the second file; First, assign an ID to the char type data "H", as shown in Table 2 and Table 3. Assume that the assigned ID = 0x00010000. According to 0x00010000, the relative address and fixed offset can be identified. The relative address and fixed offset are written into the global pointer variable, and a char type data space can be obtained. The "H" value is stored in this space.

[0043] Further, more specifically, when "set_share_value" is used to set 0x00010000, because bit16--bit19=1, the data type is char, so the data is set in the "relative address 3" interval; because bit0--bit15=0, the parameter sequence number is 0, so the fixed offset is 0; that is, the g_ptr pointer is modified to a byte of data at the starting address + relative address 3 + fixed offset 0 byte address, and the fixed offset 0 bit address of the char type data marked with the shared attribute write in "relative address 1" is modified to 1.

[0044] In a specific embodiment of the present invention, the target process reads the data in the second file including the following steps: The target process reads the instruction get_share_value, which means that the target process global pointer variable g_ptr reads the data in the second file ram.bin and puts it into the cache. When "get_share_value" is used to read 0x00010000, it first determines whether the corresponding bit of the shared attribute write mark of the global pointer variable is written with data. If the bit is 0, the read failure is returned; if the bit is 1, the g_ptr pointer is read as a byte of data at the starting address + relative address 3 + fixed offset 0 byte address and stored in the cache.

[0045] When the present invention uses mmap to map a ram.bin file, memory allocation is divided into fixed formats, and parameter IDs are associated with memory allocations, and data partitions are divided according to different data addresses and bits, so that one ram.bin file manages all types of data structures, parameter IDs are divided into bit functions, and ROM storage and message queues are combined to achieve power-off storage and timely response of shared attributes.

[0046] In some embodiments of the present invention, it further comprises: The temporary data in the second file is read based on a third-party tool to monitor the communication status between the target processes.

[0047] Specifically, when process 1 and process 2 exchange data, a third-party tool (equivalent to running a third process) can be used to monitor or trigger the flow of the corresponding process; because the data operated by process 1 and process 2 will eventually be synchronized to the shared memory file ram.bin, a third-party tool (equivalent to running a third process) is used to read the value of the corresponding data ID to monitor the communication status of process 1 and process 2; when process 1 and process 2 require certain specific scenarios, but it is inconvenient to build test scenarios during the simulation test phase, a third-party tool can be used directly to set the corresponding shared attribute value to trigger the working conditions of the specific scenario.

[0048] This embodiment uses a three-level storage structure to store shared attribute data (ROM, RAM, cache). The ROM memory is used to save data when power is off, the RAM memory is used to share data, and the cache area of ​​the process is used to quickly read and write data.

[0049] In some embodiments of the present invention, it further comprises: The shared attribute management process writes the second file into the first file in a timing or triggering manner.

[0050] When the shared attribute management process synchronizes data to rom.bin, it will first determine if bit22 in 0x00810000 is 0 (no need to save after power-off), then set the shared attribute write flag to 0, and the data cannot be read at the next power-on synchronization; if bit22 is 1 (need to save after power-off), the current data will be written to the rom.bin file, and the data can be read at the next power-on synchronization; If the real-time requirement of a certain data is relatively high, it is hoped that the data can be captured immediately after setting; for the data that needs to be known immediately, a message queue (msg_queue) can be added for processing; when using "set_share_value" to set 0x00810000, because bit23=1 (need change notification), a 0x00810000 data change message notification will be broadcast while setting the data value. When other processes receive the message, they can read the data value and process it.

[0051] In order to better implement an inter-process communication method based on shared memory in an embodiment of the present invention, based on an inter-process communication method based on shared memory, correspondingly, Figure 5 As shown, the embodiment of the present invention further provides an inter-process communication device based on a shared memory. The inter-process communication device 500 based on a shared memory includes: A shared file acquisition module 501, configured to copy a first file in the ROM area to a RAM area to obtain a second file based on a shared attribute management process; A mapped address space acquisition module 502 is used to map the second file to the address space of the target process based on the target process to obtain the mapped address space; A global pointer variable acquisition module 503 is used to obtain a global pointer variable based on the mapped address space; A temporary data acquisition module 504 is used to read and write cache data of the mapped address space based on the target process and in combination with the global pointer variable to obtain temporary data; The updating module 505 is used for the target process to update the temporary data into the second file.

[0052] The inter-process communication device 500 based on shared memory provided in the above embodiment can implement the technical solution described in the above embodiment of an inter-process communication method based on shared memory. The specific implementation principles of the above modules or units can refer to the corresponding contents in the above embodiment of an inter-process communication method based on shared memory, which will not be repeated here.

[0053] like Figure 6As shown, the present invention also provides an electronic device 600. The electronic device 600 includes a processor 601, a memory 602 and a display 603. Figure 6 Only some components of the electronic device 600 are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0054] In some embodiments, the processor 601 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run program codes or process data stored in the memory 602, such as an inter-process communication method based on shared memory in the present invention.

[0055] In some embodiments, the processor 601 may be a single server or a server group. The server group may be centralized or distributed. In some embodiments, the processor 601 may be local or remote. In some embodiments, the processor 601 may be implemented in a cloud platform. In some embodiments, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud, a distributed cloud, an internal cloud, a multi-cloud, etc., or any combination thereof.

[0056] In some embodiments, the memory 602 may be an internal storage unit of the electronic device 600, such as a hard disk or memory of the electronic device 600. In other embodiments, the memory 602 may also be an external storage device of the electronic device 600, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., equipped on the electronic device 600.

[0057] Furthermore, the memory 602 may include both an internal storage unit of the electronic device 600 and an external storage device. The memory 602 is used to store application software installed in the electronic device 600 and various data.

[0058] In some embodiments, the display 603 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 603 is used to display information on the electronic device 600 and to display a visual user interface. The components 601-603 of the electronic device 600 communicate with each other via a system bus.

[0059] In one embodiment, when the processor 601 executes an inter-process communication program based on a shared memory in the memory 602, the following steps may be implemented: Based on the shared attribute management process, the first file in the ROM area is copied to the RAM area to obtain a second file; Mapping the second file to the address space of the target process based on the target process to obtain a mapped address space; Get the global pointer variable based on the mapped address space; Based on the target process and in combination with the global pointer variable, cache data of the mapped address space is read and written to obtain temporary data; The target process updates the temporary data into the second file.

[0060] It should be understood that: when the processor 601 executes an inter-process communication program based on shared memory in the memory 602, in addition to the above functions, other functions can also be implemented. For details, please refer to the description of the corresponding method embodiment above.

[0061] Furthermore, the embodiment of the present invention does not specifically limit the type of the electronic device 600 mentioned, and the electronic device 600 may be a portable electronic device such as a mobile phone, a tablet computer, a personal digital assistant (PDA), a wearable device, a laptop computer, etc. Exemplary embodiments of portable electronic devices include but are not limited to portable electronic devices equipped with IOS, Android, Microsoft or other operating systems. The above-mentioned portable electronic devices may also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface (e.g., a touch panel). It should also be understood that in some other embodiments of the present invention, the electronic device 600 may not be a portable electronic device, but a desktop computer with a touch-sensitive surface (e.g., a touch panel).

[0062] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.

[0063] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.

Claims

1. A method for inter-process communication based on shared memory, characterized in that: include: Based on the shared attribute management process, the first file in the ROM area is copied to the RAM area to obtain a second file; Mapping the second file to the address space of the target process based on the target process to obtain a mapped address space; Get the global pointer variable based on the mapped address space; Based on the target process and in combination with the global pointer variable, cache data of the mapped address space is read and written to obtain temporary data; The target process updates the temporary data into the second file.

2. The inter-process communication method based on shared memory according to claim 1, characterized in that: Both the first file and the second file are binary files.

3. The inter-process communication method based on shared memory according to claim 1, characterized in that: Mapping the second file to the address space of the target process based on the target process to obtain the mapped address space includes: Based on the target process and in combination with mmap technology, the second file is mapped to the address space of the target process to obtain the mapped address space.

4. The inter-process communication method based on shared memory according to claim 1, characterized in that: The step of reading and writing the cache data of the mapped address space based on the target process and in combination with the global pointer variable to obtain temporary data includes: When the target process needs to modify the data in the second file, obtaining the data type of the data to be written in the cache data; Determine the bitmap ID of the data to be written based on the data type; Obtaining a relative address and a fixed offset of data to be written based on the bitmap ID; According to the global pointer variable combined with the relative address and fixed offset, the temporary data of the process address space is obtained.

5. The inter-process communication method based on shared memory according to claim 4, characterized in that: Also includes: When the target process needs to read the data in the second file, when it is determined that the shared attribute write mark of the global pointer variable is readable, temporary data is obtained based on the global pointer variable.

6. The inter-process communication method based on shared memory according to claim 1, characterized in that: The memory allocation format of the second file includes: a first relative address, a second relative address, a third relative address, a fourth relative address, a fifth relative address, a sixth relative address, a seventh relative address, an eighth relative address, a ninth relative address and a tenth relative address: The first relative address is used to represent the shared attribute information header, the second relative address is used to represent the shared attribute write mark, the third relative address is used to represent the bool type data interval, the fourth relative address is used to represent the char type data interval, the fifth relative address is used to represent the short type data interval, the sixth relative address is used to represent the int type data interval, the seventh relative address is used to represent the float type data interval, the eighth relative address is used to represent the double type data interval, the ninth relative address is used to represent the string type data interval, and the tenth relative address is used to represent the check value.

7. The inter-process communication method based on shared memory according to claim 1, characterized in that: Also includes: Based on the shared attribute management process, the second file is written into the first file in a timing or triggering manner.

8. The inter-process communication method based on shared memory according to claim 1, characterized in that: Also includes: The temporary data in the second file is read based on a third-party tool to monitor the communication status between the target processes.

9. An inter-process communication device based on shared memory, characterized in that: include: A shared file acquisition module, used for copying a first file in the ROM area to a RAM area to obtain a second file based on a shared attribute management process; A mapped address space acquisition module, used for mapping the second file to the address space of the target process based on the target process to obtain the mapped address space; A global pointer variable acquisition module is used to obtain a global pointer variable based on the mapped address space; A temporary data acquisition module, used for reading and writing cache data of the mapped address space based on the target process and in combination with the global pointer variable to obtain temporary data; An updating module is used for the target process to update temporary data into the second file.

10. An electronic device, characterized in that: comprising a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in the inter-process communication method based on shared memory as described in any one of claims 1 to 8 above.

Citation Information

Patent Citations

  • Inter-process communication method and system based on shared memory

    CN112860458A

  • Parallelization method for improving post-processing performance

    CN114003385A

  • Handheld terminal low-power-consumption data acquisition method based on mmap memory mapping

    CN115687185A

  • Memory processing method and device, equipment and medium

    CN115952017A

  • Method and system for file access using a shared memory

    US20080120476A1