Log processing method and device, electronic equipment, storage medium and vehicle

By employing a log processing method based on a dual-processor architecture, the system jitter and data loss issues caused by log information recording in embedded operating systems are resolved, achieving efficient and secure log information processing.

CN115509453BActive Publication Date: 2026-05-01GUOKE FOUNDATION STONE (CHONGQING) SOFTWARE CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUOKE FOUNDATION STONE (CHONGQING) SOFTWARE CO LTD
Filing Date
2022-09-27
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

In embedded operating systems, the existing methods of recording log information can lead to race conditions in the critical sections of the cache, causing system thrashing. Furthermore, due to the limited size of the cache, log information is easily lost.

Method used

The system employs a dual-processor architecture. The first processor writes log information to the log buffer and triggers a log write message. The second processor responds to the message, reads from the buffer, and writes it to the storage device. Synchronous processing of log information is achieved through a shared memory area and an event notification mechanism.

Benefits of technology

It effectively avoids system jitter, improves log information processing efficiency, prevents log information loss, and ensures the security and real-time nature of log information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115509453B_ABST
    Figure CN115509453B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a log processing method, device, electronic equipment, storage medium and vehicle. The log processing method comprises: a first processor receiving log information of an application program in response to a write log operation of any application program; the first processor writing the log information into a log cache area; the first processor triggering a log write message to notify a second processor to write the log information in the log cache area into a storage device; and the second processor reading the log information from the log cache area and writing the log information into the storage device in response to receiving the log write message.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of embedded software development, and more particularly to a log processing method, apparatus, electronic device, storage medium, and vehicle. Background Technology

[0002] In the field of embedded operating systems, the System-on-a-Chip (SoC), as the main control chip, integrates increasingly more functions and needs to respond to and process various parallel tasks in a timely manner. For example, in the field of automotive operating systems, the processing speed of the SoC is particularly important.

[0003] Applications on existing embedded operating systems record logs by writing to files. Typically, log information is written to the kernel cache and then waits for the system to schedule the writing of the log information to disk space. Since many applications run on the SoC, when writing back to disk space, there may be cache critical section race conditions, causing system jitter and reducing the real-time performance of the SoC. Furthermore, due to the limited cache size, if the old log information has not yet been written to disk space when new log information is written to the cache, the log information will be lost.

[0004] Therefore, in the field of embedded operating systems, how to efficiently and securely process application log information is a technical problem that urgently needs to be solved. Summary of the Invention

[0005] To overcome the problems existing in related technologies, this disclosure provides a log processing method, apparatus, electronic device, storage medium, and vehicle.

[0006] According to a first aspect of the present disclosure, a log processing method is provided, comprising: a first processor receiving log information from an application in response to a write log operation of any application; the first processor writing the log information into a log buffer; the first processor triggering a log write message and sending the log write message to a second processor; and the second processor reading log information from the log buffer and writing the log information into the storage device in response to receiving the log write message.

[0007] In some embodiments, the first processor writes the log information into a log cache, including: organizing the content of the log information according to a log information structure; wherein the log information structure includes at least the following members: an application name variable, a timestamp variable, and a log content variable; and writing the log information into the log cache.

[0008] In some embodiments, the log cache includes a first cache and a second cache, and writing the log information into the log cache includes: writing the log information into the first cache; copying the contents of the first cache into the second cache, so that the second processor reads the log information from the second cache.

[0009] In some embodiments, copying the contents of the first cache to the second cache includes: copying the contents of the first cache to the second cache when the length of the data written to the first cache is greater than a preset length threshold.

[0010] In some embodiments, the first processor triggers a log write message by: triggering the log write message after copying the contents of the first buffer to the second buffer.

[0011] In some embodiments, in response to receiving the log write message, the second processor reads log information from the log buffer and writes the log information to the storage device, including: reading the log information stored in the log buffer; and writing the log information to the storage device according to the log information structure.

