A file management method based on loongson 2k1000 and domestic door operating system

By adopting a file management method based on Loongson 2k1000 and a domestic operating system, using RTC to generate date and time strings to construct directory and file names, and combining it with a message queue mechanism, the problem of managing and storing a large amount of experimental data on surface ships was solved, realizing convenient retrieval and automatic cleanup, and ensuring the effective use of hard disk space.

CN116126788BActive Publication Date: 2026-01-13CHINA STATE SHIPBUILDING CORP NO 707 RES INST
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310103741.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-13
Publication Date
2026-01-13
Estimated Expiration
2043-02-13

AI Technical Summary

Technical Problem

When inertial navigation equipment is installed on surface ships, long-term voyages result in a large number of test data files, requiring a reasonable directory structure and file naming mechanism for easy retrieval and management. At the same time, limited hard disk space necessitates the automatic cleanup of early data.

Method used

A file management method based on Loongson 2k1000 and the domestic Dao OS is adopted. The RTC timekeeping method is used to generate date and time strings, construct storage directories and file names, and design information storage process through message queue mechanism to achieve reliable data reception and storage.

Benefits of technology

It enables efficient file management on surface ships, ensuring convenient data retrieval, automatically cleaning up old data, guaranteeing efficient use of hard disk space, and meeting real-time and reliability requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116126788B_ABST
    Figure CN116126788B_ABST
Patent Text Reader

Abstract

The application relates to a file management method based on a Loongson 2K1000 and a domestic path operating system, and the method is based on a domestic Loongson 2K1000 and a path operating system software and hardware platform, a file management task is created after starting, is used for generating a new storage directory and a storage file, and hard disk space is monitored in real time to clean early data files in time. When the directory and the file are created, a real-time clock module (RTC) in the Loongson is used to generate a date and time string, which is attached to the name, so as to facilitate user retrieval and automatic cleaning. Basic file IO in the path operating system is used to perform file system operations such as directory and file creation, file reading and writing, remaining hard disk space query, directory and file deletion and the like. The message queue mechanism of the path operating system is used to design an information storage flow, so as to guarantee reliable reception and storage of data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of embedded computer application software technology, and in particular to a file management method based on Loongson 2k1000 and a domestic operating system. Background Technology

[0002] Inertial navigation equipment is installed on surface ships, and a single voyage can last for months, requiring the storage of a large amount of experimental data for post-voyage simulation and problem tracing. Due to the long voyage time and large data volume, the number of generated files is also enormous, necessitating the design of a reasonable directory structure and naming mechanism to facilitate user retrieval and management of experimental data files. Furthermore, the hard drive capacity used to store experimental data is limited, requiring automatic cleanup of older data when storage space is insufficient. Summary of the Invention

[0003] The purpose of this invention is to overcome the shortcomings of the prior art and propose a file management method based on Loongson 2k1000 and the domestic Dao OS, which can utilize the message queue mechanism of Dao OS to design information storage process and ensure reliable data reception and storage.

[0004] The technical problem solved by this invention is achieved through the following technical solution:

[0005] A file management method based on Loongson 2k1000 and a domestic operating system includes an RTC timekeeping method, a storage directory and filename construction method, a data storage method, and a file management method.

[0006] The RTC timekeeping method includes the following steps:

[0007] Step 1.1: Set the structure of RTC information data;

[0008] The RTC information data structure includes: millisecond value, second, minute, hour, day, month, year, RTC validity flag, and UTC validity count;

[0009] Step 1.2: Initialize the RTC;

[0010] Initialize the RTC information data structure to January 1, 2000, 00:00:00, and clear the RTC validity flag and UTC validity count to 0;

[0011] Step 1.3: Correct the RTC using the RMC message from the satellite navigation receiver;

[0012] Step 1.4: Read RTC information data after RTC calibration.

[0013] Furthermore, step 1.3 includes the following steps:

