An inter-process data parameter sharing method, device, equipment and medium
By loading a shared parameter kernel module into the embedded device and using a hash algorithm to manage memory, and providing an interface to support scripting languages, the stability and performance issues of inter-process data sharing in embedded systems are solved, achieving efficient data storage and access.
Patent Information
- Application Number
- CN202311479912.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-08
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2043-11-08
AI Technical Summary
Existing methods for inter-process data sharing in embedded devices suffer from limited memory resources, high stability and performance requirements, high inter-process coupling, the need for secondary encapsulation, inability to be directly extended, and database-based methods are memory-intensive and prone to corruption.
The kernel module with shared parameters is loaded when the device starts up. The shared cache is initialized through the init program. Memory is managed using hash algorithms and timers. Interfaces for creating, reading, writing, deleting, and committing storage are provided. Scripting languages are supported. Timers can be configured to trigger storage backups.
It improves the stability and performance of embedded systems, reduces memory usage, decreases inter-process coupling, supports scripting languages, prevents data corruption, and improves system development efficiency and data access speed.
Smart Images

Figure CN117421141B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of embedded applications, and in particular to an inter-process data parameter sharing method, device, equipment and medium. BACKGROUND
[0002] Currently, commonly used inter-process data sharing methods include shared memory, pipes, messages, databases and the like. These methods have the common feature of running in the application layer and requiring a creator to manage shared parameter data. In embedded device systems, memory resources are limited. When the device is running for a long time, the application memory is insufficient or the system application program is abnormal, the shared memory creator may be abnormal, thereby causing abnormal shared data. Therefore, the stability or performance requirements of the system function module program are very high.
[0003] At the same time, the coupling degree and independence between the processes of the system function modules are also problems to be solved. For example, using a database in an embedded environment occupies more memory, and the data sharing access is also a problem that requires a special access process to read and write. The existing shared memory, pipes and messages do not have a ready-made direct data storage solution and need to be packaged or developed twice. In addition, the commonly used shared memory, pipes, messages and databases on the market cannot directly support script languages and cannot be directly extended for use.
[0004] In summary, the commonly used shared memory, pipes, messages and databases on the market have the problems of not being friendly to low memory state support in embedded systems, limited resources or difficulty in ensuring stability when running for a long time; the functions and memory run in the application layer, and the stability or performance requirements of the system function module program are very high; the coupling degree between the processes of the system function modules is high, and independent design decoupling is required; there is no ready-made data storage interface and development is required; the database method consumes memory when storing, and the concurrent access support is not friendly in the embedded system; the database file or random storage file is easily damaged by power failure; and the script language program is not supported.
[0005] Therefore, the present application is proposed. SUMMARY
[0006] Therefore, the purpose of the present application is to provide an inter-process data parameter sharing method, device, equipment and medium, which can effectively solve the problems of the prior art, such as high stability or performance requirements of the system function module program, the need for secondary packaging or development, and the inability to directly extend for use.
[0007] The present application discloses an inter-process data parameter sharing method, comprising:
[0008] When it is judged that the device starts the system kernel, the parameter sharing kernel module is loaded;
[0009] Through the init program, the shared cache export library is started to initialize parameter data, it is judged whether the device is run for the first time, a judgment result is generated, and shared parameter memory cache data is initialized according to the judgment result;
[0010] The creation, read, write, delete, and commit storage interfaces of the export library are called to access shared parameter data and storage files;
[0011] The commit storage operation of the export library is called to execute, and a timer is configured to trigger storage backup.
[0012] Preferably, when it is judged that the device starts the system kernel, the parameter sharing kernel module is loaded, specifically:
[0013] When it is judged that the device starts the system kernel, the parameter sharing kernel module is loaded, the hash algorithm key, the maximum number of bytes of a field, and the maximum number of bytes of data are set;
[0014] The shared parameter list cache, the hash table cache, and the fragmentation consolidation cache are applied for;
[0015] The fragmentation consolidation threshold and the fragmentation consolidation timer are set, and the loading of the parameter sharing kernel module is completed.
[0016] Preferably, through the init program, the shared cache export library is started to initialize parameter data, specifically:
[0017] The init process is started, the shared parameter library is initialized, and the creation, read-write, deletion, and commit storage access interfaces are exported;
[0018] The kernel storage is mapped to the application space, and it is detected whether the file system has a shared parameter save file;
[0019] If yes, the parameter file is loaded into the mapped memory space;
[0020] If no, the shared parameter save file and the backup file are established.
[0021] Preferably, it is judged whether the device is run for the first time, a judgment result is generated, and shared parameter memory cache data is initialized according to the judgment result, specifically:
[0022] It is judged whether the device is run for the first time;
[0023] If yes, the cache information is obtained from the kernel module after the library initialization, and the storage data file and the backup file are pre-allocated in the flash storage;
[0024] If not, check the integrity of the data storage file, and generate a check result;
[0025] When the check result is that the storage file is complete and the data version is newer, use the storage file data to initialize the shared parameter cache data;
[0026] When the check result is that the storage file is abnormal or the data version is lower than the backup file, restore the data from the backup file to the storage file, and then use the storage file data to initialize the shared parameter cache data.
[0027] Preferably, the export library's create, read, write, delete, and commit storage interfaces are called to perform access operations on the shared parameter data and the storage file, and specifically:
[0028] The write interface of the export library is called, and the parameter field is passed in to write data;
[0029] The field corresponding data address is obtained through the hash table, and it is determined whether the current address maximum write field is out of bounds;
[0030] If yes, the data length is out of bounds, the current address data is cleared, a new address is found for writing, and the fragment flag and number are marked;
[0031] If not, the read function is locked, and the data is written and then unlocked;
[0032] When it is determined that the fragment consolidation timer is triggered, fragment consolidation is performed;
[0033] The create interface of the export library is called to create a field and configure the field attribute;
[0034] The interface library calls the drive module interface to initialize the field attribute.
[0035] Preferably, the export library's create, read, write, delete, and commit storage interfaces are called to perform access operations on the shared parameter data and the storage file, and specifically:
[0036] The read interface of the export library is called, and the parameter field is passed in to read the field data;
[0037] The field attribute is obtained through the hash table, and it is determined whether it is locked;
[0038] If yes, it is locked, and the field corresponding data address is obtained through the hash table and read;
[0039] If not, the field corresponding data address is obtained through the hash table and read;
[0040] When it is determined that it needs to be unlocked, unlocking is performed;
[0041] The delete interface of the export library is called to delete the field, and the hash table node data, fragment address, and format are cleared;
[0042] determining whether the fragments exceed a threshold value;
[0043] If yes, when it is determined that the fragment collection timer is triggered, fragment collection is performed.
[0044] Preferably, the export library is called to perform the commit storage operation, and the timer is configured to trigger the storage backup, specifically:
[0045] The storage interface of the export library is called to commit storage, and the cached data is stored into a file;
[0046] The timer is configured to trigger the file backup.
[0047] The application further discloses an inter-process data parameter sharing device, comprising:
[0048] A module loading unit is configured to load a parameter sharing kernel module when it is determined that a device starts a system kernel;
[0049] A system initialization unit is configured to start a shared cache export library through an init program to initialize parameter data, determine whether the device is run for the first time, generate a determination result, and initialize shared parameter memory cache data according to the determination result;
[0050] An access unit is configured to call a create, read, write, delete and commit storage interface of the export library to perform access operation on shared parameter data and a storage file;
[0051] A parameter storage unit is configured to call the export library to perform a commit storage operation, and configure a timer to trigger a storage backup.
[0052] The application further discloses an inter-process data parameter sharing device, comprising a processor, a memory and a computer program stored in the memory and configured to be executed by the processor, and the processor implements the inter-process data parameter sharing method according to any one of the above when executing the computer program.
[0053] The application further discloses a readable storage medium, which stores a computer program, and the computer program can be executed by a processor of a device where the storage medium is located to implement the inter-process data parameter sharing method according to any one of the above.
[0054] In summary, the process inter-data parameter sharing method, device, equipment and medium provided by the embodiment first loads the shared parameter driving module when the device starts the system kernel: the module registers the device node to the system, pre-divides the memory cache of the shared parameter data to be used, the memory fragment is arranged, the hash list node cache is arranged, the memory cache of the shared parameter data is formatted, the hash table key value is arranged, the fragment arrangement threshold value is arranged, and the application layer cache mapping address is exported; secondly, the system starts the shared cache export library through the init program to initialize the parameter data; thirdly, the application program calls the creation, reading, writing, deleting and storage submission interface of the export library to access the shared parameter data and the storage file; finally, the application program calls the export library to execute the storage submission operation and configure the timer to trigger the storage backup; wherein, the script program uses the command line program of the creation, reading, writing, deleting and storage submission interface to access the shared parameter data and expand the use of the shared parameter data function. Thus, the problems of the prior art, such as the unfriendly support of the low memory state of the embedded system, the difficulty to guarantee the stability when the resources are limited or run for a long time, the high requirement of the stability or performance of the system function module program when the function and memory run in the application layer, the high coupling degree between the system function module processes, the need to independently design the decoupling, the lack of ready-made data storage interface, the need to develop and realize, the inconvenience of the lightweight database process inter-parameter sharing on the embedded system, the unfriendly support of the concurrent access, the easy damage of the database file or random storage file due to power failure, and the non-support of the script language program, are solved. BRIEF DESCRIPTION OF DRAWINGS
[0055] Figure 1 FIG. 1 is a flow diagram of a process inter-data parameter sharing method provided by an embodiment of the application.
[0056] Figure 2 FIG. 2 is a data storage structure diagram of the process inter-data parameter sharing method provided by the embodiment of the application.
[0057] Figure 3 FIG. 3 is a module loading flow diagram of the process inter-data parameter sharing method provided by the embodiment of the application.
[0058] Figure 4 FIG. 4 is a system initialization flow diagram of the process inter-data parameter sharing method provided by the embodiment of the application.
[0059] Figure 5 FIG. 5 is a parameter writing flow diagram of the process inter-data parameter sharing method provided by the embodiment of the application.
[0060] Figure 6 FIG. 6 is a parameter creation flow diagram of the process inter-data parameter sharing method provided by the embodiment of the application.
[0061] Figure 7 is a parameter reading process schematic diagram of an inter-process data parameter sharing method provided by an embodiment of the present application.
[0062] Figure 8 is a parameter deletion process schematic diagram of an inter-process data parameter sharing method provided by an embodiment of the present application.
[0063] Figure 9 is a parameter storage process schematic diagram of an inter-process data parameter sharing method provided by an embodiment of the present application.
[0064] Figure 10 is a module schematic diagram of an inter-process data parameter sharing device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0065] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.
[0066] The specific embodiments of the present application will be described in detail below with reference to the drawings.
[0067] Referring to Figures 1 to 2 The first embodiment of the present application provides an inter-process data parameter sharing method, which can be executed by an inter-process data parameter sharing device (hereinafter referred to as a sharing device), in particular, by one or more processors in the sharing device, to implement the following steps:
[0068] In the present embodiment, the sharing device can be a user terminal device (such as a smart phone, a smart computer or other smart devices), which can establish a communication connection with a server in the cloud to realize data interaction.
[0069] Referring to Figure 3 S101, when it is judged that the device starts the system kernel, the parameter sharing kernel module is loaded for processing;
[0070] Specifically, the step S101 comprises: loading a parameter sharing kernel module when judging that the device starts a system kernel, setting a hash algorithm key, a field maximum byte number and a data maximum byte number;
[0071] applying for sharing parameter list cache, hash table cache and fragment consolidation cache;
[0072] setting a fragment consolidation threshold and a fragment consolidation timer, and completing loading of the parameter sharing kernel module.
[0073] Specifically, in the embodiment, the device starts a sharing parameter driving module when starting a system kernel: the module registers a device node to the system, pre-allocates memory caches required to use sharing parameter data, memory fragment consolidation cache, hash table node cache, formats the memory cache of the sharing parameter data, configures the hash table key value, configures the fragment consolidation threshold, and exports the application layer cache mapping address. The sharing parameter data memory cache and other related memory caches that may be used are pre-allocated when the module is loaded when the system starts. The first memory cache is used in the high memory area of the kernel and is independent of the application memory, preventing the application program from being damaged or modified due to memory overflow, abnormal access, etc. The second, in the access operation of the sharing parameter, does not need to dynamically allocate memory, ensuring that the device system will not cause functional abnormalities due to the failure to apply for memory when the memory is low.
[0074] In the embodiment, the memory cache can be mapped to the process space address through the export library, without the need to use the driving interface to copy and access the high kernel and the application memory, improving the access efficiency. The driving module can use the hash algorithm to calculate the hash algorithm through the field of the sharing parameter, and maintain the hash index table, further improving the access efficiency of the sharing parameter. Memory fragment consolidation refers to triggering the fragment consolidation of the sharing parameter cache when the sharing parameter cache area produces memory fragments after long-term application and release, when the fragment ratio is higher than the threshold or the available area is lower than the threshold, improving the utilization rate of the cache.
[0075] Please refer to Figure 4 , S102, through the init program, starting the sharing cache export library to initialize the parameter data, judging whether the device is first run, generating a judgment result, and initializing the sharing parameter memory cache data according to the judgment result;
[0076] Specifically, the step S102 comprises: starting the init process, initializing the sharing parameter library, and exporting the creation, read-write, deletion and submission storage access interface;
[0077] Mapping the kernel storage to the application space, detecting whether the file system has a sharing parameter save file;
[0078] If yes, loading the parameter file into the mapped memory space;
[0079] If not, a shared parameter save file and a backup file are established.
[0080] It is judged whether the device is first run or not;
[0081] If yes, the cache information is obtained from the kernel module after the library initialization, and the storage data file and the backup file are pre-allocated in the flash storage;
[0082] If not, the integrity of the data storage file is checked, and a check result is generated;
[0083] When the check result is that the storage file is complete and the data version is newer, the shared parameter cache data is initialized using the storage file data;
[0084] When the check result is that the storage file is abnormal or the data version is lower than the backup file, the data is recovered from the backup file to the storage file, and the shared parameter memory cache data is initialized using the storage file data.
[0085] Specifically, in the embodiment, the system starts the shared cache export library for parameter data initialization through the init program. When the device is first run, the cache information is obtained from the kernel module after the library initialization, and the storage data file and the backup file are pre-allocated in the flash storage. When the device is not first run, the integrity of the data storage file is checked. If the storage file is complete and the data version is newer, the shared parameter cache data is initialized using the storage file data. If the storage file is abnormal or the data version is lower than the backup file, the data is recovered from the backup file to the storage file, and the shared parameter memory cache data is initialized using the storage file data.
[0086] Please refer to Figures 5 to 8 , S103, the creation, read, write, delete, and commit storage interfaces of the export library are called to access the shared parameter data and the storage file;
[0087] Specifically, step S103 includes: calling the write interface of the export library, and transmitting the parameter field write data;
[0088] The field corresponding data address is obtained through the hash table, and it is judged whether the current address maximum write field is out of bounds or not;
[0089] If yes, the data length is out of bounds, the current address data is cleared, a new address is found to write, and the flag fragment and the number are marked;
[0090] If not, the read function is locked, and the data is unlocked after being written;
[0091] When it is judged that the fragment arrangement timer is triggered, the fragment arrangement is performed;
[0092] The creation interface of the export library is called to create the field, and the field attribute is configured;
[0093] Interface library call driver module interface initialization field attribute.
[0094] Call the read interface of the export library, pass in the parameter field read field data;
[0095] Get the field attribute through the hash table, and judge whether to lock;
[0096] If yes, lock, get the field corresponding data address through the hash table, and read;
[0097] If not, get the field corresponding data address through the hash table, and read;
[0098] When it is judged that it needs to be unlocked, unlock;
[0099] Call the delete interface of the export library, delete the field, and clear the hash table node data, flag fragment address and format;
[0100] Judge whether the fragment exceeds the threshold;
[0101] If yes, when it is judged that the fragment arrangement timer is triggered, perform fragment arrangement.
[0102] Specifically, in the embodiment, the application program calls the create, read, write, delete, and commit storage interfaces of the export library to access the shared parameter data and the storage file. Among them, the application program calls the load export library process, and the export library automatically maps the shared parameter cache and the hash table cache to the process address space of the application program. When creating a shared data field, the field can be configured as a write lock or a read-write lock attribute according to the needs, and the field name and field attribute are written into the hash table cache area, the hash algorithm is run to generate a hash access index, and the hash dynamic linked list pointer is adjusted; the shared parameter data is written into the shared parameter cache area, and the data address in the field attribute data is updated. When the shared parameter data is updated less and the concurrent read operation is more, the attribute can be configured as only a write lock. When reading, it is judged whether there is a write lock. If there is a write lock, the read is prevented from waiting for the write to be unlocked to prevent reading dirty data. The read data is not locked. In this way, when multiple processes access and read shared parameter data with high concurrency, there is no need to lock and synchronize access to data, which can greatly improve the system running efficiency. Deleting a field only needs to clear the corresponding field attribute content in the hash table cache area, and update the data cache fragment value. When the fragment value exceeds the preset fragment arrangement threshold, start the timer to trigger the fragment arrangement. Using the export library interface to access the shared parameter data, the application program only needs to care about the use demand of the field data itself, and does not need to care about the access operation of other module processes, so as to achieve the design of high internal set and low coupling between program modules, and improve the development efficiency and stability of the system.
[0103] Please refer to Figure 9, S104, calling the export library to perform a commit storage operation and configuring a timer to trigger a storage backup.
[0104] Specifically, step S104 includes: calling a storage interface of the export library, committing storage, and storing the cached data into a file.
[0105] Configuring a timer to trigger a file backup.
[0106] Specifically, in the embodiment, the application program calls the export library to perform a commit storage operation and configures a timer to trigger a storage backup. When the application program commits a storage operation, the timer is used to trigger the storage backup, with the purposes of: 1. preventing the storage file from being damaged due to abnormal power failure, flash bad block, program exception, etc., and recovering the data of the storage from the backup file; and 2. triggering the backup by the timer, preventing backup from being performed every time the storage is committed, reducing the flash write operation, and improving the flash life and CPU usage.
[0107] In the embodiment, the script program uses the command program of the create, read, write, delete, and commit storage interface to perform access operation on the shared parameter data, and expands the use of the shared parameter data function.
[0108] In summary, the inter-process data parameter sharing method has the following advantages: 1. The kernel of the system integrates a parameter sharing function module driver, which pre-allocates the parameter memory cache to be shared and the memory cache to be defragmented, to ensure the stability of the module function when the embedded system uses low memory; 2. The cache is formatted, the hash algorithm is used to locate the field corresponding data storage address, to prevent reading dirty data and improve the access rate of the shared parameter data accessed by multiple processes concurrently; 3. The shared parameter data is in the high memory address space of the system kernel, which is not easily affected by the system application memory usage, to ensure the stability and data security of the function; 4. The field data can be selectively write-locked without read-locking, to prevent reading dirty data and improve the efficiency of the shared parameter data accessed by multiple processes concurrently; 5. The application layer uses the library export shared parameter access operation interface and command interface, which is compatible with the script language program and the high-level language program, to reduce the coupling degree between processes, improve the independence of the program function, and improve the efficiency and stability of the system integration; 6. Only the create, read, write, delete, and commit storage interfaces are exported, and the interfaces are operated simply and conveniently with the parameter field as the key; 7. The shared cache supports defragmentation, to improve the cache utilization rate; 8. The shared data parameter can be stored synchronously on the fixed storage device of the flash; 9. The storage file and the backup file are pre-allocated on the flash, to prevent the file from being damaged when power fails; and 10. The storage file integrity check and the backup file recovery ensure the recovery of the parameter file when the parameter file is abnormal.
[0109] Please refer to Figure 10The second embodiment of the present application provides an inter-process data parameter sharing device, comprising:
[0110] The module loading unit 201 is configured to load the parameter sharing kernel module when it is determined that the device starts the system kernel;
[0111] The system initialization unit 202 is configured to start the shared cache export library to initialize the parameter data through an init program, determine whether the device is run for the first time, generate a determination result, and initialize the shared parameter memory cache data according to the determination result.
[0112] The access unit 203 is configured to call the creation, reading, writing, deleting, and storage submitting interfaces of the export library to perform access operations on the shared parameter data and the storage file.
[0113] The parameter storage unit 204 is configured to call the export library to perform the storage submitting operation and configure a timer to trigger the storage backup.
[0114] The third embodiment of the present application provides an inter-process data parameter sharing device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and the processor implements the inter-process data parameter sharing method according to any one of the above embodiments when executing the computer program.
[0115] The fourth embodiment of the present application provides a readable storage medium, which stores a computer program, and the computer program can be executed by a processor of a device where the storage medium is located to implement the inter-process data parameter sharing method according to any one of the above embodiments.
[0116] Exemplarily, the computer program in the third embodiment and the fourth embodiment of the present application can be divided into one or more modules, and the one or more modules are stored in the memory and executed by the processor to complete the present application. The one or more modules can be a series of computer program instruction segments capable of completing a specific function, and the instruction segments are used to describe the execution process of the computer program in the inter-process data parameter sharing device. For example, the device in the second embodiment of the present application.
[0117] The processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic components, discrete hardware components, etc. The general-purpose processor can be a microprocessor or can also be any conventional processor. The processor is a control center of the inter-process data parameter sharing method, and connects various parts of the inter-process data parameter sharing method through various interfaces and lines.
[0118] The memory can be used to store the computer program and / or modules, and the processor realizes various functions of the inter-process data parameter sharing method by running or executing the computer program and / or modules stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area. The program storage area can store an operating system, at least one application program required by a function (such as a sound playing function, a text conversion function, etc.), etc.; and the data storage area can store data created according to the use of the mobile phone (such as audio data, text message data, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other volatile solid-state storage device.
[0119] The implemented modules, if implemented in the form of software function units and sold or used as independent products, can be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the above-mentioned embodiment methods can also be completed by a computer program instructing related hardware, and the computer program can be stored in a computer readable storage medium. The computer program can implement the steps of each method embodiment when executed by a processor. The computer program includes computer program code, which can be in the form of source code, object code, executable files or some intermediate forms. The computer readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the contents included in the computer readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction, for example, in some jurisdictions, according to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.
[0120] It should be noted that the above-described device embodiments are only schematic, and the units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or distributed on multiple network units. Part or all of the modules can be selected to achieve the purpose of the embodiment scheme according to actual needs. In addition, the connection relationship between the modules in the device embodiment provided by the present application indicates that there is a communication connection between them, which can be realized as one or more communication buses or signal lines. Those skilled in the art can understand and implement it without creative labor.
[0121] The above is only the preferred embodiment of the present application, and the protection scope of the present application is not limited to the above-mentioned embodiments. Any technical solution falling within the idea of the present application belongs to the protection scope of the present application.
Claims
1. A method for sharing data parameters between processes, characterized by, The application comprises the following steps: When it is judged that the device starts the system kernel, a parameter sharing kernel module is loaded; Through an init program, a shared cache export library is started to initialize parameter data, it is judged whether the device is run for the first time, a judgment result is generated, and shared parameter memory cache data is initialized according to the judgment result, specifically as follows: It is judged whether the device is run for the first time; If yes, the library initializes the cache information from the kernel module, and pre-allocates storage data files and backup files in the flash storage; If no, the integrity of the data storage file is verified, and a verification result is generated; When the verification result is that the storage file is complete and the data version is newer, the shared parameter memory cache data is initialized using the storage file data; When the verification result is that the storage file is abnormal or the data version is lower than the backup file, the data is recovered from the backup file to the storage file, and the shared parameter memory cache data is initialized using the storage file data; The create, read, write, delete and commit storage interfaces of the export library are called to access the shared parameter data and the storage file; The commit storage operation of the export library is called, and a timer is configured to trigger storage backup.
2. The method of claim 1, wherein, When it is judged that the device starts the system kernel, a parameter sharing kernel module is loaded, specifically as follows: When it is judged that the device starts the system kernel, the parameter sharing kernel module is loaded, the hash algorithm key, the maximum number of bytes of the field and the maximum number of bytes of the data are set; The shared parameter list cache, the hash table cache and the fragment consolidation cache are applied; The fragment consolidation threshold and the fragment consolidation timer are set, and the loading of the parameter sharing kernel module is completed.
3. The method of claim 1, wherein, Through an init program, a shared cache export library is started to initialize parameter data, specifically as follows: The init process is started, the shared parameter library is initialized, and the create, read, write, delete and commit storage access interfaces are exported; The kernel storage is mapped to the application space, and it is detected whether the file system has a shared parameter save file; If yes, the shared parameter save file is loaded into the mapped memory space; If no, the shared parameter save file and the backup file are established.
4. The method of claim 1, wherein, The create, read, write, delete and commit storage interfaces of the export library are called to access the shared parameter data and the storage file, specifically as follows: The write interface of the export library is called, and the parameter field write data is transmitted; The field corresponding data address is obtained through the hash table, and it is judged whether the current address maximum write field is out of bounds; If yes, the data length is out of bounds, the current address data is cleared, a new address is found for writing, and the fragment and the number of fragments are marked; If no, the read function is locked, and the data is unlocked after being written; When it is judged that the fragment consolidation timer is triggered, fragment consolidation is performed; The create interface of the export library is called to create a field, and the field attribute is configured; The interface library calls the drive module interface to initialize the field attribute.
5. The method of claim 4, wherein, The create, read, write, delete and commit storage interfaces of the export library are called to access the shared parameter data and the storage file, and specifically as follows: The read interface of the export library is called, and the parameter field read field data is transmitted; The field attribute is obtained through the hash table, and it is judged whether it is locked; If yes, it is locked, the field corresponding data address is obtained through the hash table, and it is read; If not, the field corresponding data address is obtained through the hash table and read; When it is judged that unlocking is needed, unlocking is performed; The delete interface of the export library is called to delete the field and clear the hash table node data, flag fragment address and format; It is judged whether the fragment exceeds the threshold; If yes, when it is judged that the fragment arrangement timer is triggered, fragment arrangement is performed.
6. The method of claim 5, wherein, The export library is called to perform the commit storage operation and configure the timer to trigger the storage backup, specifically: The storage interface of the export library is called to commit storage and store the cache data into the file; The timer is configured to trigger the file backup.
7. An apparatus for sharing data parameters between processes, comprising: The method comprises the following steps: The module loading unit is configured to load the parameter shared kernel module when it is judged that the device starts the system kernel; The system initialization unit is configured to start the shared cache export library through the init program to initialize the parameter data, judge whether the device is run for the first time, generate a judgment result, and initialize the shared parameter memory cache data according to the judgment result, specifically: It is judged whether the device is run for the first time; If yes, the library initialization is completed to obtain the cache information from the kernel module, and the storage data file and the backup file are pre-allocated in the flash storage; If not, the integrity of the data storage file is verified to generate a verification result; When the verification result is that the storage file is complete and the data version is newer, the shared parameter memory cache data is initialized using the storage file data; When the verification result is that the storage file is abnormal or the data version is lower than the backup file, the data is recovered from the backup file to the storage file, and the shared parameter memory cache data is initialized using the storage file data; The access unit is configured to call the create, read, write, delete and commit storage interfaces of the export library to perform access operations on the shared parameter data and the storage file; The parameter storage unit is configured to call the export library to perform the commit storage operation and configure the timer to trigger the storage backup.
8. An inter-process data parameter sharing device, comprising: The computer program is stored in the storage medium and configured to be executed by the processor, and the processor executes the computer program to implement the inter-process data parameter sharing method of any one of claims 1 to 6.
9. A readable storage medium, characterized by, The computer program is stored in the storage medium and configured to be executed by the processor, and the processor executes the computer program to implement the inter-process data parameter sharing method of any one of claims 1 to 6.
Citation Information
Patent Citations
Inter-core communication system of multi-core system
CN115080277A
Data sharing method, device and system and storage medium
CN116401004A