[0012] According to a second aspect of the present disclosure, a log processing apparatus is provided, comprising a receiving module for causing a first processor to receive log information of an application in response to a write log operation of any application; a writing module for causing the first processor to write the log information into a log buffer; a triggering module for triggering a log write message and sending the log write message to a second processor; and a reading module for causing the second processor to read log information from the log buffer and write the log information into the storage device in response to receiving the log write message.

[0013] According to a third aspect of the present disclosure, a vehicle is provided that stores a set of instructions, which are executed by the vehicle to implement the log processing method provided in the first aspect of the present disclosure.

[0014] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising: a processor; a memory for storing executable instructions of the processor; the processor being configured to read the executable instructions from the memory and execute the instructions to implement the log processing method provided in the first aspect of the present disclosure.

[0015] According to a fifth aspect of the present disclosure, a computer-readable storage medium is provided that stores computer program instructions thereon, which, when executed by a processor, implement the steps of the log processing method provided in the first aspect of the present disclosure.

[0016] The technical solutions provided by the embodiments of this disclosure can include the following beneficial effects: In the embodiments provided by this disclosure, a first processor receives log information from an application in response to a write log operation of any application; the first processor writes the log information to a log buffer; the first processor triggers a log write message to notify a second processor to write the log information in the log buffer to a storage device; the second processor, in response to receiving the log write message, reads the log information from the log buffer and writes the log information to the storage device. This allows for efficient and secure processing of application log information, avoiding system jitter and log information loss.

[0017] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0018] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0019] Figure 1 This is a flowchart illustrating a log processing method according to an exemplary embodiment.

[0020] Figure 2 This is a flowchart illustrating a method for a first processor and a second processor to read and write log information according to an exemplary embodiment.

[0021] Figure 3 This is a flowchart illustrating a method for a first processor and a second processor to read and write log information according to yet another exemplary embodiment.

[0022] Figure 4 This is an example diagram illustrating, according to an exemplary embodiment, how a first processor and a second processor read and write log information through a shared cache.

[0023] Figure 5 This is a block diagram illustrating a log processing apparatus according to an exemplary embodiment.

[0024] Figure 6 This is a block diagram illustrating a vehicle according to an exemplary embodiment.

[0025] Figure 7 This is a block diagram illustrating an electronic device according to an exemplary embodiment. Detailed Implementation

[0026] The exemplary embodiments will now be described in detail with reference to the accompanying drawings.

[0027] It should be noted that the relevant embodiments and accompanying drawings are only for describing and illustrating exemplary embodiments provided by this disclosure, and not all embodiments of this disclosure, nor should this disclosure be understood to be limited to the relevant exemplary embodiments.

[0028] It should be noted that the terms "first," "second," etc., used in this disclosure are only used to distinguish different steps, devices, or modules. These terms do not represent any specific technical meaning, nor do they indicate any order or interdependence between them.

[0029] It should be noted that the terms “a,” “a plurality of,” and “at least one” used in this disclosure are illustrative rather than restrictive. Unless otherwise expressly indicated in the context, they should be understood as “one or more.”

[0030] It should be noted that the term "and / or" used in this disclosure is used to describe the relationship between related objects, and generally indicates that there are at least three relationships. For example, A and / or B can at least indicate: the existence of A alone, the existence of both A and B, and the existence of B alone.

[0031] It should be noted that the various steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Unless otherwise specified, the scope of this disclosure is not limited by the order in which the steps are described in the relevant embodiments.

[0032] It should be noted that all actions involving the acquisition of signals, information, or data in this disclosure are carried out in compliance with the relevant data protection laws and policies of the country where the location is situated, and with authorization from the owner of the relevant device.

[0033] Exemplary methods

[0034] For ease of understanding, the technical solutions of this disclosure are described below in conjunction with the accompanying drawings and embodiments.

[0035] Figure 1 This is a flowchart illustrating a log processing method according to an exemplary embodiment.

[0036] Reference Figure 1 As shown, the log processing method provided in this embodiment includes the following steps: S110, S120, S130, and S140. This method can be executed by a terminal running an embedded operating system, which may have at least two processors.