[0014] Step 1.3.1: Subtract the UTC time of the previous frame's RMC message from the UTC time of the current satellite navigation receiver's RMC message. If the difference is 1 second, increment the UTC valid count by 1; otherwise, clear the UTC valid count to 0.

[0015] Step 1.3.2: When the UTC valid count is greater than or equal to 5, if the current value of the RTC valid flag is 0, proceed to steps 1.3.3 to 1.3.5;

[0016] Step 1.3.3: Set the RTC valid flag to 1;

[0017] Step 1.3.4: Modify the RTC_INFO structure using UTC date and time;

[0018] Step 1.3.5: Call the RTC driver to write the date and time in RTC_INFO to the RTC.

[0019] Furthermore, step 1.4 includes the following steps:

[0020] Step 1.4.1: Call the RTC driver to read the current date and time into the RTC_INFO structure;

[0021] Step 1.4.2: Generate a date string using RTC date format YYYYMMDD, padding with zeros if the number of data bits is insufficient;

[0022] Step 1.4.3: Generate a time string using RTC time, in the format HHMMSS, padding with zeros if the number of data bits is insufficient.

[0023] Furthermore, the method for constructing the storage directory and filename includes the following steps:

[0024] Step 2.1: Construct a data type directory. The data type directory is a first-level directory with the format: data type name. The first-level directory stores all voyage data files of the same data type.

[0025] Step 2.2: Construct the voyage directory. The voyage directory is a second-level directory with the format: data type name_date_time. The second-level directory is created each time the system is powered on based on the RTC date and time and their validity, and is used to store the data files for this voyage.

[0026] Step 2.3: Generate storage files in the constructed voyage directory.

[0027] Furthermore, the data storage method includes the following steps:

[0028] Step 3.1: Determine if there is data in the current message queue. If there is data in the current message queue, proceed to step 3.2; otherwise, proceed to step 3.3.

[0029] Step 3.2: Take a piece of data from the head of the queue, save it as a message, and store it in a file of the corresponding data type;

[0030] Step 3.3: End the processing of the current message queue and move on to the processing of the next message queue.

[0031] Furthermore, the file management method includes: constructing a file management task operation mechanism, constructing a directory creation function, and a file cleanup function.

[0032] Furthermore, the aforementioned file management task execution mechanism includes the following steps:

[0033] Step 4.1.1: The functions of setting file management tasks include: directory creation and file cleanup;

[0034] Step 4.1.2: Set the priority of file management tasks;

[0035] Step 4.1.3: Set the execution cycle of the file management task;

[0036] The start time of this run is T0. If the time taken for this task to run is less than 1 second, the time taken for the next task to run will be T0+1 second. If the start time of this run is T0, and the time taken for this task to run is more than 1 second, the next task will start immediately after the task ends.

[0037] Furthermore, the directory creation function includes the following steps:

[0038] Step 4.2.1: Query the RTC validity flag. If the RTC validity flag is valid, proceed to step 4.2.2; otherwise, end the process.

[0039] Step 4.2.2: Enter each data type directory and check if the voyage directory has been created. If the voyage directory has been created, end the process; otherwise, proceed to step 4.2.3.

[0040] Step 4.2.3: Read the date and time of the RTC information data, create the voyage directory and the first data file of the voyage directory, and set the voyage directory creation flag to 1.

[0041] Furthermore, the file cleanup function includes the following steps:

[0042] Step 4.3.1: Query the remaining space on the hard drive. If the remaining space is less than the warning value, proceed to step 4.3.2; otherwise, end the process.

[0043] Step 4.3.2: Traverse all voyage directory names under the current data type directory and delete the voyage directory with the smallest string comparison result;

[0044] Step 4.3.3: Determine if there are any other data type directories that have not been cleaned up. If there are other data type directories that have not been cleaned up, return to 4.3.2; otherwise, end.

[0045] The advantages and positive effects of this invention are:

