Data processing method and device, computer readable storage medium and computer equipment
By obtaining and calculating the storage address of dynamic memory type data in shared memory, the problem of inaccurate data access in multi-process environments is solved, and memory consumption and waste are reduced.
Patent Information
- Application Number
- CN202310716703.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-15
- Publication Date
- 2024-12-17
AI Technical Summary
In a multi-process environment, dynamic memory type data cannot be accurately accessed in shared memory, resulting in increased memory space waste and consumption.
By obtaining the storage location of the data structure of the shared data in the shared memory, determining the address information of the target pointer and the process, and calculating the storage address of the shared data based on the address offset value, accurate data access between processes is achieved.
It reduces the system memory consumption during multi-process running, avoids data access failures due to different mapping relationships, and improves memory utilization efficiency.
Smart Images

Figure CN119149261A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the computer field, and in particular to a data processing method, device, computer-readable storage medium, and computer equipment. Background Art
[0002] Computer devices can generally run multiple processes at the same time. They can run multiple processes corresponding to different applications, or they can run multiple processes of the same application (for example, dual or multiple applications). The operation of each process requires the support of corresponding process data. The operating system can allocate a memory space in the memory to store the corresponding process data for each process.
[0003] Since there are some identical data among the process data corresponding to different processes, if a storage space is allocated separately for each process to store the corresponding process data, the identical process data will occupy multiple different memory spaces in the memory, thus resulting in a waste of memory space. In order to reduce the waste of memory space, those skilled in the art set up a shared memory in the memory, and then store the data that can be shared between processes in the shared memory, so that the problem of identical process data occupying multiple memory spaces can be avoided, thereby reducing memory consumption.
[0004] However, there is still a large amount of data in the process data, which cannot be accurately accessed by other processes after being written into the shared memory by the created process, resulting in the inability to share these data between processes through the shared memory, which in turn leads to a large waste of memory space. Summary of the invention
[0005] The embodiments of the present disclosure provide a data processing method and related methods, apparatuses, computer-readable storage media, and computer equipment. The method enables an access process to accurately access shared data created in a shared memory, thereby reducing system memory consumption when multiple processes are running.
[0006] According to one aspect of the present disclosure, there is provided a data processing method, comprising:
[0007] When the first process initiates access to the target shared data in the shared memory, obtaining the storage location of the data structure corresponding to the target shared data in the shared memory;
[0008] Determine first address information corresponding to the target pointer in the data structure and the first process based on the storage location;
[0009] Obtaining an address offset value stored in the target pointer, the address offset value indicating an address offset between the target pointer and an object pointed to by the target pointer;
[0010] Calculate second address information of the target shared data corresponding to the first process according to the first address information and the address offset value;
[0011] The target shared data stored in the storage space indicated by the second address information is loaded into the first process, so that the first process can access the target shared data.
[0012] According to one aspect of the present disclosure, there is provided a data processing device, comprising:
[0013] A first acquisition unit, configured to acquire a storage location of a data structure corresponding to the target shared data in the shared memory when the first process initiates access to the target shared data in the shared memory;
[0014] a determining unit, configured to determine, based on the storage location, first address information corresponding to a target pointer in the data structure and the first process;
[0015] a second acquiring unit, configured to acquire an address offset value stored in the target pointer, wherein the address offset value indicates an address offset between the target pointer and the object pointed to by the target pointer;
[0016] a calculating unit, configured to calculate second address information corresponding to the target shared data and the first process according to the first address information and the address offset value;
[0017] A loading unit is used to load the target shared data stored in the storage space indicated by the second address information into the first process, so as to enable the first process to access the target shared data.
[0018] Optionally, the computing unit comprises:
[0019] A first calculation subunit, configured to calculate the sum of a value corresponding to the first address information and the address offset value to obtain a target value;
[0020] The first determining subunit is used to determine the second address information according to the target value.
[0021] Optionally, the second acquiring unit includes:
[0022] A first acquisition subunit, used to acquire the ciphertext data stored in the target pointer;
[0023] The decryption subunit is used to decrypt the ciphertext data to obtain an address offset value when it is detected that the first process has access rights to the target shared data.
[0024] Optionally, the decryption subunit includes:
[0025] A first acquisition module, used to acquire application information corresponding to the first process;
[0026] The decryption module is used to decrypt the ciphertext data to obtain an address offset value when it is determined that the application indicated by the application information is a preset application.
[0027] Optionally, the decryption module includes:
[0028] an acquisition submodule, configured to acquire first key data matching the preset application when it is determined that the application indicated by the application information is a preset application;
[0029] A decryption submodule is used to decrypt the ciphertext data according to the first key data to obtain an address offset value.
[0030] Optionally, the determining unit includes:
[0031] A second determining subunit is used to determine third address information corresponding to the first memory unit in the storage area corresponding to the storage location and the first process;
[0032] The third determining subunit is used to determine the first address information corresponding to the target pointer and the first process according to the third address information and the storage position of the target pointer associated with the target shared data in the data structure.
[0033] Optionally, the first acquiring unit includes:
[0034] A second acquisition subunit is used to acquire a structure tag of a data structure corresponding to the target shared data;
[0035] The fourth determining subunit is used to determine the storage location of the data structure in the shared memory according to the structure tag.
[0036] Optionally, the structure tag includes a shared memory primary tag and a structure secondary tag, and the fourth determination subunit includes:
[0037] A first determining module, configured to determine a target sub-shared memory in the shared memory according to the shared memory primary tag;
[0038] The second determining module is used to determine the storage location of the data structure in the target sub-shared memory according to the secondary tag of the structure.
[0039] Optionally, the data processing device further includes:
[0040] A running subunit, configured to run a second process, wherein the second process is associated with the same application as the first process;
[0041] A first creating subunit, configured to create a shared memory in the memory based on the second process;
[0042] A second creation subunit, used for creating a data structure including a target pointer in the shared memory;
[0043] A first writing subunit is used to write the shared data of the dynamic memory type in the process data of the second process into the shared memory based on the data structure containing the target pointer;
[0044] The second calculation subunit is used to calculate an address offset value according to the target pointer and the address information of the shared data, and store the address offset value in the target pointer.
[0045] Optionally, the second computing subunit includes:
[0046] A second acquisition module, used for acquiring fourth address information corresponding to the target pointer and the second process, and acquiring fifth address information corresponding to the shared data and the second process;
[0047] The calculation module is used to calculate the difference between the numerical value corresponding to the fifth address information and the numerical value corresponding to the fourth address information to obtain an address offset value.
[0048] Optionally, the data processing device further includes:
[0049] an identification subunit, configured to identify read-only data and global data in the process data of the second process, wherein the global data is data whose modification will be applied in real time to all processes related to the application;
[0050] A fifth determining subunit is configured to determine shared data according to the read-only data and the global data.
[0051] Optionally, the first creating subunit includes:
[0052] A calling module, configured to call a shared memory management class encapsulating a preset operating system application interface based on the second process;
[0053] A creation module is used to create a shared memory according to a shared memory creation function in the shared memory management class.
[0054] Optionally, the data processing device further includes:
[0055] A query subunit, configured to respond to a query instruction for a shared memory in the memory space and search for a corresponding shared memory according to a shared memory query function in the shared memory management class;
[0056] The release subunit is used to release the shared memory according to the shared memory destruction function in the shared memory management class in response to the release instruction of the shared memory.
[0057] Optionally, the writing subunit includes:
[0058] an encryption module, used for encrypting the shared data in the process data of the second process to obtain encrypted shared data;
[0059] A writing module, used for writing the encrypted shared data into the shared memory;
[0060] The second computing subunit is further configured to:
[0061] The shared data address offset value is calculated according to the target pointer and the address information of the encrypted shared data, and the shared data address offset value is stored in the target pointer.
[0062] Optionally, the data processing device further includes:
[0063] A second writing subunit, used for writing the second key data corresponding to the encrypted shared data into the shared memory;
[0064] A third calculation subunit, used for calculating a key address offset value according to the target pointer and the address information of the second key data;
[0065] The storage subunit is used to store the key address offset value in the target pointer.
[0066] Optionally, the second creation subunit includes:
[0067] A third acquisition module is used to acquire a shared memory allocation class that defines a target pointer type;
[0068] A construction module is used to construct a data structure based on the shared memory allocation class to obtain a data structure containing a target pointer.
[0069] According to one aspect of the present disclosure, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the data processing method as described above when executing the computer program.
[0070] According to one aspect of the present disclosure, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the data processing method described above is implemented.
[0071] According to one aspect of the present disclosure, a computer program product is provided. The computer program product includes a computer program. The computer program is read and executed by a processor of a computer device, so that the computer device executes the data processing method as described above.
[0072] In the embodiment of the present disclosure, when a process accesses data in a shared memory, it can first determine the data structure corresponding to the data to be accessed. Then determine the address information corresponding to the pointer and the access process in the data structure and the address offset value stored in the pointer, and calculate the address information corresponding to the data to be accessed and the access process according to the address information and the address offset value of the pointer. In this way, the access process can accurately access the data to be accessed in the shared memory according to the address information corresponding to the data to be accessed and the access process. In this way, the present disclosure constructs a data structure maintained by a pointer storing an address offset value, and compared with a data structure maintained by a pointer storing mapping address information, the data structure can be untied from the creation process, thereby avoiding the problem that the access process cannot access accurate data according to the mapping address information corresponding to the creation process due to the different mapping relationships between the memory space and different processes. This allows data of dynamic storage types to be shared between processes in the shared memory, thereby greatly reducing the memory overhead of computer devices when multiple processes are running.
[0073] Other features and advantages of the present disclosure will be described in the following description, and partly become apparent from the description, or understood by practicing the present disclosure. The purpose and other advantages of the present disclosure can be realized and obtained by the structures particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] The accompanying drawings are used to provide further understanding of the technical solution of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the technical solution of the present disclosure and do not constitute a limitation on the technical solution of the present disclosure.
[0075] Figure 1 is a system architecture diagram of a data processing method application according to an embodiment of the present disclosure;
[0076] Figure 2 It is a schematic diagram of applying the data processing method according to an embodiment of the present disclosure to a scenario where multiple games are opened in a terminal;
[0077] Figure 3 is a schematic diagram of applying the data processing method according to an embodiment of the present disclosure in a cloud gaming scenario;
[0078] Figure 4 is a flowchart of a data processing method according to an embodiment of the present disclosure;
[0079] Figure 5A It is a schematic diagram of creating shared data of dynamic memory type in shared memory in the related art;
[0080] Figure 5B It is a schematic diagram of accessing shared data of a dynamic memory type in a shared memory in the related art.
[0081] Figure 6 It is a flowchart of the shared data creation method provided by the present disclosure;
[0082] Fig. 7A is a schematic diagram of creating shared data of dynamic memory type in shared memory in the present disclosure;
[0083] Figure 7B is a schematic diagram of accessing shared data of a dynamic memory type in a shared memory in the present disclosure;
[0084] Figure 8 is another flow chart of the data processing method provided by the present disclosure;
[0085] Fig. 9 is a schematic diagram of multiple game processes of a target game application running simultaneously in a computer device in the present application;
[0086] Fig.10 is a structural schematic diagram of a data processing device according to an embodiment of the present disclosure;
[0087] Fig.11 is a terminal structure diagram for implementing various methods according to an embodiment of the present disclosure;
[0088] Fig.12 It is a server structure diagram for implementing various methods according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0089] In order to make the purpose, technical solution and advantages of the present disclosure more clear, the present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present disclosure and are not used to limit the present disclosure.
[0090] Before further describing the embodiments of the present disclosure in detail, the nouns and terms involved in the embodiments of the present disclosure are described. The nouns and terms involved in the embodiments of the present disclosure are subject to the following interpretations:
[0091] Standard Template Library (STL): It is the standard template library of C++ (a high-level computer programming language, which is an extension and upgrade of C language). It is a general term for a series of software. The STL library provides basic class templates such as containers (vector), memory allocators (allocator) and algorithms (Algorithm).
[0092] Boost: is a large and comprehensive C++ template library that expands and enriches STL.
[0093] Dynamic memory type: a data type that will be dynamically requested during construction and use. This type of data is generally maintained by a pointer. When constructing data of a dynamic memory type, memory space is allocated for the data in the dynamic memory and a pointer to the data is returned. For example, the types of data maintained by containers and strings in the STL library.
[0094] Shared memory: A named system object that corresponds to a section of memory maintained by the operating system and can be accessed by multiple different processes using names.
[0095] Virtual address: The mapping address of a process to a section of physical memory has nothing to do with the actual corresponding physical address. The operating system maintains the mapping relationship between the virtual address and the physical address of each process.
[0096] Cloud gaming: Cloud gaming is a gaming method based on cloud computing. In the cloud gaming mode, all games are run on the server side. The server side receives the operation instructions sent by the terminal, runs the game according to the received operation instructions, and compresses the rendered game screen and transmits it to the user through the network. On the client side, the user's gaming device does not need any high-end processors and graphics cards, only basic video decompression capabilities are needed.
[0097] Since dynamic memory type data will dynamically apply for the required memory space during the creation process, pointers are generally used to maintain the storage address of dynamic memory type data in memory. When a process (herein referred to as the creation process) needs to create dynamic memory type data in shared memory, it can first create a data structure corresponding to the data in shared memory, such as creating a vector. The implementation principle of Vector is to maintain three pointers internally: begin, end, and capacity. The begin pointer indicates the starting position of the data in the vector, the end indicates the ending position of the data in the vector, and the capacity indicates the ending position of the memory currently belonging to the vector. When the vector needs to expand its capacity, the memory application operation can be performed through the shared memory memory allocator. The shared memory memory allocator can also perform memory release operations. After the vector is created, the start pointer is determined, that is, the virtual address corresponding to the first physical memory storing the shared data in the vector, which is the virtual address corresponding to the creation process. Since the end pointer and capacity pointer will change when writing dynamic memory type data, they can only be determined after the above dynamic memory type data is written into the shared memory. That is, after writing the dynamic memory type data into the shared memory, the three pointers of the vector can be determined. These three pointers correspond to a virtual address respectively. The virtual address is the virtual address corresponding to the physical memory pointed to by the pointer and the creation process.
[0098] When other processes (such as access processes) need to access the above-mentioned dynamic memory type data stored in the shared memory, the above-mentioned vector is found in the shared memory, and then three pointers of the vector are obtained. The virtual addresses corresponding to these three pointers are the virtual addresses corresponding to the physical memory and the creation process, and the same physical memory will obtain different virtual addresses after being mapped by different processes. This results in the access process being unable to map to the accurate physical address storing the dynamic memory type data after obtaining the virtual address in the vector pointer. The dynamic memory type data created by the creation process in the shared memory cannot be accurately accessed by other processes through pointers, resulting in the inability to share the dynamic memory type data between processes through shared memory, which in turn leads to a waste of memory space when multiple processes are running. In this regard, the present disclosure provides a data processing method, in order to solve the problem that the dynamic memory type data created by the creation process in the shared memory cannot be accurately accessed by other processes, thereby reducing the memory overhead of computer devices when multiple processes are running.
[0099] System architecture and scenario description of the application of the embodiments of the present disclosure
[0100] Figure 11 is a system architecture diagram used by the data processing method according to the embodiment of the present disclosure, which includes a terminal 140, the Internet 130, a gateway 120, a server 110, and the like.
[0101] The terminal 140 includes various forms such as desktop computers, laptop computers, PDAs (personal digital assistants), mobile phones, vehicle-mounted terminals, home theater terminals, and dedicated terminals. In addition, it can be a single device or a collection of multiple devices. The terminal 140 can communicate with the Internet 130 in a wired or wireless manner to exchange data.
[0102] The server 110 refers to a computer system that can provide certain services to the terminal 140. Compared with the ordinary terminal 140, the server 110 has higher requirements in terms of stability, security, performance, etc. The server 110 can be a high-performance computer in a network platform, a cluster of multiple high-performance computers, a part of a high-performance computer (such as a virtual machine), a combination of parts of multiple high-performance computers (such as virtual machines), etc.
[0103] The gateway 120 is also called an internetwork connector or a protocol converter. The gateway realizes network interconnection at the transport layer and is a computer system or device that acts as a converter. The gateway is a translator between two systems that use different communication protocols, data formats or languages, or even completely different architectures. At the same time, the gateway can also provide filtering and security functions. The message sent by the terminal 140 to the server 110 must be sent to the corresponding server 110 through the gateway 120. The message sent by the server 110 to the terminal 140 must also be sent to the corresponding terminal 140 through the gateway 120.
[0104] The data processing method of the embodiment of the present disclosure may be completely implemented in the terminal 140 ; may be completely implemented in the server 110 ; or may be partially implemented in the terminal 140 and the other partially implemented in the server 110 .
[0105] When the data processing method is fully implemented in the terminal 140, a storage area can be set in the memory of the terminal 140 as a shared memory, and the shared data of the dynamic storage type and the data structure corresponding to the shared data are stored in the shared memory. The data structure contains a target pointer for maintaining the storage address of the shared data, and the target pointer stores the address offset value between the pointer's own address and the shared data address. A plurality of processes that can access the shared memory are also running in the terminal 140. When any process needs to access the shared data in the shared memory, the data structure corresponding to the shared data can be found in the shared memory, and then the target pointer in the data structure and the virtual address corresponding to the process can be obtained, and the target virtual address corresponding to the shared data and the process can be further calculated based on the virtual address and the address offset value stored in the target pointer, so that the process can accurately access the shared data stored in the shared memory based on the target virtual address. In this way, the memory overhead of the terminal 140 can be reduced when multiple processes are running.
[0106] When the data processing method is fully implemented in the server 110, a storage area can be set in the memory of the server 110 as a shared memory, and the shared memory stores shared data of dynamic memory type and a corresponding data structure, and the data structure also includes a target pointer storing an address offset value. Multiple processes that can access the shared memory can also be run in the server 110. When any process accesses the shared data in the shared process, it can obtain the target pointer in the data structure corresponding to the shared data and the virtual address corresponding to the process, and calculate the target virtual address corresponding to the shared data and the process based on the virtual address and the address offset value stored in the target pointer. In this way, the process can accurately access the shared data according to the target virtual address.
[0107] In the case where a part of the data processing method is implemented in the terminal 140 and the other part is implemented in the server 110, a storage area can be set in the memory of the server 110 as a shared memory. Multiple processes running in multiple terminals 140 can access the shared data stored in the shared memory of the server 110 by communicating with the server through the gateway 120 and the Internet 130. When a process running in any terminal 140 accesses the shared data stored in the shared memory of the server 110, it can first obtain the data structure corresponding to the shared data in the shared memory, and then obtain the target pointer in the data structure and the virtual address corresponding to the process, and then calculate the target virtual address corresponding to the shared data and the process according to the virtual address and the address offset value stored in the target pointer, so that the process can accurately access the shared data according to the target virtual address.
[0108] The embodiments of the present disclosure can be applied in various scenarios, such as Figure 2The scene of multiple games opened in the terminal shown, Figure 3 The cloud gaming scenario shown, etc.
[0109] (I) Scenario of multiple games opened in the terminal
[0110] The terminal 140 may be loaded with a game application, such as a Massive Multiplayer Online Role-Playing Game (MMORPG). When playing a game, the subject may need to control multiple accounts at the same time, for example, some accounts can be idle for upgrading, or multiple accounts are needed to play a copy together. The subject can open multiple game processes in the terminal 140, where multiple openings refer to the same executable program opening multiple processes on the same device. Figure 2 As shown, three game processes 210 can be run simultaneously in the terminal 140, and these three game processes 210 can be three processes corresponding to the same game application. The same data exists in the process data corresponding to these three game processes, such as a game character configuration table or a skill configuration table. In the memory 220 of the terminal 140, a storage area can be set as a shared memory, for example, a first shared memory 221 is set in the memory 220. Shared data (including static memory type data and dynamic memory type data) shared by multiple game processes can be stored in the first shared memory 221. When any game process 210 needs to access the shared data of the dynamic memory type in the first shared memory 221, the target pointer in the data structure in the first shared memory 221 and the virtual address corresponding to the game process can be obtained, and then the storage address of the shared data and the target virtual address corresponding to the game process are calculated according to the virtual address and the address offset value stored in the target pointer, so that the game process can access the shared data stored in the first shared memory 221 according to the target virtual address. Since different game processes can access the shared data stored in the shared memory according to the above method, it is not necessary to store a copy of the shared data in the memory for each game process. Only one copy of the shared data needs to be stored in the shared memory to enable multiple game processes to access the shared data. This can greatly reduce the memory overhead of the terminal 140 when running multiple game processes.
[0111] 2. Cloud gaming scenarios
[0112] In the cloud game scenario, the server 110 receives the game start instruction and the game operation instruction sent by the terminal 140, and the server 110 runs the corresponding cloud game process in the server according to the received game start instruction, and controls the operation of the corresponding cloud game process according to the received operation instruction. Figure 3As shown, when the server 110 receives game start-up instructions from multiple terminals 140, multiple cloud game processes 310 can be run in the server. The server 110 controls the operation of the cloud game process according to the operation instructions sent by the terminal corresponding to each cloud game process 310, and returns the game screen corresponding to the cloud game process 310 to the corresponding terminal.
[0113] When multiple cloud game processes are running in the server, each cloud game process has corresponding process data, when these multiple cloud game processes correspond to the same cloud game application. There may be shared data that can be shared in the process data corresponding to multiple cloud game processes. In the server memory 320 of the server 110, a second shared memory 321 can be set to store the above shared data. When any cloud game process 310 needs to access the shared data stored in the second shared memory 321, the target pointer in the data structure in the second shared memory 321 and the virtual address corresponding to the cloud game process can be obtained, and the storage address of the shared data and the target virtual address corresponding to the cloud game process can be calculated according to the address offset value and virtual address stored in the target pointer. In this way, the cloud game process can access the shared data stored in the second shared memory 321 according to the target virtual address. Since different cloud game processes can access the shared data stored in the second shared memory 321 according to the above method. Therefore, there is no need to store a copy of the above shared data in the server memory for each cloud game process. It is only necessary to store a copy of the shared data in the shared memory to realize the access of multiple cloud game processes to the shared data. This can greatly reduce the memory overhead of the server 110 when running multiple cloud game processes.
[0114] General description of the disclosed embodiments
[0115] According to an embodiment of the present disclosure, a data processing method is provided. The method can be used for Figure 2 The scenario of multiple games being opened in the terminal and Figure 3 The cloud gaming scenario shown can also be applied to other scenarios of multiple applications or cloud applications.
[0116] like Figure 4 FIG. 1 is a flow chart of a data processing method provided by the present disclosure. The method can be applied to a data processing device, which can be integrated in a computer device, which can be a terminal or a server. The data processing method may include:
[0117] Step 410: When the first process initiates access to target shared data in the shared memory, the storage location of the data structure corresponding to the target shared data in the shared memory is obtained.
[0118] In the related art, when storing data of a dynamic memory type in memory, it is necessary to maintain a data structure corresponding to the data of the dynamic memory type in the memory, and the pointer in the data structure indicates the storage address corresponding to the data of the dynamic memory type. The data structure can be a container, a string, or other data structure maintained by a pointer. The pointer in the data structure is constructed using a standard type of pointer template, that is, the value corresponding to the pointer is a virtual address, which is the virtual address corresponding to the process that creates and stores the data structure corresponding to the pointer. Based on this type of pointer, the shared data of the dynamic memory type is written to the shared memory, and other processes cannot access the shared data through the virtual address corresponding to the pointer. This can be explained in detail below. As Figure 5A As shown, it is a schematic diagram of creating shared data of dynamic memory type in shared memory in the related art. As shown in the figure, the creation process (process 1) creates container A in the shared memory, and writes the shared data of dynamic memory type into the shared memory based on the container A. Container A maintains three pointers: the start pointer (corresponding to the virtual address 0x00B00000), the end pointer (corresponding to the virtual address 0x00B00030) and the capacity pointer (corresponding to the virtual address 0x00B00030). These three pointers indicate the storage location of the shared data in the shared memory and also indicate the capacity of container A. The virtual addresses corresponding to the three pointers in container A are the physical memory storing the shared data and the virtual addresses corresponding to process 1. The physical address corresponding to the virtual address 0x00B00000 is 0x00101000, and the physical address corresponding to the virtual address 0x00B00030 is 0x00101030, that is, the shared data is stored in the thirty bytes of shared memory from the physical address 0x00101000 to 0x00101030.
[0119] like Figure 5BAs shown, it is a schematic diagram of accessing shared data of dynamic memory type in shared memory in the related art. As shown in the figure, when the access process (process 2) accesses the shared data of dynamic memory type written by process 1 in the shared memory, it is necessary to first obtain the information of the container (i.e., container A) corresponding to the shared data stored in the shared memory, specifically including the aforementioned start pointer, end pointer, and capacity pointer, and the virtual addresses corresponding to the start pointer, end pointer, and capacity pointer are all virtual addresses corresponding to process 1. Since the same physical memory is mapped by different processes, different virtual addresses will be obtained, so that the physical memory storing the shared data and the virtual address corresponding to process 2 are not the same as the virtual address corresponding to the pointer in container A. The physical memory accessed by process 2 according to the virtual address corresponding to the pointer in container A is not the aforementioned shared data, but other unknown data. Therefore, when the creation process stores the shared data (i.e., shared data of dynamic memory type) whose storage address is maintained by the pointer in the data structure into the shared memory, the access process cannot access the shared data stored in the shared memory according to the pointer of the data structure constructed by the creation process, resulting in that the shared data of dynamic memory type cannot be shared between processes through the shared memory. In order to solve the problem that the shared data of the dynamic memory type created by the creating process in the shared memory cannot be accurately accessed by other accessing processes according to the virtual address corresponding to the pointer, the present disclosure provides a data processing method, so that the accessing process can accurately access the corresponding shared data of the dynamic memory type according to the pointer in the shared memory. The method is introduced in detail below.
[0120] In the disclosed embodiment, when the first process initiates access to the target shared data in the shared memory, the storage location of the data structure corresponding to the target shared data in the shared memory can be obtained. The first process here can be the aforementioned access process, specifically any process running in the computer device, the first process can be a process corresponding to a game application, a process corresponding to a document application, a process corresponding to a browser application, or a process corresponding to other applications that can be opened in multiple computer devices, and the specific application corresponding to the first process is not limited here.
[0121] After the first process is run in the computer device, the process data corresponding to the first process can be stored in the memory of the computer device. The process data can be stored in a shared area (i.e., shared memory) in the memory of the computer device, or in a non-shared area in the memory of the computer device. The process data can include static memory type data and dynamic memory type data, wherein the memory size required to store the static memory type data is clear, and the required memory size and storage address have been determined when the memory is allocated; the memory size required for the dynamic memory type data is unclear, so it is necessary to dynamically allocate memory, and a pointer is required to indicate the location of the storage space. When accessing the static memory type data, it can be accessed directly according to the storage address; when accessing the dynamic memory type data, it is necessary to first obtain the data structure corresponding to the dynamic memory type data, in which a pointer is stored, and then the storage address of the dynamic memory type data can be determined and accessed according to the information carried in the pointer. Here, the data structure corresponding to the target shared data can be the aforementioned vector or string.
[0122] During the operation of the first process, it may be necessary to access the process data at any time to implement the corresponding process function. Since the data processing method provided by the embodiment of the present disclosure can specifically be a method for accessing data of a dynamic storage type in a shared memory, when the first process accesses the process data, the target shared data stored in the shared memory that needs to be accessed can be determined first, and the target shared data here can specifically be data of a dynamic memory type, such as a role configuration table or a skill configuration table of a game application. Then, the storage location of the data structure corresponding to the target shared data in the shared memory can be obtained. The storage location here can specifically be a storage area in the shared memory, and can specifically include the first address and the last address of the storage area, the first address being the address of the first memory block in the storage area, and the last address being the address of the last memory block in the storage area. Among them, the first address and the last address here are both addresses related to the first process, and can specifically be the virtual address of the corresponding memory block set by the operating system mapped to the first process.
[0123] In some embodiments, obtaining the storage location of a data structure corresponding to the target shared data in the shared memory includes:
[0124] Get the structure tag of the data structure corresponding to the target shared data;
[0125] Determine the storage location of the data structure in shared memory based on the structure tag.
[0126] In the disclosed embodiment, multiple shared data can be stored in the shared memory at the same time, and each shared data can store a data structure that maintains the storage address of the corresponding shared data in the shared memory. The multiple data structures stored in the shared memory can be distinguished by different structure tags. For example, when the data structure is a vector, structure tags such as vector1 and vector2 can be used to distinguish it; or the name of the shared data can be used as the structure tag of the corresponding structure, for example, the name of the shared data such as the role configuration table and the skill configuration table can be used as the structure tag of its corresponding structure.
[0127] In this way, when it is necessary to determine the storage location of the data structure corresponding to the target shared data in the shared memory, the structure tag of the data structure corresponding to the target shared data can be obtained first. The structure tags of the data structures corresponding to these shared data can be written into the running data of the first process by the operating system when the first process is started. When the first process needs to access the target shared data, the corresponding structure tags can be directly read. Among them, the process data of the aforementioned process can be data stored in the memory that the process may need to call during operation. Here, the running data of the process can specifically be code data that supports the operation of the process, such as an executable file.
[0128] After obtaining the structure tag corresponding to the target shared data, the corresponding data structure can be further found in the shared memory according to the structure tag, and the storage location of the data structure in the shared memory can be determined. This method can quickly locate the storage location of the data structure corresponding to the target shared data in the shared memory according to the structure tag of the target shared data, thereby improving the access efficiency to the shared data in the shared memory.
[0129] In some embodiments, the structure tag includes a shared memory primary tag and a structure secondary tag, and determining the storage location of the data structure in the shared memory according to the structure tag includes:
[0130] Determine the target sub-shared memory in the shared memory according to the shared memory first-level tag;
[0131] The storage location of the data structure is determined in the target child shared memory according to the secondary tag of the structure.
[0132] Among them, in the embodiment of the present disclosure, there may be multiple shared memories in the memory, that is, multiple storage areas may be allocated in the memory, and each storage area corresponds to a shared memory. The shared memory in the embodiment of the present disclosure may be a whole composed of the above-mentioned multiple shared memories, and one shared memory among the above-mentioned multiple shared memories may be called a sub-shared memory. In addition, the structure tag of the data structure corresponding to the target shared data may include a shared memory first-level tag and a structure second-level tag, wherein the shared memory first-level tag may indicate the target sub-shared memory corresponding to the data structure, and the structure second-level tag may indicate the specific location of the data structure in the target sub-shared memory. The structure tag of the data structure corresponding to the shared data may be stored in the running data of the first process in the form of a data group, and the data group may specifically be a data pair composed of a shared memory first-level tag and a structure second-level tag.
[0133] In this way, after obtaining the structure tag of the data structure corresponding to the target shared data, the target sub-shared memory storing the data structure corresponding to the target shared data can be determined in the shared memory according to the shared memory primary tag in the structure tag. Then, the storage location of the data structure corresponding to the target shared data can be further found in the target sub-shared memory according to the structure secondary tag.
[0134] In some embodiments, it is understandable that before the first process initiates access to the target shared data in the shared memory, it is necessary to first construct the target shared data in the shared memory. Of course, other shared data other than the target shared data may also be constructed in the shared memory. Figure 6 FIG. 1 is a flow chart of a method for creating shared data provided by the present disclosure, and the method includes:
[0135] Step 610, running the second process.
[0136] Among them, in the disclosed embodiment, before the first process accesses the target shared data stored in the shared memory, the target shared data needs to be written into the shared memory first, that is, the target shared data needs to be created in the shared memory first. Specifically, the target shared data can be created in the shared memory by the second process (creating process). Of course, the second process can not only create the target shared data in the shared memory, but also create other shared data, and the other shared data includes the shared data of the static memory type and the shared data of the dynamic memory type. In the disclosed embodiment, it is mainly explained by the second process creating the shared data of the dynamic memory type in the shared memory.
[0137] Here, the second process and the aforementioned first process can be different processes or the same process, that is, the creation process and the access process can be the same process. After the second process creates shared data in the shared memory, the shared data in the shared memory can also be accessed during the running of the second process. When the first process and the second process are not the same process, the first process and the application associated with the first process can be the same application or different applications, as long as there is data that can be shared in the process data corresponding to the two processes. In the embodiment of the present disclosure, the application associated with the first process and the second process can specifically be the same application, such as the aforementioned MMORPG game application. The second process can be running before the first process runs, or it can be started after the first process runs.
[0138] In response to receiving a start instruction for a specific application in the computer device, the process corresponding to the application is run, that is, the second process is run. When the second process is run, the process data corresponding to the second process needs to be written into the memory for storage. The process data corresponding to the second process includes data that can be shared and data that cannot be shared. Whether the process data can be shared can be predetermined and set. When the second process is run, the data that is predetermined to be unshared can be directly created in the non-shared memory area in the memory; the data that is predetermined to be shared can be created in the shared memory.
[0139] Step 620: Create a shared memory in the memory based on the second process.
[0140] Before the second process creates shared data in the shared memory, it can first create shared memory in the memory based on the second process. That is, the second memory can apply for shared memory from the operating system, and the operating system can allocate a memory area as shared memory according to the application request. Then, the second process can create shared data in the shared memory.
[0141] Among them, the shared data creation method or data processing method provided by the present disclosure can be applied to various operating systems, such as Windows system (system developed by Microsoft), Android system or IOS system (system developed by Apple), etc. Since different operating systems have different application programming interfaces (Application Programming Interface, API), in order to facilitate the management of shared memory by the memory manager and avoid the memory manager directly docking with the API of the operating system when in use, a new class is defined in this embodiment, which is referred to as a shared memory management class (ManagedShm). The shared memory management class encapsulates the API related to the shared memory in the operating system, so when it is necessary to create shared memory, the newly defined shared memory management class can be directly called to create it.
[0142] That is, create shared memory in the memory based on the second process, including:
[0143] Based on the second process calling the shared memory management class that encapsulates the preset operating system application interface;
[0144] Create shared memory according to the shared memory creation function in the shared memory management class.
[0145] In the embodiment of the present disclosure, since a shared memory management class is predefined, the shared memory management class encapsulates the API related to the shared memory in the operating system. Thus, when the second process needs to create a shared memory during operation, the shared memory management class encapsulating the operating system application interface can be called to create the shared memory. Specifically, the shared memory creation function (CreateFileMapping) in the shared memory management class can be called to create the shared memory.
[0146] For usage scenarios corresponding to different operating systems, you only need to replace the API related to shared memory in the operating system in the shared memory management class with the API corresponding to the operating system, that is, the newly defined shared memory management class can be applied to shared memory management in any operating system.
[0147] In some embodiments, the data processing method provided by the present disclosure may further include:
[0148] In response to a query instruction for a shared memory in the memory space, searching for a corresponding shared memory according to a shared memory query function in a shared memory management class;
[0149] In response to the release instruction for the shared memory, the shared memory is released according to the shared memory destruction function in the shared memory management class.
[0150] In the disclosed embodiment, the newly defined shared memory management class not only includes a shared memory creation function, but also may include a shared memory address mapping function, which is used to map each memory block in the shared memory to each process, and obtain the virtual address of each memory block mapped to a different process. The shared memory management class may also include a memory query function, which may be used to find the corresponding shared memory in the memory space. Specifically, in response to a query instruction for the shared memory in the memory space, the corresponding shared memory may be found according to the shared memory query function in the shared memory management class. In addition, the shared memory management class may also include a shared memory destruction function, and when the process that created the shared memory ends its operation, the shared memory may be destroyed to release the memory space. Specifically, in response to a release instruction for the shared memory, the shared memory destruction function in the shared memory management class may be called to release the shared memory.
[0151] Step 630, create a data structure containing the target pointer in the shared memory.
[0152] When the shared data is static memory type shared data, a certain shared memory area can be allocated in the shared memory to create the static memory type shared data. When other processes are running, the operating system will map this certain shared memory area to the virtual addresses corresponding to these processes. When these processes need to access the static memory type shared data, they can access the corresponding shared data according to the corresponding virtual addresses.
[0153] When the shared data is a dynamic memory type shared data, a data structure containing a target pointer can be created in the shared memory. Here, the data structure can be the aforementioned container or string maintained by the pointer, and the target pointer can be a pointer storing an address offset, which is the offset value between the target pointer's own address and the address of the object pointed to by the target pointer. When creating the data structure, the data structure can be named to generate a structure tag corresponding to the data structure.
[0154] Among them, the shared data creation method or data processing method provided by the embodiment of the present disclosure can be specifically applied in the scenario of using STL for the development and maintenance of application programs or operating systems. As described above, Boost is a large and comprehensive C++ template library, which is an expansion and enrichment of STL. And it is precisely because of the large number of Boost templates that the performance loss of related services caused by using Boost in the project is also much higher than that of STL. Moreover, since both STL and Boost are complete template libraries, in general, if STL is used in a certain project, the templates in Boost will not be introduced. Because if the templates in Boost are introduced while using STL, it will cause confusion to the entire project to a certain extent. With the further development of the project, there may be a situation where multiple template libraries are mixed and used, which will bring difficulties to long-term development and maintenance. Therefore, in the scenario of using STL, the templates related to memory sharing in Boost are generally not introduced. In STL, the pointer uses a fixed standard pointer type, that is, the pointer indicates a virtual address, and the virtual address cannot be shared across processes, resulting in the inability of dynamic memory type data to realize multi-process sharing in shared memory. However, the template in STL provides certain extensibility, and the data processing method provided by the present disclosure can redefine a new pointer according to the extensibility provided by STL, i.e., the aforementioned target pointer (OffsetPtr), which can point to the target data by means of base address+offset. Here, the base address can be the address of the target pointer itself, and the offset can be the address offset value between the address of the target pointer itself and the address of the target data pointed to, so the target pointer here is also a kind of offset pointer. Different from the offset pointer provided by the inter-process template in Boost, the target pointer here is a special type of pointer defined based on STL. The data structure maintained by the newly defined target pointer creates shared data in shared memory, which can replace the introduction of Boost and realize cross-process memory sharing of data of dynamic memory type based on STL. Or, in some embodiments, in some template libraries that directly use standard pointer types, such as EASTL scenarios, it is also possible to realize cross-process sharing of data of dynamic memory type by encapsulating the container twice, and then applying the solution provided by the present application.
[0155] For the newly defined target pointer, the same basic pointer operations as other pointers can be implemented. For example, pointer arithmetic operations, pointer comparison operations, pointer dereference operations, pointer type conversion operations, pointer subscript access operations, and assignment operations. In addition, the target pointer can also be copied. Since the addressing of the target pointer depends on the address of the target pointer itself, when copying the target pointer, it is not possible to simply copy it directly. Instead, it is necessary to first calculate the sum of the old address of the target pointer and the address offset value stored in the target pointer, and then subtract the new address from the sum of the old address of the target pointer and the address offset value stored in the target pointer to obtain a new address offset value, and then store the new address offset value in the copied new target pointer.
[0156] Based on this, in some embodiments, creating a data structure containing a target pointer in a shared memory includes:
[0157] Get the shared memory allocation class that defines the target pointer type;
[0158] Construct a data structure based on the shared memory allocation class to obtain a data structure containing a target pointer.
[0159] When the creation process creates shared data in shared memory, it generally uses the default memory allocator (allocator) in STL to apply for and release memory. The Allocator type contains the begin pointer, end pointer, and capacity pointer of the standard pointer type. However, the pointer of the standard pointer type cannot realize the sharing of dynamic memory type shared data between processes, so a new class needs to be redefined, which can be defined as a shared memory allocation class (ShmAllocator) here. The shared memory allocation class can be a memory allocator type that conforms to STL's allocator_traits (a class template that describes an object that supplements the allocator type. Specifically, for any allocator type, allocator_traits can be used to determine all the information required for the container that supports the allocator). The target pointer type is defined in the shared memory allocation class. Specifically, the following type names can be defined in the shared memory allocation class: pointer (pointer), constant pointer (const_pointer), and then these two pointer types are defined as offset pointers:
[0160] typedef OffsetPtr <t>pointer; define the pointer type as offset pointer;
[0161] typedef const OffsetPtr <t>const_pointer; defines the type of const_pointer as offset pointer.
[0162] After defining the shared memory allocation class, the shared memory allocation class can be used to construct corresponding data structures, such as containers (std::vector) constructed based on STL or strings (std::string) constructed based on STL. The data structure constructed using the shared memory allocation class includes a target pointer type (i.e., an offset pointer type).
[0163] In an embodiment of the present disclosure, a new shared memory allocation class is defined, and a pointer of a target pointer type is defined in the shared memory allocation class. Then, when constructing a data structure, a target pointer of the newly defined offset pointer type is used to replace a pointer of the standard pointer type to construct a corresponding data structure, thereby obtaining a data structure containing a target pointer.
[0164] Step 640: Write the shared data of the dynamic memory type in the process data of the second process into the shared memory based on the data structure including the target pointer.
[0165] After the data structure is created, dynamic memory type shared data can be created in the shared memory based on the data structure. The dynamic memory type shared data can be written into any specified memory block of the shared memory. During the process of writing the dynamic memory type shared data into the dynamic memory, the size of the shared memory allocated to the shared data is adjusted in real time until the dynamic memory type shared data is completely written into the shared memory.
[0166] Step 650, calculating the address offset value according to the target pointer and the address information of the shared data, and storing the address offset value in the target pointer.
[0167] Since the shared data of dynamic memory type is dynamically allocated memory space when it is created, the address offset between the address information of the target pointer itself and the address information of the object pointed to by the target pointer is also changing all the time during the creation process of the shared data of dynamic memory type. After the shared data of dynamic memory type is written to the shared memory, the address offset value between the address information of the target pointer itself and the address information corresponding to the object pointed to by it (i.e. shared data) is further calculated, and the address offset value is stored in the target pointer. So that other access processes can access the shared data according to the address information and address offset value of the target pointer itself. Among them, the address information of the target pointer itself and the address information of the shared data are all virtual addresses corresponding to the second process.
[0168] Among them, multiple processes of the same application can be run simultaneously in the computer device. The shared data of multiple processes can be that when the first process of the application is run, the first process creates a shared memory and creates shared data in the shared memory. The shared data of multiple processes can also be that after the multiple processes of the application are run, any one of the multiple processes creates a shared memory and creates shared data in the shared memory. In the embodiment of the present disclosure, the second process can be the first process of a certain application running in the computer device. When the second process is run, shared data can be created in the shared memory based on the second process. After the second process creates shared data in the shared memory, it starts to run the first process corresponding to the same application as the second process. At this time, it only needs to create part of the data that cannot be shared in the process data corresponding to the first process in the memory. The shared data in the process data has been pre-created in the shared memory by the second process, so that the startup efficiency of the first process can also be accelerated. When the first process needs to access the shared data, it can directly access the shared data in the shared memory.
[0169] In some embodiments, calculating the address offset value according to the target pointer and the address information of the shared data includes:
[0170] Acquire fourth address information of the target pointer and the second process, and acquire fifth address information of the shared data and the second process;
[0171] The difference between the value corresponding to the fifth address information and the value corresponding to the fourth address information is calculated to obtain the address offset value.
[0172] Among them, in the embodiment of the present disclosure, the data structure created in the shared memory may contain multiple target pointers. The address offset value corresponding to each target pointer may be the same or different, and needs to be calculated based on the address information of the target pointer itself and the address information of the shared data pointed to.
[0173] Specifically, when calculating the address offset value according to the address information of the target pointer and the shared data, the fourth address information corresponding to the target pointer and the second process can be obtained first. The fourth address information here is only for distinguishing from other address information below, and does not limit the difference in address information, nor does it limit the numerical value of the address information. The fourth address information here can specifically be the physical address of the memory block storing the target pointer mapped to the virtual address of the second process. When the created data structure is a container, there are three target pointers, and these three target pointers respectively indicate the starting position, end position and storage space of the data corresponding to the container. When there are three target pointers, the fourth address information corresponding to the target pointer is also three virtual addresses. Further, the fifth address information corresponding to the shared data and the second process can be obtained. The fifth address information is also the physical address of the first memory block and the last memory block storing the shared data mapped to the virtual address of the second process, that is, the fifth address information can be two virtual addresses. In this way, the difference between the numerical value corresponding to the fifth address information and the numerical value corresponding to the fourth address information can be further calculated, and the address offset value can be obtained.
[0174] Specifically, to calculate the difference between the numerical value corresponding to the fifth address information and the numerical value corresponding to the fourth address information, it is necessary to first determine the correspondence between the virtual address corresponding to the fifth address information and the virtual address corresponding to the fourth address information. For example, the first memory block storing shared data and the virtual address corresponding to the second process should correspond to the virtual address of the target pointer indicating the start position of the data corresponding to the container, and the difference between the numerical values corresponding to the above two virtual addresses can be calculated to obtain the address offset value of the target pointer indicating the start position of the data corresponding to the container; the last memory block storing shared data and the virtual address corresponding to the second process should correspond to the virtual address of the target pointer indicating the end position of the data corresponding to the container, and the difference between the numerical values corresponding to the above two virtual addresses can be calculated to obtain the address offset value of the target pointer indicating the end position of the data corresponding to the container; and the address offset value corresponding to the target pointer indicating the capacity of the container needs to be further determined according to the size of the shared memory allocated to the container. For example, the virtual address of the last memory block of the allocated storage space and the second process can be calculated based on the size of the shared memory allocated for the container and the virtual address of the first memory block storing the shared data and the second process. Then, the virtual address of the last memory block of the allocated storage space and the second process can be calculated, and the address offset value can be obtained by calculating the difference between the virtual address of the last memory block of the allocated storage space and the second process and the virtual address corresponding to the target pointer indicating the capacity of the container.
[0175] In some embodiments, before writing the shared data in the process data of the second process into the data structure, the method further includes:
[0176] Identify read-only data and global data in the process data of the second process, where the global data is data whose changes are applied in real time to all processes related to the application;
[0177] Determine shared data based on read-only data and global data.
[0178] In the disclosed embodiment, which of the process data of the second process needs to be created in the shared memory and which needs to be created in the non-shared memory area of the memory can be manually pre-set or automatically determined by the operating system. Specifically, the operating system can identify the read-only data and global data in the process data of the second process. Among them, the read-only data is data that will only be written in the initialization phase in terms of business logic, and can only be accessed but not rewritten afterwards. That is, read-only data is data that can only be written to the shared memory when the creation process creates shared data in the shared memory in terms of business logic, and any access process has no right to change it afterwards. For example, in the scene configuration table of a game application, the game characters can only play games in several fixed scenes, and the user cannot change the scene or create a new scene when running the game process, that is, the scene configuration table is read-only data that cannot be rewritten by any access process. Of course, this is just an example, not all application scenes of all games cannot be changed, that is, not all scene configuration tables of all games are read-only data.
[0179] In addition, there is another type of data that can be shared among multiple processes, namely global data. Global data here specifically refers to data where changes to the data are applied in real time to all processes related to the application. For example, in an online game, users can create their own characters, and in an online game, each character should be visible to all players in the corresponding server. So when a process creates a new character, that is, after modifying the character configuration table, the character configuration table should be applied in real time to all game processes running in the corresponding server. Then, the character configuration table here can be called global data, and the data can be modified, but the modification of the data will be applied in real time to all processes related to the corresponding application.
[0180] The method for automatically identifying shared data in the process data of a process provided by the present disclosure can avoid the omission problem when manually determining the shared data, and can improve the efficiency and accuracy of determining the shared data, compared with manually setting the data that can be shared. In addition, when the process data of the process changes, such as version upgrade, it is not necessary to manually determine it again, which can improve the flexibility of determining the shared data.
[0181] Step 420: Determine first address information corresponding to the target pointer in the data structure and the first process based on the storage location.
[0182] Among them, after obtaining the storage location of the data structure corresponding to the target shared data to be accessed in the shared memory, the first address information corresponding to the target pointer in the data structure and the first process can be further determined according to the storage location. As mentioned above, the data structure corresponding to the shared data of the dynamic memory type created in the shared memory may include multiple target pointers. The target pointer here and the target pointer in the data structure corresponding to the shared data created by the second process can be pointers of the same type, but the address offset values stored in the target pointers at these two places can be the same or different, and the address information of the target pointers at these two places can also be the same or different, that is, the target pointer does not indicate the same pointer, but indicates the same type of pointer. For each target pointer, there can be a virtual address corresponding to the first process, so the first address information here can include multiple virtual addresses corresponding to multiple target pointers. Specifically, the address operation can be used to obtain the first address information corresponding to each target pointer and the first process.
[0183] In some embodiments, determining first address information corresponding to a target pointer in a data structure and a first process based on a storage location includes:
[0184] Determine third address information corresponding to the first memory unit in the storage area corresponding to the storage location and the first process;
[0185] The first address information corresponding to the target pointer and the first process is determined according to the third address information and the storage position of the target pointer associated with the target shared data in the data structure.
[0186] In an embodiment of the present disclosure, when determining the first address information corresponding to each target pointer in the data structure and the first process based on the storage position of the data structure corresponding to the target shared data in the shared memory, the third address information corresponding to the first process and the first memory unit in the storage area corresponding to the storage position can be determined first. The third address information corresponding to the first memory unit in the storage area and the first process can be specifically maintained by the operating system and has been determined when the first process is running. Therefore, it is only necessary to directly read the third address information according to the corresponding mapping relationship. This third address information can also be called the first address information of the data structure.
[0187] Furthermore, since different data structures correspond to different numbers of target pointers, and different target pointers have different storage locations in the data structure, after determining the first address of the data structure, the storage location of each target pointer in the data structure can be further determined. Then, the first address information corresponding to each target pointer and the first process can be calculated based on the storage location of the target pointer in the data structure and the first address of the data structure.
[0188] Step 430, obtaining the address offset value stored in the target pointer.
[0189] In the disclosed embodiment, an address offset value may also be stored in the target pointer in the data structure corresponding to the target shared data. After determining the first address information corresponding to each target pointer and the first process, the address offset value stored in each target pointer may be further obtained. The address offset value here indicates the address offset between the target pointer and the object pointed to by the target pointer, that is, the address offset between the address information of the target pointer itself and the address information of the target shared data pointed to. Each target pointer corresponds to an address offset value, so multiple address offset values corresponding to multiple target pointers may be obtained here. This part of the content has been introduced in step 650 of the shared data creation method and will not be repeated here.
[0190] In some embodiments, obtaining the address offset value stored in the target pointer includes:
[0191] Get the ciphertext data stored in the target pointer;
[0192] When it is detected that the first process has access rights to the target shared data, the ciphertext data is decrypted to obtain the address offset value.
[0193] In the disclosed embodiment, since the shared data in the shared memory is open to the processes running in the terminal or server, any process running in the computer device can access the shared data in the shared memory. Moreover, the data structure corresponding to the shared data is also provided with a structure tag, and the structure tags of some data structures also reveal the data content of the shared data corresponding to the data structure. This causes the security of the shared data stored in the shared memory to be affected. When some processes posing security threats are running in the terminal, the shared data stored in the shared memory can be easily acquired or even changed by these processes posing security threats. Therefore, in order to ensure the data security of the shared data stored in the shared memory, a solution is provided in the present embodiment to ensure the data security of the shared data by encrypting the address offset value stored in the target pointer.
[0194] Since the address offset value stored in the target pointer in the data structure is encrypted, when the address offset value stored in the target pointer needs to be obtained, the ciphertext data stored in the target pointer needs to be obtained first. Then, the obtained ciphertext data needs to be decrypted to obtain the address offset value stored in the target pointer.
[0195] Before decrypting the ciphertext data obtained in the target pointer, it is necessary to first detect the access rights of the first process to the target shared data to be accessed. When it is detected that the first process does not have the access rights to the target shared data to be accessed, the encrypted data cannot be decrypted. In this way, the first process cannot obtain the address offset value in the target pointer, and cannot determine the storage location of the target shared data, and thus cannot accurately access the target shared data, nor can it change the target shared data. In this way, the security of the target shared data can be guaranteed. When it is detected that the first process has the access rights to the target shared data to be accessed, the ciphertext data can be decrypted to obtain the address offset value stored in the target pointer, and then the first process can further access the target shared data based on the address offset value and the first address information.
[0196] It is detected whether the first process has access rights to the target shared data to be accessed. Specifically, a list of applications that have access rights to the target shared data can be obtained, and then it can be determined whether the application corresponding to the first process exists in the above application list. When the application corresponding to the first process exists in the above application list, it can be determined that the first process has access rights to the target shared data to be accessed; when the application corresponding to the first process does not exist in the application list, it is determined that the first process does not have access rights to the target shared data to be accessed.
[0197] Alternatively, it is possible to pre-set which shared data the first process has access rights to, for example, the data to which the first process has access rights constitute a data set; when detecting whether the first process has access rights to the target shared data to be accessed, it is possible to detect whether the target shared data belongs to the data set to which the first process has access rights; when the target shared data does not belong to the above data set, it is determined that the first process does not have access rights to the target shared data; when the target shared data belongs to the above data set, it is determined that the first process has access rights to the target shared data. Whether the target shared data belongs to the data set can be determined based on the structure tag of the data structure corresponding to the target shared data.
[0198] Through the method provided by the embodiment of the present disclosure, the access process needs to have the access rights to the shared data to be accessed before it can decrypt the ciphertext data stored in the target pointer, thereby obtaining the pointer offset value stored in the target pointer; otherwise, the pointer offset value in the target pointer cannot be obtained, and the storage location of the shared data cannot be determined, and the shared data cannot be accessed. In this way, access to the shared data by processes without access rights can be avoided, thereby ensuring the security of the shared data in the shared memory.
[0199] In some embodiments, when it is detected that the first process has access rights to the target shared data, the ciphertext data is decrypted to obtain the address offset value, including:
[0200] Obtain application information corresponding to the first process;
[0201] When it is determined that the application indicated by the application information is a preset application, the ciphertext data is decrypted to obtain the address offset value.
[0202] In the disclosed embodiment, in order to further ensure the security of the shared data in the shared memory, it can be set that the ciphertext data can only be decrypted when the application corresponding to the first process is detected as a preset application. The preset application here can be set to the same application as the application corresponding to the creation process that created the shared data. For example, when the application that creates the shared data in the shared memory is the target game application, when it is detected that the first process is the process corresponding to the target game application, the ciphertext data is decrypted to obtain the address offset value. When it is detected that the first process is not the process corresponding to the target game application, the ciphertext data cannot be decrypted.
[0203] Thus, after obtaining the ciphertext data stored in the target pointer, the application information of the application corresponding to the first process can be further obtained. If it is determined that the application indicated by the application information is a preset application, such as the aforementioned target game application, the ciphertext data can be decrypted to obtain the address offset value.
[0204] In some embodiments, when it is determined that the application indicated by the application information is a preset application, the ciphertext data is decrypted to obtain the address offset value, including:
[0205] When it is determined that the application indicated by the application information is a preset application, obtaining first key data matching the preset application;
[0206] The ciphertext data is decrypted according to the first key data to obtain the address offset value.
[0207] When it is detected that the first process has access rights to the target shared data, specifically when it is determined that the application corresponding to the first process is a preset application, the first key data matching the preset application can be further obtained. A mapping relationship table between application information and key data can be stored in the memory of the computer device, and in the mapping relationship table, the application information and the key data correspond one to one. To obtain the first key data matching the preset application, the application information corresponding to the preset application can be found in the mapping relationship table between the application information and the key data, and then the first key data corresponding to the preset application can be determined according to the mapping relationship.
[0208] After obtaining the first key data, the ciphertext data can be decrypted according to the obtained first key data to obtain the address offset value. In the embodiment of the present disclosure, the encryption of the address offset value can be performed using a symmetric encryption algorithm. When the symmetric encryption algorithm is used for encryption, the encryption key and the decryption key can be the same key. The computer device can use a certain key to encrypt the address offset value to obtain the ciphertext data, and then store the ciphertext data in the target pointer. Furthermore, the computer device can also update the mapping relationship between the key and the application information into the aforementioned mapping relationship table between the application information and the key data.
[0209] In some embodiments, the address offset value obtained by decrypting the encrypted data using the first key data may further include a shared data address offset value and a key address offset value. Wherein, the shared data address offset value indicates the address offset between the storage address corresponding to the target shared data and the address of the target pointer itself, and the key address offset value indicates the address offset between the storage address of the second key data and the address of the target pointer itself. Wherein, in the disclosed embodiment, the target shared data is also encrypted ciphertext data, and the second key data is the key for decrypting the ciphertext data corresponding to the target shared data. In this way, when the first process initiates access to the target shared data in the shared memory, the first address information corresponding to the target pointer and the first process in the data structure corresponding to the target shared data can be determined first, and the ciphertext data can be obtained from the target pointer. Then the ciphertext data is decrypted to obtain the shared data address offset value and the key address offset value, and the target shared data ciphertext is obtained according to the shared data address offset value and the second key data is obtained according to the key address offset value. Then the second key data is used to decrypt the target shared data ciphertext to obtain the target shared data. By adopting the method provided by the embodiment of the present disclosure, it is possible to further avoid storing the plaintext data of the shared data in the shared memory. Moreover, the key for decrypting the ciphertext of the shared data is also maintained in the shared memory using an offset pointer, so that the key can be obtained more conveniently and efficiently; in addition, since the storage address of the key for decrypting the ciphertext of the shared data is maintained using an encrypted offset pointer, a process without access rights cannot know the storage location of the key in the shared memory, and thus cannot obtain the key. This can further improve the security of the shared data.
[0210] The above steps introduce in detail the solution for improving the security of shared data during access by the access process. Correspondingly, in the process of building shared data, corresponding encryption operations need to be performed in advance, which is explained in detail below.
[0211] Specifically, for Figure 6 Step 640 in the provided shared data creation method, i.e., writing the shared data of the dynamic memory type in the process data of the second process into the shared memory, may include:
[0212] Encrypting the shared data of the dynamic memory type in the process data of the second process to obtain encrypted shared data;
[0213] Write the encrypted shared data into the shared memory;
[0214] Then the address offset value is calculated according to the address information of the target pointer and the shared data, and the address offset value is stored in the target pointer, including:
[0215] The shared data address offset value is calculated according to the target pointer and the address information of the encrypted shared data, and the shared data address offset value is stored in the target pointer.
[0216] That is, in the embodiment of the present disclosure, in the process of creating shared data in the shared memory, before writing the shared data of the dynamic memory type in the process data of the second process (i.e., the creating process) into the shared memory, the shared data of the dynamic memory type in the process data of the second process can be encrypted to obtain encrypted shared data. Among them, there can be multiple shared data of the dynamic memory type in the process data of the second process, and here, it can be encrypted for any one of the shared data of the dynamic memory type, that is, the shared data of multiple dynamic memory types are encrypted separately. The encryption of each shared data of the dynamic memory type can be specifically encrypted using a symmetric encryption algorithm.
[0217] Then, after encrypting the shared data of the dynamic memory type in the process data of the second process, the encrypted shared data can be written into the shared memory. Generally, the encrypted shared data obtained by encrypting the shared data of the dynamic memory type is also data of the dynamic memory type, that is, it is also necessary to include a data structure of the target pointer to maintain its storage position in the shared memory. In this way, after writing the encrypted shared data into the shared memory, the address information of the encrypted shared data stored in the shared memory can be obtained, and the address offset value can be calculated based on the address information of the encrypted shared data stored in the shared memory and the address information of the target pointer itself, and then the address offset value is stored in the target pointer. Among them, the specific process of calculating the address offset value based on the address information of the encrypted shared data stored in the shared memory and the address information of the target pointer itself can be to first determine the virtual address corresponding to the address information of the encrypted shared data stored in the shared memory and the second process, and then obtain the storage address of the target pointer itself and the virtual address corresponding to the second process, and then further calculate the difference between the two virtual addresses, so as to obtain the address offset value.
[0218] By adopting the shared data creation method provided by the embodiment of the present disclosure, it is possible to avoid directly storing the plaintext data of the shared data in the shared data, thereby avoiding the access and attack of the shared data by abnormal processes, and ensuring the security of the shared data created in the shared memory.
[0219] In some embodiments, the above shared data creation method may further include:
[0220] Writing the second key data corresponding to the encrypted shared data into the shared memory;
[0221] Calculate the key address offset value according to the target pointer and the address information of the second key data;
[0222] Store the key address offset value into the target pointer.
[0223] After encrypting the shared data created in the shared memory, the second key data used when encrypting the shared data can be further written into the shared memory for storage, and the second key data and the corresponding shared data ciphertext can be written in the same shared memory or in different shared memories. In some embodiments, the second key data can also be written in a non-shared memory area in the memory of the computer device.
[0224] When the second key data is static memory type data, the operating system can directly maintain the storage location and the virtual address corresponding to each access process, and when the access process meets the access rights, the second key data can be obtained. When the second key data is dynamic memory type data, the key address offset value can be calculated based on the address information of the second key data and the address information of the target pointer, and then the key address offset value can be stored in the target pointer.
[0225] That is, in the disclosed embodiment, the target pointer can not only maintain the storage address information of the shared data ciphertext in the shared memory, but also maintain the storage address information of the key for decrypting the shared key ciphertext in the shared memory. This can not only ensure the security of the shared data, but also improve the efficiency of obtaining the key when accessing the shared data, thereby improving the access efficiency to the shared data on the basis of ensuring the security of the shared data.
[0226] In some embodiments, before storing the shared data address offset value and the key address offset value in the target pointer, the shared data address offset value and the key address offset value can be further encrypted, and the access to the shared data in the shared memory needs to be verified by the access right before the ciphertext data of the shared data address offset value and the key address offset value can be decrypted to obtain the shared data address offset value and the key address offset value. In this way, the access of the shared data in the shared memory by abnormal processes can be further avoided, thereby further improving the security of the shared data.
[0227] Step 440: Calculate second address information of the target shared data corresponding to the first process according to the first address information and the address offset value.
[0228] After obtaining the first address information corresponding to the target pointer and the first process in the data structure and the address offset value stored in the target pointer, the second address information corresponding to the target shared data and the first process can be further calculated based on the first address information and the address offset value. As mentioned above, since there are multiple target pointers in the data structure corresponding to the target shared data, each target pointer has the first address information corresponding to the first process, and each target pointer stores the address offset value corresponding to the target pointer. Therefore, here the second address information corresponding to the target shared data and the first process is calculated based on the first address information and the address offset value. Specifically, multiple virtual addresses corresponding to the first process can be calculated based on the first address information corresponding to each target pointer and the first process and the address offset value stored in the corresponding target pointer. These multiple virtual addresses indicate the storage location of the target shared data in the shared memory.
[0229] In some embodiments, calculating second address information corresponding to the target shared data and the first process according to the first address information and the address offset value includes:
[0230] Calculate the sum of the value corresponding to the first address information and the address offset value to obtain a target value;
[0231] The second address information is determined according to the target value.
[0232] In the disclosed embodiment, the second address information corresponding to the target shared data and the first process is calculated based on the first address information and the address offset value. Specifically, the sum of the numerical value corresponding to the first address information and the address offset value is calculated to obtain the target numerical value, and then the second address information can be determined based on the target numerical value. For example, the numerical value corresponding to the first address information corresponding to the first process corresponding to the target pointer is 0x100000, and the address offset value is 0x5000, then the sum of the two is calculated to obtain 0x105000, that is, the numerical value corresponding to the second address information corresponding to the target shared data and the first process is 0x105000. When the data structure corresponding to the target shared data is a container, and the target pointer whose numerical value corresponding to the first address information corresponding to the first process is 0x100000 is the start pointer, it can be determined that the virtual address corresponding to the first memory block in the storage area of the target shared data and the first process is 0x105000. If the target pointer corresponding to the end pointer in the container and the first address information corresponding to the first process have a value of 0x100001, and the address offset value stored in the target pointer corresponding to the end pointer is 0x9999, then the sum of the two is calculated to obtain the target value 0x110000, so it can be determined that the last memory block in the storage area of the target shared data and the virtual address corresponding to the first process is 0x110000. That is, the target shared data is stored in the storage area of the shared memory with the virtual address corresponding to the first process being 0x105000 to 0x110000.
[0233] Next, it will be further illustrated that the data processing method provided by the present disclosure can realize accurate access of the access process to the shared data of the dynamic memory type stored in the shared memory. Fig. 7A As shown, it is a schematic diagram of creating shared data of dynamic memory type in shared memory in the present disclosure. As shown in the figure, the creation process (process 1) creates container B in shared memory, and three target pointers are maintained in container B: target pointer 1 (maintaining the starting position of the storage location pointing to the data), target pointer 2 (maintaining the end position of the storage location pointing to the data) and target pointer 3 (maintaining the position of the last memory block where the data can be stored). Among them, the physical address of the memory block storing target pointer 1 is 0x20000, and the virtual address corresponding to target pointer 1 and process 1 is 0x100000. Process 1 creates shared data of dynamic memory type in shared memory based on container B. The physical address of the first memory block in the area where shared data is stored is 0x25000, and the virtual address corresponding to process 1 is 0x105000. Then, the address offset value (0x105000-0x100000=0x5000) is calculated based on the virtual address 0x105000 corresponding to process 1 and the virtual address 0x100000 corresponding to process 1 of the first memory block of the shared data storage area. Then, the address offset value 0x5000 is stored in target pointer 1. Further, the address offset value corresponding to target pointer 2 and the address offset value corresponding to target pointer 3 can be calculated, and the address offset values corresponding to target pointer 2 and target pointer 3 can be stored in the corresponding target pointers. The address offset value 0x9999 of target pointer 2 and target pointer 3 in the figure is only a schematic representation. Specifically, the address offset value corresponding to target pointer 2 can be calculated based on the virtual address corresponding to process 1 of the last memory block storing shared data and the virtual address corresponding to process 1 and the virtual address corresponding to target pointer 2 and process 1. For example, the virtual address corresponding to target pointer 2 and process 1 is 0x100001, and the virtual address corresponding to the last memory block storing shared data and process 1 is 0x110000. Then, by subtracting these two virtual addresses, we can get the address offset value 0x9999 corresponding to target pointer 2. In this way, dynamic memory type shared data is created in shared memory based on process 1, and the shared data is stored in the storage area from virtual address 0x105000 to virtual address 0x110000 corresponding to process 1.
[0234] like Figure 7B As shown, it is a schematic diagram of accessing shared data of dynamic memory type in shared memory in the present disclosure. As shown in the figure, when the access process (i.e., process 2) needs to access shared data of dynamic memory type stored in shared memory, the storage location of the data structure (i.e., container B) corresponding to the shared data to be accessed can be obtained first in the shared memory, that is, container B is found in the shared memory. Then, the three target pointers contained in container B can be addressed based on process 2 to obtain the virtual addresses corresponding to target pointer 1, target pointer 2, and target pointer 3 and process 2. For example, it is found that target pointer 1 is stored in a memory block with a physical address of 0x20000, and the address operation is performed on target pointer 1 based on process 2, and the virtual address corresponding to target pointer 1 and process 2 is 0x800000. Similarly, the address operation can also be performed on target pointer 2 based on the second process, for example, the virtual address corresponding to target pointer 2 and process 2 is 0x800001.
[0235] Furthermore, the address offset value stored in each target pointer can be obtained. Specifically, the address offset value stored in target pointer 1 can be obtained as 0x5000, and the address offset value stored in target pointer 2 can be obtained as 0x9999. Then, the virtual address corresponding to the first memory block in the storage area of shared data and process 2 can be calculated based on the virtual address corresponding to target pointer 1 and process 2 and the address offset value stored in target pointer 1; and the virtual address corresponding to the last memory block in the storage area of shared data and process 2 can be calculated based on the virtual address corresponding to target pointer 2 and process 2 and the address offset value stored in target pointer 2. Specifically, the virtual address corresponding to target pointer 1 and process 2 is 0x800000, and the address offset value stored in target pointer 1 is 0x5000, and the virtual address corresponding to the first memory block in the storage area of shared data and process 2 is calculated to be 0x805000. Furthermore, according to the virtual address 0x800001 corresponding to target pointer 2 and process 2, and the address offset value 0x9999 stored in target pointer 2, it can be calculated that the virtual address of the last memory block in the storage area of shared data corresponding to process 2 is 0x810000. In this way, it can be determined that the shared data is stored in the storage area of virtual addresses 0x805000 to 0x810000 corresponding to process 2. And according to the corresponding physical address, it can be confirmed that the corresponding shared data can be accurately accessed according to the virtual addresses 0x805000 to 0x810000 corresponding to process 2.
[0236] Step 450: Load the target shared data stored in the storage space indicated by the second address information into the first process.
[0237] After calculating a plurality of second address information corresponding to the first process according to the first address information corresponding to the plurality of target pointers and the first process and the address offset value stored in each target pointer, the storage space of the target shared data in the shared memory can be determined according to the plurality of second address information corresponding to the first process. Then, the target shared data stored in the storage space determined according to the plurality of second address information corresponding to the first process is loaded into the first process for use, thereby realizing the first process's access to the target shared data.
[0238] In summary, the data processing method provided by the present disclosure is adopted, that is, when the first process initiates access to the target shared data in the shared memory, the storage position of the data structure corresponding to the target shared data in the shared memory is obtained; based on the storage position, the first address information corresponding to the target pointer and the first process in the data structure is determined; the address offset value stored in the target pointer is obtained, and the address offset value indicates the address offset between the target pointer and the object pointed to by the target pointer; the second address information corresponding to the target shared data and the first process is calculated according to the first address information and the address offset value; the target shared data stored in the storage space indicated by the second address information is loaded into the first process, so as to realize the first process's access to the target shared data. The method maintains the storage address of dynamic memory type data by using a data structure constructed by a target pointer storing a pointer offset value, so that any access process can accurately determine the storage address of the dynamic memory type data according to the target pointer's own address and the address offset value when accessing the dynamic memory type data, so that the dynamic memory type data can be shared between processes in the shared memory, thereby reducing the system memory overhead when multiple processes are running.
[0239] The embodiments of the present disclosure are described in detail in combination with specific application scenarios.
[0240] like Figure 8 As shown, it is another flow chart of the data processing method provided by the present disclosure. In the embodiment of the present disclosure, the data processing method provided by the present disclosure is applied to the scenario of opening multiple game processes in a terminal as an example to introduce the data processing method provided by the present disclosure in detail. The method specifically includes the following steps:
[0241] Step 801: The computer device obtains a customized shared memory management class and a shared memory allocation class.
[0242] In the embodiments of the present disclosure, the data processing method provided can be specifically applied to the scenario of using STL as a template library for the development and maintenance of applications and operating systems. Because in different operating systems, there are differences in the APIs related to shared processes. Moreover, in some operating systems, there is still a lack of APIs for managing shared memory. In order to ensure that the data processing solution provided by the present disclosure can be applied to any operating system, and to facilitate the management of shared memory by the shared memory allocator and avoid direct connection with the operating system's API when in use, a shared memory management class (ManagedShm) can be pre-defined, which not only adaptively encapsulates the shared process-related APIs that match the operating system of the application, but also encapsulates the function functions of creating, mapping, destroying, querying, acquiring addresses, and reading and writing data at specified locations for shared memory.
[0243] Because the default shared memory allocator in STL uses a pointer of a standard pointer type when constructing a container (in this embodiment, taking the container as an example, it can also be other data structures such as strings) that maintains the storage address of dynamic memory type data. The pointer of the standard pointer type cannot realize the sharing of dynamic memory type data between processes, so it is necessary to define a new pointer type to maintain the storage address of the shared data corresponding to the container in the shared memory, and the new pointer type here can be an offset pointer (OffsetPtr), and the pointer of the standard pointer type is essentially a virtual address, and the virtual address is only valid for one process, and the offset pointer stores the address offset value between its own address and the address of the object pointed to, so that multiple processes can accurately access the object pointed to by the offset pointer according to the address and address offset value of the offset pointer. In order to cooperate with the use of the newly defined offset pointer, it is also necessary to define a shared memory allocation class (ShmAllocator), which can be a memory classifier type that conforms to the allocator_traits of STL. The memory allocation class needs to define the following type names: value_type (value type); pointer (pointer); const_pointer (constant pointer); reference (reference); const_reference (constant reference); size_type (size type) and difference_type (distance type). Since the container will use the pointer types (pointer and const_pointer) in the shared memory allocation class to replace the types of its begin, end and capacity pointers, after defining the type names in the shared memory allocation class, it is necessary to further define pointer and const_pointer as offset pointer types. For the other several type names defined in the shared memory allocation class, you can keep the same processing method as the type names in the memory allocator in STL.
[0244] After defining the above-mentioned shared memory management class, shared memory allocation class and offset pointer, the computer device can construct the shared memory and create shared data in the shared memory based on the above-mentioned definition.
[0245] Step 802: In response to a start instruction for a target game application, the computer device runs a first game process of the target game application.
[0246] A target game application that can be opened multiple times can be loaded in a computer device, and the target game application can specifically be an MMORPG type game application. When receiving a start instruction for the target game, the computer device runs a game process corresponding to the target game application in the operating system. In the disclosed embodiment, before this, the operating system of the computer device may not have run a game process corresponding to the target game application, that is, the game process run here may be the first process run by the target game application in the operating system of the computer device, so the game process is referred to as the first game process.
[0247] When the first game process is run, the complete process data corresponding to the first game process needs to be written into the memory of the computer device. Among them, there are many files such as data tables in the process data corresponding to the first game process, which will not be modified by the user during use in each release version, such as the role configuration table and skill configuration table corresponding to the target game application, etc. These data can also be called read-only data. These read-only data can be put into the shared memory, so when multiple processes of the target game application are run in the computer device, multiple processes can share this data, so as to avoid the repetition of exactly the same data in the memory of the operating system as much as possible, and reduce the consumption of the operating system memory. The read-only data includes static memory type data and dynamic memory type data. Static memory type data, such as int (integer) and float (floating point number), can be directly shared in the shared memory, and dynamic memory type data can be shared between processes by the following method.
[0248] Step 803: The computer device calls the shared memory management class to create a shared memory.
[0249] In the disclosed embodiment, in order to realize the sharing of dynamic memory type data among multiple game processes, when running the first game process, the computer device can call the newly defined shared memory management class to create a shared memory in the memory of the computer device. Specifically, a shared memory creation request can be initiated in the memory of the computer device based on the first game process, and then the computer device can allocate a storage area in the memory of the computer device as a shared memory based on the shared memory creation request.
[0250] Among them, a game process can create a shared memory in the memory of the computer device, or can create multiple shared memories. Here, creating a shared memory is used as an example for explanation. After the shared memory is created, the storage area corresponding to the shared memory and the virtual address corresponding to the first process can be returned, which can specifically include the first address and the last address. In addition, the newly created shared memory can also be named, for example, named the first shared memory, to facilitate the management of the shared memory.
[0251] Step 804: The computer device calls the shared memory allocation class based on the first game process to create a container in the shared memory.
[0252] After the shared memory is created, data can be created in the shared memory, that is, the read-only data of the aforementioned dynamic memory type can be written into the shared memory. First, a container can be created in the shared memory by calling the shared memory allocation class based on the first game process. Specifically, the computer device can first create a container in the shared memory through the first game process, and set a shared memory allocation class based on this shared memory for it. Since the pointer type in the shared memory allocation class is an offset pointer type, the pointer in the constructed container is also a pointer of the offset pointer type. After creating the container, the created container can be further named. For example, it can be named a skill configuration table.
[0253] Step 805: The computer device creates shared data of a dynamic memory type in the process data of the first game process in the shared memory based on the container.
[0254] After creating a container in the shared memory, you can further create corresponding data in the shared memory based on the container, that is, write the read-only data of the dynamic memory type into the shared memory based on the container. The read-only data written into the shared memory can also be called shared data.
[0255] When writing shared data into shared memory, if the container needs to expand its capacity, it can apply for and release memory through the corresponding shared memory allocation class until the shared data is completely written into the shared memory.
[0256] Step 806: The computer device calculates an address offset value according to the virtual address of the shared data and the virtual address of the offset pointer in the container, and stores the address offset value in the offset pointer.
[0257] After writing the shared data into the shared memory, the storage location of the shared data in the shared memory can be obtained, and the storage location can be specifically represented by a virtual address. Here, the virtual address is the virtual address corresponding to the first game process, that is, the operating system maps the physical address of the storage area storing the shared data to the virtual address obtained in the first game process. For example, the storage area of the shared data in the shared memory is represented by the virtual address from 0x105000 to 0x110000.
[0258] In addition, the offset pointers in the container are also stored in the shared memory, and the storage location of each offset pointer and the virtual address corresponding to the first game process can be further determined. Different offset pointers point to different objects. For example, the offset pointer corresponding to the begin pointer points to the first memory block of the shared data in the shared memory, the offset pointer corresponding to the end pointer points to the last memory block of the shared data in the shared memory, and the offset pointer corresponding to the capacity pointer points to the last memory block where the shared data can be stored in the shared memory. Furthermore, the address offset value corresponding to each offset pointer can be calculated based on the virtual address corresponding to each offset pointer and the first game process, and the virtual address corresponding to the object pointed to by each offset pointer and the first game process. Then, the address offset value can be stored in each offset pointer.
[0259] Step 807, in response to the restart instruction of the target game application, the computer device runs the second game process of the target game application, and writes the non-sharable data in the process data of the second game process into the memory.
[0260] As mentioned above, the target game application is an application that can be opened multiple times in a computer device. That is, during the operation of the first game process, the second game process of the target game application can also be run in the computer device in response to the start instruction initiated again to the target game application. When the second game process is run, the process data corresponding to the second game process also needs to be written into the memory of the computer device. However, since the shareable read-only data has been stored in the shared memory when the first game process is run, the shared data in the shared memory can be shared in multiple game processes corresponding to the target game application. Therefore, when the second game process is run, it is only necessary to write the non-shareable data in the process data of the second game process into the storage area corresponding to the second game process in the memory.
[0261] like Fig. 9 , which is a schematic diagram of a plurality of game processes of a target game application being run simultaneously in a computer device in the present application. As shown in the figure, a first game process can be run in a computer device 900 first, and a first user interface 910 corresponding to the first game process can be displayed in a display device of the computer device 900. Then a second game process can be further run in the computer device 900, where the second game process and the first game process are both game processes corresponding to the target game application, and at the same time, a second user interface 920 corresponding to the second game process can be displayed in the display device of the computer device 900. The first user interface 910 and the second user interface 920 can display the same picture of the same viewing angle, or different pictures of different viewing angles.
[0262] Step 808: When any game process of the first game process or the second game process initiates access to the shared data, the computer device obtains the offset pointer in the container and the virtual address corresponding to the game process initiating the access.
[0263] After the first game process and the second game process are simultaneously running in the computer device, if any game process needs to initiate access to the shared data in the shared memory (the game process that initiates access to the shared data can be referred to as the access process here), the container corresponding to the shared data can be found in the memory first. Specifically, the container corresponding to the shared data can be found in the memory of the computer device according to the shared memory name and the container name. After the container corresponding to the shared data is found in the memory, the offset pointer in the container can be fetched based on the access process to obtain the virtual address corresponding to each offset pointer and the access process.
[0264] Step 809, the computer device obtains the address offset value stored in the offset pointer, and calculates the target virtual address of the shared data corresponding to the game process initiating the access based on the address offset value and the offset pointer and the virtual address corresponding to the game process initiating the access.
[0265] After obtaining the virtual address corresponding to each offset pointer and the access process, the computer device can further obtain the address offset value stored in each offset pointer. Then, the virtual address corresponding to the shared data and the access process can be calculated based on the virtual address corresponding to each offset pointer and the access process and the address offset value stored in each offset pointer, which can be referred to as the target virtual address. Since there are multiple offset pointers, the calculated target virtual addresses are also multiple, and the multiple target virtual addresses indicate a storage area in the shared memory.
[0266] In step 810, the computer device loads the storage data corresponding to the target virtual address corresponding to the game process initiating the access into the game process initiating the access, thereby realizing access to the shared data.
[0267] After calculating the target virtual address corresponding to the shared data and the access process, the storage area of the shared data can be determined according to the target virtual address. After determining the storage area of the shared data, the shared data stored in the storage area can be further loaded into the access process, thereby achieving accurate access to the shared data.
[0268] The data processing method provided by the disclosed embodiment is suitable for reducing the memory overhead of a computer device in a scenario where multiple game applications are opened. Specifically, when the first game process of the application is run, the dynamic memory data that can be shared in the process data of the game process is created in the shared memory through a container maintained by an offset pointer. When other processes of the game application are run, it is only necessary to create the non-shareable data in the process data of the process in the memory. The shareable data can be accurately accessed in the shared memory by obtaining the offset pointer address and combining the address offset value stored in the offset pointer. In this way, when multiple game processes are run, only one copy of the shared data needs to be stored in the shared memory. This can greatly reduce the memory overhead of the computer device when multiple processes are running. In addition, since the memory overhead of the computer device is reduced, the low memory usage can also improve the operating efficiency of the running process.
[0269] Assuming that the memory occupied by the sharable part of the game process is Ms, and the memory occupied by the non-sharable part is Mn, then the memory occupied by a single process is Ms+Mn. If the data processing method provided in this application is not used to create shared data in shared memory, the total memory consumption when opening K game processes is K*(Ms+Mn); if the data processing method provided in this application is used, the total memory consumption when opening K game processes is K*Mn+Ms, that is, a total of (K-1)*Ms of memory can be saved. Assuming that 600MB (megabytes) of data in the game process is shared, then three openings can save 1.2GB (gigabytes).
[0270] Description of the apparatus and device of the present disclosure
[0271] It is to be understood that, although the steps in the above-mentioned flowcharts are sequentially displayed according to the characterization of arrows, these steps are not necessarily executed in sequence according to the order of arrow characterization. Unless there is a clear description in the present embodiment, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the above-mentioned flowcharts can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the steps or stages in other steps.
[0272] It should be noted that in each specific embodiment of the present disclosure, when it comes to the need to perform relevant processing based on data related to the characteristics of the target object such as the target object attribute information or attribute information set, the permission or consent of the target object will be obtained first, and the collection, use and processing of these data will comply with the relevant laws, regulations and standards of the relevant countries and regions. In addition, when the embodiment of the present application needs to obtain the attribute information of the target object, the separate permission or separate consent of the target object will be obtained through a pop-up window or jump to a confirmation page. After clearly obtaining the separate permission or separate consent of the target object, the necessary target object-related data for enabling the normal operation of the embodiment of the present application will be obtained.
[0273] Fig.10 The data processing device 1000 provided in the embodiment of the present disclosure is a schematic diagram of the structure of the data processing device 1000. The data processing device 1000 includes:
[0274] A first acquisition unit 1010 is used to acquire a storage location of a data structure corresponding to the target shared data in the shared memory when the first process initiates access to the target shared data in the shared memory;
[0275] A determining unit 1020, configured to determine first address information corresponding to a target pointer in a data structure and a first process based on a storage location;
[0276] A second acquisition unit 1030 is used to acquire an address offset value stored in the target pointer, where the address offset value indicates an address offset between the target pointer and the object pointed to by the target pointer;
[0277] A calculation unit 1040, configured to calculate second address information of the target shared data corresponding to the first process according to the first address information and the address offset value;
[0278] The loading unit 1050 is used to load the target shared data stored in the storage space indicated by the second address information into the first process, so as to enable the first process to access the target shared data.
[0279] Optionally, the computing unit 1040 includes:
[0280] A first calculation subunit, used to calculate the sum of a value corresponding to the first address information and an address offset value to obtain a target value;
[0281] The first determining subunit is used to determine the second address information according to the target value.
[0282] Optionally, the second obtaining unit 1030 includes:
[0283] A first acquisition subunit, used to acquire the ciphertext data stored in the target pointer;
[0284] The decryption subunit is used to decrypt the ciphertext data to obtain the address offset value when it is detected that the first process has access rights to the target shared data.
[0285] Optionally, when the decryption subunit includes:
[0286] A first acquisition module, used to acquire application information corresponding to the first process;
[0287] The decryption module is used to decrypt the ciphertext data to obtain the address offset value when it is determined that the application indicated by the application information is a preset application.
[0288] Optionally, the decryption module includes:
[0289] An acquisition submodule, configured to acquire first key data matching the preset application when it is determined that the application indicated by the application information is a preset application;
[0290] The decryption submodule is used to decrypt the ciphertext data according to the first key data to obtain the address offset value.
[0291] Optionally, the determining unit 1020 includes:
[0292] A second determining subunit is used to determine third address information corresponding to the first memory unit in the storage area corresponding to the storage location and the first process;
[0293] The third determining subunit is used to determine the first address information corresponding to the target pointer and the first process according to the third address information and the storage position of the target pointer associated with the target shared data in the data structure.
[0294] Optionally, the first acquiring unit 1010 includes:
[0295] A second acquisition subunit is used to acquire a structure tag of a data structure corresponding to the target shared data;
[0296] The fourth determining subunit is used to determine the storage location of the data structure in the shared memory according to the structure tag.
[0297] Optionally, the structure tag includes a shared memory primary tag and a structure secondary tag, and the fourth determination subunit includes:
[0298] A first determination module, used for determining a target sub-shared memory in the shared memory according to a shared memory primary tag;
[0299] The second determination module is used to determine the storage location of the data structure in the target sub-shared memory according to the secondary tag of the structure.
[0300] Optionally, the data processing device 1000 further includes:
[0301] A running subunit, used for running a second process, where the second process is associated with the same application as the first process;
[0302] A first creation subunit, used to create a shared memory in the memory based on the second process;
[0303] A second creation subunit is used to create a data structure containing a target pointer in the shared memory;
[0304] A first writing subunit is used to write the shared data of the dynamic memory type in the process data of the second process into the shared memory based on the data structure containing the target pointer;
[0305] The second calculation subunit is used to calculate the address offset value according to the target pointer and the address information of the shared data, and store the address offset value in the target pointer.
[0306] Optionally, the second computing subunit includes:
[0307] A second acquisition module is used to acquire fourth address information corresponding to the target pointer and the second process, and to acquire fifth address information corresponding to the shared data and the second process;
[0308] The calculation module is used to calculate the difference between the value corresponding to the fifth address information and the value corresponding to the fourth address information to obtain the address offset value.
[0309] Optionally, the data processing device 1000 further includes:
[0310] an identification subunit, used to identify read-only data and global data in the process data of the second process, where the global data refers to data whose changes will be applied in real time to all processes related to the application;
[0311] The fifth determining subunit is used to determine the shared data according to the read-only data and the global data.
[0312] Optionally, the first creation subunit includes:
[0313] A calling module, used for calling a shared memory management class encapsulating a preset operating system application interface based on a second process;
[0314] A creation module is used to create shared memory according to the shared memory creation function in the shared memory management class.
[0315] Optionally, the data processing device 1000 further includes:
[0316] A query subunit, configured to respond to a query instruction for a shared memory in the memory space and search for a corresponding shared memory according to a shared memory query function in a shared memory management class;
[0317] The release subunit is used to release the shared memory according to the shared memory destruction function in the shared memory management class in response to the release instruction of the shared memory.
[0318] Optionally, write a subunit, including:
[0319] An encryption module, used for encrypting the shared data in the process data of the second process to obtain encrypted shared data;
[0320] A writing module, used to write encrypted shared data into shared memory;
[0321] The second computing subunit is further configured to:
[0322] The shared data address offset value is calculated according to the target pointer and the address information of the encrypted shared data, and the shared data address offset value is stored in the target pointer.
[0323] Optionally, the data processing device 1000 further includes:
[0324] A second writing subunit, used for writing second key data corresponding to the encrypted shared data into the shared memory;
[0325] A third calculation subunit, used for calculating the key address offset value according to the target pointer and the address information of the second key data;
[0326] The storage subunit is used to store the key address offset value into the target pointer.
[0327] Optionally, the second creation subunit includes:
[0328] A third acquisition module is used to acquire a shared memory allocation class that defines a target pointer type;
[0329] A construction module is used to construct a data structure based on the shared memory allocation class to obtain a data structure containing a target pointer.
[0330] Reference Fig.11 , Fig.11 The structural block diagram of the terminal 140 for implementing the data processing method of the embodiment of the present disclosure is as follows: the terminal 140 includes: a radio frequency (RF) circuit 1110, a memory 1115, an input unit 1130, a display unit 1140, a sensor 1150, an audio circuit 1160, a wireless fidelity (WiFi) module 1170, a processor 1180, and a power supply 1190. Those skilled in the art can understand that Fig.11 The structure of the terminal 140 shown does not constitute a limitation on a mobile phone or a computer, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0331] The RF circuit 1110 may be used for receiving and sending signals during information transmission or communication. In particular, after receiving downlink information from the base station, the information is sent to the processor 1180 for processing. In addition, the uplink data is sent to the base station.
[0332] The memory 1115 may be used to store software programs and modules. The processor 1180 executes various functional applications and data processing of the terminal by running the software programs and modules stored in the memory 1115 .
[0333] The input unit 1130 may be used to receive input digital or character information and generate key signal input related to the terminal's settings and function control. Specifically, the input unit 1130 may include a touch panel 1131 and other input devices 1132 .
[0334] The display unit 1140 may be used to display input information or provided information and various menus of the terminal. The display unit 1140 may include a display panel 1141 .
[0335] The audio circuit 1160 , the speaker 1161 , and the microphone 1162 may provide an audio interface.
[0336] In this embodiment, the processor 1180 included in the terminal 140 can execute the data processing method of the previous embodiment.
[0337] The terminal 140 of the embodiment of the present disclosure includes but is not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc. The embodiment of the present invention can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, etc.
[0338] Fig.12 A block diagram of the structure of a portion of a server 110 for implementing a data processing method according to an embodiment of the present disclosure. The server 110 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPUs) 1222 (e.g., one or more processors) and a storage device 1232, and one or more storage media 1230 (e.g., one or more mass storage devices) storing application programs 1242 or data 1244. Among them, the storage device 1232 and the storage medium 1230 may be temporary storage or permanent storage. The program stored in the storage medium 1230 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server 110. Furthermore, the central processing unit 1222 may be configured to communicate with the storage medium 1230 and execute a series of instruction operations in the storage medium 1230 on the server 110.
[0339] The server 110 may also include one or more power supplies 1226, one or more wired or wireless network interfaces 1250, one or more input and output interfaces 1258, and / or one or more operating systems 1241, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0340] The central processor 1222 in the server 110 may be used to execute the data processing method of the embodiment of the present disclosure.
[0341] The embodiments of the present disclosure further provide a computer-readable storage medium, which is used to store program codes, and the program codes are used to execute the data processing methods of the aforementioned embodiments.
[0342] The embodiment of the present disclosure also provides a computer program product, which includes a computer program. A processor of a computer device reads and executes the computer program, so that the computer device executes and implements the above-mentioned data processing method.
[0343] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "comprises" and "comprising" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0344] It should be understood that in the present disclosure, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or plural.
[0345] It should be understood that in the description of the embodiments of the present disclosure, the meaning of multiple (or multiple items) is more than two, greater than, less than, exceed, etc. are understood to not include the number, and above, below, within, etc. are understood to include the number.
[0346] In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0347] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0348] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0349] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program codes.
[0350] It should also be understood that the various implementations provided in the embodiments of the present disclosure can be combined arbitrarily to achieve different technical effects.
[0351] The above is a specific description of the implementation methods of the present disclosure, but the present disclosure is not limited to the above implementation methods. Technical personnel familiar with the art can also make various equivalent modifications or substitutions without violating the spirit of the present disclosure. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present disclosure.< / t> < / t>
Claims
1. A data processing method, characterized in that: The method comprises: When the first process initiates access to the target shared data in the shared memory, obtaining the storage location of the data structure corresponding to the target shared data in the shared memory; Determine first address information corresponding to the target pointer in the data structure and the first process based on the storage location; Obtaining an address offset value stored in the target pointer, the address offset value indicating an address offset between the target pointer and an object pointed to by the target pointer; Calculate second address information of the target shared data corresponding to the first process according to the first address information and the address offset value; The target shared data stored in the storage space indicated by the second address information is loaded into the first process, so that the first process can access the target shared data.
2. The method according to claim 1, characterized in that: When the first process initiates access to the target shared data in the shared memory, before obtaining the storage location of the data structure corresponding to the target shared data in the shared memory, the method further includes: Running a second process, where the second process is associated with the same application as the first process; Creating a shared memory in the memory based on the second process; Creating a data structure containing a target pointer in the shared memory; Writing the shared data of the dynamic memory type in the process data of the second process into the shared memory based on the data structure including the target pointer; An address offset value is calculated according to the target pointer and the address information of the shared data, and the address offset value is stored in the target pointer.
3. The method according to claim 2, characterized in that The creating a shared memory in the memory based on the second process includes: Based on the second process, a shared memory management class encapsulating a preset operating system application interface is called; Create a shared memory according to the shared memory creation function in the shared memory management class.
4. The method according to claim 2, characterized in that: The step of creating a data structure containing a target pointer in the shared memory comprises: Get the shared memory allocation class that defines the target pointer type; A data structure is constructed based on the shared memory allocation class to obtain a data structure including a target pointer.
5. The method according to claim 2, characterized in that: Before writing the shared data in the process data of the second process into the data structure, the method further includes: Identifying read-only data and global data in the process data of the second process, wherein the global data is data whose changes are applied in real time to all processes related to the application; Shared data is determined according to the read-only data and the global data.
6. The method according to claim 2, characterized in that Writing the shared data of the dynamic memory type in the process data of the second process into the shared memory includes: Encrypting the shared data of the dynamic memory type in the process data of the second process to obtain encrypted shared data; Writing the encrypted shared data into the shared memory; The calculating the address offset value according to the target pointer and the address information of the shared data, and storing the address offset value in the target pointer, comprises: The shared data address offset value is calculated according to the target pointer and the address information of the encrypted shared data, and the shared data address offset value is stored in the target pointer.
7. The method according to claim 6, characterized in that The method further comprises: Writing the second key data corresponding to the encrypted shared data into the shared memory; Calculate the key address offset value according to the target pointer and the address information of the second key data; The key address offset value is stored in the target pointer.
8. The method according to claim 1, characterized in that The obtaining the address offset value stored in the target pointer includes: Obtaining the ciphertext data stored in the target pointer; When it is detected that the first process has access rights to the target shared data, the ciphertext data is decrypted to obtain an address offset value.
9. The method according to claim 8, characterized in that When it is detected that the first process has access rights to the target shared data, decrypting the ciphertext data to obtain the address offset value includes: Obtaining application information corresponding to the first process; When it is determined that the application indicated by the application information is a preset application, the ciphertext data is decrypted to obtain an address offset value.
10. The method according to claim 1, characterized in that The obtaining the storage location of the data structure corresponding to the target shared data in the shared memory includes: Obtaining a structure tag of a data structure corresponding to the target shared data; The storage location of the data structure in the shared memory is determined according to the structure tag.
11. The method according to claim 10, characterized in that The structure tag includes a shared memory primary tag and a structure secondary tag, and determining the storage location of the data structure in the shared memory according to the structure tag includes: Determine a target sub-shared memory in the shared memory according to the shared memory primary tag; The storage location of the data structure is determined in the target sub-shared memory according to the secondary tag of the structure.
12. A data processing device, characterized in that: The device comprises: A first acquisition unit, configured to acquire a storage location of a data structure corresponding to the target shared data in the shared memory when the first process initiates access to the target shared data in the shared memory; a determining unit, configured to determine, based on the storage location, first address information corresponding to a target pointer in the data structure and the first process; a second acquiring unit, configured to acquire an address offset value stored in the target pointer, wherein the address offset value indicates an address offset between the target pointer and the object pointed to by the target pointer; a calculating unit, configured to calculate second address information corresponding to the target shared data and the first process according to the first address information and the address offset value; A loading unit is used to load the target shared data stored in the storage space indicated by the second address information into the first process, so as to enable the first process to access the target shared data.
13. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the data processing method according to any one of claims 1 to 11 is implemented.
14. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the data processing method according to any one of claims 1 to 11 is implemented.
15. A computer program product, comprising a computer program, wherein the computer program is read and executed by a processor of a computer device, so that the computer device executes the data processing method according to any one of claims 1 to 11.
Citation Information
Cited By
Data processing method and device, computer equipment and computer readable storage medium
CN119987670A
Data processing method and device, computer equipment and computer readable storage medium
CN119987670B