[0037] In step S110, the first processor receives the log information of any application in response to a write log operation.

[0038] The first processor is the main control chip of the control terminal (e.g., the control system of an intelligent vehicle), and the operating system runs on the first processor. The first processor can be various processor chips; for example, the first processor can be a system-on-a-chip (SoC).

[0039] In practice, applications can perform log writing operations by calling file read / write operation interface functions. As an example, in the Linux operating system, applications can write log information to memory by calling the log write function `int logwrite(const char* app, const char* log)`. The `logwrite` function takes two parameters: a pointer variable `*app` that passes the application name, and a pointer variable `*log` that passes the log information content.

[0040] The first processor can receive log information from any application within the file read / write operation interface functions. As an example, in the Linux operating system, the first processor can obtain the name of the application writing the log using the pointer variable *app from the logwrite function; the first processor can obtain the content of the log information using the pointer variable *log from the logwrite function.

[0041] In step S120, the first processor writes the log information to the log cache.

[0042] like Figure 4 As shown, the log cache is a shared memory area between the first and second processors. Memory sharing between the first and second processors can be achieved in various ways. As an example, in the Linux operating system, the size of the shared memory can be defined in the cmd file; shared variables can be defined in the .c file; and shared memory can be allocated for the shared variables in the cmd file. The first and second processors can then write data to or read data from the shared memory through these shared variables. The cmd file is the linker command file, which specifies the program space and data space settings, as well as the specific locations of the compiled program segments in the program or data space.

[0043] As an example only, the first processor can write the log information obtained from the *log variable to the log buffer in the logwrite function.

[0044] In step S130, the first processor triggers a log write message to notify the second processor to write the log information in the log buffer to the storage device.

[0045] The log write message is a message registered according to the operating system's notification chain mechanism to notify the second processor to process log information. In specific implementation, after the first processor writes the log information to the shared buffer, it can trigger the log write message through the operating system's message notification mechanism to notify the second processor that a log message has been written to the log buffer, and that the log information in the log buffer can be written to the storage device.

[0046] In step S140, in response to receiving the log write message, the second processor reads log information from the log buffer and writes the log information to the storage device.

[0047] The second processor can be a processor chip in a control terminal (e.g., the control system of an intelligent vehicle) that assists the main control chip in processing tasks. The second processor can be a variety of processing chips; for example, the second processor can be a microcontroller (MCU), or, for example, a system-on-a-chip (SoC), and is not limited to the description in this specification.

[0048] In practice, the second processor can respond to log write messages in various ways. For example, the second processor can register a callback function for log write messages. When a log write message is triggered, the callback function is executed, and the second processor can read log information from the log buffer and write the log information to the storage device within the callback function.

[0049] Storage devices can be non-transitory computer-readable storage media, such as ROM, flash memory, CD-ROM, magnetic tape, floppy disk, and optical data storage devices.

[0050] For details of several embodiments of the method for reading and writing log information by the first and second processors, please refer to [link / reference]. Figure 3 and Figure 4 The relevant descriptions will not be repeated here.

[0051] In the embodiments provided in this disclosure, the first processor, in response to a write log operation by any application, receives log information from the application, writes the log information to a log buffer, and triggers a log write message to notify the second processor to write the log information in the log buffer to a storage device. Since the first processor only writes log information to the log buffer, and the time required to write data to the log buffer located in memory is much shorter than the time required to write data to the storage device, the first processor can effectively save time processing log information, allowing it to handle other tasks with higher real-time requirements in a timely manner.

[0052] In the embodiments provided in this disclosure, the second processor, in response to receiving a log write message, reads log information from the log buffer and writes the log information to the storage device. Since the second processor is not the main control chip and performs fewer tasks, having the second processor write the log information to the storage device can avoid system jitter. Furthermore, because the second processor can respond to the log write message promptly, it can also prevent the loss of log information due to untimely processing.