[0046] This invention is based on the domestic Loongson 2K1000 and Dao OS hardware and software platform. Upon boot, a file management task is created to generate new storage directories and files, and hard disk space is monitored in real time to promptly clean up older data files. When creating directories and files, the Loongson's internal real-time clock module (RTC) generates date and time strings that are appended to the names for easy user retrieval and automatic cleanup. Basic file I / O in the Dao OS is used for file system operations such as directory and file creation, file reading and writing, remaining hard disk space querying, and directory and file deletion. The message queue mechanism of the Dao OS is used to design the information storage process, ensuring reliable data reception and storage. Attached Figure Description

[0047] Figure 1 This is a schematic diagram of the storage directory structure of the present invention;

[0048] Figure 2 This is a schematic diagram of the data storage process of the present invention. Detailed Implementation

[0049] The present invention will be further described in detail below with reference to the accompanying drawings.

[0050] A file management method based on Loongson 2k1000 and a domestic operating system includes an RTC timekeeping method, a storage directory and filename construction method, a data storage method, and a file management method.

[0051] The RTC timekeeping method includes the following steps:

[0052] Step 1.1: Set the structure of RTC information data.

[0053] The RTC information data structure is defined as follows:

[0054]

[0055] Step 1.2: Initialize RTC.

[0056] The RTC information data structure is initialized to January 1, 2000, 00:00:00, and the RTC validity flag and UTC validity count are cleared to 0.

[0057] Step 1.3: Perform RTC correction using RMC messages from the satellite navigation receiver. To ensure the reliability of the satellite navigation information, the following criteria are used to determine the validity of the UTC time after receiving each frame:

[0058] Step 1.3.1: Subtract the UTC time of the previous frame's RMC message from the UTC time of the current satellite navigation receiver's RMC message. If the difference is 1 second, increment the UTC valid count by 1; otherwise, clear the UTC valid count to 0.

[0059] Step 1.3.2: When the UTC valid count is greater than or equal to 5, if the current value of the RTC valid flag is 0, proceed to steps 1.3.3 to 1.3.5;

[0060] Step 1.3.3: Set the RTC valid flag to 1;

[0061] Step 1.3.4: Modify the RTC_INFO structure using UTC date and time;

[0062] Step 1.3.5: Call the RTC driver to write the date and time in RTC_INFO to the RTC.

[0063] Once the RTC is corrected once (i.e., the RTC valid flag is set to 1), the RTC module can self-time without external information. Thereafter, the date and time information read from the RTC module can be used to generate new storage directories and storage file name strings.

[0064] Step 1.4: Read RTC information data after RTC calibration;

[0065] Step 1.4.1: Call the RTC driver to read the current date and time into the RTC_INFO structure;

[0066] Step 1.4.2: Generate a date string using RTC date format YYYYMMDD, padding with zeros if the number of data bits is insufficient;

[0067] Step 1.4.3: Generate a time string using RTC time, in the format HHMMSS, padding with zeros if the number of data bits is insufficient.

[0068] like Figure 1 As shown, the method for constructing storage directories and filenames includes the following steps:

[0069] Step 2.1: Construct a data type directory. The data type directory is a first-level directory with the format: data type name (such as "pulse100Hz", "atti1000Hz", etc.). The first-level directory stores all flight data files of the same data type.

[0070] Step 2.2: Construct the voyage directory. The voyage directory is a second-level directory with the format: data type name_date_time ("pulse100Hz_20220815_150130"). The second-level directory is created each time the system is powered on based on the RTC date and time and their validity, and is used to store the data files of this voyage.

[0071] Step 2.3: In the constructed voyage directory, automatically generate storage files according to the following strategy:

[0072] When creating the cruise catalog (in this example, "pulse100Hz_20220815_150130"), directly create the first storage file for this cruise, with the format: data type name_date_time.bin (in this example, "pulse100Hz_20220815_150130.bin");

