A file storage method
By dividing the file storage process into multiple file states and dividing the tasks into main tasks and file maintenance tasks, the storage operation out-synchronization problem caused by the difference in file storage speed between MPUs in the rail transit signal system is solved, and high-availability file storage and synchronization control is achieved.
Patent Information
- Application Number
- CN202111580974.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-22
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2041-12-22
AI Technical Summary
In the rail transit signal system, there are differences in file storage speeds between each logical computing unit (MPU), resulting in out-of-synchronization of storage operations, resulting in inconsistent application outputs, and seriously affecting system availability.
By dividing the file storage process into several file states and dividing the file storage task into the main task and the file maintenance task, each MPU multicast, synchronizes and converts the file state in the main task, generates a file write signal, and writes the file to the preset memory according to the write signal in the file maintenance task.
Complete file storage without taking up very little time for the main task, improve system availability, and realize synchronous control of asynchronous stored file processes, so that upper-level applications can obtain synchronous and consistent file status.
Smart Images

Figure CN114237855B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of rail transit technology, and in particular to a file storage method for a secure computing platform. Background Art
[0002] To ensure the safety, reliability and availability of rail transit signal systems, rail transit signal products are usually developed based on a safety computing platform that meets the highest safety level SIL4 standard. The safety computing platform adopts a two-by-two-out-of-two architecture, in which two main logic units (MPUs) form one system to achieve two-out-of-two; at the same time, a backup system is added to achieve "hot standby redundancy" or two-out-of-two, which enhances availability.
[0003] In the vehicle system, a large amount of data needs to be stored locally in the form of files, and the file size is usually larger than 1MB. To ensure that the file data stored between each MPU is correct and consistent, it is necessary to calculate the checksum of the stored file and broadcast it to other MPUs through the M-LVDS bus for verification. At the same time, in the real-time system, the execution time of the task is strictly controlled, and the system will fail after the task timeout. Since file storage is a time-consuming operation, it needs to be treated as a separate task and stored asynchronously.
[0004] However, in the process of using separate tasks for asynchronous file storage, there are large differences in the storage speeds of each MPU, which will lead to asynchronous storage operations between the MPUs, and ultimately cause inconsistent application outputs, resulting in system failures. In addition, since the file is too large, calculating the checksum will consume a lot of time. In existing systems, the time spent calculating the file checksum usually accounts for 20% to 60% of the main cycle length, leaving very little time for the application, which seriously affects system availability. Therefore, it is necessary to adjust or improve the file storage method. Summary of the invention
[0005] The purpose of the present invention is to provide a file storage method that can complete file storage while occupying very little main task time, thereby greatly improving the availability of the system; at the same time, it can also realize synchronous control of the asynchronous file storage process, so that the upper-level application can obtain a synchronous and consistent file status.
[0006] In order to achieve the above object, the present invention is implemented by the following technical solutions:
[0007] A file storage method is applied to a secure computing platform, wherein the secure computing platform includes a main system and a backup system, wherein the main system and the backup system each include at least two logic operation units (MPUs), and all the MPUs store the same file; the file storage method includes:
[0008] Divide the file storage process into several file states;
[0009] Divide file storage tasks into main tasks and file maintenance tasks;
[0010] Each of the MPUs performs multicast, synchronization and conversion of the file status in the main task to generate a file write signal and sends it to the file maintenance task; and
[0011] Each of the MPUs writes the file into a preset memory according to the file write signal in the file maintenance task to store the file.
[0012] Preferably, the plurality of file states include file does not exist, file storage is started, file verification code is being calculated, file verification code calculation is completed, file is being written, file writing is completed, file storage is completed, file storage fails, and file is out of sync.
[0013] Preferably, the priority of the main task is higher than the priority of the file maintenance task.
[0014] Preferably, before executing the step of each MPU performing multicast, synchronization and conversion of the file status in the main task, the method further includes:
[0015] Each of the MPUs reads the stored file to obtain the size and checksum of the stored file;
[0016] Each of the MPUs multicasts the size and check code of the stored file obtained by itself to other MPUs, and receives the size and check code of the stored file multicasted by other MPUs;
[0017] Each of the MPUs performs consistency check between the size and check code of the stored file obtained by itself and the size and check code of the stored file multicasted by other MPUs to obtain the initial file status.
[0018] Preferably, the size and check code of the stored file obtained by each MPU itself are consistent with the size and check code of the stored file multicasted by other MPUs, and the initial file status of all MPUs is that the file storage is completed;
[0019] The size and check code of the stored file obtained by any of the MPUs itself are inconsistent with the size and check code of the stored files multicast by other MPUs, and the initial file status of all MPUs is that the file does not exist.
[0020] Preferably, the steps of performing multicast, synchronization and conversion of the file status by each of the MPUs in the main task include:
[0021] Dividing the operation cycle of the main task into a first time slot, a second time slot and a third time slot;
[0022] In the first time slot, each of the MPUs multicasts a file management message to other MPUs, and receives a file management message multicast by other MPUs; the file management message includes a file size, a file status, and a file check code;
[0023] In the second time slot, each of the MPUs performs consistency check on its own file status and the file status multicasted by other MPUs to obtain file synchronization information and output it;
[0024] In the third time slot, each of the MPUs converts its own file status to generate a check code calculation signal or the file write signal and sends it to the file maintenance task.
[0025] Preferably, the file status of each MPU is consistent with the file status of other MPU multicasts, and the file synchronization information of all MPUs is their own file status;
[0026] The file status of any of the MPUs is inconsistent with the file status of other MPU multicasts, and the file synchronization information of all MPUs is that the files are out of synchronization.
[0027] Preferably, each of the MPUs calculates a file check code according to the check code calculation signal in the file maintenance task and feeds it back to the main task; and writes the file into the preset memory according to the file write signal, and feeds back the file write result to the main task.
[0028] Preferably, when storing the same file, the number of the operation cycles of the main task is at least five, namely, the first operation cycle, the second operation cycle, the third operation cycle, the fourth operation cycle and the fifth operation cycle; and in the first operation cycle of the main task,
[0029] In the first time slot, each of the MPUs sends a first file management message to other MPUs and receives a first file management message multicasted by other MPUs; the first file management message is the size and checksum of the stored file and the initial file status;
[0030] In the second time slot, each of the MPUs performs consistency check on its own initial file state and the initial file state multicasted by other MPUs to obtain first file synchronization information and output it to the application; the application sends a new file storage command to each of the MPUs; and according to the new file storage command, each of the MPUs converts its own initial file state into file storage startup;
[0031] In the third time slot, each of the MPUs sends a verification code calculation signal to the file maintenance task, and each of the MPUs converts its own file status from file storage startup to file verification code calculation.
[0032] Preferably, in the second operation cycle of the main task,
[0033] In the first time slot, each of the MPUs sends a second file management message to other MPUs and receives a second file management message multicasted by other MPUs; the second file management message includes the size and checksum of the new file and the file status;
[0034] In the second time slot, each of the MPUs performs consistency check on its own file status and the file status multicasted by other MPUs to obtain second file synchronization information and output it to the application;
[0035] In the third time slot, each of the MPUs receives a new file verification code fed back by the file maintenance task, and each of the MPUs changes its own file status from file verification code being calculated to file verification code calculation completed.
[0036] Preferably, in the third operation cycle of the main task,
[0037] In the first time slot, each of the MPUs sends a third file management message to other MPUs and receives a third file management message multicasted by other MPUs; the third file management message includes the size and checksum of the new file and the file status;
[0038] In the second time slot, each of the MPUs performs consistency check on its own file status and the file status multicasted by other MPUs to obtain third file synchronization information and output it to the application;
[0039] In the third time slot, each of the MPUs will perform consistency check on the new file verification code obtained by itself and the new file verification codes multicast by other MPUs, and after the check is passed, each of the MPUs will send the file write signal to the file maintenance task, and each of the MPUs will convert its own file status from file verification code calculation completed to file being written.
[0040] Preferably, in the fourth operation cycle of the main task,
[0041] In the first time slot, each of the MPUs sends a fourth file management message to other MPUs and receives a fourth file management message multicasted by other MPUs; the fourth file management message includes the size and checksum of the new file and the file status;
[0042] In the second time slot, each of the MPUs performs consistency check on its own file status and the file status multicasted by other MPUs to obtain fourth file synchronization information and output it to the application;
[0043] In the third time slot, each of the MPUs receives the file writing result fed back by the file maintenance task, and each of the MPUs converts its own file status from a file writing in progress status to a file writing completion status.
[0044] Preferably, in the fifth operation cycle of the main task,
[0045] In the first time slot, each of the MPUs sends a fifth file management message to other MPUs and receives a fifth file management message multicasted by other MPUs; the fifth file management message includes the size and checksum of the new file and the file status;
[0046] In the second time slot, each of the MPUs performs consistency check on its own file status and the file status multicasted by other MPUs to obtain fifth file synchronization information and output it to the application;
[0047] In the third time slot, each of the MPUs converts its own file status from a file writing completion status to a file storage completion status.
[0048] Preferably, if any of the MPUs fails to receive a new file verification code fed back by the file maintenance task within a first preset time period, the MPU converts its own file status to file storage failure.
[0049] Preferably, if the new file verification code obtained by any of the MPUs itself is inconsistent with the new file verification codes multicast by other MPUs, the file status of all MPUs is converted to file storage failure.
[0050] Preferably, if any of the MPUs fails to receive the file writing result fed back by the file maintenance task within the second preset time period, it converts its own file status into file storage failure.
[0051] Preferably, if the file status of any one of the MPUs is converted to file storage failure, the file status of other MPUs are all converted to file storage failure.
[0052] Compared with the prior art, the present invention has at least one of the following advantages:
[0053] A file storage method provided by the present invention can divide the file storage process into several file states and divide the file storage task into a main task and a file maintenance task; each MPU can perform multicast, synchronization and conversion of the file state in the main task to generate a file write signal, so that each MPU can write the file to a preset memory in the file maintenance task according to the file write signal, thereby completing the file storage with very little main task time occupied, thereby greatly improving the system availability.
[0054] The present invention can also perform time-consuming operations such as checksum calculation and file deletion in the file maintenance task, that is, operations that occupy a long CPU time, so as to complete the file checksum calculation and the like while occupying very little time of the main task, thereby further improving the availability of the system.
[0055] In the present invention, during the operation cycle of the main task, when the file status of each MPU itself is consistent with the file status of other MPUs, the file synchronization information of all MPUs can be set to its own file status, otherwise the file synchronization information of all MPUs is set to file asynchrony, so as to ensure that the file synchronization information of all MPUs is the same, thereby ensuring that the MPUs output consistent file status when asynchronously calculating check codes and asynchronously writing operations, thereby realizing synchronous control of the asynchronous file storage process, and enabling the upper-layer application to obtain a synchronous and consistent file status.
[0056] When the present invention performs a file writing operation in a file maintenance task, the file can be divided into a plurality of file segments and each file segment can be written into a preset memory in sequence. The file maintenance task releases the CPU between two writes, so that the large file storage segments can be intermittently written into the preset memory, thereby avoiding long-term blocking of lower priority tasks, while reducing the system failure rate and improving system stability. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 is a flow chart of a file storage method provided by an embodiment of the present invention;
[0058] Figure 2 It is a flowchart of file status conversion in a file storage method provided by an embodiment of the present invention;
[0059] Figure 3 This is a timing diagram of a main task operation cycle in a file storage method provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0060] The following is a further detailed description of a file storage method proposed by the present invention in conjunction with the accompanying drawings and specific embodiments. According to the following description, the advantages and features of the present invention will be clearer. It should be noted that the accompanying drawings are in a very simplified form and use non-precise proportions, which are only used to conveniently and clearly assist in explaining the purpose of the embodiments of the present invention. In order to make the purposes, features and advantages of the present invention more obvious and easy to understand, please refer to the accompanying drawings. It should be noted that the structures, proportions, sizes, etc. illustrated in the accompanying drawings of this specification are only used to match the contents disclosed in the specification for people familiar with this technology to understand and read, and are not used to limit the limiting conditions for the implementation of the present invention, so they have no technical substantive significance. Any structural modification, change in proportional relationship or adjustment of size, without affecting the effects that the present invention can produce and the purposes that can be achieved, should still fall within the scope of the technical content disclosed by the present invention.
[0061] It should be noted that, in this article, 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 "include", "comprise" 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, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0062] Combined with Figures 1 to 3 As shown, this embodiment provides a file storage method, which is applied to a secure computing platform, wherein the secure computing platform includes a main system and a backup system, wherein the main system and the backup system respectively include at least two logical operation units MPU, and all the MPUs store the same file; the file storage method includes: step S101, dividing the file storage process into several file states; step S102, dividing the file storage task into a main task and a file maintenance task; step S103, each of the MPUs performs multicast, synchronization and conversion of the file state in the main task to generate a file write signal and send it to the file maintenance task; and step S104, each of the MPUs writes the file to a preset memory according to the file write signal in the file maintenance task to store the file.
[0063] Specifically, in this embodiment, the secure computing platform may include four MPUs (MPU1A, MPU2A, MPU1B and MPU2B respectively); two MPUs (MPU1A and MPU2A respectively) constitute the main system, and the other two MPUs (MPU1B and MPU2B respectively) constitute the backup system; and all the MPUs can communicate and multicast through the MLVDS bus, but the present invention is not limited to this.
[0064] Please continue to refer to Figure 1 and Figure 2 , several of the file states include file does not exist NOTEXIST, file storage starts FILESTORESTART, file checksum is being calculated CALMD5, file checksum calculation is completed CALMD5_DONE, file is being written to SAVEFLASH, file writing is completed SAVEFLASH_DONE, file storage is completed STORECOMPLETE, file storage fails STOREFAILED, and file is not synchronized STATENOTSYN.
[0065] It can be understood that, in some other embodiments, before executing the step S103, it also includes: each of the MPUs reads the stored file to obtain the size and verification code of the stored file; each of the MPUs multicasts the size and verification code of the stored file obtained by itself to other MPUs, and receives the size and verification code of the stored file multicast by other MPUs; each of the MPUs performs consistency check on the size and verification code of the stored file obtained by itself and the size and verification code of the stored file multicast by other MPUs to obtain the initial file status.
[0066] In some embodiments, the size and verification code of the stored file obtained by each of the MPUs itself are consistent with the size and verification code of the stored files multicasted by other MPUs, and the initial file status of all MPUs is that the file storage is completed; the size and verification code of the stored file obtained by any of the MPUs itself are inconsistent with the size and verification code of the stored files multicasted by other MPUs, and the initial file status of all MPUs is that the file does not exist.
[0067] Specifically, in this embodiment, after the secure computing platform is powered on, each of the MPUs needs to perform an initialization process before executing step S103 to obtain the initial file status. More specifically, in the initialization process, each of the MPUs can read the stored files from the preset memory, calculate the size and check code of the stored files, and save them locally. In the case of dual-system operation, if the stored file size and check code saved locally by each of the MPUs are all consistent with the stored file size and check code multicast by other MPUs, that is, both the intra-system check and the inter-system check are passed, the initial file status of all MPUs can be set to file storage complete STORECOMPLETE, otherwise the file cache is cleared and the initial file status of all MPUs is set to file does not exist NOTEXIST; since the initial file status of all MPUs is the same, the consistency of the file cache during initialization can be guaranteed. Preferably, the preset memory can be a Flash memory, and the check code can be an MD5 code, but the present invention is not limited to this.
[0068] Please also refer to Figure 1 , Figure 2 and Figure 3 , the step S103 includes: dividing the operation cycle of the main task into a first time slot, a second time slot and a third time slot; in the first time slot, each of the MPUs multicasts a file management message to other MPUs, and receives a file management message multicast by other MPUs; the file management message includes a file size, a file status and a file check code; in the second time slot, each of the MPUs performs a consistency check on its own file status with the file status multicast by other MPUs to obtain file synchronization information and output it; in the third time slot, each of the MPUs converts its own file status to generate a check code calculation signal or the file write signal and sends it to the file maintenance task.
[0069] It can be understood that, in some other embodiments, the file status of each MPU itself is consistent with the file status of other MPU multicasts, and the file synchronization information of all MPUs is its own file status; if the file status of any MPU itself is inconsistent with the file status of other MPU multicasts, the file synchronization information of all MPUs is that the files are out of sync.
[0070] Specifically, in this embodiment, the file management message can be sent using a control frame to ensure that each MPU can multicast and receive the file management message and cache it locally before the end of the first time slot. Preferably, each operation cycle of the main task can be 150ms, wherein the first time slot can be 30ms, the second time slot can be 100ms, and the third time slot can be 20ms, but the present invention is not limited thereto.
[0071] Specifically, in this embodiment, during the operation cycle of the main task, when the dual systems are running, if the file status local_state of each MPU is consistent with the file status of other MPUs, that is, the intra-system check and the inter-system check are passed, then the file synchronization information syn_state of all MPUs can be set to their own file status local_state, otherwise the file synchronization information syn_state of all MPUs is set to file asynchronous STATENOTSYN; when the single system is running, only the intra-system check needs to be passed, and the file synchronization information syn_state of all MPUs in the system is set to their own file status local_state, otherwise the file synchronization information syn_state of all MPUs in the system is set to file asynchronous STATENOTSYN. The file synchronization information syn_state is the file status finally provided to the application. The same file synchronization information of all MPUs can ensure that the MPUs output consistent file status to the outside during asynchronous calculation of the check code and asynchronous write operation, thereby realizing synchronous control of the asynchronous file storage process, and then enabling the application to obtain a synchronous and consistent file status, but the present invention is not limited to this.
[0072] Please continue to refer to Figure 1 , each of the MPUs calculates a file check code according to the check code calculation signal in the file maintenance task and feeds it back to the main task; and writes the file into the preset memory according to the file write signal, and feeds back the file write result to the main task.
[0073] It can be understood that, in some other embodiments, the priority of the main task is higher than the priority of the file maintenance task.
[0074] Specifically, in this embodiment, operations that take a long time, that is, operations that occupy a long CPU time (including checksum calculation, file writing, file deletion, etc.) can be performed in the file maintenance task, so that the file checksum calculation and file writing, etc. are completed with very little time occupied by the main task, thereby greatly improving the availability of the system. More specifically, when each of the MPUs receives the checksum calculation signal sent by the main task in the file maintenance task, it performs the checksum calculation operation and feeds back the calculation result to the main task. When each of the MPUs receives the file write signal sent by the main task in the file maintenance task, it performs the file write operation and feeds back the file write result (including file write success and file write failure) to the main task. When each of the MPUs receives the file delete signal sent by the main task in the file maintenance task, it performs the file delete operation and feeds back the file delete result (including file delete success and file delete failure) to the main task. Preferably, when performing a file writing operation, the file can be divided into several file segments according to a preset length, and each file segment is written to the preset memory in sequence, and the file maintenance task releases the CPU through a delay function between two writes, so that the large file storage segments are intermittently written to the preset memory, thereby avoiding long-term blocking of lower priority tasks, reducing system failure rate and improving system stability. More preferably, the preset length can be 128KB, but the present invention is not limited thereto.
[0075] Please continue to refer to Figure 2 If any of the MPUs fails to receive a new file verification code fed back by the file maintenance task within a first preset time period, it converts its own file status into file storage failure.
[0076] It is understandable that, in some other embodiments, the new file verification code obtained by any of the MPUs itself is inconsistent with the new file verification codes multicast by other MPUs, and the file status of all MPUs is converted to file storage failure.
[0077] In some embodiments, if any of the MPUs does not receive the file writing result fed back by the file maintenance task within the second preset time period, it converts its own file status to file storage failure.
[0078] Specifically, in this embodiment, during the running phase of the main task, each of the MPUs can receive a new file storage command from the application and perform a new file storage operation, and the file status conversion process is as follows: when the file status is file does not exist NOTEXIST, file storage is completed STORECOMPLETE, or file storage fails STOREFAILED, the file status is always waiting for the file storage command; when there is a new file storage command, the file status is converted to file storage start FILESTORESTART. When the file status is file storage start FILESTORESTART, the file maintenance task is notified to calculate a new file checksum, and the file status is converted to file checksum calculation CALMD5. When the file status is file checksum calculation CALMD5, wait for feedback from the file maintenance task. If a new file checksum is received, the file status is converted to file checksum calculation completed CALMD5_DONE; if the waiting exceeds the first preset time length or the file maintenance task fails to calculate the new file checksum, the file status is converted to file storage failure STOREFAILED. When the file status is that the calculation of the file check code is completed CALMD5_DONE, each of the MPUs verifies the consistency of the local new file check code with the file check code sent by other MPUs. If the verification is passed, the file maintenance task is notified to perform the new file write operation, and the file status is converted to the file being written to SAVEFLASH; if the verification fails, if it is still within the forgiveness period, the next operation cycle verification is waited for, and if the forgiveness period is exceeded, the file status is converted to the file storage failure STOREFAILED. When the file status is that the file is being written to SAVEFLASH, the feedback of the file maintenance task is waited for. If the file is successfully written, the file status is converted to the file writing completion SAVEFLASH_DONE; if the waiting exceeds the second preset time or the file fails to be written, the file status is converted to the file storage failure STOREFAILED. When the file status is that the file is written to SAVEFLASH_DONE, the file status is converted to the file storage completion STORECOMPLETE in the next operation cycle. Preferably, the first preset time is the forgiveness period for calculating the file check code, and the forgiveness period can be 2 operation cycles; the second preset time can be 1 operation cycle, but the present invention is not limited to this.
[0079] Please continue to refer to Figure 3, when storing the same file, the number of operation cycles of the main task is at least five, namely the first operation cycle, the second operation cycle, the third operation cycle, the fourth operation cycle and the fifth operation cycle; and in the first operation cycle of the main task, in the first time slot, each of the MPUs sends a first file management message to other MPUs and receives the first file management message multicast by other MPUs; the first file management message is the size and check code of the stored file and the initial file state; in the second time slot, each of the MPUs performs consistency check on its own initial file state with the initial file state multicast by other MPUs to obtain the first file synchronization information and output it to the application; the application sends a new file storage command to each of the MPUs; and according to the new file storage command, each of the MPUs converts its own initial file state into file storage startup; in the third time slot, each of the MPUs sends a check code calculation signal to the file maintenance task, and each of the MPUs converts its own file state from file storage startup to file check code calculation.
[0080] In the second operation cycle of the main task, in the first time slot, each of the MPUs sends a second file management message to other MPUs and receives a second file management message multicasted by other MPUs; the second file management message includes the size and check code of the new file and the file status; in the second time slot, each of the MPUs performs consistency check on its own file status with the file status multicasted by other MPUs to obtain second file synchronization information and output it to the application; in the third time slot, each of the MPUs receives a new file check code fed back by the file maintenance task, and each of the MPUs converts its own file status from file check code being calculated to file check code calculation completed.
[0081] In the third operation cycle of the main task, in the first time slot, each of the MPUs sends a third file management message to other MPUs and receives a third file management message multicasted by other MPUs; the third file management message includes the size and checksum of the new file and the file status; in the second time slot, each of the MPUs performs a consistency check on its own file status with the file status multicasted by other MPUs to obtain third file synchronization information and output it to the application; in the third time slot, each of the MPUs performs a consistency check on the new file checksum obtained by itself with the new file checksum multicasted by other MPUs, and after the check is passed, each of the MPUs sends the file write signal to the file maintenance task, and each of the MPUs converts its own file status from file checksum calculation completed to file being written.
[0082] In the fourth operation cycle of the main task, in the first time slot, each of the MPUs sends a fourth file management message to other MPUs and receives a fourth file management message multicasted by other MPUs; the fourth file management message includes the size and checksum of the new file and the file status; in the second time slot, each of the MPUs performs a consistency check on its own file status with the file status multicasted by other MPUs to obtain fourth file synchronization information and output it to the application; in the third time slot, each of the MPUs receives the file writing result fed back by the file maintenance task, and each of the MPUs converts its own file status from the file being written to the file writing completion status.
[0083] In the fifth operation cycle of the main task, in the first time slot, each of the MPUs sends the fifth file management message to other MPUs and receives the fifth file management message multicast by other MPUs; the fifth file management message includes the size and checksum of the new file and the file status; in the second time slot, each of the MPUs performs consistency check on its own file status with the file status multicast by other MPUs to obtain the fifth file synchronization information and output it to the application; in the third time slot, each of the MPUs converts its own file status from the file write completion status to the file storage completion status.
[0084] Specifically, in this embodiment, in the second time slot of the first operating cycle of the main task, since the initial file status of all MPUs is that the file storage is completed STORECOMPLETE or that the file does not exist NOTEXIST, the first file synchronization information is that the file storage is completed STORECOMPLETE or that the file does not exist NOTEXIST. At this time, the application can send a new file storage command to each of the MPUs according to the first file synchronization information. More specifically, when storing the same file, the application only sends a new file storage command to each of the MPUs in the first operating cycle of the main task, that is, from the second operating cycle of the main task until the file storage is completed or the storage fails, the application only receives the corresponding file synchronization information and no longer sends any commands, but the present invention is not limited to this.
[0085] Specifically, in this embodiment, in the second time slot of the second operation cycle of the main task, since the file status of all MPUs is that the file verification code is calculating CALMD5, the second file synchronization information is that the file verification code is calculating CALMD5. In the third time slot, different situations may occur. In the first situation, each of the MPUs receives a new file verification code, and each of the MPUs changes its own file status from "file verification code is being calculated CALMD5" to "file verification code calculation completed CALMD5_DONE"; in the second situation, only three MPUs (MPU1A, MPU2A and MPU1B) receive a new file verification code, and the three MPUs (MPU1A, MPU2A and MPU1B) change their own file status from "file verification code is being calculated CALMD5" to "file verification code calculation completed CALMD5_DONE"; since the file verification code has a tolerance period of 2, this operation period is the first tolerance period, and the file status of the other MPU (i.e., MPU2B) that has not received the new file verification code is still "file verification code is being calculated CALMD5", and continues to wait for feedback from the file maintenance task, but the present invention is not limited to this.
[0086] Specifically, in this embodiment, for the first case: in the second time slot of the third operation cycle of the main task, since the file status of all MPUs is that the file check code is calculating CALMD5, the third file synchronization information is that the file check code is calculating CALMD5. In the third time slot, if the new file check codes of each MPU are all consistent, each MPU can send the file write signal to the file maintenance task and convert its own file status from file check code calculation completed to file being written.
[0087] For the second case: in the second time slot of the third operation cycle of the main task, since only three MPUs (MPU1A, MPU2A and MPU1B) have a file status of file verification code calculation completed CALMD5_DONE, the file status of another MPU (MPU2B) that has not received a new file verification code in the second operation cycle is still file verification code calculation CALMD5, then the third file synchronization information is all file asynchronous STATENOTSYN. In the third time slot, if an MPU (i.e., MPU2B) that has not received the new file verification code in the second operation cycle receives the new file verification code at this time, the MPU (i.e., MPU2B) can convert its own file status from the file verification code being calculated to the file verification code calculation completed; since the MPU (i.e., MPU2B) has saved the new file verification code multicasted by the other three MPUs (i.e., MPU1A, MPU2A, and MPU1B) locally, the MPU (i.e., MPU2B) can perform consistency check on the new file verification code with the other three MPUs (i.e., MPU1A, MPU2A, and MPU1B), and when the check passes, the MPU (i.e., MPU2B) MPU U2B) can send the file write signal to the file maintenance task, and convert its own file status from file check code calculation completed CALMD5_DONE to file being written to SAVEFLASH; in addition, since the new file check code of the MPU (i.e., MPU2B) is still in the calculation state when the other three MPUs (i.e., MPU1A, MPU2A and MPU1B) perform consistency check on the new file check code, the other three MPUs (i.e., MPU1A, MPU2A and MPU1B) will convert their own file status to file being written to SAVEFLASH in the next cycle, i.e., the fourth operating cycle, but the present invention is not limited to this.
[0088] Specifically, in this embodiment, since the sizes of the new files to be stored are different and a segmented intermittent writing method is adopted, the file maintenance task may take several operation cycles from receiving the file write signal to writing the new file to the preset memory to feeding back the new file write result to the main task. Therefore, the file maintenance task will feed back the new file write result to the main task in the Nth operation cycle (N is an integer and N≥4).
[0089] For the first case: all MPUs change their own file status from file being written to SAVEFLASH to file writing completion status SAVEFLASH_DONE in the Nth operation cycle; and in the N+1th operation cycle, the file synchronization information of each MPU is the file writing completion status SAVEFLASH_DONE, and each MPU changes its own file status from the file writing completion status SAVEFLASH_DONE to the file storage completion STORECOMPLETE.
[0090] For the second case: one MPU (i.e., MPU2B) will change its own file status from "file is being written to SAVEFLASH" to "file write completed status SAVEFLASH_DONE" in the Nth operation cycle, and change its own file status to "file storage completed STORECOMPLETE" in the N+1th operation cycle; three MPUs (respectively, MPU1A, MPU2A, and MPU1B) will change their own file status from "file is being written to SAVEFLASH" to "file write completed status SAVEFLASH_DONE" in the N+1th operation cycle, and change their own file status to "file storage completed STORECOMPLETE" in the N+2th operation cycle. Therefore, in the N+3th operation cycle, the file synchronization information of each MPU is "file storage completed STORECOMPLETE".
[0091] Please continue to refer to Figure 1 , if the file status of any of the MPUs is converted to file storage failure, the file status of other MPUs will all be converted to file storage failure.
[0092] Specifically, in the present embodiment, when storing a file, if the file status of any MPU (i.e., MPU2B) is converted to file storage failure STOREFAILED, then the remaining MPUs (respectively, MPU1A, MPU2A, and MPU1B) will convert their own file status to file storage failure STOREFAILED because the new file verification code fails or because it is found that the file status of an MPU (i.e., MPU2B) is converted to file storage failure STOREFAILED, thereby achieving consistency of file status, but the present invention is not limited to this.
[0093] In summary, this embodiment provides a file storage method, which can divide the file storage process into several file states and divide the file storage task into a main task and a file maintenance task; each MPU can perform multicast, synchronization and conversion of the file state in the main task to generate a file write signal, so that each MPU can write the file to the preset memory in the file maintenance task according to the file write signal, thereby completing the storage of the file with very little main task time, thereby greatly improving the availability of the system. This embodiment can also perform operations such as checksum calculation and file deletion in the file maintenance task that are time-consuming, that is, operations that occupy a long CPU time, thereby completing the file checksum calculation, etc. with very little main task time, thereby further improving the availability of the system. In this embodiment, during the operation cycle of the main task, when the file status of each MPU itself is consistent with the file status of other MPUs, the file synchronization information of all MPUs can be set to its own file status, otherwise the file synchronization information of all MPUs is set to file synchronization, so as to ensure that the file synchronization information of all MPUs is the same, thereby ensuring that the MPUs output consistent file status when asynchronously calculating check codes and asynchronously writing operations, thereby realizing synchronous control of the asynchronous file storage process, and enabling the upper-layer application to obtain synchronous and consistent file status.
[0094] Although the content of the present invention has been described in detail through the above preferred embodiments, it should be appreciated that the above description should not be considered as a limitation of the present invention. After reading the above content, it will be apparent to those skilled in the art that various modifications and substitutions of the present invention will occur. Therefore, the protection scope of the present invention should be limited by the appended claims.
Claims
1. A file storage method, applied to a secure computing platform, wherein the secure computing platform comprises a main system and a backup system, wherein the main system and the backup system respectively comprise at least two logic operation units MPU, and all the MPUs store the same file; characterized in that: The file storage method comprises: Divide the file storage process into several file states; Divide file storage tasks into main tasks and file maintenance tasks; Each of the MPUs performs multicast, synchronization and conversion of the file status in the main task to generate a file write signal and sends it to the file maintenance task; and Each of the MPUs writes the file into a preset memory according to the file write signal in the file maintenance task to store the file; Before executing the steps of each of the MPUs performing multicasting, synchronization and conversion of the file status in the main task, the method further includes: Each of the MPUs reads the stored file to obtain the size and checksum of the stored file; Each of the MPUs multicasts the size and check code of the stored file obtained by itself to other MPUs, and receives the size and check code of the stored file multicasted by other MPUs; Each of the MPUs performs consistency check on the size and check code of the stored file obtained by itself and the size and check code of the stored file multicasted by other MPUs to obtain an initial file status; The size and checksum of the stored file obtained by each MPU itself are consistent with the size and checksum of the stored file multicasted by other MPUs, and the initial file status of all MPUs is that the file storage is completed; The size and checksum of the stored file obtained by any of the MPUs are inconsistent with the size and checksum of the stored file multicast by other MPUs, and the initial file status of all MPUs is that the file does not exist; The steps of each of the MPUs performing multicast, synchronization and conversion of the file status in the main task include: Dividing the operation cycle of the main task into a first time slot, a second time slot and a third time slot; In the first time slot, each of the MPUs multicasts a file management message to other MPUs, and receives a file management message multicast by other MPUs; the file management message includes a file size, a file status, and a file check code; In the second time slot, each of the MPUs performs consistency check on its own file status and the file status multicasted by other MPUs to obtain file synchronization information and output it; In the third time slot, each of the MPUs converts its own file status to generate a check code calculation signal or the file write signal and sends it to the file maintenance task; The file status of each MPU is consistent with the file status of other MPU multicasts, and the file synchronization information of all MPUs is their own file status; The file status of any of the MPUs is inconsistent with the file status of other MPU multicasts, and the file synchronization information of all MPUs is that the files are out of sync; Each of the MPUs calculates a file check code according to the check code calculation signal in the file maintenance task and feeds it back to the main task; and writes the file into the preset memory according to the file write signal, and feeds back the file write result to the main task.
2. The file storage method according to claim 1, characterized in that: The file states include file does not exist, file storage is started, file verification code is being calculated, file verification code calculation is completed, file is being written, file writing is completed, file storage is completed, file storage fails, and file is out of sync.
3. The file storage method according to claim 1, characterized in that: The priority of the main task is higher than the priority of the file maintenance task.
4. The file storage method according to claim 1, characterized in that: When storing the same file, the number of the operation cycles of the main task is at least five, namely, the first operation cycle, the second operation cycle, the third operation cycle, the fourth operation cycle and the fifth operation cycle; and in the first operation cycle of the main task, In the first time slot, each of the MPUs sends a first file management message to other MPUs and receives a first file management message multicasted by other MPUs; The first file management message is the size and checksum of the stored file and the initial file status; In the second time slot, each of the MPUs performs consistency check on its own initial file status and the initial file status multicasted by other MPUs to obtain first file synchronization information and output it to the application; The application sends a new file storage command to each of the MPUs; And according to the new file storage command, each of the MPUs converts its own initial file state to file storage start; In the third time slot, each of the MPUs sends a verification code calculation signal to the file maintenance task, and each of the MPUs converts its own file status from file storage startup to file verification code calculation.
5. The file storage method according to claim 4, characterized in that: In the second operation cycle of the main task, In the first time slot, each of the MPUs sends a second file management message to other MPUs and receives a second file management message multicasted by other MPUs; the second file management message includes the size and checksum of the new file and the file status; In the second time slot, each of the MPUs performs consistency check on its own file status and the file status multicasted by other MPUs to obtain second file synchronization information and output it to the application; In the third time slot, each of the MPUs receives a new file verification code fed back by the file maintenance task, and each of the MPUs changes its own file status from file verification code being calculated to file verification code calculation completed.
6. The file storage method according to claim 5, characterized in that: In the third operation cycle of the main task, In the first time slot, each of the MPUs sends a third file management message to other MPUs and receives a third file management message multicasted by other MPUs; the third file management message includes the size and checksum of the new file and the file status; In the second time slot, each of the MPUs performs consistency check on its own file status and the file status multicasted by other MPUs to obtain third file synchronization information and output it to the application; In the third time slot, each of the MPUs will perform consistency check on the new file verification code obtained by itself and the new file verification codes multicast by other MPUs, and after the check is passed, each of the MPUs will send the file write signal to the file maintenance task, and each of the MPUs will convert its own file status from file verification code calculation completed to file being written.
7. The file storage method according to claim 6, characterized in that: In the fourth operation cycle of the main task, In the first time slot, each of the MPUs sends a fourth file management message to other MPUs and receives a fourth file management message multicasted by other MPUs; The fourth file management message includes the size and checksum of the new file and the file status; In the second time slot, each of the MPUs performs consistency check on its own file status and the file status multicasted by other MPUs to obtain fourth file synchronization information and output it to the application; In the third time slot, each of the MPUs receives the file writing result fed back by the file maintenance task, and each of the MPUs converts its own file status from a file writing in progress status to a file writing completion status.
8. The file storage method according to claim 7, characterized in that: In the fifth running cycle of the main task, In the first time slot, each of the MPUs sends a fifth file management message to other MPUs and receives a fifth file management message multicasted by other MPUs; the fifth file management message includes the size and checksum of the new file and the file status; In the second time slot, each of the MPUs performs consistency check on its own file status and the file status multicasted by other MPUs to obtain fifth file synchronization information and output it to the application; In the third time slot, each of the MPUs converts its own file status from a file writing completion status to a file storage completion status.
9. The file storage method according to claim 5, characterized in that: If any of the MPUs fails to receive a new file verification code fed back by the file maintenance task within a first preset time period, the MPU converts its own file status to file storage failure.
10. The file storage method according to claim 6, characterized in that: If the new file verification code obtained by any of the MPUs is inconsistent with the new file verification codes multicast by other MPUs, the file status of all MPUs will be converted to file storage failure.
11. The file storage method according to claim 7, characterized in that: If any of the MPUs does not receive the file writing result fed back by the file maintenance task within the second preset time period, it converts its own file status to file storage failure.
12. The file storage method according to any one of claims 9 to 11, characterized in that: If the file status of any of the MPUs is converted to file storage failure, the file status of other MPUs are all converted to file storage failure.
Citation Information
Patent Citations
Data processing method and device and computer equipment
CN107992752A
File loading method by means of inter-processor communication(IPC), especially for loading desired file to desired processor between processors equipped in exchange for transmitting / receiving ipc message
KR1019990039779A