Data management method and system based on memory and electronic equipment
By setting parameter information and data memory units in memory and managing data based on parameter information, the overflow, overwrite and parsing errors caused by mismatch in shared memory are solved, and stable access and secure management of memory data is achieved.
Patent Information
- Application Number
- CN202411573499.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-02-07
AI Technical Summary
In shared memory technology, due to the rapid update and iteration of the memory data structure version, it is easy to cause the written memory data format to mismatch the format of the shared memory area, resulting in overflow, illegal overwriting and data parsing errors in the memory data area.
By setting parameter information memory unit and data memory unit in memory, obtaining parameter information and managing data based on them, ensuring that exceptions are avoided during data writing, exporting and access. The specific steps include receiving an external data write request, verifying the identification information and parameter information, and if passed, writing the data into memory based on the parameter information.
It effectively avoids memory data area overflow, illegal overwrite and data parsing errors caused by data format mismatch, and provides security guarantees for daily application of memory data.
Smart Images

Figure CN119396743A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a memory-based data management method, system and electronic device. Background Art
[0002] When using shared memory technology, due to the rapid iteration of the memory data structure version, it is easy for the format of the written memory data to not match the format of the shared memory area. For example, the length of the written memory data exceeds the size of the shared memory area, which easily causes overflow and illegal overwriting of the shared memory data area. Or when the memory data structure version is inconsistent, it will cause memory data parsing errors. Therefore, how to achieve stable memory access, writing and exporting is a technical problem that technicians in this field need to solve urgently. Summary of the invention
[0003] The purpose of this application is to provide a memory-based data management method, system and electronic device, which manages data through parameter information and data memory units to avoid memory anomalies during application processes such as writing, exporting and accessing.
[0004] In order to solve the above technical problems, the present application provides a data management method based on memory, wherein the memory includes a parameter information memory unit and a data memory unit, and the data management method includes:
[0005] Acquire parameter information in the parameter information memory unit, where the parameter information represents characteristic information of the data memory unit;
[0006] The data is managed according to the parameter information and the data memory unit.
[0007] Optionally, managing the data according to the parameter information and the data memory unit includes:
[0008] receiving a request to write external data into the memory;
[0009] Verifying the identification information of the external data and the parameter information;
[0010] If the verification fails, the writing is terminated;
[0011] If the verification is successful, the external data is written into the memory according to the parameter information and the data memory unit.
[0012] Optionally, writing the external data into the memory according to the parameter information and the data memory unit includes:
[0013] Performing an address offset in the write address according to the size of the parameter information to obtain a first target address in the data memory unit;
[0014] The data is written into the data memory unit according to the first target address.
[0015] Optionally, before verifying the identification information and the parameter information of the external data, the step further includes:
[0016] Verifying the external data;
[0017] If the verification fails, the writing is terminated;
[0018] If the verification passes, the identification information of the external data and the parameter information are verified again.
[0019] Optionally, the data is located in the data memory unit, and managing the data according to the parameter information and the data memory unit includes:
[0020] receiving a request for accessing the memory;
[0021] verifying the access request based on the parameter information;
[0022] If the verification fails, the access is terminated;
[0023] If the verification passes, the access request is responded to according to the parameter information and the data memory unit.
[0024] Optionally, responding to the access request according to the parameter information and the data memory unit includes:
[0025] Performing an address offset in the access address according to the size of the parameter information to obtain a second target address of the data in the data memory unit;
[0026] The access request is responded to according to the second target address.
[0027] Optionally, the data is located in the data memory unit, and managing the data according to the parameter information and the data memory unit includes:
[0028] receiving a request to read the data;
[0029] Reading out the data and part or all of the parameter information according to the read request to obtain read data;
[0030] Verifying the read data according to the parameter information;
[0031] If the verification is passed, the read data is read out and saved;
[0032] If the verification fails, the read request is terminated.
[0033] Optionally, before managing the data according to the parameter information and the data memory unit, the method further includes:
[0034] Accessing the memory;
[0035] Verifying the access identification information and the parameter information;
[0036] If the verification fails, the access is terminated;
[0037] If the verification passes, access is allowed.
[0038] The present application also provides a memory-based data management system, wherein the memory includes a parameter information memory unit and a data memory unit, and the data management system includes:
[0039] A parameter information acquisition module, used to acquire parameter information in the parameter information memory unit, wherein the parameter information represents characteristic information of the data memory unit;
[0040] A data management module is used to manage the data according to the parameter information and the data memory unit.
[0041] The present application also provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of the above-mentioned method when calling the computer program in the memory.
[0042] The present application provides a memory-based data management method, wherein the memory includes a parameter information memory unit and a data memory unit, and the data management method includes: obtaining parameter information in the parameter information memory unit, wherein the parameter information represents characteristic information of the data memory unit; and managing the data according to the parameter information and the data memory unit.
[0043] When executing memory data management, the present application first obtains the parameter information in the parameter information memory unit, and then manages the memory data according to the characteristic information of the data memory unit represented by the parameter information and the data memory unit, which can avoid overflow, illegal overwrite and data parsing errors of the memory data area caused by data format mismatch between external data and memory, and provide security guarantee for the daily application of memory data.
[0044] The present application also provides a memory-based data management system and electronic device, which have the above-mentioned beneficial effects and will not be described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0046] Figure 1 A flowchart of a memory-based data management method provided in an embodiment of the present application;
[0047] Figure 2 A schematic diagram of the first memory structure provided in an embodiment of the present application;
[0048] Figure 3 A schematic diagram of a second memory structure provided in an embodiment of the present application;
[0049] Figure 4 A flowchart of another memory-based data management method provided in an embodiment of the present application;
[0050] Figure 5 A schematic diagram of the structure of a system for writing memory data provided in an embodiment of the present application;
[0051] Figure 6 A structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0053] The object information involved in this application, including but not limited to the object device information, object personal information, etc., and data, including but not limited to data used for analysis, stored data, displayed data, etc., are all information and data authorized by the object or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the laws, regulations and standards of relevant countries and regions.
[0054] See also Figure 1 , Figure 1 A memory-based data management method is provided in an embodiment of the present application, wherein the memory includes a parameter information memory unit and a data memory unit, and the data management method includes:
[0055] S101: Acquire parameter information in the parameter information memory unit, where the parameter information represents characteristic information of the data memory unit;
[0056] S102: Manage the data according to the parameter information and the data memory unit.
[0057] This embodiment can be applied to process application scenarios in an operating system, particularly shared memory applications. Shared memory refers to a method for sharing and transferring data between two or more processes, which allows unrelated processes to access the same shared memory. A process can connect the same shared memory to its own address space, so that multiple processes can access addresses in the shared memory in the same way as they access their own memory. UNIX shared memory is an efficient inter-process communication method that allows multiple processes to directly access the same memory area.
[0058] The data management method provided in this embodiment uses a memory that includes at least a data memory unit and a parameter information memory unit, which are used to store parameter information and data (i.e., memory data), respectively. The management process described in this application includes, but is not limited to, various application methods of memory, such as access, reading, writing, and reading out. In various management processes, it is necessary to obtain the parameter information in the parameter information memory unit, so as to perform corresponding data management according to the characteristic information of the data memory unit represented by the parameter information.
[0059] The information type and specific content contained in the parameter information are not limited here. In a feasible implementation, the parameter information at least includes the memory data structure version information version and the memory size information length, as well as at least one of the memory module module, memory name name, and content verification information, or any combination thereof. There is no limitation on the memory verification method used, including but not limited to CRC (Cyclic Redundancy Check) and hash value verification.
[0060] The memory data structure version information version can identify the data structure version of the current memory, that is, the version of the data stored in the data memory unit. In the actual application process, the change of the bit length of different data may generate a new data structure version. For example, in version 1.0, image data is stored in 128-bit bytes, and in version 2.0, it can be stored in 256-bit bytes. If the data structure version is not verified at this time, it is easy to cause data parsing errors. The memory size length can record the size of the currently applied shared memory, which includes the parameter information memory unit length and the data memory unit length. If the length of the imported data exceeds the length of the data memory unit, it will cause overflow and illegal overwriting of the data memory unit. The module to which the memory belongs module is the module information to which the memory belongs. Through the combination of this information and other information, the unique ID can be determined in the operating system. Multiple processes can initiate access requests to the same memory block based on the unique ID. The memory name name stores the name of the current shared memory, which is convenient for output to the terminal and file for identification. Because the parameter information is also part of the shared memory and will be shared and accessed between multiple processes, it is necessary to ensure the correctness of the memory data through content verification information.
[0061] In addition, the parameter information in the parameter information memory unit is not specifically limited. In a feasible implementation, the address information of the parameter information memory unit can be further determined based on the address offset of the parameter information memory unit, and the parameter information in the parameter information memory unit can be obtained based on the address information. In the embodiments of the present application, all memories include a parameter information memory unit for storing the parameter information of the memory.
[0062] It should be noted that the embodiment of the present application only requires that the parameter information memory unit is located in the shared memory, and does not limit its specific address. Figure 2 As shown, Figure 2 A schematic diagram of the first memory data structure provided in an embodiment of the present application. Therefore, it is necessary to determine the parameter information memory unit according to the address offset of the parameter information memory unit. The address offset of the parameter information memory unit belongs to the range address, which is used to indicate the start and end addresses and the end address of the parameter information memory unit in the memory. For example, the address offset may include two offset information, which are used to indicate the position of the start address of the parameter information memory unit relative to the first address of the memory, and the position of the end address relative to the first address of the memory. Or it may include an offset information (the position information of the start address of the parameter information memory unit relative to the first address of the memory) and the length of the parameter information memory unit.
[0063] See also Figure 3 , Figure 3 The second memory data structure diagram provided in the embodiment of the present application, in a preferred implementation mode, the parameter information memory unit length can be set in the memory header, that is, Figure 3 As shown, at this time, the address offset of the parameter information memory unit only needs to include the end address of the parameter information memory unit or the length of the parameter information memory unit, and it is also convenient to quickly read the parameter information of the memory, which is beneficial to improving the writing efficiency of the memory data.
[0064] When executing memory data management, the embodiment of the present application first obtains the parameter information in the parameter information memory unit, and then manages the memory data according to the characteristic information of the data memory unit represented by the parameter information. This can avoid overflow, illegal overwrite and data parsing errors in the memory data area caused by data format mismatch between external data and memory, and provide security guarantee for daily application of memory data.
[0065] The following describes the common memory data management process:
[0066] When writing external data to memory, the following steps may be included:
[0067] Step 1: receiving a request to write external data into the memory;
[0068] Step 2: Verify the identification information of the external data and the parameter information; if the verification fails, proceed to step 3; if the verification succeeds, proceed to step 4;
[0069] Step 3: Terminate writing;
[0070] Step 4: Write the external data into the memory according to the parameter information and the data memory unit.
[0071] When writing external data to the memory, the identification information of the external data can be determined, and the parameter information of the memory can be determined. The external data can be exported in advance, for example, it can be exported in advance as a local binary file, and the identification information can be obtained from the local binary file of the external data accordingly. In addition, the external data can also be memory data requested by other processes.
[0072] The identification information can be used to verify the parameter information of the memory, or the identification information can be verified separately. Verification of the identification information and the parameter information of the memory is used to ensure whether the external data can be written to the memory, while separate verification is used to verify the legality of the request to write the external data to the memory, such as whether the write permission is available, whether the request initiator is legal, etc. It can be seen that the identification information can also include other types of information not included in the parameter information, such as write permission information, and can also include information used for verification with the parameter information of the memory, such as the data structure version information of the external data and the external data size information (i.e., the memory size required to store the external data).
[0073] The verification method includes but is not limited to comparing the external data size with the memory size recorded in the parameter information to avoid overflow and illegal overwriting of the data area caused by the external data size being larger than the memory size.
[0074] In this embodiment, the identification information and parameter information are divided into characteristic information characterizing external data and memory, and belong to the parameter information memory unit of external data and memory respectively, and the external data can be written into the memory only after the verification is successful. It is easy to understand that the corresponding verification method can be adopted according to the information type of the parameter information, and it is not limited to examples one by one here.
[0075] Taking the example that the parameter information at least includes the memory data structure version information and the memory size information, and the information type of the identification information at least includes the external data structure version and the external data size, the specific matching process when verifying with the identification information can be as follows:
[0076] Determine whether the external data structure version in the identification information is consistent with the memory data structure version in the parameter information;
[0077] If they are consistent, and the external data size in the identification information satisfies the memory size in the parameter information, it can be confirmed that the parameter information and the identification information are successfully verified.
[0078] First, determine whether the external data structure version is consistent with the memory data structure version, and then determine whether the memory size of the memory can meet the memory size information required to store external data recorded in the identification information (i.e., the external data size). Here, the memory size is determined based on the proposed memory length when applying for memory, which is usually not less than the sum of the parameter information memory unit length and the data memory unit length.
[0079] In addition, if there is compatibility between the memory data structure versions in the parameter information, such as upward compatibility or downward compatibility, it is necessary to compare the version number sequence of the external data structure version in the identification information and the memory data structure version in the parameter information to determine which data structure version comes first, and determine whether they match based on the compatibility type of the memory data structure version.
[0080] When the identification information and parameter information are successfully verified, the external data is written to the memory. In the specific writing process, if there is memory data in the data memory unit of the memory, the memory data can be updated or the memory data can be overwritten according to the default setting or user selection. Regardless of whether the memory data is updated or overwritten, it will not affect the technical effect produced by this embodiment.
[0081] When writing memory data, the embodiment of the present application first obtains the identification information of the external data and verifies it with the parameter information in the memory. The external data is written to the memory only after the verification is successful. This can avoid overflow of the memory data area, illegal overwrite and data parsing errors caused by data format mismatch between the external data and the memory, and provide security guarantees for the sharing of memory data.
[0082] It is easy to understand that before writing external data to the memory, it is also necessary to determine the address of the data memory unit. In a feasible implementation, the address offset can be performed in the write address according to the size of the parameter information to obtain the first target address in the data memory unit, so that the external data is written to the data memory unit according to the first target address. The write address is the starting address of the memory, and the parameter information memory unit can be located at any position in the memory, so it is necessary to add an address offset to determine the actual writable first target address in the data memory unit and the length of the data memory unit, and write the external data according to the first target address.
[0083] On this basis, in order to ensure that the data in the memory is correct, the external data can be verified before the identification information and parameter information of the external data are verified. If the verification fails, the writing is terminated. If the verification passes, the steps of verifying the identification information and parameter information of the external data in the above text are executed. By verifying the data in the memory, it is ensured that the data in the memory has not been tampered with or the parameter information has changed, so as to avoid the impact of external data writing due to changes in the data in the memory.
[0084] The corresponding complete implementation process is as follows Figure 4 As shown, Figure 4 A flowchart of another memory-based data management method provided in an embodiment of the present application:
[0085] S201: receiving a request to write external data into the memory;
[0086] S202: Verify the external data to determine whether the verification is passed; if not, proceed to S203; if so, proceed to S204;
[0087] S203: Terminate writing;
[0088] S204: verify the identification information of the external data and the parameter information; determine whether the verification is passed; if not, proceed to S203; if yes, proceed to S205;
[0089] S205: performing an address shift in the write address according to the size of the parameter information to obtain a first target address in the data memory unit, and writing the data into the data memory unit according to the first target address.
[0090] It should be noted that, when receiving a request to write external data into the memory, the identification information of the external data and the parameter information are verified. If the verification fails, the writing is terminated. If the verification succeeds, the external data is written into the memory according to the parameter information and the data memory unit, and the parameter information is updated according to the identification information. That is, when the memory data structure version in the parameter information has compatibility, such as upward compatibility or downward compatibility, the parameter information needs to be updated after the external data is imported; for example, when the data structure version of the data memory unit represented by the parameter information has downward compatibility, the data structure version of the current data memory unit is version 1.0, and the external data is version 2.0. After the external data is imported, if all the original memory data in the memory is replaced, the information representing the data structure version in the parameter information should be updated to version 2.0. If the parameter information is not updated, the subsequent import of external data of version 1.0 will not be able to merge with the data of the existing data memory unit, so it is necessary to update the parameter information.
[0091] On the basis of the above-mentioned embodiments, when managing data according to parameter information and data memory units, access requests to memory can also be managed. Specifically, a request to access memory can be received, and the access request can be verified based on parameter information; if the verification fails, the access is terminated; if the verification passes, the access request is responded to according to the data memory unit; it should be noted that if the verification passes, the request can be responded to, and there is no limitation on how the external access is performed, for example, the external can only view the data in the data memory unit or the external can further read the data in the data memory unit.
[0092] If the verification is passed, the address of the data memory unit can be obtained by adding the address offset of the parameter information memory unit to the memory address mapped to the initiating process, thereby responding to the access request according to the address of the data memory unit. Specifically, the address offset can be performed in the access address according to the size of the parameter information to obtain the second target address of the data in the data memory unit, and the access request can be responded to according to the second target address. After that, the memory can allow the initiator of the access request to directly access the memory according to the second target address to realize memory data sharing. For example, the memory can allow the initiator of the access request to directly access the memory according to the second target address and read the data.
[0093] If the check fails, it means that the access request may be illegal or there is an error. For example, the access address range contained in the access request exceeds the memory size in the parameter information. Obviously, the object actually accessed by the access request does not exist in the memory, indicating that there is an error in the access request. At this time, the access can be terminated, and an error message can also be generated.
[0094] This embodiment further describes the management of memory access requests, which can verify the access request based on parameter information to ensure the data security of the memory and avoid illegal or invalid access. If the verification passes, the initiating process can share the memory, which helps to achieve efficient communication between processes.
[0095] On the basis of the above embodiment, when managing the data according to the parameter information and the data memory unit, the reading of the data in the memory can also be managed. Specifically, the following steps may be included:
[0096] The first step is to receive a read request for the data;
[0097] Step 2: Read out the data and part or all of the parameter information according to the read request to obtain read data;
[0098] Step 3: Verify the read data according to the parameter information; if the verification passes, proceed to step 4; if the verification fails, proceed to step 5;
[0099] Step 4: reading and saving the read data;
[0100] Step 5: terminating the read request.
[0101] When a read request for memory data is detected, part or all of the data and parameter information can be read out according to the requirements of the read request. It can be read directly to another memory space or read as a local file, such as a local binary file.
[0102] When the read data is verified according to the parameter information, it can be used to verify whether the actual read data is consistent with the read data range corresponding to the read request, avoid over-reading or under-reading, and verify whether the read data meets the characteristics recorded in the parameter information or verify whether the read data is legal. For example, ensure that the read data size should not be greater than the memory size in the parameter information, and that the data structure of the read data should match the memory data structure version information recorded in the parameter information.
[0103] In addition, based on the above embodiment, when reading out a local file, in order to avoid tampering of the local file and causing losses when writing the local file to other memories, content verification can be performed on the reading process and the writing process respectively.
[0104] The first step is to obtain a first content verification result of the read data when outputting the read data as a local file;
[0105] Step 2: When writing the read data into the memory, the local file is verified to obtain a second content verification result;
[0106] Step 3: If the comparison between the first content verification result and the second content verification result is passed, the local file is written into the memory.
[0107] Specifically, the memory may be any memory or a shared memory. If the first content verification result and the second content verification result are compared, it is confirmed that the local file content is the same. If the first content verification result and the second content verification result are compared, it is confirmed that there is an abnormality in the local file, and the writing of the local file to the memory is terminated.
[0108] When the read data is output as a local file, the parameter information and data in the external data can be content verified to obtain a first content verification result; the parameter information, the data in the data memory unit and the first content verification result are exported to generate a local binary file.
[0109] From this, it can be seen that the first content verification result is the benchmark data for content verification when writing local files to other memories, and is used to compare with the second content verification result to determine whether the read data has been tampered with after being read, thereby ensuring the data security when the read data is reused.
[0110] It should be noted that in order to further improve the security of memory access and data management, before managing data according to parameter information and data memory units, it is also necessary to verify whether the memory itself is suitable for further external access or data management by accessing and verifying the memory in advance. The specific steps are as follows:
[0111] Access to memory;
[0112] Verify the access identification information and parameter information;
[0113] If the verification fails, the access is terminated;
[0114] If the verification passes, access is allowed.
[0115] From this, it can be seen that by using the identification information carried in the access request and the parameter information of the memory to perform verification, if the verification fails, the access is terminated and an error is reported to the user. If the verification passes, access is allowed, and the target address information of the data memory unit of the memory is returned to the object that initiated the access request, so as to ensure security for subsequent data management based on the parameter information and the data memory unit.
[0116] It is easy to understand that the present embodiment assumes that the memory has been applied for before the memory is managed, and there is no specific limitation on how to apply for memory. For example, in System V shared memory, the shmget function can be used to apply for shared memory from the system. In a feasible implementation, the parameter information memory unit length can be determined according to the data length of the parameter information, and then the memory length to be applied for can be determined according to the parameter information memory unit length and the data memory unit length. Finally, the memory can be applied for according to the memory identifier and the memory length to be applied for. The data memory unit length can be set by a person skilled in the art or by a user, and can be determined by the program requirements corresponding to the process, the actual physical memory and virtual memory size of the device, etc. The memory identifier (i.e., a unique ID) is used to distinguish the memory application object, i.e., to clarify the process of applying for memory, which can be a unique ID. It should be noted that in the actual application process of the present application, for example, when applying for shared memory from the system using the shmget function, other information such as memory access rights may also be involved, which can be set accordingly according to the actual application environment, and does not affect the determination process of the memory length to be applied for and the memory application process in the present embodiment.
[0117] When determining the length of the parameter information memory unit, it is necessary to obtain the information type of all parameter information, determine the data length corresponding to the parameter information of each information type, thereby calculating the total data length of the parameter information of all information types, and obtaining the parameter information memory unit length according to the preset rule. The preset rule is used to determine the parameter information memory unit length according to the total data length of the parameter information. In principle, the parameter information memory unit length is not less than the total data length of the parameter information. The specific rule content of the preset rule is not limited here. For example, the minimum power of 2 that is not less than the total data length of the parameter information can be selected as the parameter information memory unit length. It is also possible to directly set the parameter information memory unit length of several levels according to the total data length of the parameter information of the currently applied and allocated memory area, so as to determine the parameter information memory unit length of the corresponding level according to the total data length of the parameter information. Similarly, the memory length to be applied is not less than the parameter information memory unit length and the data memory unit length. When determining the memory length to be applied, the length redundancy can be set, or the sum of the parameter information memory unit length and the data memory unit length can be directly used as the memory length to be applied.
[0118] In order to better understand the memory data writing method provided in this application, as well as the memory export, memory access and other processes involved on this basis, the following is a description of the process, assuming that the parameter information memory unit is located at the head of the memory.
[0119] Assuming that the memory corresponds to process A, process A first applies to the system to create memory through the shmget function according to the memory identifier and the length of the memory to be applied for. It first determines the data length of each information type in the parameter information, and then calculates the total length of the data.
[0120] The parameter information includes the memory data structure version information version, the memory size length, the module to which the memory belongs moudule, the memory name name and crc32 (i.e. the content verification information in the above embodiment). After the memory application is successful, the fields of the above parameter information are recorded in the parameter information memory unit of the memory. The shmat function is called to map the memory to the address space of process A, and the address mapped by shmat plus the address offset of the parameter information memory unit is returned to process A as the address of the data memory unit. After the application is successful, a CRC check is performed on the fields except crc32 to obtain the crc check value and write it into the parameter information memory unit.
[0121] If the initiating process is process B. Process B can use the memory identifier to apply for memory access through the shmget function. After the memory is mapped to process B through shmat, the parameter information of the memory is checked by CRC and compared with the crc check value stored in the parameter information. If they are inconsistent, that is, the CRC check fails, it means that the memory has been tampered with, the access is terminated and an error is reported to the user. If they are consistent, the CRC check passes, and the access address mapped to the memory of process B is offset according to the size of the parameter information to obtain the second target address of the data in the data memory unit, and returned to process B for user operation; it should be noted that the parameter information of the memory is checked by CRC, and its parameter information represents the characteristic information of the data memory unit after the memory is mapped to process B through shmat.
[0122] When reading the memory through any process, the parameter information of the memory data structure version information version, memory size length, memory module module, memory name name and other information types in the memory parameter information can be output, and the parameter information can be saved together with the memory data of the memory, and a hash check can be performed on part or all of the data to obtain the first content check result to prevent the data from being maliciously tampered with. At this time, the parameter information, the data in the memory and the first content check result can be exported to generate a local binary file.
[0123] When writing the memory data contained in the local binary file through any process, the local binary file is first hash-checked to obtain the second content check result, and then compared with the first content check result. If the two are consistent, it can be confirmed that the local binary file is safe and valid, and then the parameter information of the memory is matched with the identification information of the external data. If the match is successful, the data is written. Otherwise, it means that the memory size or version is inconsistent, and the memory write operation is terminated.
[0124] See also Figure 5 , Figure 5 This is a structural diagram of a memory data writing system provided in an embodiment of the present application. The present application also provides a memory-based data management system, wherein the memory includes a parameter information memory unit and a data memory unit, and the data management system includes:
[0125] A parameter information acquisition module, used to acquire parameter information in the parameter information memory unit, wherein the parameter information represents characteristic information of the data memory unit;
[0126] A data management module is used to manage the data according to the parameter information and the data memory unit.
[0127] Based on the above embodiment, as a preferred embodiment, the data management module includes a write management submodule, and the write management submodule includes:
[0128] A write request receiving unit, used for receiving a request to write external data into the memory;
[0129] A write request verification unit, used to verify the identification information of the external data and the parameter information; if the verification fails, the writing is terminated; if the verification succeeds, the data writing unit is entered;
[0130] A data writing unit is used to write the external data into the memory according to the parameter information and the data memory unit.
[0131] Based on the above embodiments, as a preferred embodiment, the data writing unit is a unit for performing an address offset in the writing address according to the size of the parameter information to obtain a first target address in the data memory unit; and writing the data into the data memory unit according to the first target address.
[0132] Based on the above embodiment, as a preferred embodiment, the write management submodule further includes:
[0133] A data verification unit, used to verify the external data; if the verification fails, the writing is terminated;
[0134] If the verification passes, the identification information of the external data and the parameter information are verified again.
[0135] Based on the above embodiment, as a preferred embodiment, the data management module includes an access management submodule, and the access management submodule is a submodule for performing the following steps:
[0136] An access request receiving unit, configured to receive an access request to the memory;
[0137] An access request verification unit, configured to verify the access request based on the parameter information; if the verification fails, the access is terminated; if the verification passes, the access request response unit is entered;
[0138] An access request response unit is used to respond to the access request according to the parameter information and the data memory unit.
[0139] Based on the above embodiments, as a preferred embodiment, the access request response unit is used to perform an address offset in the access address according to the size of the parameter information to obtain a second target address of the data in the data memory unit; and a unit to respond to the access request according to the second target address.
[0140] Based on the above embodiment, as a preferred embodiment, the data management module includes a read management submodule, and the read management submodule is a submodule for performing the following steps:
[0141] A read request receiving unit, used for receiving a read request for the data;
[0142] A data reading unit, configured to read out a part or all of the data and the parameter information according to the read request to obtain read data;
[0143] The read data verification unit is used to verify the read data according to the parameter information; if the verification passes, the read data is read out and saved; if the verification fails, the read request is terminated.
[0144] The present application also provides an electronic device, see Figure 6 , a structural diagram of an electronic device provided in an embodiment of the present application, such as Figure 6 As shown, a processor 1410 and a memory 1420 may be included.
[0145] Among them, the processor 1410 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1410 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 1410 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1410 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1410 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0146] The memory 1420 may include one or more computer-readable storage media, which may be non-transitory. The memory 1420 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 1420 is at least used to store the following computer program 1421, wherein, after the computer program is loaded and executed by the processor 1410, it can implement the relevant steps in the method performed by the electronic device side disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 1420 may also include an operating system 1422 and data 1423, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 1422 may include Windows, Linux, Android, etc.
[0147] In some embodiments, the electronic device may further include a display screen 1430 , an input / output interface 1440 , a communication interface 1450 , a sensor 1460 , a power source 1470 , and a communication bus 1480 .
[0148] certainly, Figure 6 The structure of the electronic device shown does not constitute a limitation on the electronic device in the embodiments of the present application. In actual applications, the electronic device may include Figure 6 More or fewer components than shown, or combinations of certain components.
[0149] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the system provided in the embodiment, since it corresponds to the method provided in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0150] Specific examples are used herein to illustrate the principles and implementation methods of the present application, and the description of the above embodiments is only used to help understand the method and core ideas of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the present application.
[0151] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. A memory-based data management method, characterized in that: The memory includes a parameter information memory unit and a data memory unit, and the data management method includes: Acquire parameter information in the parameter information memory unit, where the parameter information represents characteristic information of the data memory unit; The data is managed according to the parameter information and the data memory unit.
2. The data management method according to claim 1, characterized in that: The managing the data according to the parameter information and the data memory unit comprises: receiving a request to write external data into the memory; Verifying the identification information of the external data and the parameter information; If the verification fails, the writing is terminated; If the verification is successful, the external data is written into the memory according to the parameter information and the data memory unit.
3. The data management method according to claim 2, characterized in that: Writing the external data into the memory according to the parameter information and the data memory unit comprises: Performing an address offset in the write address according to the size of the parameter information to obtain a first target address in the data memory unit; The data is written into the data memory unit according to the first target address.
4. The data management method according to claim 2, characterized in that: Before verifying the identification information and the parameter information of the external data, the following step is further included: Verifying the external data; If the verification fails, the writing is terminated; If the verification passes, the identification information of the external data and the parameter information are verified again.
5. The data management method according to claim 1, characterized in that: The data is located in the data memory unit, and managing the data according to the parameter information and the data memory unit includes: receiving a request for accessing the memory; verifying the access request based on the parameter information; If the verification fails, the access is terminated; If the verification passes, the access request is responded to according to the parameter information and the data memory unit.
6. The data management method according to claim 5, characterized in that: The responding to the access request according to the parameter information and the data memory unit comprises: Performing an address offset in the access address according to the size of the parameter information to obtain a second target address of the data in the data memory unit; The access request is responded to according to the second target address.
7. The data management method according to claim 1, characterized in that: The data is located in the data memory unit, and managing the data according to the parameter information and the data memory unit includes: receiving a request to read the data; Reading out the data and part or all of the parameter information according to the read request to obtain read data; Verifying the read data according to the parameter information; If the verification is passed, the read data is read out and saved; If the verification fails, the read request is terminated.
8. The data management method according to claims 1-7, characterized in that: Before managing the data according to the parameter information and the data memory unit, the method further includes: Accessing the memory; Verifying the access identification information and the parameter information; If the verification fails, the access is terminated; If the verification passes, access is allowed.
9. A memory-based data management system, characterized in that: The memory includes a parameter information memory unit and a data memory unit, and the data management system includes: A parameter information acquisition module, used to acquire parameter information in the parameter information memory unit, wherein the parameter information represents characteristic information of the data memory unit; A data management module is used to manage the data according to the parameter information and the data memory unit.
10. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the method according to any one of claims 1 to 8 when executing the computer program.