[0053] Figure 2 This is a flowchart illustrating a method for a first processor and a second processor to read and write log information according to an exemplary embodiment.

[0054] like Figure 2 As shown, the method includes the following steps.

[0055] In step S210, the content of the log information is organized according to the log information structure; wherein the log information structure includes at least the following members: application name variable, timestamp variable, and log content variable.

[0056] As an example only, in C, a log message structure can be as follows:

[0057]

[0058] Wherein, type is an integer code corresponding to the application, used to identify the application corresponding to the log information. The second processor can obtain information such as the name of the application corresponding to the log information through this identifier; appName is an application name variable used to store the name of the application; tv is a timestamp variable used to record the writing time of the log information; log[log_len] is a log content variable used to store the content of the log information. log_len is the length of the log information content, and the unit can be bytes (char), words (word), etc., which are not limited by the description in this specification.

[0059] As an example only, the first processor can organize the log message content according to the log message structure in the logwrite function, as shown below:

[0060]

[0061] Here, `log_struct` is a variable representing the log information structure. It can be a local variable or a global variable, and is not limited by the description in this specification. `strncpy(log_detail_struct.appName, app, len)` assigns the application name passed by the application through the parameter `app` to the `appName` member of the `log_struct` variable; `strncpy(log_detail_struct.log, log, len)` assigns the content of the log information passed by the application through the parameter `log` to the `log` member of the `log_struct` variable; and `do_chushi_gettimeofday(&log_detail_struct->tv)` retrieves the current time information and assigns it to the `tv` member of the `log_struct` variable.

[0062] In step S220, the log information is written to the log buffer.

[0063] In practice, the first processor can write log information organized according to the log information structure into the log buffer. For example, the first processor can write the assigned value of the `log_struct` variable from step S210 into the log buffer.

[0064] In this embodiment, the second processor reads the log information stored in the log buffer; according to the log information structure, it writes the log information into the storage device. In specific implementation, the second processor can read the data stored in the log buffer and assign the read data to a log information structure variable. This variable can be a local variable or a global variable, not limited by the description in this specification. Based on each member of the log structure variable, it obtains information such as the name of the application corresponding to the log information and the timestamp of the log information, and writes the log content into the storage device based on this information. As an example only, the second processor can perform the above operations in a callback function, as follows:

[0065]

[0066] Specifically, the content of the log buffer is assigned to the log structure variable "detail" by "detail = (struct log_detail_struct*)buf"; the name of the application corresponding to the log information is obtained from the log structure variable "detail" by "strncpy(appname, detail->appname, len)"; and the name of the application corresponding to the log information, the timestamp, and the content of the log information are written to the storage device by calling "do_writelog(appname, detail->tv, detail->log)".

[0067] In the embodiments provided in this disclosure, log information organized according to the log information structure is written into the log cache area, so that the second processor can know the name of the application corresponding to the log information, the timestamp of writing the log information, and other information according to the log information structure, thereby realizing the synchronization of log information between the first processor and the second processor.

[0068] Figure 3 This is a flowchart illustrating a method for a first processor and a second processor to read and write log information according to yet another exemplary embodiment. Figure 3 As shown, the method includes the following steps.

[0069] In step S310, the log information is written to the first buffer.

[0070] In some embodiments, such as Figure 4 As shown, the log cache includes a first cache and a second cache. The first processor writes log information to the first cache, and the second processor reads log information from the second cache. In specific implementations, the first cache may also include at least one data partition.

[0071] In some embodiments, the first processor and the second processor share a log buffer. The first processor writes log information to this buffer, and the second processor reads log information from it. When the application performs frequent write operations on log information, it may happen that when the first processor needs to write log information, the second processor is reading log information. Therefore, the first processor needs to wait for the second processor to release the log buffer resources before continuing its write operation, thus increasing the time the first processor spends writing log information. In this embodiment, dividing the log buffer into a first buffer for the first processor to write log information and a second buffer for the second processor to read log information can effectively avoid competition for log buffer resources between the first and second processors, further improving the efficiency of the first processor in processing log information.