[0073] If the data stored in the current file (“pulse100Hz_20220815_150130.bin” in this example exceeds 12 hours, then the current storage file is closed, and a new storage file is regenerated in the current flight directory (“pulse100Hz_20220815_150130” in this example) based on the RTC date and time, with the format: data type name_date_time.bin. (“pulse100Hz_20220816_030130.bin” in this example).

[0074] The experimental data is stored using the operating system's message queue mechanism. A first-in, first-out (FIFO) message queue is established for each data type, with a queue length equal to the maximum number of data packets that can be received within one second. Tasks that generate messages add them to the end of the corresponding data type's message queue in real time. Data storage tasks query the message queues of each stored data type every 10ms. The processing flow is as follows: Figure 2 As shown, the data storage method includes the following steps:

[0075] Step 3.1: Determine if there is data in the current message queue. If there is data in the current message queue, proceed to step 3.2; otherwise, proceed to step 3.3.

[0076] Step 3.2: Take a piece of data from the head of the queue, save it as a message, and store it in a file of the corresponding data type;

[0077] Step 3.3: End the processing of the current message queue and move on to the processing of the next message queue.

[0078] Furthermore, the file management method includes: constructing a file management task operation mechanism, constructing a directory creation function, and a file cleanup function.

[0079] The steps to build a file management task execution mechanism are as follows:

[0080] Step 4.1.1: The functions of setting file management tasks include: directory creation and file cleanup;

[0081] Step 4.1.2: Set the priority of file management tasks;

[0082] Step 4.1.3: Set the execution cycle of the file management task;

[0083] The start time of this run is T0. If the time taken for this task to run is less than 1 second, the time taken for the next task to run will be T0+1 second. If the start time of this run is T0, and the time taken for this task to run is more than 1 second, the next task will start immediately after the task ends.

[0084] Furthermore, the directory creation function includes the following steps:

[0085] Step 4.2.1: Query the RTC validity flag. If the RTC validity flag is valid, proceed to step 4.2.2; otherwise, end the process.

[0086] Step 4.2.2: Enter each data type directory and check if the voyage directory has been created. If the voyage directory has been created, end the process; otherwise, proceed to step 4.2.3.

[0087] Step 4.2.3: Read the date and time of the RTC information data, create the voyage directory and the first data file of the voyage directory, and set the voyage directory creation flag to 1.

[0088] Furthermore, the file cleanup function includes the following steps:

[0089] Step 4.3.1: Query the current remaining hard disk space. If the current remaining hard disk space is less than the warning value (2 GBytes in this example), proceed to step 4.3.2; otherwise, end.

[0090] Step 4.3.2: Traverse all voyage directory names under the current data type directory and delete the voyage directory with the smallest string comparison result;

[0091] Step 4.3.3: Determine if there are any other data type directories that have not been cleaned up. If there are other data type directories that have not been cleaned up, return to 4.3.2; otherwise, end.

[0092] Based on the above-mentioned file management method using Loongson 2k1000 and a domestic operating system, the effectiveness of the invention is demonstrated through testing.

[0093] The operating environment for this invention is:

[0094] Hardware environment:

[0095] Processor: Loongson 2k1000

[0096] CPU frequency: 1000MHz

[0097] Number of cores: 2

[0098] Memory: 2GB

[0099] Network interface card: Gigabit Ethernet x2

[0100] Hard drive: 512GB NVMe SSD

[0101] Software environment:

[0102] Operating System: DeltaOS 6.2

[0103] Local file system: FAT32

[0104] FTP server: The system comes with a built-in FTP service component.

[0105] Host computer environment:

[0106] Network interface card: Gigabit Ethernet

[0107] Operating System: WIN7

[0108] FTP client: FileZilla

[0109] Hardware and software resource configuration and initialization:

[0110] (1) System clock initialization: set sysClkRate to 1000;

[0111] (2) RTC initialization: After power-on, the RTC information data structure is initialized to January 1, 2000, 00:00:00, and the RTC validity flag and UTC validity count are cleared to 0.

[0112] (3) Message queue initialization:

[0113] The message queue type is FIFO

[0114] Message size is set to the length of the stored data packet.

[0115] The message count is set to the maximum number of data packets that can be received within 1 second.

[0116] (4) Data storage task initialization:

[0117] Task priority: 105

[0118] Task type: Floating-point task

[0119] Task stack: 200000

[0120] (5) File management task initialization:

[0121] Task priority: 107

[0122] Task type: Floating-point task

[0123] Task stack: 200000.

[0124] The operating plan is as follows:

[0125] (1) Data storage task execution plan

[0126] a) Use binary semaphores to control task execution, with a cycle time of 10ms;

