Log recording method and device, electronic equipment and storage medium
Through the combination of arbitration module and data processing module, the task type is judged and logs are recorded in a delayed manner, which solves the problem of excessive CPU burden on the embedded operating system, and achieves real-time and resource saving effects.
Patent Information
- Application Number
- CN202411220366.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-12-27
AI Technical Summary
When an embedded operating system performs logging tasks and other tasks with high real-time requirements, the CPU is overburdened, affecting real-time. The existing technology requires additional equipment to record data, which increases complexity and cost.
The combination of arbitration module and a data processing module is adopted to obtain the associated information of the target task, judge the task type, decide whether to delay logging, reduce IO operations, avoid frequent CPU burdens, and do not require external logging devices.
It alleviates the CPU burden, ensures the real-time nature of the embedded operating system, reduces network resource consumption and implementation costs, and simplifies the complexity of the solution.
Smart Images

Figure CN119201602A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of embedded operating system log recording, and in particular to a log recording method, device, electronic device and storage medium. Background Art
[0002] Embedded operating systems have good reliability and excellent real-time performance, and are widely used in communications, military, aviation, aerospace and other high-tech fields as well as fields with extremely high real-time requirements, such as satellite communications, navigation and guidance. The real-time performance of embedded operating systems is reflected in completing the specified tasks within a limited time and responding to external asynchronous events.
[0003] When designing embedded operating system software, it is necessary to perform logging tasks through the embedded operating system to record the generated error data or key status data. This process requires frequent IO (Input / Output) operations on the embedded operating system. At the same time, the embedded operating system will also perform other tasks with high real-time requirements, and will also perform frequent IO operations, which will occupy a large amount of CPU resources of the embedded device, making the CPU overloaded and affecting the real-time performance of the embedded operating system. In the prior art, the error data or key status data of the embedded operating system is sent to the backup device through UDP (User Datagram Protocol) for recording, which will not affect the real-time performance of the embedded operating system of the embedded device, but this requires the addition of an additional device that does not require real-time performance, consumes network resources, increases the complexity of the solution, and has a high implementation cost.
[0004] Therefore, when the embedded operating system executes logging tasks and other tasks with high real-time requirements at the same time, the CPU is overloaded and cannot maintain the real-time performance of the embedded operating system, which is an existing problem.
[0005] Application Contents
[0006] In view of this, the purpose of the present application is to provide a method to solve the above problems, reduce the burden of the CPU of the embedded operating system, and ensure the real-time performance of the embedded operating system.
[0007] In a first aspect, an embodiment of the present application provides a log recording method, wherein the embedded operating system includes an arbitration module and a data processing module; the method includes:
[0008] The arbitration module obtains the associated information of the target task being executed by the embedded operating system; wherein the target task includes: a real-time task and a non-real-time task, and the priority of the non-real-time task is lower than the priority of the real-time task;
[0009] The arbitration module determines whether the target task is the non-real-time task according to the description of the target task in the association information, and obtains a first determination result;
[0010] If the first judgment result indicates that the target task is the non-real-time task, determining whether the real-time task stops running to obtain a second judgment result;
[0011] If the second judgment result indicates that the real-time task stops running, the arbitration module sends a first instruction to the data processing module, so that the data processing module records the execution log of the target task according to the first instruction;
[0012] If the first judgment result indicates that the target task is a real-time task, the arbitration module sends a second instruction to the data processing module, so that the data processing module records the execution log of the target task after a first delay period according to the second instruction.
[0013] Preferably, the method further comprises:
[0014] If the first judgment result indicates that the target task is a real-time task, the arbitration module sends the first instruction to the data processing module after delaying the first period of time, so that the data processing module records the execution log of the target task according to the first instruction.
[0015] Preferably, the embedded operating system further includes an initialization module; and the method further includes:
[0016] If the log record folder and the log configuration file exist at the same time, the initialization module obtains the number of log record files in the log record folder; wherein the log configuration file is used to record the number of each log record file created;
[0017] If the number of the log record files is less than the number threshold, the initialization module creates the tth log record file; wherein the number threshold is the maximum number of log record files allowed to exist in the log record folder;
[0018] The initialization module records the number of the tth log record file as t in the log configuration file.
[0019] Preferably, the method further comprises:
[0020] If the log record folder exists and the log configuration file does not exist, the initialization module creates the log configuration file and the first log record file;
[0021] The initialization module records the number of the first log record file as 1 in the log configuration file.
[0022] Preferably, the method further comprises:
[0023] If the number of the log record files is equal to the number threshold, the initialization module deletes some or all of the log record files and creates the tth log record file;
[0024] The initialization module records the number of the tth log record file as t in the log configuration file.
[0025] Preferably, the execution log includes a text log and a data flow log; the method further includes:
[0026] The data processing module obtains the execution log;
[0027] If the execution log is the text log, the initialization module creates a text log message queue according to the number and memory occupied by the text log;
[0028] If the execution log is the data flow log, the initialization module creates a data flow log message queue according to the number of the data flow logs and the memory occupied.
[0029] Preferably, the step of recording the execution log of the target task includes:
[0030] If the execution log is the data flow log, the data processing module determines the type, generation time, ID and byte length of the data flow log according to the content of the data flow log recorded in the data flow log message queue;
[0031] The data processing module records the content, type, generation time, ID and byte length of the data flow log in the form of binary data in the log record file;
[0032] If the execution log is the text log, the data processing module records the content and generation time of the text log recorded by the text log message queue in a text form in a corresponding log record file.
[0033] The logging method provided by this application brings the following beneficial effects:
[0034] The present application provides a log recording method, in which the arbitration module determines whether the target task is a non-real-time task according to the description of the target task in the associated information, and if so, determines whether the real-time task stops running, and if so, sends a first instruction to the data processing module so that the data processing module records the execution log of the target task according to the first instruction, and if not, the arbitration module sends a second instruction to the data processing module so that the data processing module records the execution log of the target task after a delay of the first period according to the second instruction. The method does not require frequent IO operations, relieves the burden of the CPU, occupies less CPU resources, and ensures the real-time performance of the embedded operating system when executing the target task. In addition, the method does not require additional log recording equipment outside the embedded operating device, saves network resources, reduces the complexity of the solution, and reduces the implementation cost.
[0035] In a second aspect, the present application further provides a log recording device, the device comprising:
[0036] The arbitration module is used to obtain the associated information of the target task being executed by the embedded operating system; wherein the target task includes: a real-time task and a non-real-time task, and the priority of the non-real-time task is lower than the priority of the real-time task;
[0037] The arbitration module is further used to determine whether the target task is the non-real-time task according to the description of the target task in the association information, and obtain a first determination result;
[0038] The arbitration module is further configured to determine whether the real-time task stops running if the first determination result indicates that the target task is the non-real-time task, thereby obtaining a second determination result;
[0039] The arbitration module is further configured to send a first instruction to the data processing module if the second judgment result indicates that the real-time task stops running;
[0040] The data processing module is used to record the execution log of the target task according to the first instruction;
[0041] The arbitration module is further configured to send a second instruction to the data processing module if the first judgment result indicates that the target task is a real-time task;
[0042] The data processing module is further configured to record the execution log of the target task after a delay of a first period of time according to the second instruction.
[0043] The log recording device provided in the embodiment of the present application has the same technical features as the log recording method provided in the above embodiment, so it can also solve the same technical problems and achieve the same technical effects.
[0044] In a third aspect, the present application also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the beneficial effects of any of the methods described above are achieved, which will not be repeated here.
[0045] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the beneficial effects of any of the methods described above are achieved, which will not be repeated here.
[0046] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or understood by practicing the present application. The purpose and other advantages of the present application are realized and obtained by the structures particularly pointed out in the description and the drawings.
[0047] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0049] Figure 1 A flow chart of a log recording method provided in an embodiment of the present application;
[0050] Figure 2 A schematic diagram of the structure of a log recording device provided in an embodiment of the present application;
[0051] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present application.
[0053] To facilitate understanding of this embodiment, the embodiments of the present application are described in detail below.
[0054] The present application embodiment provides a log recording method, such as Figure 1 As shown, Figure 1 A flow chart of a log recording method provided in an embodiment of the present application. The embedded operating system includes an arbitration module 21 and a data processing module 22, and the method includes the following steps:
[0055] S101, the arbitration module 21 obtains the associated information of the target task being executed by the embedded operating system.
[0056] The target tasks include: real-time tasks and non-real-time tasks, and the priority of the non-real-time tasks is lower than that of the real-time tasks.
[0057] Specifically, after obtaining the associated information, the arbitration module 21 may further determine the real-time requirement of the target task for the embedded operating system according to the associated information of the target task.
[0058] S102, the arbitration module 21 determines whether the target task is a non-real-time task according to the description of the target task in the associated information, and if so, executes step S103, and if not, executes step S106.
[0059] Specifically, the above description is a priority. The arbitration module 21 determines whether the target task is a non-real-time task according to the priority of the associated information. For example, the target tasks to be executed include a, b, and c. The priority of a is preset to be higher than the priority of b, and the priority of b is higher than the priority of c. The target task with a priority lower than or equal to the priority of b is a non-real-time task.
[0060] S103, the arbitration module 21 determines whether the real-time task stops running, if so, executes step S104, if not, executes step S106.
[0061] Specifically, the priority of the real-time task is higher than that of the non-real-time task. The arbitration module 21 determines whether the real-time task stops running to determine whether to send the first instruction or the second instruction to the data processing module 22 .
[0062] S104 , the arbitration module 21 sends a first instruction to the data processing module 22 .
[0063] Specifically, if the target task is a non-real-time task, the data processing module 22 sends a first instruction to the data processing module 22 through the semGive function, wherein the semGive function is a semaphore release function. From the above, it can be seen that if the target task currently executed by the embedded operating system is b (non-real-time task) or c (non-real-time task), the arbitration module 21 sends a first instruction to the data processing module 22.
[0064] S105: the data processing module 22 records the execution log of the target task according to the first instruction.
[0065] Specifically, the first instruction is a semaphore. The semaphore is used to control access to shared resources and realize synchronization and mutual exclusion between processes or threads. The data processing module 22 obtains the semaphore, which means that the target task currently executed by the embedded operating system is a non-real-time task. The target task has low requirements for the real-time performance of the embedded operating system. At this time, the IO interface of the embedded operating system is not busy and the CPU burden is light. At this time, the data processing module 22 records the execution log of the target task, which will not affect the real-time performance of the embedded operating system.
[0066] S106 , the arbitration module 21 sends a second instruction to the data processing module 22 .
[0067] Specifically, if the target task is a real-time task, the arbitration module 21 sends the second instruction to the data processing module 22. As can be seen from the above, if the target task currently executed by the embedded operating system is a (real-time task), the arbitration module 21 sends the second instruction to the data processing module 22.
[0068] S107, the data processing module 22 records the execution log of the target task after a delay of the first period according to the second instruction.
[0069] Specifically, the data processing module 22 obtains the second instruction, which means that the target task executed by the current embedded operating system is a real-time task. The target task has high requirements on the real-time performance of the embedded operating system. At this time, the IO interface of the embedded operating system is relatively busy and the CPU is heavily burdened. At this time, the data processing module 22 records the execution log of the target task, which will affect the real-time performance of the embedded operating system. Therefore, after obtaining the second instruction, the data processing module 22 delays the first period, waits for the target task to be executed, and then records the execution log of the target task.
[0070] The embodiment of the present application provides a log recording method, in which the arbitration module 21 determines whether the target task is a non-real-time task according to the description of the target task in the associated information. If so, the arbitration module 21 sends a first instruction to the data processing module 22, so that the data processing module 22 records the execution log of the target task according to the first instruction; if not, the arbitration module 21 sends a second instruction to the data processing module 22, so that the data processing module 22 records the execution log of the target task after delaying the first period according to the second instruction. In the prior art, regardless of whether the target task currently executed by the embedded operating system is a non-real-time task, the data processing module 22 will record the execution log of the target task. Compared with the prior art, the method adds an arbitration module 21, and the data processing module 22 records the execution log of the target task when it obtains the first instruction sent by the arbitration module 21. After the data processing module 22 obtains the first instruction sent by the arbitration module 21, it delays and waits for the first period to record the execution log of the target task.
[0071] The method does not require frequent IO operations, relieves the CPU burden, occupies less CPU resources, and ensures the real-time performance of the embedded operating system when executing the target task. In addition, the method does not require additional logging equipment outside the embedded operating device, saves network resources, reduces the complexity of the solution, and reduces the implementation cost.
[0072] In one implementation, if the target task is a real-time task, the arbitration module 21 sends a first instruction to the data processing module 22 after a delay of a first period of time, so that the data processing module 22 records the execution log of the target task according to the first instruction.
[0073] Specifically, in the above method, the target task currently executed by the embedded operating system is a real-time task, which has high requirements on the real-time performance of the embedded operating system. At this time, the IO interface of the embedded operating system is relatively busy and the CPU is heavily burdened. If the data processing module 22 records the execution log of the target task at this time, it will affect the real-time performance of the embedded operating system. Therefore, the arbitration processing module will delay the first time period, wait for the target task to be executed and send the second instruction, and the data processing module 22 will record the execution log of the target task after obtaining the second instruction.
[0074] In this method, when the arbitration module 21 determines that the target task currently executed by the embedded operating system is a real-time task, it delays the first time period to send the second instruction so that the data processing module 22 records the execution log of the target task according to the second instruction, thereby reducing the burden on the CPU and ensuring the real-time performance of the embedded operating system.
[0075] The following is an introduction to the initialization method of the log recording method provided in the embodiment of the present application. If the log recording folder and the log configuration file exist at the same time, the initialization module obtains the number of log recording files in the log recording folder; wherein the log configuration file is used to record the number of each log recording file created, and if the number of log recording files is less than the number threshold, the initialization module creates the tth log recording file; wherein the number threshold is the maximum number of log recording files allowed to exist in the log recording folder, and the initialization module records the number of the tth log recording file as t in the log configuration file.
[0076] Specifically, the execution log of the above-mentioned target task needs to be recorded (stored) in a log record file, and one log record file stores one execution log, the log record file is stored in a log record folder, and the number of each log record file is created by a log configuration file. Therefore, before recording the execution log of the target task, the initialization module needs to first determine whether the log record folder and the log configuration file both exist. If so, it means that the log record folder already has a log record file with an execution log recorded. At this time, the initialization module needs to continue to determine whether the number of log record files is less than the number threshold. If so, it means that the storage space of the current log record folder can at least accommodate a log record file with an execution log recorded. At this time, the initialization module creates the tth log record file for recording (storing) the tth execution log, and records the number of the tth log record file as t in the log configuration file. The following example illustrates this method. The maximum number of log record files allowed to exist in the log record folder (number threshold) is 100. There are 30 log files containing execution logs in the current log folder. It can be seen that the number of log files is less than the number threshold. At this time, the initialization module creates the 31st log file to record (store) the 31st execution log, and records the number of the 31st log file as 31 in the log configuration file.
[0077] In this method, the initialization module first determines whether the log recording folder and the log configuration file exist before recording the execution log of the target task. If so, it continues to determine whether the number of log recording files is less than the number threshold. If so, it creates the tth log recording file to record (store) the tth execution log. Among them, this method opens the log recording folder through the opendir function to determine whether the log recording folder exists. If it does not exist, the log recording folder is created through the mkdir function. The number threshold is obtained by querying the log recording folder through the statfs function. This method avoids the situation where the execution log cannot be recorded and overflows the system due to insufficient storage space in the log recording folder. This method ensures the normal execution of the logging work, reduces the overflow rate of the execution log, and improves the integrity of the execution log of the target task in the log recording file.
[0078] In one implementation, if the log record folder exists and the log configuration file does not exist, the initialization module creates the log configuration file and the first log record file; the initialization module records the number of the first log record file as 1 in the log configuration file.
[0079] Specifically, in this method, the initialization module determines that the log record folder exists and the log configuration file does not exist, which means that the current log record folder does not have a log record file that records the execution log. At this time, the initialization module needs to create a log configuration file and the first (first) log record file for recording (storing) the first execution log. And the number of the first log record file is recorded as 1 in the log configuration file.
[0080] In this method, the initialization module determines that the log recording folder exists but the log configuration file does not exist, then the initialization module creates the log configuration file and the first log recording file for recording the first execution log. The purpose of this setting is to prepare for the recording of the execution logs of subsequent target tasks, avoid the situation where the execution logs have nowhere to be stored, and ensure the normal execution of the log recording work.
[0081] In one implementation, if the number of log record files is equal to the number threshold, the initialization module deletes some or all of the log record files and creates the tth log record file; the initialization module records the number of the tth log record file as t in the log configuration file.
[0082] Specifically, in this method, if the initialization module determines that the number of log files is equal to the number threshold, it means that the storage space of the current log folder is full. At this time, the initialization module needs to read some or all log files in the log folder through the readdir function, delete the read log files, create the tth log file, and record the number of the tth log file as t in the log configuration file.
[0083] This method avoids the situation where the execution log cannot be recorded and overflows the system due to insufficient storage space in the log recording folder, ensures the normal execution of the log recording work, reduces the overflow rate of the execution log, and improves the integrity of the execution log of the target task in the log recording file.
[0084] The following is an introduction to the creation method of the message queue. The above-mentioned execution log includes a text log and a data flow log. The data processing module 22 obtains the execution log. If the execution log is a text log, the initialization module creates a text log message queue according to the number of text logs and the memory occupied; if the execution log is a data flow log, the initialization module creates a data flow log message queue according to the number of data flow logs and the memory occupied.
[0085] Specifically, the above-mentioned data flow log includes 1553B log, network log and switch log. When creating a data flow log message queue, it is necessary to pre-set the number of the maximum data flow logs that the data flow log message queue can store and the maximum byte length (memory occupied) of each data flow log, so as to avoid the number of data flow logs obtained by the data processing module 22 exceeding the number of the maximum data flow logs that the data flow log message queue can store, or the memory occupied by each data flow log exceeds the maximum byte length (memory occupied) of each data flow log that the data flow log message queue can store. When creating a text log message queue, it is necessary to pre-set the number of the maximum text logs that the text log message queue can store and the maximum byte length (memory occupied) of each text log, so as to avoid the number of text logs obtained by the data processing module 22 exceeding the number of the maximum text logs that the text log message queue can store, or the memory occupied by each text log exceeds the maximum byte length (memory occupied) of each text log that the text log message queue can store.
[0086] In addition, when creating a data flow log message queue and a text log message queue, the "first in, first out, last in, last out" principle must be set to ensure that the data flow logs are output from the data flow log message queue in the order in which they are input into the data flow log message queue, and the text logs are output from the text log message queue in the order in which they are input into the text log message queue. For example, if the order in which the data flow logs are input into the data flow log message queue is data flow log 1, data flow log 2, and data flow log 3, then the order in which the data flow logs are output from the data flow log message queue is still data flow log 1, data flow log 2, and data flow log 3; if the order in which the text logs are input into the text log message queue is text log 1, text log 2, and text log 3, then the order in which the text logs are output from the text log message queue is still text log 1, text log 2, and text log 3. In real scenarios, the number and memory of data flow logs are greater than the number and memory of text logs, so when creating a data flow log message queue, the storage space capacity of the data flow log message queue should be set larger than that of the text log message queue.
[0087] The data flow log message queue created in this way reduces the overflow rate of the data flow log, ensures that the data flow log enters and leaves the data flow log message queue in an orderly manner, and ensures the normal execution of the log recording work. The text log message queue created in this way reduces the overflow rate of the text log, ensures that the text log enters and leaves the text log message queue in an orderly manner, and ensures the normal execution of the log recording work.
[0088] The following describes the recording method of the execution log of the target task. If the execution log is a data flow log, the data processing module 22 determines the type, generation time, ID and byte length of the data flow log according to the content of the data flow log recorded by the data flow log message queue; the data processing module 22 records the content, type, generation time, ID and byte length of the data flow log in the form of binary data in the log record file; if the execution log is a text log, the data processing module 22 records the content and generation time of the text log recorded by the text log message queue in the form of text in the corresponding log record file.
[0089] Specifically, data stream log message queue and text log message queue are both a kind of data caching mechanism, and can also guarantee the transmission of data when the embedded operating system load is high. The content of data stream log is stored in the data stream log message queue in binary data form, and data processing module 22 parses the content of data stream log, obtains the type, generation time, ID and byte length of the data stream log, and splices the type, generation time, ID and byte length of the data stream log with the content of data stream log to form a complete data stream log in binary data form. Data processing module 22 stores the data stream log in complete binary data form in the log record file. The content of text log is stored in the text log message queue in binary data form, and data processing module 22 parses the content and generation time of text log, obtains the content and generation time of text log in text form, and stores the content and generation time of text log in text form in the log record file. Wherein, the text log in the log record file is readable.
[0090] In this method, the data flow log is stored in the log record file in the form of binary data, which is convenient for the embedded operating system to call, and the text log is stored in the log record file in the form of readable text, which is convenient for the staff to view and timely discover the status and problems when the embedded operating system executes the target task.
[0091] In one embodiment, if the target task executed by the embedded operating system is a shutdown task, the data processing module 22 stops recording the execution log of the target task, and stops obtaining the first instruction and the second instruction sent by the arbitration module 21, deletes the text log message queue, deletes the data flow log message queue, and closes the log record folder.
[0092] In this method, since the target task executed by the embedded operating system is a shutdown task, after the target task is completed, the embedded operating system is in a shutdown state and no longer executes any target task, so there is no need to record the log. The data processing module 22 stops obtaining the first instruction and the second instruction sent by the arbitration module 21, deletes the text log message queue, deletes the data flow log message queue, and closes the log record folder, thereby avoiding excessive waste of system resources.
[0093] Based on the above method embodiment, the present application embodiment provides a log recording device, such as Figure 2 As shown, Figure 2 A schematic diagram of the structure of a log recording device provided in an embodiment of the present application. The device includes an arbitration module 21 and a data processing module 22. The arbitration module 21 and the data processing module 22 are applied to an embedded operating system. The functions of each module of the device are as follows:
[0094] The arbitration module 21 is used to obtain the associated information of the target task being executed by the embedded operating system; wherein the target task includes: a real-time task and a non-real-time task, and the priority of the non-real-time task is lower than the priority of the real-time task;
[0095] The arbitration module 21 is further used to determine whether the target task is a non-real-time task according to the description of the target task in the associated information, and obtain a first determination result;
[0096] The arbitration module 21 is further configured to determine whether the real-time task stops running if the first determination result indicates that the target task is a non-real-time task, thereby obtaining a second determination result;
[0097] The arbitration module 21 is further configured to send a first instruction to the data processing module if the second judgment result indicates that the real-time task stops running;
[0098] The data processing module 22 is used to record the execution log of the target task according to the first instruction;
[0099] The arbitration module 21 is further configured to send a second instruction to the data processing module if the first judgment result indicates that the target task is a real-time task;
[0100] The data processing module 22 is further configured to record the execution log of the target task after delaying the first period of time according to the second instruction.
[0101] The log recording device provided in the embodiment of the present application has the same technical features as the log recording method provided in the above embodiment, so it can also solve the same technical problems and achieve the same technical effects.
[0102] Preferably, the arbitration module 21 is further configured to send a first instruction to the data processing module after a first delay if the first judgment result indicates that the target task is a real-time task;
[0103] The data processing module 22 is further configured to record the execution log of the target task according to the first instruction.
[0104] Preferably, the device further comprises an initialization module;
[0105] An initialization module, used for obtaining the number of log files in the log folder if the log folder and the log configuration file exist at the same time; wherein the log configuration file is used to record the number of each log file created;
[0106] The initialization module is further used to create the tth log record file if the number of log record files is less than the number threshold; wherein the number threshold is the maximum number of log record files allowed to exist in the log record folder;
[0107] The initialization module is also used to record the number of the tth log record file as t in the log configuration file.
[0108] Preferably, the initialization module is further used to create the log configuration file and the first log file if the log folder exists and the log configuration file does not exist;
[0109] The initialization module is also used to record the number of the first log file as 1 in the log configuration file.
[0110] Preferably, the initialization module is further used to delete some or all of the log record files and create a tth log record file if the number of log record files is equal to the number threshold;
[0111] The initialization module is also used to record the number of the tth log record file as t in the log configuration file.
[0112] Preferably, the execution log includes a text log and a data flow log;
[0113] The data processing module 22 is also used to obtain the execution log;
[0114] The initialization module is also used to create a text log message queue according to the number of text logs and the memory occupied if the execution log is a text log;
[0115] The initialization module is also used to create a data flow log message queue according to the number of data flow logs and the memory occupied if the execution log is a data flow log.
[0116] Preferably, the data processing module 22 is specifically used to determine the type, generation time, ID and byte length of the data flow log according to the content of the data flow log recorded in the data flow log message queue if the execution log is a data flow log;
[0117] The data processing module 22 is also used to record the content, type, generation time, ID and byte length of the data flow log in the form of binary data in the log record file;
[0118] The data processing module 22 is further configured to record the content and generation time of the text log recorded in the text log message queue in a text form in a corresponding log record file if the execution log is a text log.
[0119] The log recording device provided in the embodiment of the present application has the same technical features as the log recording method provided in the above embodiment, so it can also solve the same technical problems and achieve the same technical effects.
[0120] An embodiment of the present application also provides an electronic device, including a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above-mentioned logging method.
[0121] See also Figure 3 As shown, the electronic device includes a processor 100 and a memory 101, wherein the memory 101 stores machine executable instructions that can be executed by the processor 100, and the processor 100 executes the machine executable instructions to implement the above-mentioned logging method.
[0122] Further, Figure 3 The electronic device shown further includes a bus 102 and a communication interface 103 , and the processor 100 , the communication interface 103 and the memory 101 are connected via the bus 102 .
[0123] Among them, the memory 101 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which can be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. can be used. The bus 102 can be an ISA (Industrial Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Enhanced Industry Standard Architecture) bus, etc. The above-mentioned bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0124] The processor 100 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 100. The above processor 100 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 101, and the processor 100 reads the information in the memory 101 and completes the steps of the method of the above embodiment in combination with its hardware.
[0125] This embodiment also provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the above-mentioned logging method.
[0126] The computer program product of the logging method, device, and electronic device provided in the embodiments of the present application includes a computer-readable storage medium storing program code, and the instructions included in the program code can be used to execute the method described in the previous method embodiment. The specific implementation can be referred to the method embodiment, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the previous method embodiment, which will not be repeated here.
[0127] In addition, in the description of the embodiments of the present application, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be directly connected, or indirectly connected through an intermediate medium, or it can be the internal connection of two components. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances. If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile computer-readable storage medium that can be executed by a processor. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.
[0128] In the description of the present application, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present application. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0129] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A log recording method, characterized in that: The embedded operating system includes an arbitration module and a data processing module; The method comprises: The arbitration module obtains the associated information of the target task being executed by the embedded operating system; wherein the target task includes: a real-time task and a non-real-time task, and the priority of the non-real-time task is lower than the priority of the real-time task; The arbitration module determines whether the target task is the non-real-time task according to the description of the target task in the association information, and obtains a first determination result; If the first judgment result indicates that the target task is the non-real-time task, determining whether the real-time task stops running to obtain a second judgment result; If the second judgment result indicates that the real-time task stops running, the arbitration module sends a first instruction to the data processing module, so that the data processing module records the execution log of the target task according to the first instruction; If the first judgment result indicates that the target task is a real-time task, the arbitration module sends a second instruction to the data processing module, so that the data processing module records the execution log of the target task after a first delay period according to the second instruction.
2. The log recording method according to claim 1, characterized in that: The method further comprises: If the first judgment result indicates that the target task is a real-time task, the arbitration module sends the first instruction to the data processing module after delaying the first period of time, so that the data processing module records the execution log of the target task according to the first instruction.
3. The log recording method according to claim 1, characterized in that: The embedded operating system also includes an initialization module; the method also includes: If the log record folder and the log configuration file exist at the same time, the initialization module obtains the number of log record files in the log record folder; wherein the log configuration file is used to record the number of each log record file created; If the number of the log record files is less than the number threshold, the initialization module creates the tth log record file; wherein the number threshold is the maximum number of log record files allowed to exist in the log record folder; The initialization module records the number of the tth log record file as t in the log configuration file.
4. The log recording method according to claim 3, characterized in that: The method further comprises: If the log record folder exists and the log configuration file does not exist, the initialization module creates the log configuration file and the first log record file; The initialization module records the number of the first log record file as 1 in the log configuration file.
5. The log recording method according to claim 3, characterized in that: The method further comprises: If the number of the log record files is equal to the number threshold, the initialization module deletes some or all of the log record files and creates the tth log record file; The initialization module records the number of the tth log record file as t in the log configuration file.
6. The log recording method according to claim 3, characterized in that: The execution log includes a text log and a data flow log; the method further includes: The data processing module obtains the execution log; If the execution log is the text log, the initialization module creates a text log message queue according to the number and memory occupied by the text log; If the execution log is the data flow log, the initialization module creates a data flow log message queue according to the number of the data flow logs and the memory occupied.
7. The log recording method according to claim 6, characterized in that: The step of recording the execution log of the target task includes: If the execution log is the data flow log, the data processing module determines the type, generation time, ID and byte length of the data flow log according to the content of the data flow log recorded in the data flow log message queue; The data processing module records the content, type, generation time, ID and byte length of the data flow log in the form of binary data in the log record file; If the execution log is the text log, the data processing module records the content and generation time of the text log recorded by the text log message queue in a text form in a corresponding log record file.
8. A log recording device, characterized in that: The device comprises: The arbitration module is used to obtain the associated information of the target task being executed by the embedded operating system; wherein the target task includes: a real-time task and a non-real-time task, and the priority of the non-real-time task is lower than the priority of the real-time task; The arbitration module is further used to determine whether the target task is the non-real-time task according to the description of the target task in the association information, and obtain a first determination result; The arbitration module is further configured to determine whether the real-time task stops running if the first determination result indicates that the target task is the non-real-time task, thereby obtaining a second determination result; The arbitration module is further configured to send a first instruction to the data processing module if the second judgment result indicates that the real-time task stops running; The data processing module is used to record the execution log of the target task according to the first instruction; The arbitration module is further configured to send a second instruction to the data processing module if the first judgment result indicates that the target task is a real-time task; The data processing module is further configured to record the execution log of the target task after a delay of a first period of time according to the second instruction.
9. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 7 are executed.