[0072] In step S320, the contents of the first cache are copied to the second cache so that the second processor can read log information from the second cache.

[0073] In the specific implementation process, after the first processor writes the log information to the first buffer, it can trigger a data transfer thread, which will copy the data in the first buffer (for example, by using the memcpy function) to the second buffer.

[0074] In some embodiments, to reduce the number of thread calls and conserve the computing resources of the first processor, the contents of the first cache can be copied to the second cache if the length of data written to the first cache exceeds a preset length threshold. For example, if the size of the first cache is 256 megabytes, a data transfer thread can be triggered if the length of data written to the first cache exceeds 200 megabytes.

[0075] In this embodiment, after copying the contents of the first cache to the second cache, a log write message is triggered so that the second processor can obtain log information from the second cache in a timely manner.

[0076] Exemplary device

[0077] Figure 5 This is a block diagram illustrating a log processing apparatus according to an exemplary embodiment. (Refer to...) Figure 5 The device 500 includes a receiving module 510, a writing module 520, a triggering module 530, and a reading module 540.

[0078] The receiving module 510 is used to enable the first processor to receive the log information of any application in response to a write log operation of any application; for details regarding the first processor receiving the log information of any application in response to a write log operation of any application, please refer to the relevant description in step S110, which will not be repeated here.

[0079] The writing module 520 is used to enable the first processor to write the log information into the log cache area; for details on the first processor writing the log information into the log cache area, please refer to the relevant description in step S120, which will not be repeated here.

[0080] Trigger module 530 is used to trigger a log write message and send the log write message to the second processor; for details about triggering the log write message, please refer to the relevant description in step S130, which will not be repeated here.

[0081] The read module 540 is configured to cause the second processor, in response to receiving the log write message, to read log information from the log buffer and write the log information to the storage device. For details regarding the second processor's response to receiving the log write message, reading log information from the log buffer, and writing the log information to the storage device, please refer to the relevant description in step S140, which will not be repeated here.

[0082] In some embodiments, the first processor writes the log information into a log cache, including: organizing the content of the log information according to a log information structure; wherein the log information structure includes at least the following members: an application name variable, a timestamp variable, and a log content variable; and writing the log information into the log cache.

[0083] In some embodiments, the log cache includes a first cache and a second cache, and writing the log information into the log cache includes: writing the log information into the first cache; copying the contents of the first cache into the second cache, so that the second processor reads the log information from the second cache.

[0084] In some embodiments, copying the contents of the first cache to the second cache includes: copying the contents of the first cache to the second cache when the length of the data written to the first cache is greater than a preset length threshold.

[0085] In some embodiments, the first processor triggers a log write message by: triggering the log write message after copying the contents of the first buffer to the second buffer.

[0086] In some embodiments, in response to receiving the log write message, the second processor reads log information from the log buffer and writes the log information to the storage device, including: reading the log information stored in the log buffer; and writing the log information to the storage device according to the log information structure.

[0087] The specific processing and technical effects of each embodiment of the above-described log processing device can be found in the relevant descriptions in the corresponding method embodiments, and will not be repeated here.

[0088] Exemplary vehicle

[0089] Figure 6 This is a block diagram illustrating a vehicle 600 according to an exemplary embodiment. The vehicle 600 may be a gasoline vehicle, a hybrid vehicle, an electric vehicle, a fuel cell vehicle, or other types of vehicles.

[0090] Reference Figure 6 The vehicle 600 may include multiple subsystems, such as a drive system 610, a control system 620, a sensing system 630, a communication system 640, an information display system 650, and a computing processing system 660. The vehicle 600 may also include more or fewer subsystems, and each subsystem may include multiple components, which will not be described in detail here.

[0091] The drive system 610 includes components that provide power to the vehicle 600. These include, for example, an engine, an energy source, and a transmission.