[0127] b) After the task acquires CPU control and enters the running state, it uses a non-blocking method to obtain the number of messages in each message queue;

[0128] c) If there is data in the message queue, write each message to the corresponding storage file in sequence;

[0129] d) If the current file has stored data for 12 hours, close the current file and regenerate a new storage file using the RTC date and time.

[0130] (2) File Management Task Execution Plan

[0131] a) Get the current sysClkTick value T0;

[0132] b) If the current voyage catalog has not been created, proceed to c); otherwise, proceed to d).

[0133] c) If the RTC valid flag is 1, create the current voyage storage directory based on the RTC date and time; otherwise, proceed to d).

[0134] d) Perform file cleanup operations based on the remaining hard disk space;

[0135] e) Get the current sysClkTick value T1;

[0136] f) If (T1-T0)<1000, then proceed to g); otherwise, proceed to h).

[0137] g) Wait for (1000 - (T1 - T0)) ticks;

[0138] h) Return to a).

[0139] (3) Message queue operation functions

[0140] The DeltaOS operating system provides a message queue library (msgQLib.h). The functions and features used in this invention are shown in the table below:

[0141] Message queue functions Functionality msgQCreate Create a message queue msgQSend Send the message to the tail of the message queue. msgQNumMsgs Get the number of unread messages in the message queue msgQReceive Fetch the next message from the head of the message queue.

[0142] (4) Standard file I / O functions

[0143] The DeltaOS operating system provides a standard file I / O library (stdio.h). The functions and features used in this invention are shown in the table below:

[0144]

[0145] (5) File transfer scheme

[0146] Data transmission utilizes the built-in FTP service component of the operating system. A regular Windows computer is connected to the inertial navigation device via a network cable. After connecting to the FTP service using the FileZilla client, users can perform basic file operations such as querying, downloading, modifying, and deleting data files on the hard drive.

[0147] This invention has been running stably for three months in a scientific research experiment on a surface warship, during which no less than 100GB of data was collected. The designed directory storage structure and naming method facilitate user querying and file management. When hard disk space is insufficient, it can automatically clean up early files, ensuring the real-time performance and reliability of other tasks while fulfilling file management functions.

[0148] It should be emphasized that the embodiments described in this invention are illustrative rather than limiting. Therefore, this invention includes, but is not limited to, the embodiments described in the specific implementation. Any other implementations derived by those skilled in the art based on the technical solutions of this invention are also within the scope of protection of this invention.

Claims

1. A file management method based on Loongson 2k1000 and a domestically developed operating system, characterized in that: This includes RTC timekeeping methods, methods for constructing storage directories and filenames, methods for data storage, and methods for file management. The RTC timekeeping method includes the following steps: Step 1.1: Set the structure of RTC information data; The RTC information data structure includes: millisecond value, second, minute, hour, day, month, year, RTC validity flag, and UTC validity count; Step 1.2: Initialize the RTC; Initialize the RTC information data structure to January 1, 2000, 00:00:00, and clear the RTC validity flag and UTC validity count to 0; Step 1.3: Correct the RTC using the RMC message from the satellite navigation receiver; Step 1.3.1: Subtract the UTC time of the previous frame's RMC message from the UTC time of the current satellite navigation receiver's RMC message. If the difference is 1 second, increment the UTC valid count by 1; otherwise, clear the UTC valid count to 0. Step 1.3.2: When the UTC valid count is greater than or equal to 5, if the current value of the RTC valid flag is 0, proceed to steps 1.3.3 to 1.3.5; Step 1.3.3: Set the RTC valid flag to 1; Step 1.3.4: Modify the RTC_INFO structure using UTC date and time; Step 1.3.5: Call the RTC driver to write the date and time from RTC_INFO to the RTC; Step 1.4: Read RTC information data after RTC calibration; The method for constructing storage directories and filenames includes the following steps: Step 2.1: Construct a data type directory. The data type directory is a first-level directory with the format: data type name. The first-level directory stores all voyage data files of the same data type. Step 2.2: Construct the voyage directory. The voyage directory is a second-level directory with the format: data type name_date_time. The second-level directory is created each time the system is powered on based on the RTC date and time and their validity, and is used to store the data files for this voyage. Step 2.3: Generate storage files in the constructed voyage directory.

