Load monitoring method and device, embedded device, computer device and medium
By using a ring-shaped storage area in the embedded device to alternately store task scheduling information and send it to an external computer device to calculate the load information, the stability problem caused by MCU resource consumption is solved, and the stability and response efficiency of device operation are improved.
Patent Information
- Application Number
- CN202510750307.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-06
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2045-06-06
AI Technical Summary
In the prior art, the microcontroller unit (MCU) of embedded devices consumes a lot of resources when calculating load information, which leads to reduced device stability. This may cause system response delays and device failures, especially in applications with high real-time requirements.
By using a circular storage area in the embedded device to alternately store task scheduling information and marking a completion flag when half of the area is full, the information is sent to an external computer device for load information calculation, thereby reducing the resource consumption of the MCU.
It reduces the load on the MCU, improves the operational stability of embedded devices, reduces system response latency and failure risk, and achieves high efficiency and accuracy in load monitoring.
Smart Images

Figure CN120276940B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of load monitoring technology, and in particular to a load monitoring method, apparatus, embedded device, computer device, and medium. Background Technology
[0002] Load monitoring is the process of real-time monitoring and analysis of the workload borne by a system or device during operation.
[0003] Taking embedded devices as an example, load monitoring can be used to determine the load information of the microcontroller unit (MCU) in the embedded device, such as the time percentage of MCU scheduled tasks. In related technologies, the MCU needs to calculate the load information based on the scheduling information of different tasks, which consumes MCU resources, increases the MCU load, and reduces the stability of the device's operation. Summary of the Invention
[0004] Therefore, it is necessary to provide a load monitoring method, apparatus, embedded device, computer device, and medium to address the aforementioned technical problems.
[0005] In a first aspect, embodiments of this application provide a load monitoring method applied to an embedded device, the method comprising:
[0006] When scheduling tasks by executing a scheduler, the scheduling information of each task is alternately stored in different half-areas of the circular storage area, and a completion flag is marked for any half-area when it is full; the completion flag is used to instruct the instruction processing device to send the scheduling information stored in any half-area to an external computer device.
[0007] Receive load information of the embedded device determined by an external computer device based on scheduling information;
[0008] Determine the load monitoring results of the embedded device based on the load information.
[0009] In this embodiment, the scheduling information in the ring storage area is sent to an external computer device, which then determines the load information of the embedded device based on the scheduling information, thereby obtaining the load monitoring result. This realizes the calculation of load information off-chip without the embedded device consuming its own resources, thus reducing the occupation of MCU resources in the embedded device, reducing the MCU load, and improving the stability of the embedded device's operation.
[0010] In one embodiment, when scheduling tasks by executing a scheduler, the scheduling information of each task is alternately stored in different halves of a circular storage region, including:
[0011] For any given task, in the case of a scheduled task, obtain the task identifier, the in-point timestamp when the scheduled task begins, and the out-point timestamp when the scheduled task is completed.
[0012] The current half-area is determined based on the storage status of different half-areas within the circular storage region;
[0013] The task identifier, in-point timestamp, and out-point timestamp are used as the task's scheduling information and stored in the current half-segment.
[0014] In this embodiment, the task identifier, in-point timestamp, and out-point timestamp of the scheduled task are used as the scheduling information obtained by scheduling the task, realizing full time recording of the task scheduling process, providing a rich data foundation for subsequent determination of load information, and improving the diversity of the determined load information.
[0015] In one embodiment, the ring-shaped storage region includes a first half and a second half. Determining the current half based on the storage status of the different half of the ring-shaped storage region includes:
[0016] Obtain the storage flags for the first and second halves of the memory;
[0017] If one of the storage flag bits in the first half-segment and the other is a non-complete flag, then the half-segment with the non-complete flag is determined as the current half-segment.
[0018] If both the storage flag bits of the first and second halves are incomplete, the current half is determined based on the storage status pointers of the first and second halves.
[0019] In one embodiment, determining the current half-region based on the storage state pointers of the first and second half-regions includes:
[0020] Based on the storage state pointers of the first and second halves, determine the half that the storage state pointer points to in the first and second halves, which is not the end of the half, and use it as the current half.
[0021] In this embodiment, the current half-zone is determined in the first and second half-zones by combining the storage flag bit and the storage status pointer. This adapts to the diverse storage states of the first and second half-zones, improving the efficiency and convenience of determining the current half-zone.
[0022] In one embodiment, obtaining the task identifier, the ingress timestamp when the task scheduling begins, and the egress timestamp when the task scheduling is completed includes:
[0023] Call the pre-hook function to get the task identifier of the scheduled task, and get the time when the scheduled task started to be scheduled, and record it as the in-point timestamp;
[0024] Call the post-hook function to get the time when the scheduled task was completed, and record it as the output timestamp.
[0025] In this embodiment, by calling the pre-hook function and the post-hook function respectively, the scheduling status of the scheduled task and whether it has been completed are tracked without affecting the scheduling of the task by the scheduler, thereby improving the accuracy and reliability of the obtained task identifier, in-point timestamp and out-point timestamp.
[0026] In one embodiment, the circular storage region includes a first half and a second half. Marking a complete state for either half when it is full includes:
[0027] If any half-segment is the first half-segment, mark the storage flag of the first half-segment as the completion flag;
[0028] If any half-segment is the second half-segment, mark the storage flag of the second half-segment as the completion flag.
[0029] In this embodiment, when the first or second half-area is full, the storage flag bit of the corresponding half-area is marked as a completion flag so as to promptly instruct the instruction processing device to obtain the scheduling information stored in the corresponding half-area, thereby improving the timeliness and orderliness of load monitoring.
[0030] In one embodiment, the method further includes:
[0031] The instruction processing device receives a flag clearing instruction for the first half of the region; the flag clearing instruction for the first half of the region is generated by the instruction processing device based on the operation of sending the scheduling information stored in the first half of the region to an external computer device.
[0032] According to the flag clearing instruction, the completion flag in the storage flags of the first half of the region is cleared.
[0033] In this embodiment, the instruction processing device triggers a flag clearing instruction for the storage flag bit of the first half of the storage area when the scheduling information stored in the first half of the storage area is full. This is to instruct the embedded device to update the storage flag bit of the first half of the storage area in a timely manner, thereby improving the orderliness of subsequent scheduling information outgoing and improving the accuracy of the determined load information, thus improving the reliability of load monitoring.
[0034] In one embodiment, the method further includes:
[0035] The instruction processing device receives a flag clearing instruction for the second half of the region; the flag clearing instruction for the second half of the region is generated by the instruction processing device based on the operation of sending the scheduling information stored in the second half of the region to an external computer device.
[0036] According to the flag clearing instruction, the completion flag in the storage flags of the second half of the region is cleared.
[0037] In this embodiment, the instruction processing device triggers a flag clearing instruction for the storage flag bit of the second half of the storage area when the scheduling information stored in the second half of the storage area is full. This is to instruct the embedded device to update the storage flag bit of the second half of the storage area in a timely manner, thereby improving the orderliness of subsequent scheduling information outgoing and improving the accuracy of the determined load information, thus improving the reliability of load monitoring.
[0038] In one embodiment, the instruction processing device sends the scheduling information stored in any half-area to the external computer device by calling the memory access interface to access the address of the ring memory area, reading the scheduling information from the ring memory area through the data read / write register, and sending the read scheduling information to the external computer device.
[0039] Secondly, embodiments of this application also provide a load monitoring method applied to an external computer device, the method comprising:
[0040] The embedded device receives scheduling information stored in the ring-shaped storage area of the embedded device from the instruction processing device. The scheduling information is generated by the embedded device scheduling each task by executing the scheduler, and the scheduling information of each task is alternately stored in different half of the ring-shaped storage area. When any half is full, a completion flag is marked for any half. The completion flag is used to instruct the instruction processing device to send the scheduling information stored in any half to an external computer device.
[0041] The load information of the embedded device is determined based on the received scheduling information, and the load information is sent to the embedded device; the load information is used by the embedded device to determine the load monitoring results of the embedded device.
[0042] In this embodiment, an external computer device receives scheduling information sent by an embedded device to determine the load information of the embedded device using the resources provided by the external computer device, thereby obtaining load monitoring results. This achieves load information calculation off-chip without the embedded device consuming its own resources, thus reducing the occupation of MCU resources in the embedded device, reducing the MCU load, and improving the stability of the embedded device's operation.
[0043] In one embodiment, determining the load information of the embedded device based on the received scheduling information includes:
[0044] The load information of different tasks within the reference time period is determined based on the received scheduling information;
[0045] The load information of the embedded device is determined based on the load information of different tasks.
[0046] In this embodiment, the scheduling information received by the external computer device can be stored for a long time without being overwritten. The external computer device can determine the task load information within any time period based on the received scheduling information, thus reducing time limitations and improving the flexibility of determining the time period for load information.
[0047] In one embodiment, the scheduling information includes a task identifier, an ingress timestamp, and an egress timestamp; the load information of different tasks within a reference time period is determined based on the received scheduling information, including:
[0048] The runtime of each task scheduled within the reference time period is determined based on the scheduling information; the runtime is the time difference between the in-time timestamp and the out-time timestamp of each task scheduled.
[0049] For tasks with the same task identifier, obtain the ratio of the sum of the runtime of each scheduled task to the total duration of the reference time period, and use it as the task's load information.
[0050] Thirdly, this application also provides a load monitoring system, which includes: an embedded device, an instruction processing device, and an external computer device, wherein the embedded device and the external computer device are communicatively connected through the instruction processing device;
[0051] The embedded device is used to alternately store the scheduling information of each task into different half of the circular storage area when the task is scheduled by executing a scheduler, and to mark the completion flag of any half when any half is full, as well as to receive the load information of the embedded device sent by an external computer device, and to determine the load monitoring result of the embedded device based on the load information of the embedded device.
[0052] The instruction processing device is used to retrieve the scheduling information stored in any half-segment upon the indication of the completion flag and send it to an external computer device;
[0053] The external computer device uses the received scheduling information to determine the load information of the embedded device and sends it to the embedded device.
[0054] Fourthly, embodiments of this application also provide a load monitoring device, which includes:
[0055] The task scheduling module is used to alternately store the scheduling information of each task into different half of the circular storage area when scheduling each task by executing the scheduler, and to mark any half of the ...
[0056] The information receiving module is used to receive the load information of the embedded device determined by the external computer device based on the scheduling information;
[0057] The result determination module is used to determine the load monitoring results of the embedded device based on the load information.
[0058] Fifthly, embodiments of this application also provide a load monitoring device, which includes:
[0059] The scheduling receiving module is used to receive scheduling information stored in the ring-shaped storage area of the embedded device sent by the instruction processing device. The scheduling information is generated by the embedded device scheduling each task by executing the scheduler, and the scheduling information of each task is alternately stored in different half of the ring-shaped storage area. When any half is full, a completion flag is marked for any half. The completion flag is used to instruct the instruction processing device to send the scheduling information stored in any half to an external computer device.
[0060] The load determination module is used to determine the load information of the embedded device based on the received scheduling information and send the load information to the embedded device; the load information is used by the embedded device to determine the load monitoring results of the embedded device.
[0061] In a sixth aspect, embodiments of this application also provide an embedded device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the load monitoring method provided in any of the embodiments of the first aspect above.
[0062] In a seventh aspect, embodiments of this application also provide a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the load monitoring method provided in any of the embodiments of the second aspect above.
[0063] Eighthly, embodiments of this application also provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps in the load monitoring method provided in any of the above embodiments.
[0064] Ninthly, embodiments of this application also provide a computer program product, including a computer program that, when executed by a processor, implements the steps in the load monitoring method provided in any of the above embodiments.
[0065] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0066] Figure 1 This is a schematic diagram of the structure of a load monitoring system in one embodiment;
[0067] Figure 2 This is a flowchart illustrating a load monitoring method in one embodiment;
[0068] Figure 3 This is a schematic diagram of the process for storing scheduling information in one embodiment;
[0069] Figure 4 This is a schematic diagram of the process for determining the current half-region in one embodiment;
[0070] Figure 5 This is a schematic diagram of the process for obtaining scheduling information in one embodiment;
[0071] Figure 6 This is a schematic diagram illustrating the process of completing the marking of a half-region in one embodiment;
[0072] Figure 7 This is a flowchart illustrating the process of clearing the completion marker in one embodiment;
[0073] Figure 8 This is a flowchart illustrating the process of clearing the completion marker in another embodiment;
[0074] Figure 9 This is a flowchart illustrating the load monitoring method in another embodiment;
[0075] Figure 10 This is a flowchart illustrating the process of determining load information in one embodiment;
[0076] Figure 11 This is a flowchart illustrating the process of determining load information in another embodiment;
[0077] Figure 12 This is a flowchart illustrating the load monitoring method in another embodiment;
[0078] Figure 13 This is a structural block diagram of a load monitoring device in one embodiment;
[0079] Figure 14 This is a structural block diagram of the load monitoring device in another embodiment;
[0080] Figure 15 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0081] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0082] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application; the term "comprising" and any variations thereof in the specification, claims and foregoing description of the drawings are intended to cover non-exclusive inclusion.
[0083] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0084] In the description of the embodiments of this application, the term "and / or" is merely a description of the association relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. In the description of the embodiments of this application, the term "multiple" refers to two or more (including two), unless otherwise explicitly specified.
[0085] Load monitoring is the process of real-time monitoring and analysis of the workload borne by a system or device during operation.
[0086] Taking embedded devices as an example, load monitoring plays a crucial role as a key technology to ensure stable device operation. The Microcontroller Unit (MCU), as the "brain" of the embedded device, bears the important responsibility of executing various task instructions and coordinating the work of different modules. Accurately obtaining MCU load information (such as the time percentage of MCU-scheduled tasks) is one of the core objectives of embedded device load monitoring.
[0087] In related technologies, MCUs need to calculate load information based on the scheduling information of different tasks. During this calculation, the MCU consumes significant computing resources and processing time to execute related algorithms. However, in embedded applications with high real-time requirements, such as industrial robot control and autonomous driving assistance systems, the MCU itself needs to rapidly process large amounts of sensor data and control commands. Performing complex load calculations on top of this will undoubtedly further increase the MCU's load. This not only reduces the MCU's operating efficiency but may also lead to system response delays and task timeouts due to excessive resource consumption, severely impacting the stability of the device and potentially causing equipment failure and incalculable losses.
[0088] Therefore, the load monitoring process in related technologies consumes MCU resources, increases the MCU load, and reduces the stability of the device's operation.
[0089] In one embodiment, a load monitoring method is provided, which is applied to Figure 1 The load monitoring system 100 includes an embedded device 102, an instruction processing device 104, and an external computer device 106. The embedded device 102 and the external computer device 106 are communicatively connected through the instruction processing device 104.
[0090] In this context, embedded device 102 refers to an electronic device that carries an application program to implement corresponding business functions. Instruction processing device 104 is an intermediate device for data transmission and analysis between embedded device 102 and external computer device 106. External computer device 106 is a computer device independent of embedded device 102.
[0091] For example, the embedded device 102 may be a new energy vehicle equipped with a battery management application, which can be used to manage the vehicle battery, such as battery data acquisition, thermal runaway management, and power balancing management. The instruction processing device 104 may be a parser, which may also include a debugger. The external computer device 106 may be a host computer for the embedded device 102.
[0092] The instruction processing device 104 is communicatively connected to the embedded device 102 and the external computer device 106 via communication interfaces. Exemplarily, this communication interface can be a serial port (SP), a universal serial bus (USB) interface, or a controller area network (CAN) bus interface. In this embodiment, the type of communication interface between the instruction processing device 104 and the embedded device 102 and the external computer device 106 is not specifically limited, as long as it meets the communication requirements.
[0093] The process by which the embedded device 102 runs an application to implement corresponding business functions is the process of executing tasks through a scheduler. Different business functions correspond to different types of tasks. The embedded device 102 can schedule each task by executing the scheduler, and when scheduling each task, the scheduling information of each task is alternately stored in different halves of the circular storage area, and a completion flag is marked for any half of the half when it is full.
[0094] Instruction processing device 104 can, under the instruction of the completion flag, obtain the scheduling information stored in any half-segment and send the scheduling information to external computer device 106.
[0095] The external computer device 106 receives the scheduling information, determines the load information of the embedded device 102 based on the scheduling information, and sends it to the embedded device 102.
[0096] The embedded device 102 receives the load information accordingly and determines the load monitoring result of the embedded device 102 based on the load information.
[0097] The load monitoring system 100 described above can monitor the load of the MCU in the embedded device 102.
[0098] In one embodiment, this application provides a load monitoring method, such as... Figure 2 As shown, this method is applied to Figure 1 Taking an embedded device as an example, the steps include:
[0099] S210. When scheduling each task by executing the scheduler, the scheduling information of each task is alternately stored in different half-areas of the circular storage area, and a completion flag is marked for any half-area when any half-area is full; the completion flag is used to instruct the instruction processing device to send the scheduling information stored in any half-area to an external computer device.
[0100] Each task can include business tasks where the embedded device runs the application to perform corresponding business functions, or it can include idle tasks where no application is running.
[0101] Scheduling information refers to the data obtained from scheduling tasks. For example, scheduling information may include the task identifier (such as ID) or task type (such as periodic task or non-periodic task) of the scheduled task, and may also include time information, such as the start time of scheduling, the end time of scheduling, or the scheduling duration from the start of scheduling to the end of scheduling, etc.
[0102] A circular storage area is a temporary storage area in embedded devices, also known as a buffer. The process of storing data using a circular storage area is as follows:
[0103] Starting from a storage location in the ring-shaped storage area, data is stored along a preset circumferential direction. When the ring-shaped storage area is full, the system continues to use the same starting point to overwrite the old data with new data, thereby reusing the storage area to continuously store data.
[0104] A half-area within a ring-shaped storage region represents a portion (not the entire) of the storage area within that ring. A ring-shaped storage region can include at least two half-areas. The completion flag indicates that the corresponding half-area has reached its full storage capacity, meaning that the corresponding half-area is full.
[0105] Optionally, the embedded device can enable scheduling upon receiving a task execution instruction, and schedule each task through the scheduler, such as scheduling each task in the task scheduling table in sequence. During scheduling, the scheduling information obtained by scheduling each task is recorded and stored in a half-area of the circular cache area. At the same time, the data storage volume of each half-area is detected, and when the data storage volume reaches a full state, that is, when any half-area in the circular storage area is full, a completion flag is marked for that half-area.
[0106] For example, after marking a completion flag for any half-area, the embedded device can send the scheduling information stored in that half-area to the instruction processing device. The instruction processing device can periodically read the completion flag by polling the embedded device, and when a completion flag is read, it can obtain the scheduling information stored in the half-area corresponding to the completion flag, and then send the received / obtained scheduling information to an external computer device so that the external computer device can determine the load information of the embedded device based on the scheduling information.
[0107] S220: Receive the load information of the embedded device determined by the external computer device based on the scheduling information.
[0108] The load information of the embedded device is used to characterize the load of the MCU in the embedded device performing tasks. For example, the load information may include the duration of each task, the total duration of executing different / same tasks within a preset time period, the percentage of time spent executing different / same tasks within the preset time period, etc.
[0109] Optionally, the external computer device can statistically determine, based on scheduling information, at least one of the following: the execution time of each task by the MCU in the embedded device, the total execution time of all / the same tasks within a preset time period, and the percentage of the total execution time of all / the same tasks within the preset time period. This information is then used as the load information of the embedded device and sent to the instruction processing device, which in turn sends the load information of the embedded device back to the embedded device. The embedded device then receives the load information determined by the external computer device.
[0110] S230. Determine the load monitoring results of the embedded device based on the load information.
[0111] Optionally, the load information of the embedded device determined by the external computer device is obtained. The embedded device can directly use the load information as the load monitoring result of the embedded device, or it can further process the load information to determine the load monitoring result of the embedded device.
[0112] For example, taking the load information as the percentage of time the MCU spends executing the same task within a preset time period, the obtained load information for the embedded device includes the time percentage T1 for executing task A. The embedded device can compare T1 with the preset time percentage T to determine the load monitoring result of the embedded device based on the comparison result. For example, if T1 > T, the load monitoring result of the embedded device is determined to be that the load of the embedded device for task A exceeds the load threshold; if T1 ≤ T, the load monitoring result of the embedded device is determined to be that the load of the embedded device for task A does not exceed the load threshold.
[0113] In this embodiment, when the embedded device schedules various tasks by executing a scheduler, it alternately stores the scheduling information of each task in different halves of a circular storage area. When any half of the storage area is full, a completion flag is marked for that half of the storage area. The embedded device receives the load information of the embedded device determined by an external computer device based on the scheduling information, and then determines the load monitoring result of the embedded device based on the load information. The completion flag is used to instruct the instruction processing device to send the scheduling information stored in any half of the storage area to the external computer device. In the above method, the scheduling information in the circular storage area is sent to the external computer device, which determines the load information of the embedded device based on the scheduling information, and then obtains the load monitoring result. This realizes the calculation of load information off-chip without the embedded device consuming its own resources, thus reducing the occupation of MCU resources of the embedded device, reducing the MCU load, and improving the stability of the embedded device's operation.
[0114] The task scheduling information includes the task identifier, the in-time timestamp of the scheduled task, and the out-time timestamp of the task completion date. Based on this, in one embodiment, such as... Figure 3 As shown, in S210 above, when scheduling each task by executing the scheduler, the scheduling information of each task is alternately stored in different half-areas of the circular storage area, including:
[0115] S310. For any task, in the case of scheduling tasks, obtain the task identifier, the in-point timestamp when the scheduling task starts, and the out-point timestamp when the scheduling task is completed.
[0116] The task identifier is used to distinguish different tasks; different tasks have different task identifiers, while tasks of the same type have the same task identifier. For example, the task identifier can be a task ID. Ingress timestamp (T) start The output timestamp (T) indicates the moment when the scheduling process begins scheduling the task. end () indicates the moment when the scheduling process completes the scheduling of the task.
[0117] Optionally, the embedded device monitors the scheduling status of each task synchronously during the scheduling process. For any scheduled task, it obtains the task identifier of the task and determines the time when the task scheduling begins as the in-time timestamp, and determines the time when the task scheduling is completed as the out-time timestamp.
[0118] S320. Determine the current half-area based on the storage status of different half-areas in the circular storage region.
[0119] The current half-area represents the half-area used to store newly obtained scheduling information.
[0120] Optionally, after the embedded device obtains new scheduling information, it can determine the half-area whose storage state meets the preset requirements based on the storage state of different half-areas in the ring storage area, and use it as the half-area for storing the newly obtained scheduling information, i.e., the current half-area.
[0121] For example, the storage state of a half-area can be represented by a storage state pointer, which points to the current storage location reached by the half-area. After obtaining new scheduling information, the embedded device can read the storage state pointers of each half-area in the circular storage area, and determine the half-area whose storage state pointer points to a location that is not the end of the half-area, as the current half-area.
[0122] S330. Store the task identifier, in-point timestamp, and out-point timestamp as the task's scheduling information in the current half-segment.
[0123] Optionally, after determining the current half-segment, the embedded device uses the task identifier, in-point timestamp, and out-point timestamp obtained from the scheduling task as the scheduling information of the scheduled task and stores it in the determined current half-segment.
[0124] In this embodiment, for any task, when scheduling the task, the task identifier, the in-time stamp, and the out-time stamp of the task are obtained. Based on the storage status of different half-areas in the circular storage area, the current half-area is determined, and the task identifier, in-time stamp, and out-time stamp are stored in the current half-area as the scheduling information of the task. In the above method, the task identifier, in-time stamp, and out-time stamp of the scheduled task are used as the scheduling information obtained by scheduling the task, realizing the full time recording of the task scheduling process, providing a rich data foundation for subsequent determination of load information, and improving the diversity of the determined load information.
[0125] In one embodiment, where the ring-shaped storage region comprises two halves, namely the first half and the second half, as follows: Figure 4 As shown, S320 above, determining the current half-region based on the storage status of different half-regions in the circular storage region, includes:
[0126] S410: Obtain the storage flags of the first and second half-segments.
[0127] The storage flag bit can be used to characterize the storage status of a half-area. The storage flag bit can be a completion flag or a non-completion flag. A completion flag indicates that the storage status of the half-area has reached a full state, while a non-completion flag indicates that the storage status of the half-area has not reached a full state. For example, the completion flag is 1, and the non-completion flag is empty or 0.
[0128] Optionally, when the current half-area is determined in the ring-shaped storage region, the embedded device can obtain the storage flag bits of the first half-area and the second half-area in the ring-shaped storage region respectively, that is, read the flag information in the storage flag bits.
[0129] S420. If one of the storage flag bits in the first half-segment and the second half-segment is a completion flag and the other is a non-completion flag, determine the half-segment with the non-completion flag as the current half-segment.
[0130] Optionally, after obtaining the storage flag bits of the first half and the second half, the embedded device may determine the half with the non-complete flag as the current half if one of the storage flag bits in the first half and the second half is a complete flag and the other is a non-complete flag.
[0131] It should be noted that a half-space marked with a completion flag indicates that the half-space has been filled, while a half-space without a completion flag indicates that the half-space has not yet been filled. It may be a half-space currently used to store scheduling information, or it may be a free half-space that has not yet stored scheduling information. If one half-space is full and the other is not full, the half-space that is not full is selected as the current half-space for storing new scheduling information.
[0132] In the case of a circular storage area comprising three or more half-areas, if the storage flag bit of one half-area is a completion flag and the completion flag bits of the other half-areas are non-completion flags, the embedded device will take the half-area below the completion flag half-area along the preset surrounding direction as the current half-area.
[0133] S430. If both the storage flag bits of the first half-segment and the second half-segment are non-complete flags, determine the current half-segment based on the storage status pointers of the first half-segment and the second half-segment.
[0134] In addition to the storage flag bit, which can be used to represent the storage status of a half-area, the storage status pointer can also be used to represent the storage status of a half-area, specifically pointing to the current storage location reached by the half-area. The storage flag bits for both the first and second half-areas are incomplete flags, corresponding to scenarios where the circular storage area has not yet stored scheduling information, has just begun storing scheduling data, or has had all stored data cleared.
[0135] Optionally, if both the storage flag bits of the first half-region and the second half-region are non-complete flags, the embedded device may further read the storage status pointers of the first half-region and the second half-region to determine the current half-region in the first half-region and the second half-region.
[0136] In an optional embodiment, determining the current half-region based on the storage state pointers of the first and second half-regions in S430 includes:
[0137] Based on the storage state pointers of the first and second halves, determine the half that the storage state pointer points to in the first and second halves, which is not the end of the half, and use it as the current half.
[0138] The endpoint of a half-area is the last storage location of the corresponding half-area in the preset wrapping direction, while the endpoint of a non-half-area is any storage location of the corresponding half-area in the preset wrapping direction that is not the last storage location, i.e. any storage location between the start point and the endpoint (including the start point but excluding the endpoint).
[0139] It should be noted that the storage location pointed to by the storage status pointer changes continuously as data is stored. After the storage status pointer points to the end of a half-area, if new data is stored in that half-area, the storage status pointer of that half-area will then point to the storage location reached after the new data is stored.
[0140] Optionally, obtaining the storage status pointers of the first and second halves yields the storage locations they point to. The embedded device can determine whether the storage status pointers of the first and second halves point to storage locations other than the end of a half-region, and select the half-region pointing to the non-end point as the current half-region. If both the storage status pointers of the first and second halves point to locations other than the end point of a half-region (i.e., both pointing to the start point of a half-region), the embedded device can select either the first or second half-region, or a preset half-region (such as the first or second half-region), as the current half-region.
[0141] When a circular storage region comprises three or more half-regions, if the completion flags of all half-regions are set to non-completion, the embedded device acquires the storage status pointers of each half-region and identifies the half-region whose storage status pointer points to a region other than its end point as the current half-region. If the storage status pointers of all half-regions point to regions other than their end points (i.e., all half-regions' storage status pointers point to their start points), the embedded device can select any half-region or a preset half-region as the current half-region. This preset half-region can be any half-region within the circular storage region.
[0142] In this embodiment, the storage flag bits of the first half-segment and the second half-segment are obtained. If one of the storage flag bits in the first half-segment and the second half-segment is a completion flag and the other is a non-completion flag, the half-segment with the non-completion flag is determined as the current half-segment. If both the storage flag bits in the first half-segment and the second half-segment are non-completion flags, the current half-segment is determined based on the storage status pointers of the first half-segment and the second half-segment. Specifically, the half-segment whose storage status pointer points to a position other than the end of the first half-segment can be determined as the current half-segment. In the above method, the current half-segment is determined in the first half-segment and the second half-segment by combining the storage flag bits and the storage status pointer, which is adapted to the diverse storage states of the first half-segment and the second half-segment and improves the efficiency and convenience of determining the current half-segment.
[0143] To obtain the task identifier, ingress timestamp, and touchpoint timestamp, in one embodiment, such as Figure 5 As shown, the process of obtaining the task identifier, the in-time stamp of the task scheduling start, and the out-time stamp of the task scheduling completion in S310 includes:
[0144] S510. Call the pre-hook function to obtain the task identifier of the scheduled task and obtain the time when the scheduled task started to be scheduled, and record it as the in-point timestamp.
[0145] Among them, the prehook function is a callback function that is triggered and called before the task is scheduled.
[0146] Optionally, before scheduling a task through the scheduler, the embedded device triggers a pre-hook function to track the scheduling status of the task by calling the pre-hook function, so as to obtain the task identifier of the scheduled task and the time when the scheduled task started to be scheduled, and record the time when the scheduled task started to be scheduled as the in-point timestamp.
[0147] S520. Call the post-hook function to get the time when the scheduled task was completed, and record it as the output timestamp.
[0148] Among them, the posthook function is also a callback function, which is triggered and called after a scheduled task.
[0149] Optionally, after the embedded device schedules a task through the scheduler, it triggers a post-hook function. By calling the post-hook function, it tracks whether the task has been scheduled and executed, obtains the time when the scheduled task was completed, and records the time when the scheduled task was completed as the output timestamp.
[0150] In this embodiment, a pre-hook function is called to obtain the task identifier of the scheduled task and the time when the scheduled task begins to be scheduled, which is recorded as the in-time timestamp. A post-hook function is called to obtain the time when the scheduled task is completed, which is recorded as the out-time timestamp. In the above method, by calling the pre-hook function and the post-hook function respectively, the scheduling status of the scheduled task and whether it has been completed are tracked without affecting the scheduler's scheduling of the task, thereby improving the accuracy and reliability of the obtained task identifier, in-time timestamp and out-time timestamp.
[0151] The ring-shaped storage region comprises two halves, namely the first half and the second half. Based on this, in one embodiment, such as Figure 6 As shown, in S210 above, marking any half-region as complete when any half-region is full includes:
[0152] S610. If any half-segment is the first half-segment, mark the storage flag bit of the first half-segment as the completion flag.
[0153] The storage flag bit can be used to characterize the storage status of a half-area. The storage flag bit can be a completion flag or a non-completion flag. A completion flag indicates that the storage status of the half-area has reached a full state, while a non-completion flag indicates that the storage status of the half-area has not reached a full state. For example, the completion flag is 1, and the non-completion flag is empty or 0.
[0154] Optionally, if any half-area that is filled is the first half-area in a circular storage area, and the storage state of the first half-area is characterized as full, the embedded device marks the storage flag of the first half-area as a completion flag.
[0155] S620. If any half-segment is the second half-segment, mark the storage flag of the second half-segment as the completion flag.
[0156] Optionally, if any half-area that is filled is the second half-area in a circular storage area, and the storage state of the second half-area is characterized as full, the embedded device marks the storage flag of the second half-area as a completion flag.
[0157] In this embodiment, the ring-shaped storage area includes a first half and a second half. When either half is the first half, the storage flag bit of the first half is marked as a completion flag. When either half is the second half, the storage flag bit of the second half is marked as a completion flag. In the above method, when either the first or second half is full, the storage flag bit of the corresponding half is marked as a completion flag, so as to promptly instruct the instruction processing device to obtain the scheduling information stored in the corresponding half, thereby improving the timeliness and orderliness of load monitoring.
[0158] The embedded device is also used to update memory flags under the instruction of the instruction processing device. For the first half of the circular memory region, in one embodiment, as... Figure 7 As shown, the above method also includes:
[0159] S710, Receive the instruction processing device to clear the flag bits of the first half-zone; the instruction processing device generates the instruction to clear the flag bits of the first half-zone based on the operation of sending the scheduling information stored in the first half-zone to an external computer device.
[0160] The flag clear instruction is used to indicate that the completion flag in the stored flags should be cleared.
[0161] Optionally, if the first half of the circular storage area is full, the embedded device marks the storage flag of the first half as a completion flag. When the instruction processing device receives / reads the storage flag of the first half as a completion flag, it retrieves the call information stored in the first half and sends the scheduling information stored in the first half to an external computer device. Simultaneously, it generates a clear command for the flags of the first half and sends it to the embedded device. The embedded device then receives the clear command for the flags of the first half from the instruction processing device.
[0162] S720. According to the flag clearing instruction, clear the completion flag in the storage flags of the first half of the area.
[0163] Optionally, after receiving the flag clear instruction for the first half-segment, the embedded device, in response to the flag clear instruction, clears the completion flag in the storage flags of the first half-segment.
[0164] In this embodiment, the instruction processing device sends a flag clearing instruction for the first half-zone. Based on this instruction, the completion flag in the storage flags of the first half-zone is cleared. The flag clearing instruction for the first half-zone is generated by the instruction processing device based on the operation of sending the scheduling information stored in the first half-zone to an external computer device. In the above method, the instruction processing device triggers the flag clearing instruction for the storage flags of the first half-zone by sending the scheduling information stored in the first half-zone when it is full. This instructs the embedded device to update the storage flags of the first half-zone in a timely manner, improving the orderliness of subsequent scheduling information transmission and correspondingly improving the accuracy of the determined load information, thereby enhancing the reliability of load monitoring.
[0165] For the second half of the ring-shaped storage region, in one embodiment, such as Figure 8 As shown, the above method also includes:
[0166] S810, Receive the instruction processing device to clear the flag bits of the second half-zone; the instruction processing device generates the instruction to clear the flag bits of the second half-zone based on the operation of sending the scheduling information stored in the second half-zone to the external computer device.
[0167] Optionally, if the second half of the circular storage area is full, the embedded device marks the storage flag of the second half as a completion flag. When the instruction processing device receives / reads the storage flag of the second half as a completion flag, it retrieves the call information stored in that second half and sends the scheduling information stored in that second half to an external computer device. Simultaneously, it generates a clear command for the flags of the second half and sends it to the embedded device. The embedded device then receives the clear command for the flags of the second half from the instruction processing device.
[0168] S820. According to the flag clearing instruction, clear the completion flag in the storage flags of the second half of the area.
[0169] Optionally, after receiving the flag clear instruction for the second half of the region, the embedded device, in response to the flag clear instruction, clears the completion flag in the storage flags of the second half of the region.
[0170] In this embodiment, the instruction processing device sends a flag clearing instruction for the second half of the storage area. Based on this instruction, the completion flag in the storage flags of the second half of the storage area is cleared. The flag clearing instruction for the second half of the storage area is generated by the instruction processing device based on the operation of sending the scheduling information stored in the second half of the storage area to an external computer device. In the above method, the instruction processing device triggers the flag clearing instruction for the storage flags of the second half of the storage area by sending the scheduling information stored in the second half of the storage area when it is full. This instructs the embedded device to update the storage flags of the second half of the storage area in a timely manner, improving the orderliness of subsequent scheduling information transmission and correspondingly improving the accuracy of the determined load information, thereby improving the reliability of load monitoring.
[0171] In an optional embodiment, the instruction processing device sends the scheduling information stored in any half-area to the external computer device by calling the memory access interface to access the address of the ring memory area, reading the scheduling information from the ring memory area through the data read / write register, and sending the read scheduling information to the external computer device.
[0172] The Memory Access Point (MeM-AP) is the communication interface that enables memory access between the instruction processing device and the embedded device. The Data Read / Write Register is the data read / write interface used to read raw data from memory, that is, to read the scheduling information stored in the circular memory area.
[0173] For example, taking the instruction processing device as the parser, the parser accesses the address of the ring memory area in the embedded device through MeM-AP, reads the scheduling information stored in the ring memory area through the data read / write register, and sends the read scheduling information to an external computer device.
[0174] In one embodiment, this application also provides a load monitoring method, such as... Figure 9 As shown, this method is applied to Figure 1 Taking an external computer device as an example, the steps include:
[0175] S910, Receive scheduling information stored in the ring-shaped storage area of the embedded device sent by the instruction processing device; the scheduling information is that when the embedded device schedules each task by executing the scheduler, it alternately stores the scheduling information of each task in different halves of the ring-shaped storage area, and marks any half of the ...
[0176] Each task can include business tasks where the embedded device runs the application to perform corresponding business functions, or it can include idle tasks where no application is running.
[0177] Scheduling information refers to the data obtained from scheduling tasks. For example, scheduling information may include the task identifier (such as ID) or task type (such as periodic task or non-periodic task) of the scheduled task, and may also include time information, such as the start time of scheduling, the end time of scheduling, or the scheduling duration from the start of scheduling to the end of scheduling, etc.
[0178] A circular storage area is a temporary storage area in embedded devices, also known as a buffer. The process of storing data using a circular storage area is as follows:
[0179] Starting from a storage location in the ring-shaped storage area, data is stored along a preset circumferential direction. When the ring-shaped storage area is full, the system continues to use the same starting point to overwrite the old data with new data, thereby reusing the storage area to continuously store data.
[0180] A half-area in a ring storage region represents a portion (not the entire) of the storage region within the ring storage region. A ring storage region can include at least two half-areas.
[0181] Optionally, upon receiving a task execution instruction, the embedded device can activate a scheduling process to schedule various tasks, such as scheduling tasks in a task scheduling table sequentially. During scheduling, the device records the scheduling information obtained from scheduling each task and stores this information in a half-area of the circular buffer area. Simultaneously, it monitors the data storage volume of each half-area and marks it as complete when any half-area in the circular buffer area is full. The instruction processing device can receive / acquire the scheduling information stored in different half-areas of the circular buffer area and send this information to an external computer device. The external computer device then receives the scheduling information sent by the instruction processing device.
[0182] S920. Determine the load information of the embedded device based on the received scheduling information, and send the load information to the embedded device; the load information is used by the embedded device to determine the load monitoring results of the embedded device.
[0183] The load information of the embedded device is used to characterize the load of the MCU in the embedded device performing tasks. For example, the load information may include the duration of each task, the total duration of executing different / same tasks within a preset time period, the percentage of time spent executing different / same tasks within the preset time period, etc.
[0184] Optionally, an external computer device can statistically determine, based on scheduling information, at least one of the following: the duration of each task executed by the MCU in the embedded device, the total duration of all / the same tasks executed within a preset time period, and the percentage of the total duration of all / the same tasks executed within a preset time period in the preset time period. This information is used as the load information of the embedded device and sent to the instruction processing device. The instruction processing device then sends the load information of the embedded device back to the embedded device so that the embedded device can determine the load monitoring results of the embedded device.
[0185] In this embodiment, an external computer device receives scheduling information stored in the ring-shaped storage area of the embedded device from an instruction processing device, determines the load information of the embedded device based on the received scheduling information, and sends the load information to the embedded device. The scheduling information is generated when the embedded device schedules each task by executing a scheduler, and alternately stores the scheduling information of each task in different halves of the ring-shaped storage area, marking any half-area as complete when it is full. The completion flag is used to instruct the instruction processing device to send the scheduling information stored in the half-area to the external computer device. The load information is used by the embedded device to determine the load monitoring result of the embedded device. In the above method, the external computer device receives the scheduling information sent by the embedded device to determine the load information of the embedded device using the resources provided by the external computer device, and then obtains the load monitoring result. This realizes the calculation of load information off-chip without the embedded device consuming its own resources, thus reducing the occupation of MCU resources of the embedded device, reducing the MCU load, and improving the stability of the embedded device's operation.
[0186] To obtain load information for the embedded device, in one embodiment, such as Figure 10 As shown, in S920 above, determining the load information of the embedded device based on the received scheduling information includes:
[0187] S1010. Determine the load information of different tasks within the reference time period based on the received scheduling information.
[0188] The reference time period is any pre-set time period.
[0189] Optionally, the external computer device can determine the tasks to be scheduled within the reference time period from the received scheduling information, and then determine the load information of different tasks within the reference time period. The tasks to be scheduled within the reference time period are those that begin scheduling and complete scheduling within the reference time period.
[0190] For example, the scheduling information includes a task identifier, an ingress timestamp, and an egress timestamp. The scheduling information received by the external computer device is ordered chronologically as follows:
[0191] T i-start1 T i-end1 T j-start1 T j-end1 T k-start1 T k-end1 .
[0192] i, j, k represent task identifiers, T start Indicates the ingress timestamp, T end This indicates the timestamp, where 1 represents the first scheduling.
[0193] Taking the reference time period [T1, T2] as an example, when T1 is earlier than T... i-start1 And T2 is later than T k-end1 In this case, the embedded device can determine that tasks i, j, and k are all scheduled within the reference time period [T1, T2], and the embedded device can determine the load information of tasks i, j, and k based on the above scheduling information.
[0194] S1020. Determine the load information of the embedded device based on the load information of different tasks.
[0195] Optionally, after obtaining the load information of each task scheduled within the reference time period, the external computer device can determine the load information of the embedded device within the reference time period based on the load information of each task.
[0196] For example, an external computer device can directly use the load information of each task within the reference time period as the load information of the embedded device within the reference time period, or it can obtain the sum of the load information of each task within the reference time period as the load information of the embedded device within the reference time period.
[0197] In this embodiment, the load information of different tasks within a reference time period is determined based on the received scheduling information, and the load information of the embedded device is determined based on the load information of different tasks. In the above method, the scheduling information received by the external computer device can be stored for a long time without being overwritten, and the external computer device can determine the load information of tasks within any time period based on the received scheduling information, thus reducing the time limitation and improving the time period flexibility for determining the load information.
[0198] Load information can be represented by time percentage. In one embodiment, where scheduling information includes task identifier, ingress timestamp, and egress timestamp, such as... Figure 11 As shown, S1010 above, determining the load information of different tasks within the reference time period based on the received scheduling information, includes:
[0199] S1110. Determine the runtime of each task scheduled within the reference time period based on the scheduling information; the runtime is the time difference between the in-time timestamp and the out-time timestamp of each task scheduled.
[0200] Optionally, the external computer device can determine the tasks to be scheduled within the reference time period from the received scheduling information, and for each task to be scheduled within the reference time period, obtain the time difference between the in time stamp and the out time stamp of the task, as the runtime of the task.
[0201] S1120. For tasks with the same task identifier, obtain the ratio of the sum of the runtime of each scheduled task to the total duration of the reference time period, and use it as the task's load information.
[0202] Optionally, after obtaining the runtime of each task scheduled each time within the reference time period, the external computer device can calculate the sum of the runtimes of each task scheduled for the same task identifier, and obtain the ratio of the runtime to the total duration of the reference time period as the load information of the task.
[0203] For example, taking the total duration T of the reference period, and the tasks within the reference period including TaskA, TaskB, and TaskC, and obtaining the scheduled runtime of TaskA as TA1, the scheduled runtime of TaskB as TB1 and TB2, and the scheduled runtime of TaskC as TC1, TC2, and TC3, the embedded device can obtain the load information TA1 / T of TaskA, the load information (TB1+TB2) / T of TaskB, and the load information (TC1+TC2+TC3) / T of TaskC.
[0204] In addition to task load information, external computer devices can also determine the running status of tasks. The external computer device can obtain the runtime of each task being invoked each time within a reference time period, determine the reference duration for invocation of tasks with the same task identifier, and then determine the running status of the task corresponding to that same task identifier based on this reference duration.
[0205] For example, the reference duration can be the average runtime, the maximum runtime, or the minimum runtime.
[0206] Optionally, after obtaining the runtime of each task being invoked each time within the reference time period, the external computer device can extract the runtime of each task invocation corresponding to the same task identifier, calculate the average runtime as the reference runtime for that task, and then compare the reference runtime with a preset runtime range to determine the running status of the task based on the comparison result. For example, if the reference runtime is within the preset runtime range, the running status of the task is determined to be normal; conversely, if the reference runtime is not within the preset runtime range, the running status of the task is determined to be abnormal.
[0207] The external computer device can also determine the scheduling status of the embedded device's task scheduling. The external computer device can obtain the scheduling order of tasks scheduled according to a reference time period, match this scheduling order with a preset order, and determine the scheduling status of the embedded device's task scheduling based on the matching result. For example, if the scheduling order matches the preset order (i.e., a match), the scheduling status of the embedded device's task scheduling is determined to be normal; conversely, if the scheduling order does not match the preset order (i.e., a mismatch), the scheduling status of the embedded device's task scheduling is determined to be abnormal.
[0208] It should be noted that the external computer device can not only send load information to the embedded device through the instruction processing device, but also, upon obtaining the task's running status and / or the embedded device's task scheduling status, synchronously send the task's running status and / or the embedded device's task scheduling status to the embedded device through the instruction processing device.
[0209] In one embodiment, this application also provides a load monitoring system, such as Figure 1 As shown, the load monitoring system 100 includes an embedded device 102, an instruction processing device 104, and an external computer device 106. The embedded device 102 and the external computer device 106 are communicatively connected through the instruction processing device 104.
[0210] The embedded device 102 is used to alternately store the scheduling information of each task into different half of the circular storage area when scheduling each task by executing a scheduler, and to mark any half of the ...
[0211] The instruction processing device 104 is used to retrieve the scheduling information stored in any half-segment under the indication of the completion flag and send it to the external computer device 106.
[0212] External computer device 106 uses the received scheduling information to determine the load information of embedded device 102 and sends it to embedded device 102.
[0213] The embedded device 102 and the external computer device 106 in the above-mentioned load monitoring system are used to implement a load monitoring method. For details of the specific process, please refer to the aforementioned related embodiments, which will not be repeated here.
[0214] To facilitate understanding by those skilled in the art, the load monitoring method provided in this application is described in detail below, for application to... Figure 1 Taking the load monitoring system in the middle as an example, such as Figure 12 As shown, the method may include:
[0215] S1201. For any task scheduled by executing a scheduler, the embedded device, when scheduling the task, calls the pre-hook function to obtain the task identifier of the scheduled task, and obtains the time when the scheduled task starts to be scheduled, which is recorded as the in-time stamp, and calls the post-hook function to obtain the time when the scheduled task is completed, which is recorded as the out-time stamp.
[0216] S1202. In the case where one of the storage flag bits in the first half and the second half of the circular storage area is a completion flag and the other is a non-completion flag, the half of the storage area with the non-completion flag is determined as the current half of the storage area.
[0217] S1203. If both the storage flag bits of the first half-zone and the second half-zone are non-complete flags, determine the half-zone in the first half-zone and the second half-zone whose storage status pointer points to a non-half-zone end point, based on the storage status pointers of the first half-zone and the second half-zone, and use it as the current half-zone.
[0218] S1204. Store the task identifier, in-point timestamp, and out-point timestamp of the scheduled task as the scheduling information of the task in the current half-segment; the first half-segment and the second half-segment are used alternately as the current half-segment.
[0219] S1205. If any half of the circular storage area is full, mark the storage flag of that half of the area as a completion flag.
[0220] S1206. When the instruction processing device reads that the storage flag bit of the first half-segment is a completion flag, it obtains the scheduling information stored in the first half-segment and sends it to the external computer device.
[0221] S1207. When the instruction processing device reads that the storage flag bit of the second half of the region is a completion flag, it obtains the scheduling information stored in the second half of the region and sends it to the external computer device.
[0222] S1208. The external computer device determines the runtime of each task being scheduled each time within the reference time period based on the received scheduling information; the runtime is the time difference between the in-time timestamp and the out-time timestamp of each task being scheduled.
[0223] S1209. For tasks corresponding to the same task identifier, obtain the ratio of the sum of the runtime of each scheduled task to the total duration of the reference time period, and use it as the load information of the task.
[0224] S1210. Determine the load information of the embedded device based on the load information of different tasks, and send the load information of the embedded device to the embedded device.
[0225] S1211. The embedded device determines the load monitoring result of the embedded device based on the received load information.
[0226] It should be noted that the descriptions in S1201-S1211 above can be found in the relevant descriptions in the above embodiments, and their effects are similar, so they will not be repeated here.
[0227] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0228] In one embodiment, such as Figure 13 As shown, a load monitoring device is provided, including: a task scheduling module 1301, an information receiving module 1302, and a result determination module 1303; wherein:
[0229] The task scheduling module 1301 is used to alternately store the scheduling information of each task into different half-areas of the circular storage area when scheduling each task by executing the scheduler, and to mark any half-area as complete when any half-area is full; the completion mark is used to instruct the instruction processing device to send the scheduling information stored in any half-area to an external computer device.
[0230] The information receiving module 1302 is used to receive the load information of the embedded device determined by the external computer device according to the scheduling information;
[0231] The result determination module 1303 is used to determine the load monitoring results of the embedded device based on the load information.
[0232] The load monitoring device described above can be used to implement any of the aforementioned load monitoring methods for embedded devices. For details of the process, please refer to the aforementioned embodiments, which will not be repeated here.
[0233] In one embodiment, such as Figure 14 As shown, a load monitoring device is provided, including: a scheduling receiving module 1401 and a load determination module 1402; wherein:
[0234] The scheduling receiving module 1401 is used to receive scheduling information stored in the ring-shaped storage area of the embedded device sent by the instruction processing device. The scheduling information is generated by the embedded device scheduling each task by executing a scheduler, and the scheduling information of each task is alternately stored in different half-areas of the ring-shaped storage area. When any half-area is full, a completion flag is marked for any half-area. The completion flag is used to instruct the instruction processing device to send the scheduling information stored in any half-area to an external computer device.
[0235] The load determination module 1402 is used to determine the load information of the embedded device based on the received scheduling information and send the load information to the embedded device; the load information is used by the embedded device to determine the load monitoring results of the embedded device.
[0236] The load monitoring device described above can be used to implement any of the aforementioned load monitoring methods applied to external computer devices. For details of the specific process, please refer to the aforementioned embodiments, which will not be repeated here.
[0237] Each module in the aforementioned load monitoring device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0238] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 15As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When executed by the processor, the computer program implements a load monitoring method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0239] It should be noted that the computer device can be an embedded device as described in any of the foregoing embodiments, or an external computer device as described in any of the foregoing embodiments.
[0240] Those skilled in the art will understand that Figure 15 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0241] In one embodiment, an embedded device is provided, including a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of any of the above-described load monitoring methods applied to the embedded device.
[0242] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of any of the above-described load monitoring methods applied to an external computer device.
[0243] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the above-described load monitoring methods.
[0244] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of any of the above-described load monitoring methods.
[0245] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0246] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0247] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A load monitoring method, characterized in that, Applied to embedded devices, the method includes: The scheduler schedules each task by executing the scheduler. When scheduling any task, the task identifier, the in-point timestamp when the scheduling of the task begins, and the out-point timestamp when the scheduling of the task is completed are obtained. Retrieve the storage flag bits of the first and second halves of the circular storage region; If one of the storage flag bits in the first half-region and the second half-region is a completion flag and the other is a non-completion flag, the half-region with the non-completion flag is determined as the current half-region; When both the storage flag bits of the first half-segment and the second half-segment are incomplete flags, the current half-segment is determined according to the storage status pointers of the first half-segment and the second half-segment; The task identifier, ingress timestamp, and egress timestamp are used as the scheduling information of the task and stored in the current half-segment. The scheduling information of each task is alternately stored in the first half-segment and the second half-segment. When any half-segment is full, a completion flag is marked on the half-segment. The completion flag is used to instruct the instruction processing device to send the scheduling information stored in the half-segment to an external computer device. The instruction processing device polls the embedded device, periodically reads the completion flags of different half-segments, and when a completion flag is read, obtains the scheduling information stored in the half-segment corresponding to the completion flag and sends the scheduling information to the external computer device. The external computer device receives the load information of the embedded device determined by the external computer device based on the scheduling information; the external computer device is used to determine the load information of different tasks within a reference time period based on the received scheduling information, and to determine the load information of the embedded device based on the load information of the different tasks. The load monitoring result of the embedded device is determined based on the load information.
2. The method according to claim 1, characterized in that, Determining the current half-region based on the storage state pointers of the first half-region and the second half-region includes: Based on the storage state pointers of the first half-region and the second half-region, determine the half-region in the first half-region and the second half-region that the storage state pointer points to is not the end of the half-region, and use it as the current half-region.
3. The method according to claim 1 or 2, characterized in that, The process of obtaining the task identifier, the ingress timestamp for starting task scheduling, and the egress timestamp for completing task scheduling includes: Call the pre-hook function to obtain the task identifier of the scheduled task, and obtain the time when the scheduled task started to be scheduled, which is recorded as the in-point timestamp; Call the post-hook function to obtain the time when the scheduled task was completed, and record it as the exit point timestamp.
4. The method according to claim 1 or 2, characterized in that, The annular storage area includes a first half and a second half. Marking a complete storage area when either half is full includes: If any one of the half-regions is the first half-region, the storage flag bit of the first half-region is marked as the completion flag; If any one of the half-regions is the second half-region, the storage flag bit of the second half-region is marked as the completion flag.
5. The method according to claim 4, characterized in that, The method further includes: The instruction processing device receives a flag clearing instruction for the first half-segment; the flag clearing instruction for the first half-segment is generated by the instruction processing device based on the operation of sending the scheduling information stored in the first half-segment to the external computer device. According to the flag clearing instruction, the completion flag in the storage flags of the first half-region is cleared.
6. The method according to claim 4, characterized in that, The method further includes: The instruction processing device receives a flag clearing instruction for the second half of the region; the flag clearing instruction for the second half of the region is generated by the instruction processing device based on the operation of sending the scheduling information stored in the second half of the region to the external computer device. According to the flag clearing instruction, the completion flag in the storage flags of the second half of the region is cleared.
7. The method according to claim 1 or 2, characterized in that, The instruction processing device sends the scheduling information stored in any half-area to the external computer device by calling the memory access interface to access the address of the ring storage area, reading the scheduling information from the ring storage area through the data read / write register, and sending the read scheduling information to the external computer device.
8. A load monitoring method, characterized in that, Applied to an external computer device, the method includes: The embedded device receives scheduling information stored in a circular storage area sent by an instruction processing device. This scheduling information is generated when the embedded device schedules various tasks by executing a scheduler. When scheduling any task, the device obtains the task identifier, the in-time stamp (starting the task scheduling), and the out-time stamp (completing the task scheduling). It also obtains the storage flags of the first and second halves of the circular storage area. If one of the storage flags in the first and second halves is a completion flag and the other is a non-completion flag, the half with the non-completion flag is determined as the current half. If both the first and second half's storage flags are non-completion flags, the device uses the storage status pointers of the first and second halves of the storage area to determine the current half. The current half-segment is determined; the task identifier, the in-point timestamp, and the out-point timestamp are used as the scheduling information of the task and stored in the current half-segment, so that the scheduling information of each task is stored alternately in the first half-segment and the second half-segment, and a completion flag is marked for any half-segment when it is full; the completion flag is used to instruct the instruction processing device to send the scheduling information stored in the half-segment to an external computer device; the instruction processing device polls the embedded device, periodically reads the completion flags of different half-segments, and when a completion flag is read, obtains the scheduling information stored in the half-segment corresponding to the completion flag, and sends the scheduling information to the external computer device; The load information of different tasks within the reference time period is determined based on the received scheduling information. The load information of the embedded device is determined based on the load information of the different tasks, and the load information is sent to the embedded device. The load information is used by the embedded device to determine the load monitoring result of the embedded device.
9. The method according to claim 8, characterized in that, The step of determining the load information of different tasks within the reference time period based on the received scheduling information includes: The runtime of each task scheduled within the reference time period is determined based on the scheduling information; the runtime is the time difference between the in-time timestamp and the out-time timestamp of each task scheduled. For tasks corresponding to the same task identifier, the ratio of the sum of the runtime of each scheduled task to the total duration of the reference time period is obtained as the load information of the task.
10. A load monitoring system, characterized in that, The load monitoring system includes an embedded device, an instruction processing device, and an external computer device, wherein the embedded device and the external computer device are communicatively connected through the instruction processing device. The embedded device is used to schedule various tasks by executing a scheduler. When scheduling any task, it obtains the task identifier, the in-time stamp when the task is started, and the out-time stamp when the task is completed. It also obtains the storage flag bits of the first and second halves of the circular storage area. If one of the storage flag bits of the first and second halves is a completion flag and the other is a non-completion flag, the half with the non-completion flag is determined as the current half. If both the storage flag bits of the first and second halves are non-completion flags, the current half is determined according to the storage status pointers of the first and second halves. The task identifier, the ingress timestamp, and the egress timestamp are used as the task's scheduling information and stored in the current half-segment. The scheduling information of each task is alternately stored in the first half-segment and the second half-segment. When any half-segment is full, a completion flag is marked on any half-segment. The load information of the embedded device sent by the external computer device is received, and the load monitoring result of the embedded device is determined based on the load information of the embedded device. The instruction processing device is used to poll the embedded device, periodically read the completion flags of different half-regions, and when the completion flag is read, obtain the scheduling information stored in the half-region corresponding to the completion flag, and send the scheduling information to the external computer device. The external computer device is used to determine the load information of different tasks within a reference time period based on the received scheduling information, and to determine the load information of the embedded device based on the load information of the different tasks, and then send it to the embedded device.
11. A load monitoring device, characterized in that, The device includes: The task scheduling module is used to schedule various tasks by executing a scheduler. When scheduling any task, it obtains the task identifier, the in-time stamp when the task scheduling starts, and the out-time stamp when the task scheduling is completed; it obtains the storage flag bits of the first and second halves of the circular storage area; if one of the storage flag bits of the first and second halves is a completion flag and the other is a non-completion flag, it determines the half with the non-completion flag as the current half; if both the first and second half's storage flag bits are non-completion flags, it determines the current half based on the storage status pointers of the first and second halves; and it sets the task identifier, task flag, in-time stamp, and out-time stamp of the task scheduling. The in-time stamp and the out-time stamp are used as the scheduling information of the task and stored in the current half-segment. The scheduling information of each task is alternately stored in the first half-segment and the second half-segment. When any half-segment is full, a completion flag is marked on the half-segment. The completion flag is used to instruct the instruction processing device to send the scheduling information stored in the half-segment to an external computer device. The instruction processing device polls the embedded device, periodically reads the completion flags of different half-segments, and when a completion flag is read, obtains the scheduling information stored in the half-segment corresponding to the completion flag and sends the scheduling information to the external computer device. An information receiving module is used to receive the load information of the embedded device determined by the external computer device according to the scheduling information; the external computer device is used to determine the load information of different tasks within a reference time period according to the received scheduling information, and to determine the load information of the embedded device according to the load information of the different tasks. The result determination module is used to determine the load monitoring result of the embedded device based on the load information.
12. A load monitoring device, characterized in that, The device includes: A scheduling receiving module is used to receive scheduling information stored in a circular storage area of an embedded device sent by an instruction processing device. The scheduling information is generated by the embedded device scheduling various tasks through the execution of a scheduling program. When scheduling any task, the module obtains the task identifier, the in-time stamp (starting the task scheduling), and the out-time stamp (completing the task scheduling). It also obtains the storage flags of the first and second halves of the circular storage area. If one of the storage flags in the first and second halves is a completion flag and the other is a non-completion flag, the half with the non-completion flag is determined as the current half. If both the first and second half's storage flags are non-completion flags, the module determines the current half based on the storage flags in the first and second halves. The storage status pointer determines the current half-segment; the task identifier, the in-point timestamp, and the out-point timestamp are used as the scheduling information of the task and stored in the current half-segment, so that the scheduling information of each task is alternately stored in the first half-segment and the second half-segment, and a completion flag is marked for any half-segment when it is full; the completion flag is used to instruct the instruction processing device to send the scheduling information stored in the half-segment to an external computer device; the instruction processing device polls the embedded device, periodically reads the completion flags of different half-segments, and when a completion flag is read, obtains the scheduling information stored in the half-segment corresponding to the completion flag, and sends the scheduling information to the external computer device; The load determination module is used to determine the load information of different tasks within a reference time period based on the received scheduling information, determine the load information of the embedded device based on the load information of the different tasks, and send the load information to the embedded device; the load information is used by the embedded device to determine the load monitoring result of the embedded device.
13. An embedded device, characterized in that, The embedded device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the method according to any one of claims 1 to 7.
14. A computer device, characterized in that, The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the method of claim 8 or 9.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 9.
16. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Log recording method, battery management system, vehicle and electronic equipment
CN110555006A
Data backup method, electronic equipment and computer readable storage medium
CN116954996A