[0092] The control system 620 includes components that provide control for the vehicle 600. These include, for example, vehicle control, cockpit equipment control, and driver assistance control.

[0093] The perception system 630 includes components that provide the vehicle 600 with perception of its surroundings. These include, for example, a vehicle positioning system, a laser sensor, a voice sensor, an ultrasonic sensor, and camera equipment.

[0094] The communication system 640 includes components that provide communication connectivity for the vehicle 600. These may include, for example, mobile communication networks (e.g., 3G, 4G, 5G networks), WiFi, Bluetooth, and vehicle-to-everything (V2X) connectivity.

[0095] The information display system 650 includes components that provide various information displays for the vehicle 600. These include, for example, vehicle information displays, navigation information displays, and entertainment information displays.

[0096] The computing processing system 660 includes components that provide data computing and processing capabilities for the vehicle 600. The computing processing system 660 may include at least one processor 661 and a memory 662. The processor 661 can execute instructions stored in the memory 662.

[0097] Processor 661 can be any conventional processor, such as a commercially available CPU. The processor may also include, for example, a Graphics Processing Unit (GPU), a Field Programmable Gate Array (FPGA), a System on Chip (SOC), an Application-Specific Integrated Circuit (ASIC), or a combination thereof.

[0098] The memory 662 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0099] In this embodiment of the disclosure, a set of instructions is stored in the memory 662, and the processor 661 can execute the set of instructions to implement all or part of the steps of any of the log processing methods described in the exemplary embodiments above.

[0100] Exemplary electronic devices

[0101] Figure 7 This is a block diagram illustrating an electronic device according to an exemplary embodiment. The electronic device 700 may be a vehicle controller, an in-vehicle terminal, an in-vehicle computer, or other types of electronic devices.

[0102] Reference Figure 7 The electronic device 700 may include at least one processor 710 and a memory 720. The processor 710 can execute instructions stored in the memory 720. The processor 710 is communicatively connected to the memory 720 via a data bus. In addition to the memory 720, the processor 710 can also be communicatively connected to an input device 730, an output device 740, and a communication device 750 via the data bus.

[0103] The processor 710 can be any conventional processor, such as a commercially available CPU. The processor may also include, for example, a Graphics Processing Unit (GPU), a Field Programmable Gate Array (FPGA), a System on Chip (SOC), an Application-Specific Integrated Circuit (ASIC), or a combination thereof.

[0104] The memory 720 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0105] In this embodiment of the present disclosure, the memory 720 stores executable instructions, and the processor 710 can read the executable instructions from the memory 720 and execute the instructions to implement all or part of the steps of the log processing method described in any of the exemplary embodiments above.

[0106] Exemplary computer-readable storage media

[0107] In addition to the methods and apparatus described above, exemplary embodiments of this disclosure may also be a computer program product or a computer-readable storage medium storing the computer program product. The computer product includes computer program instructions that can be executed by a processor to perform all or part of the steps described in any of the methods in the exemplary embodiments described above.

[0108] The computer program product can be written in any combination of one or more programming languages ​​to perform the operations of the embodiments of this disclosure. These programming languages ​​include object-oriented programming languages ​​such as Java and C++, as well as conventional procedural programming languages ​​such as C or similar languages, and scripting languages ​​(e.g., Python). The program code can be executed entirely on a user's computing device, partially on a user's computing device, as a standalone software package, partially on a user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0109] The computer-readable storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media include: static random access memory (SRAM) having one or more electrically connected wires, electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk, or any suitable combination thereof.

[0110] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of this disclosure. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.

[0111] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.

Claims