2. The file management method based on Loongson 2k1000 and a domestic operating system according to claim 1, characterized in that: Step 1.4 includes the following steps: Step 1.4.1: Call the RTC driver to read the current date and time into the RTC_INFO structure; Step 1.4.2: Generate a date string using RTC date format YYYYMMDD, padding with zeros if the number of data bits is insufficient; Step 1.4.3: Generate a time string using RTC time, in the format HHMMSS, padding with zeros if the number of data bits is insufficient.

3. The file management method based on Loongson 2k1000 and a domestic operating system according to claim 1, characterized in that: The data storage method includes the following steps: Step 3.1: Determine if there is data in the current message queue. If there is data in the current message queue, proceed to step 3.2; otherwise, proceed to step 3.

3. Step 3.2: Take a piece of data from the head of the queue, save it as a message, and store it in a file of the corresponding data type; Step 3.3: End the processing of the current message queue and move on to the processing of the next message queue.

4. The file management method based on Loongson 2k1000 and a domestic operating system according to claim 1, characterized in that: The file management method includes: constructing a file management task operation mechanism, constructing a directory creation function, and a file cleanup function.

5. The file management method based on Loongson 2k1000 and a domestic operating system according to claim 4, characterized in that: The mechanism for executing the file management task includes the following steps: Step 4.1.1: The functions of setting file management tasks include: directory creation and file cleanup; Step 4.1.2: Set the priority of file management tasks; Step 4.1.3: Set the execution cycle of the file management task; The start time of this run is T0. If the time taken for this task to run is less than 1 second, the time taken for the next task to run will be T0+1 second. If the start time of this run is T0, and the time taken for this task to run is more than 1 second, the next task will start immediately after the task ends.

6. The file management method based on Loongson 2k1000 and a domestic operating system according to claim 4, characterized in that: The directory creation function includes the following steps: Step 4.2.1: Query the RTC validity flag. If the RTC validity flag is valid, proceed to step 4.2.2; otherwise, end the process. Step 4.2.2: Enter each data type directory and check if the voyage directory has been created. If the voyage directory has been created, end the process; otherwise, proceed to step 4.2.

3. Step 4.2.3: Read the date and time of the RTC information data, create the voyage directory and the first data file of the voyage directory, and set the voyage directory creation flag to 1.

7. A file management method based on Loongson 2k1000 and a domestic operating system according to claim 4, characterized in that: The file cleanup function includes the following steps: Step 4.3.1: Query the remaining space on the hard drive. If the remaining space is less than the warning value, proceed to step 4.3.2; otherwise, end the process. Step 4.3.2: Traverse all voyage directory names under the current data type directory and delete the voyage directory with the smallest string comparison result; Step 4.3.3: Determine if there are any other data type directories that have not been cleaned up. If there are other data type directories that have not been cleaned up, return to 4.3.2; otherwise, end.

Citation Information

Patent Citations

  • Rapid high-precision time service method for embedded GPS terminal

    CN110515294A

  • Timing startup method and device based on Loongson, and computer readable storage medium

    CN111984333A