1. A log processing method, characterized in that, The log processing method is executed by a terminal running an embedded operating system. This terminal has at least two processors: a first processor is the main control chip of the control terminal, and a second processor is a processor chip in the control terminal that assists the main control chip in processing tasks, including: The first processor responds to a write log operation from any application by receiving the log information from that application; The first processor writes the log information into a log cache area, which is a shared memory area of ​​the first and second processors, including a first cache area and a second cache area. Writing the log information into the log cache area includes: Write the log information into the first cache area; The contents of the first cache are copied to the second cache so that the second processor can read log information from the second cache; The first processor triggers a log write message, which is a message registered according to the operating system's event notification chain mechanism to notify the second processor to process log information. The first processor sends the log write message to the second processor. The second processor registers a callback function for log write messages. When a log write message is triggered, the callback function is executed. In response to receiving the log write message, the callback function reads log information from the log buffer and writes the log information to the storage device.

2. The method according to claim 1, characterized in that, The first processor uses the pointer variable of the logwrite function. app, get the name of the application that writes logs; the first processor gets the name based on the logwrite pointer variable. The first processor obtains the log information content and writes the log information into the log buffer, including: The log information content is organized according to the log information structure; wherein the log information structure includes at least the following members: application name variable, timestamp variable, and log content variable; The first processor, in the logwrite function, will... The log information obtained from the log variable is written to the log cache.

3. The method according to claim 1, characterized in that, The step of copying the contents of the first cache area to the second cache area includes: After writing log information to the first cache, if the length of the data written to the first cache exceeds a preset length threshold, the first processor triggers a data transfer thread to copy the contents of the first cache to the second cache.

4. The method according to claim 1, characterized in that, The first processor triggers a log write message, including: After copying the contents of the first cache to the second cache, the log write message is triggered.

5. The method according to claim 2, characterized in that, In response to receiving the log write message, the second processor reads log information from the log buffer and writes the log information to the storage device, including: Read the log information stored in the log buffer; The log information is written into the storage device according to the log information structure.

6. A log processing device, characterized in that, The device is executed by a terminal running an embedded operating system. This terminal has at least two processors: a first processor is the main control chip of the control terminal, and a second processor is a processor chip in the control terminal that assists the main control chip in processing tasks, including: A receiving module is configured to enable the first processor to receive log information from any application in response to a write log operation. The writing module is configured to enable the first processor to write the log information into a log cache, the log cache including a first cache and a second cache, wherein writing the log information into the log cache includes: Write the log information into the first cache area; The contents of the first cache are copied to the second cache so that the second processor can read log information from the second cache; The triggering module is used to trigger a log write message, which is a message registered according to the operating system's event notification chain mechanism to notify the second processor to process log information. The log write message is sent to the second processor. The reading module is used to enable the second processor to register a callback function for log write messages. When a log write message is triggered, the callback function is executed. In response to receiving the log write message, the callback function reads log information from the log buffer and writes the log information to the storage device.

7. The apparatus according to claim 6, characterized in that, The first processor writes the log information to the log cache, including: The log information content is organized according to the log information structure; wherein the log information structure includes at least the following members: application name variable, timestamp variable, and log content variable; The log information is written to the log cache area.

8. The apparatus according to claim 6, characterized in that, The step of copying the contents of the first cache area to the second cache area includes: If the length of data written to the first cache exceeds a preset length threshold, the contents of the first cache are copied to the second cache.

9. The apparatus according to claim 6, characterized in that, The first processor triggers a log write message, including: After copying the contents of the first cache to the second cache, the log write message is triggered.

10. The apparatus according to claim 7, characterized in that, In response to receiving the log write message, the second processor reads log information from the log buffer and writes the log information to the storage device, including: Read the log information stored in the log buffer; The log information is written into the storage device according to the log information structure.

11. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to read the executable instructions from the memory and execute the instructions to implement any of the log processing methods of claims 1-5.

12. A computer-readable storage medium having computer program instructions stored thereon, characterized in that, When the program instructions are executed by the processor, they implement the log processing method of any one of claims 1-5.

13. A vehicle, characterized in that, A set of instructions is stored, which is executed by the vehicle to implement the log processing method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Log storage method and system based on multi-core hard disk and related components

    CN111858531A

  • Power Internet of Things equipment behavior security detection method, system and equipment and storage medium

    CN114090406A

  • Control device and control method

    US20170139605A1