Load monitoring method and device, embedded equipment, computer equipment and medium
By alternately storing task scheduling information in the embedded device and sending it to external computer devices to determine the load information, the stability problem caused by MCU resource consumption is solved, and the high and stable operation of the embedded device is achieved.
Patent Information
- Application Number
- CN202510750307.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-06
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2045-06-06
AI Technical Summary
In the prior art, the microcontroller unit (MCU) of embedded devices consumes a large amount of resources when calculating load information, resulting in reduced device operation stability, especially in application scenarios where real-time requirements may cause system response delays and device failures.
By using a ring storage area in the embedded device to alternately store task scheduling information and mark the completion flag when the half area is full, the information is sent out to the external computer device, and the load information is determined by the external computer device, thereby reducing MCU resource occupation.
It reduces the load of embedded device MCUs, improves device operation stability, and reduces MCU resource consumption by calculating load information on off-chip.
Smart Images

Figure CN120276940A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of load monitoring, and particularly to a load monitoring method, device, embedded device, computer device and medium. Background Art
[0002] Load monitoring is a process of real-time monitoring and analysis of the workload borne by a system or device during operation.
[0003] Taking an embedded device as an example, load monitoring can be used to determine the load information of a microcontroller unit (MCU) in the embedded device, such as the time ratio of MCU scheduling tasks. In related technologies, the MCU needs to calculate the load information according to the scheduling information of different tasks, which consumes MCU resources, increases the MCU load, and reduces the stability of the device's own operation. Summary of the Invention
[0004] Based on this, it is necessary to provide a load monitoring method, device, embedded device, computer device and medium for the above technical problems.
[0005] In a first aspect, an embodiment of the present application provides a load monitoring method applied to an embedded device. The method includes:
[0006] When scheduling each task by executing a scheduling program, alternately store the scheduling information of each task in different half-areas of a circular storage area, and mark a completion flag for any one of the half-areas when any one of the half-areas is full; the completion flag is used to instruct an instruction processing device to send the scheduling information stored in any one of the half-areas to an external computer device;
[0007] Receive the load information of the embedded device determined by the external computer device according to the scheduling information;
[0008] Determine the load monitoring result of the embedded device according to the load information.
[0009] In an embodiment of the present application, the scheduling information in the circular storage area is sent to an external computer device, and the external computer device determines the load information of the embedded device based on the scheduling information, and then obtains the load monitoring result, realizing off-chip calculation of the load information without the embedded device consuming its own resources. Therefore, the occupation of MCU resources of the embedded device is reduced, the MCU load is reduced, and the stability of the embedded device's own operation is improved.
[0010] In one of the embodiments, when scheduling each task by executing a scheduling program, alternately storing the scheduling information of each task in different half-areas of a circular storage area includes:
[0011] For any task, in the case of scheduling the task, obtain the task identifier of the task, the entry timestamp for starting to schedule the task, and the exit timestamp for completing the scheduling of the task;
[0012] Determine the current half area according to the storage status of different half areas in the circular storage area;
[0013] Store the task identifier, the entry timestamp, and the exit timestamp as the scheduling information of the task into the current half area.
[0014] In the embodiment of the present application, taking the task identifier, the entry timestamp, and the exit timestamp of the scheduled task as the scheduling information obtained by scheduling the task realizes the full-time recording of the task scheduling process, provides a rich data basis for subsequent determination of load information, and can improve the diversity of the determined load information.
[0015] In one embodiment, the circular storage area includes a first half area and a second half area. Determining the current half area according to the storage status of different half areas in the circular storage area includes:
[0016] Obtain the storage flag bits of the first half area and the second half area;
[0017] In the case where one of the storage flag bits of the first half area and the second half area is a completion flag and the other is a non-completion flag, determine the half area with the non-completion flag as the current half area;
[0018] In the case where the storage flag bits of the first half area and the second half area are both non-completion flags, determine the current half area according to the storage status pointers of the first half area and the second half area.
[0019] In one embodiment, determining the current half area according to the storage status pointers of the first half area and the second half area includes:
[0020] According to the storage status pointers of the first half area and the second half area, determine the half area in which the storage status pointer points to a non-half area end point in the first half area and the second half area as the current half area.
[0021] In the embodiment of the present application, the current half area is determined in the first half area and the second half area by combining the storage flag bit and the storage status pointer, which is adapted to the diverse storage status of the first half area and the second half area, and improves the efficiency and convenience of determining the current half area.
[0022] In one embodiment, obtaining the task identifier of the task, the entry timestamp for starting to schedule the task, and the exit timestamp for completing the scheduling of the task includes:
[0023] Call the pre-hook function to obtain the task identifier of the scheduled task, and obtain the moment when the scheduled task starts to be scheduled, which is recorded as the entry timestamp;
[0024] Call the post - hook function to obtain the moment when the scheduled task is scheduled to completion, denoted as the out - point timestamp.
[0025] In the embodiments of the present application, by separately calling the pre - hook function and the post - hook function, while not affecting the scheduler to schedule tasks, the scheduling situation of the scheduled task and whether it has been executed are tracked, 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 area includes a first half - area and a second half - area. When any one of the half - areas is full, marking a completion flag for any one of the half - areas includes:
[0027] When any one of the half - areas is the first half - area, mark the storage flag bit of the first half - area as the completion flag;
[0028] When any one of the half - areas is the second half - area, mark the storage flag bit of the second half - area as the completion flag.
[0029] In the embodiments of the present application, when the first half - area or the second half - area is full, mark the storage flag bit of the corresponding half - area as the completion flag, so as to timely instruct the instruction processing device to obtain the scheduling information stored in the corresponding half - area, improving the timeliness and orderliness of load monitoring.
[0030] In one embodiment, the above - mentioned method further includes:
[0031] Receive a flag - clearing instruction for the first half - area sent by the instruction processing device; the flag - clearing instruction for the first half - area is generated by the instruction processing device based on the operation of sending the scheduling information stored in the first half - area to an external computer device;
[0032] According to the flag - clearing instruction, clear the completion flag in the storage flag bit of the first half - area.
[0033] In the embodiments of the present application, the external operation of the instruction processing device for the scheduling information stored in the first half - area in the full state triggers a flag - clearing instruction for the storage flag bit of the first half - area, to instruct the embedded device to update the storage flag bit of the first half - 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.
[0034] In one embodiment, the above - mentioned method further includes:
[0035] Receive the flag clearing instruction for the second half area sent by the instruction processing device; the flag clearing instruction for the second half area is generated by the instruction processing device based on the operation of sending the scheduling information stored in the second half area to an external computer device;
[0036] According to the flag clearing instruction, clear the completion flag in the storage flag of the second half area.
[0037] In the embodiment of the present application, the external transmission operation of the scheduling information stored in the second half area in the full storage state by the instruction processing device triggers the flag clearing instruction for the storage flag of the second half area, so as to instruct the embedded device to update the storage flag of the second half area in time, improve the orderliness of the subsequent external transmission of the scheduling information, and correspondingly improve the accuracy of the determined load information, thereby improving the reliability of the load monitoring.
[0038] In one embodiment, the instruction processing device sends the scheduling information stored in any half area to an external computer device by the instruction processing device calling the memory access interface to access the address of the circular storage area, reading the scheduling information from the circular storage area through the data read / write register, and sending the read scheduling information to the external computer device.
[0039] In a second aspect, the embodiment of the present application further provides a load monitoring method, which is applied to an external computer device, and the method includes:
[0040] Receive the scheduling information stored in the circular 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 a scheduling program, the scheduling information of each task is alternately stored in different half areas of the circular storage area, and 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;
[0041] Determine the load information of the embedded device according to the received scheduling information, and send the load information to the embedded device; the load information is used for the embedded device to determine the load monitoring result of the embedded device.
[0042] In the embodiment of the present application, the external computer device receives the scheduling information sent by the embedded device to determine the load information of the embedded device by using the resources of the external computer device, and then obtains the load monitoring result, realizing the calculation of the off-chip load information without the embedded device consuming its own resources. Therefore, the occupation of the MCU resources of the embedded device is reduced, the MCU load is reduced, and the stability of the embedded device itself is improved.
[0043] In one embodiment, determining the load information of the embedded device according to the received scheduling information includes:
[0044] Determining the load information of different tasks within a reference period according to the received scheduling information;
[0045] Determining the load information of the embedded device according to the load information of different tasks.
[0046] In the embodiments of the present application, the scheduling information received by the external computer device can be stored permanently without being overwritten. The external computer device can determine the load information of tasks within any period according to the received scheduling information, thereby reducing the time limitation and improving the flexibility of the period for determining the load information.
[0047] In one embodiment, the scheduling information includes a task identifier, an entry timestamp, and an exit timestamp; determining the load information of different tasks within a reference period according to the received scheduling information includes:
[0048] Determining the running duration of each task scheduled within the reference period according to the scheduling information; the running duration is the time difference between the entry timestamp and the exit timestamp of each task scheduled;
[0049] For tasks corresponding to the same task identifier, obtaining the ratio of the sum of the running durations of each scheduling to the total duration of the reference period as the load information of the task.
[0050] In a third aspect, the embodiments of the present application further provide a load monitoring system, which includes: an embedded device, an instruction processing device, and an external computer device. The embedded device and the external computer device are communicatively connected through the instruction processing device;
[0051] The embedded device is configured to alternately store the scheduling information of each task into different half areas of the circular storage area when scheduling each task by executing a scheduling program, mark a completion flag for any one of the half areas when any one of the half areas is full, receive the load information of the embedded device sent by the external computer device, and determine the load monitoring result of the embedded device according to the load information of the embedded device;
[0052] The instruction processing device is configured to obtain the scheduling information stored in any one of the half areas under the indication of the completion flag and send it to the external computer device;
[0053] The external computer device is configured to determine the load information of the embedded device according to the received scheduling information and send it to the embedded device.
[0054] In a fourth aspect, the embodiments of the present application further provide a load monitoring device, which includes:
[0055] A task scheduling module, which is used to alternately store the scheduling information of each task into different half areas of a circular storage area when scheduling each task by executing a scheduler, and mark a completion flag for any one of the half areas when any one of the half areas is full; the completion flag is used to instruct an instruction processing device to send the scheduling information stored in any one of the half areas to an external computer device;
[0056] An information receiving module, which is used to receive the load information of the embedded device determined by the external computer device according to the scheduling information;
[0057] A result determining module, which is used to determine the load monitoring result of the embedded device according to the load information.
[0058] In a fifth aspect, an embodiment of the present application further provides a load monitoring device, and the device includes:
[0059] A scheduling receiving module, which is used to receive the scheduling information stored in the circular storage area in the embedded device sent by the instruction processing device; the scheduling information is that when the embedded device schedules each task by executing a scheduler, the scheduling information of each task is alternately stored into different half areas of the circular storage area, and a completion flag is marked for any one of the half areas when any one of the half areas is full; the completion flag is used to instruct the instruction processing device to send the scheduling information stored in any one of the half areas to an external computer device;
[0060] A load determining module, which is used to determine the load information of the embedded device according to the received scheduling information and send the load information to the embedded device; the load information is used for the embedded device to determine the load monitoring result of the embedded device.
[0061] In a sixth aspect, an embodiment of the present application further provides an embedded device, which includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the steps in the load monitoring method provided in any one of the embodiments in the first aspect are implemented.
[0062] In a seventh aspect, an embodiment of the present application further provides a computer device, which includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the steps in the load monitoring method provided in any one of the embodiments in the second aspect are implemented.
[0063] In an eighth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the load monitoring method provided in any one of the embodiments are implemented.
[0064] In a ninth aspect, an embodiment of the present application further provides a computer program product, including a computer program, which 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 the present application. In order to be able to understand the technical means of the present application more clearly, it can be implemented in accordance with the content of the specification. And in order to make the above and other purposes, features, and advantages of the present application more obvious and understandable, the following specifically illustrates the specific embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Figure 1 It is a schematic structural diagram of a load monitoring system in an embodiment;
[0067] Figure 2 It is a schematic flowchart of a load monitoring method in an embodiment;
[0068] Figure 3 It is a schematic flowchart of a process for storing scheduling information in an embodiment;
[0069] Figure 4 It is a schematic flowchart of a process for determining the current half region in an embodiment;
[0070] Figure 5 It is a schematic flowchart of a process for obtaining scheduling information in an embodiment;
[0071] Figure 6 It is a schematic flowchart of a process for marking a completed mark for a half region in an embodiment;
[0072] Figure 7 It is a schematic flowchart of a process for clearing the completed mark in an embodiment;
[0073] Figure 8 It is a schematic flowchart of a process for clearing the completed mark in another embodiment;
[0074] Figure 9 It is a schematic flowchart of a load monitoring method in another embodiment;
[0075] Figure 10 It is a schematic flowchart of a process for determining load information in an embodiment;
[0076] Figure 11 It is a schematic flowchart of a process for determining load information in another embodiment;
[0077] Figure 12 It is a schematic flowchart of a load monitoring method in another embodiment;
[0078] Figure 13 It is a schematic block diagram of a load monitoring device in an embodiment;
[0079] Figure 14 It is the structural block diagram of the load monitoring device in another embodiment;
[0080] Figure 15 It is the internal structure diagram of a computer device in an embodiment. Specific embodiments
[0081] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0082] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the term "including" and any variation thereof in the specification and claims of this application and the above drawings are intended to cover non-exclusive inclusion.
[0083] Referring to "embodiments" herein means that the specific features, structures or characteristics described in connection with the embodiments may be included in at least one embodiment of the present application. The phrase appears in various places in the specification and does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art explicitly and implicitly understand that the embodiments described herein may be combined with other embodiments.
[0084] In the description of the embodiments of the present application, the term "and / or" is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. In the description of the embodiments of the present application, the term "plurality" refers to two or more (including two), unless otherwise specifically defined.
[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 an embedded device as an example, load monitoring, as a key technology to ensure the stable operation of the device, plays a crucial role. The microcontroller unit (MCU), as the "brain" of the embedded device, undertakes the important responsibilities of executing various task instructions and coordinating the work of each module of the device. Accurately obtaining the load information of the MCU (such as the time ratio of the MCU scheduling tasks) is one of the core objectives of the load monitoring of the embedded device.
[0087] In the related art, the MCU needs to calculate the load information according to the scheduling information of different tasks. During the process of calculating the load information, the MCU needs to consume a large amount of additional computing resources and processing time to execute the relevant algorithms. However, in some embedded application scenarios with high real-time requirements, such as industrial robot control, autonomous driving assistance systems, etc., the MCU itself needs to quickly process a large amount of sensor data and control instructions. At this time, performing complex load information calculations will undoubtedly further increase the load of the MCU. This will not only lead to a decrease in the operating efficiency of the MCU, but may also cause problems such as system response delay and task execution timeout due to excessive resource consumption, seriously affecting the stability of the device's own operation, and even may cause device failures, resulting in immeasurable losses.
[0088] Therefore, the load monitoring process in the related art consumes MCU resources, increases the MCU load, and reduces the stability of the device's own operation.
[0089] In one embodiment, a load monitoring method is provided. This method is applied to Figure 1 the load monitoring system therein. The load monitoring system 100 includes an embedded device 102, an instruction processing device 104, and an external computer device 106. Among them, the embedded device 102 and the external computer device 106 are communicatively connected through the instruction processing device 104.
[0090] Among them, the embedded device 102 refers to an electronic device that runs an application program to implement corresponding service functions. The instruction processing device 104 is an intermediate device for realizing data transmission and analysis between the embedded device 102 and the external computer device 106. The external computer device 106 is a computer device independent of the embedded device 102.
[0091] Exemplarily, the embedded device 102 can be a new energy vehicle equipped with a battery management application program, and the battery management application program can be used to implement the management of the vehicle battery, such as battery data collection, thermal runaway management, power balance management, etc. The instruction processing device 104 can be a parser, and the parser can also include a debugger. The external computer device 106 can be a host computer of the embedded device 102.
[0092] The instruction processing device 104 is communicatively connected to the embedded device 102 and the external computer device 106 respectively through a communication interface. Exemplarily, the 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 the 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 the communication requirements are met.
[0093] The process of the embedded device 102 running an application program to implement corresponding service functions is the process of executing tasks through a scheduler. Different service functions correspond to different types of tasks. The embedded device 102 can schedule each task by executing the scheduler. In the case of scheduling each task, 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 one of the half areas when any one of the half areas is full.
[0094] The instruction processing device 104 can, under the indication of the completion flag, obtain the scheduling information stored in any one of the half areas and send the scheduling information to the external computer device 106.
[0095] The external computer device 106 then receives the scheduling information, determines the load information of the embedded device 102 according to the scheduling information, and sends it to the embedded device 102.
[0096] The embedded device 102 correspondingly receives the load information and determines the load monitoring result of the embedded device 102 according to the load information.
[0097] The above load monitoring system 100 can realize the load monitoring of the MCU in the embedded device 102.
[0098] In one embodiment, the embodiment of the present application provides a load monitoring method. As Figure 2 shown, taking the method applied to the Figure 1 embedded device as an example, the method includes the following steps:
[0099] S210. In the case of scheduling each task by executing a scheduler, alternately store the scheduling information of each task in different half areas of the circular storage area, and mark a completion flag for any one of the half areas when any one of the half areas is full; the completion flag is used to indicate that the instruction processing device sends the scheduling information stored in any one of the half areas to the external computer device.
[0100] Among them, each task (TASK) may include a service task for the embedded device to run the loaded application program to implement the corresponding service function, or may include an idle task (Idle Task) that does not run the application program.
[0101] The scheduling information is the data information obtained by the scheduling degree for scheduling tasks. Exemplarily, the scheduling information may include the task identifier (such as ID) or task type (such as periodic task or aperiodic task) of the scheduled task, and may also include time information, such as the start time of scheduling, the completion time of scheduling, or the scheduling duration from the start of scheduling to the completion of scheduling, etc.
[0102] The circular storage area is a temporary storage area in the embedded device, and can also be referred to as a buffer. The process of storing data using the circular storage area is as follows:
[0103] Starting from a storage location in the circular storage area, data is stored along a preset circumferential direction. When the circular storage area is full, continue to use the new data to overwrite the old data starting from this starting point to continuously store data by reusing the storage area.
[0104] A half area in the circular storage area represents a partial storage area (not the entire storage area) in the circular storage area. A circular storage area may include at least two half areas. The completion flag indicates that the data storage amount in the corresponding half area reaches the full state, that is, the corresponding half area is full.
[0105] Optionally, the embedded device may, when receiving a task execution instruction, enable the scheduling degree, and schedule each task through this scheduler. For example, schedule each task in the task schedule in sequence. When scheduling, record the scheduling information obtained by the scheduling degree for scheduling each task, and store this scheduling information in a half area of the circular buffer area. At the same time, detect the data storage amount of each half area to mark a completion flag for any one of the half areas when the data storage amount reaches the full state, that is, when any one of the half areas in the circular storage area is full.
[0106] Exemplarily, after the embedded device marks the completion flag for any one of the half areas, it may send the scheduling information stored in this half area to the instruction processing device. The instruction processing device may periodically read the completion flag by polling and accessing the embedded device. When the completion flag is read, obtain the scheduling information stored in the half area corresponding to this completion flag, and then send the received / acquired scheduling information to an external computer device for the external computer device to determine the load information of the embedded device based on this scheduling information.
[0107] S220. Receive the load information of the embedded device determined by the external computer device according to the scheduling information.
[0108] Among them, the load information of the embedded device is used to characterize the load situation of the MCU in the embedded device when executing tasks. Exemplarily, the load information may include the duration of executing each task, the total duration of executing different / same tasks within a preset period, the time ratio of executing different / same tasks in the preset period, and so on.
[0109] Optionally, the external computer device can statistically determine at least one of the duration of each task executed by the MCU in the embedded device, the total duration of executing all / same tasks within a preset period, and the time ratio of the total duration of executing all / same tasks within the preset period in the preset period as the load information of the embedded device, and send it to the instruction processing device, and then the instruction processing device sends the load information of the embedded device to the embedded device. The embedded device correspondingly receives the load information of the embedded device determined by the external computer device.
[0110] S230. Determine the load monitoring result of the embedded device according to the load information.
[0111] Optionally, after obtaining the load information of the embedded device determined by the external computer device, the embedded device can directly use the load information as the load monitoring result of the embedded device, or further process the load information to determine the load monitoring result of the embedded device.
[0112] Exemplarily, taking the time ratio of the total duration of the MCU executing the same task in the preset period as the load information as an example, the obtained load information of the embedded device includes the time ratio T1 of executing task A. The embedded device can compare T1 with the preset time ratio T to determine the load monitoring result of the embedded device according to the comparison result. For example, when T1 > T, it is determined that the load monitoring result of the embedded device is that the load of the embedded device for task A exceeds the load threshold; when T1 ≤ T, it is determined that the load monitoring result of the embedded device is that the load of the embedded device for task A does not exceed the load threshold.
[0113] In the embodiments of the present application, when the embedded device schedules each task by executing a scheduler, the scheduling information of each task is alternately stored in different half areas of the circular storage area, and when any one of the half areas is full, a completion flag is marked for any one of the half areas, and the load information of the embedded device determined by the external computer device according to the scheduling information is received, so as to determine the load monitoring result of the embedded device according to the load information; the completion flag is used to instruct the instruction processing device to send the scheduling information stored in any one of the half areas to the external computer device; in the above method, the scheduling information in the circular storage area is sent to the external computer device, and the external computer device determines the load information of the embedded device based on the scheduling information, and then obtains the load monitoring result, realizing the calculation of the off-chip load information without the embedded device consuming its own resources. Therefore, the occupation of the MCU resources of the embedded device is reduced, the MCU load is reduced, and the stability of the embedded device itself during operation is improved.
[0114] The scheduling information of the task includes a task identifier, an entry timestamp for scheduling the task, and an exit timestamp for completing the task scheduling. Based on this, in one embodiment, as Figure 3 shown, in the above S210, when scheduling each task by executing a scheduler, alternately storing the scheduling information of each task in different half areas of the circular storage area includes:
[0115] S310. For any task, when scheduling the task, obtain the task identifier of the task, the entry timestamp for starting to schedule the task, and the exit timestamp for completing the task scheduling.
[0116] Among them, the task identifier is used to distinguish different tasks, and the task identifiers of different tasks are different, while the task identifiers of the same task are the same. Exemplarily, the task identifier can be the task ID. The entry timestamp (T start ) represents the moment when the scheduler starts to schedule the task, and the exit timestamp (T end ) represents the moment when the scheduler completes the scheduling of the task.
[0117] Optionally, the embedded device synchronously monitors the scheduling situation of each task during the scheduling process of each task. For any task being scheduled, when scheduling the task, obtain the task identifier of the task, and determine the moment when the scheduling of the task starts as the entry timestamp, and determine the moment when the scheduling of the task is completed as the exit timestamp.
[0118] S320. Determine the current half area according to the storage status of different half areas in the circular storage area.
[0119] Among them, the current half area represents the half area used to store the newly obtained scheduling information.
[0120] Optionally, after the embedded device obtains new scheduling information, it can determine the half region whose storage state meets the preset demand state among different half regions according to the storage states of different half regions in the circular storage area as the half region for storing the newly obtained scheduling information, that is, the current half region.
[0121] Exemplarily, the storage state of the half region can be represented by a storage state pointer, and the storage state pointer is used to point to the current storage position reached by the half region. After obtaining new scheduling information, the embedded device can read the storage state pointers of each half region in the circular storage area and determine the half region whose storage state pointer points to a non-half region end point as the current half region.
[0122] S330. Store the task identifier, entry timestamp, and exit timestamp as the scheduling information of the task in the current half region.
[0123] Optionally, after determining the current half region, the embedded device uses the task identifier, entry timestamp, and exit timestamp obtained from the scheduled task as the scheduling information of the scheduled task and stores them in the determined current half region.
[0124] In the embodiments of the present application, for any task, when scheduling the task, obtain the task identifier of the task, the entry timestamp and exit timestamp for scheduling the task, and determine the current half region according to the storage states of different half regions in the circular storage area, so as to store the task identifier, entry timestamp, and exit timestamp as the scheduling information of the task in the current half region; in the above method, using the task identifier, entry timestamp, and exit timestamp of the scheduled task as the scheduling information obtained from scheduling the task realizes the full-time recording of the task scheduling process, provides a rich data basis for subsequent determination of load information, and can improve the diversity of the determined load information.
[0125] In the case where the circular storage area includes two half regions, namely the first half region and the second half region, in one embodiment, as Figure 4 shown, the above S320. Determine the current half region according to the storage states of different half regions in the circular storage area, includes:
[0126] S410. Obtain the storage flag bits of the first half region and the second half region.
[0127] Wherein, the storage flag bit can be used to characterize the storage state of the half region. The storage flag bit can be a completion flag or a non-completion flag. The completion flag characterizes that the storage state of the half region reaches the full storage state, and the non-completion flag characterizes that the storage state of the half region does not reach the full storage state. Exemplarily, the completion flag is 1, and the non-completion flag is empty or 0.
[0128] Optionally, when determining the current half region of the circular storage region, the embedded device can respectively obtain the storage flag bits of the first half region and the second half region in the circular storage region, that is, read the flag information in the storage flag bits.
[0129] S420. When one of the storage flag bits of the first half region and the second half region is a completion flag and the other is a non-completion flag, determine the half region with the non-completion flag as the current half region.
[0130] Optionally, after obtaining the storage flag bits of the first half region and the second half region, when one of the storage flag bits of the first half region and the second half region is a completion flag and the other is a non-completion flag, the embedded device can determine the half region with the non-completion flag as the current half region.
[0131] It should be noted that the half region with the completion flag indicates that the half region has been fully stored, while the half region with the non-completion flag indicates that the half region has not been fully stored. It may be the half region that is currently used for storing scheduling information or the idle half region that has not stored scheduling information yet. When one of the two half regions is fully stored and the other is not, select the half region that is not fully stored as the current half region for storing new scheduling information.
[0132] When there are three or more half regions in the circular storage region, if the storage flag bit of one of the half regions is a completion flag and the completion flag bits of the other half regions are all non-completion flags, the embedded device will use the next half region along the preset circumferential direction and located after the half region with the completion flag as the current half region.
[0133] S430. When the storage flag bits of the first half region and the second half region are both non-completion flags, determine the current half region according to the storage status pointers of the first half region and the second half region.
[0134] Among them, in addition to the storage flag bit that can be used to represent the storage status of the half region, the storage status pointer can also be used to represent the storage status of the half region, specifically used to point to the current storage position reached by the half region. The situation where the storage flag bits of the first half region and the second half region are both non-completion flags corresponds to the scenario where the circular storage region has not stored scheduling information, or has just started storing scheduling data, or the stored data has been completely cleared.
[0135] Optionally, when the storage flag bits of the first half region and the second half region are both non-completion flags, the embedded device can 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 according to the storage status pointers of the first half region and the second half region in S430 above includes:
[0137] Based on the storage status pointers of the first half-region and the second half-region, determine, in the first half-region and the second half-region, the half-region where the storage status pointer points to a non-half-region end point as the current half-region.
[0138] Wherein, the half-region end point is the last storage position of the corresponding half-region in the preset wrapping direction, and the non-half-region end point is any storage position of the corresponding half-region that is not the last storage position in the preset wrapping direction, that is, any storage position between the start point and the end point (including the start point but not including the end point).
[0139] It should be noted that the storage position pointed to by the storage status pointer changes continuously as data is stored. After the storage status pointer points to the half-region end point, if new data continues to be stored in this half-region, the storage status pointer of this half-region will point to the storage position reached after the new data is stored again.
[0140] Optionally, obtaining the storage status pointers of the first half-region and the second half-region means obtaining the storage positions pointed to by the storage status pointers of the first half-region and the second half-region. The embedded device can respectively determine whether the storage status pointers of the first half-region and the second half-region point to storage positions that are not the half-region end points, and select the half-region that points to the non-half-region end point as the current half-region. When the storage status pointers of both the first half-region and the second half-region point to non-half-region end points, that is, the storage status pointers of both the first half-region and the second half-region point to the half-region start points, the embedded device can select any half-region or a preset half-region (such as the first half-region or the second half-region) in the first half-region and the second half-region as the current half-region.
[0141] In the case where there are three or more half-regions in the circular storage area, if the completion flag bits of all half-regions are non-completion flags, the embedded device obtains the storage status pointers of each half-region, and determines, among all half-regions, the half-region where the storage status pointer points to a non-half-region end point as the current half-region. When the storage status pointers of all half-regions point to non-half-region end points, that is, the storage status pointers of all half-regions point to the half-region start points, the embedded device can select any half-region or a preset half-region in all half-regions as the current half-region. The preset half-region can be any half-region in the circular storage area.
[0142] In the embodiments of the present application, storage flag bits of a first half region and a second half region are obtained. When one of the storage flag bits of 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. And when the storage flag bits of both the first half region and the second half region are non-completion flags, the current half region is determined according to the storage state pointers of the first half region and the second half region. Specifically, the half region in which the storage state pointer points to a non-half region end point can be determined in the first half region and the second half region as the current half region. In the above method, the current half region is determined in the first half region and the second half region by combining the storage flag bits and the storage state pointers, which is adapted to the diverse storage states of the first half region and the second half region, and improves the efficiency and convenience of determining the current half region.
[0143] To obtain a task identifier, an entry timestamp, and a contact timestamp, in one embodiment, as Figure 5 shown, obtaining the task identifier of the task, the entry timestamp for starting to schedule the task, and the exit timestamp for completing the scheduling of the task in S310 above includes:
[0144] S510. Invoke a pre-hook function to obtain the task identifier of the scheduled task, and obtain the moment when the scheduled task starts to be scheduled, denoted as the entry timestamp.
[0145] Among them, the pre-hook (PreHook) function is a callback function that is triggered and invoked before scheduling a task.
[0146] Optionally, before an embedded device schedules a task through a scheduler, the pre-hook function is triggered. By invoking the pre-hook function, the scheduling situation of the task is traced to obtain the task identifier of the scheduled task and the moment when the scheduled task starts to be scheduled, and the moment when the scheduled task starts to be scheduled is denoted as the entry timestamp.
[0147] S520. Invoke a post-hook function to obtain the moment when the scheduled task is scheduled to completion, denoted as the exit timestamp.
[0148] Among them, the post-hook (PostHook) function is also a callback function that is triggered and invoked after scheduling a task.
[0149] Optionally, after an embedded device schedules a task through a scheduler, the post-hook function is triggered. By invoking the post-hook function, it is traced whether the task has been scheduled to completion, that is, has been executed, to obtain the moment when the scheduled task is scheduled to completion, and the moment when the scheduled task is scheduled to completion is denoted as the exit timestamp.
[0150] In the embodiments of the present application, a pre - hook function is called to obtain the task identifier of the scheduled task, and the moment when the scheduled task starts to be scheduled is obtained, which is recorded as the entry - point timestamp. In addition, a post - hook function is called to obtain the moment when the scheduled task is scheduled to completion, which is recorded as the exit - point timestamp. In the above method, by calling the pre - hook function and the post - hook function respectively, without affecting the scheduler's scheduling of tasks, the scheduling situation of the scheduled task and whether it has been executed completely are traced, thereby improving the accuracy and reliability of the obtained task identifier, entry - point timestamp, and exit - point timestamp.
[0151] The circular storage area includes two half - areas, namely the first half - area and the second half - area. Based on this, in one embodiment, as Figure 6 shown, in S210 above, when any one of the half - areas is full, marking a completion flag for any one of the half - areas includes:
[0152] S610: When any one of the half - areas is the first half - area, mark the storage flag bit of the first half - area as the completion flag.
[0153] Among them, the storage flag bit can be used to represent the storage state of the half - area. The storage flag bit can be a completion flag or a non - completion flag. The completion flag represents that the storage state of this half - area has reached the full - storage state, and the non - completion flag represents that the storage state of this half - area has not reached the full - storage state. Exemplarily, the completion flag is 1, and the non - completion flag is empty or 0.
[0154] Optionally, when any one of the full - filled half - areas is the first half - area in the circular storage area, representing that the storage state of this first half - area has reached the full - storage state, the embedded device marks the storage flag bit of this first half - area as the completion flag.
[0155] S620: When any one of the half - areas is the second half - area, mark the storage flag bit of the second half - area as the completion flag.
[0156] Optionally, when any one of the full - filled half - areas is the second half - area in the circular storage area, representing that the storage state of this second half - area has reached the full - storage state, the embedded device marks the storage flag bit of this second half - area as the completion flag.
[0157] In the embodiments of the present application, the circular storage area includes the first half - area and the second half - area. When any one of the half - areas is the first half - area, mark the storage flag bit of the first half - area as the completion flag, and when any one of the half - areas is the second half - area, mark the storage flag bit of the second half - area as the completion flag. In the above method, when the first half - area or the second half - area is full, mark the storage flag bit of the corresponding half - area as the completion flag, so as to timely instruct the instruction - processing device to obtain the scheduling information stored in the corresponding half - area, improving the timeliness and orderliness of load monitoring.
[0158] The embedded device is also used to update the storage flag bit under the instruction of the instruction processing device. For the first half area in the circular storage area, in one embodiment, as Figure 7 shown, the above method further includes:
[0159] S710. Receive the flag bit clearing instruction for the first half area sent by the instruction processing device; the flag bit clearing instruction for the first half area is generated by the instruction processing device based on the operation of sending the scheduling information stored in the first half area to an external computer device.
[0160] Among them, the flag bit clearing instruction is used to indicate clearing the completion flag in the storage flag bit.
[0161] Optionally, when the first half area in the circular storage area is full, the embedded device marks the storage flag bit of the first half area as the completion flag. When the instruction processing device receives / reads that the storage flag bit of the first half area is marked as the completion flag, it will obtain the call information stored in the first half area, send the scheduling information stored in the first half area to an external computer device, synchronously generate the flag bit clearing instruction for the first half area, and send it to the embedded device. The embedded device correspondingly receives the flag bit clearing instruction for the first half area sent by the instruction processing device.
[0162] S720. According to the flag bit clearing instruction, clear the completion flag in the storage flag bit of the first half area.
[0163] Optionally, after the embedded device receives the flag bit clearing instruction for the first half area, it clears the completion flag in the storage flag bit of the first half area in response to the flag bit clearing instruction.
[0164] In the embodiment of the present application, receive the flag bit clearing instruction for the first half area sent by the instruction processing device, and according to the flag bit clearing instruction, clear the completion flag in the storage flag bit of the first half area; the flag bit clearing instruction for the first half area is generated by the instruction processing device based on the operation of sending the scheduling information stored in the first half area to an external computer device; in the above method, the external sending operation of the instruction processing device for the scheduling information stored in the first half area in the full state triggers the flag bit clearing instruction for the storage flag bit of the first half area, so as to instruct the embedded device to update the storage flag bit of the first half area in time, improve the orderliness of subsequent scheduling information external sending, and can correspondingly improve the accuracy of the determined load information, thereby improving the reliability of load monitoring.
[0165] For the second half area in the circular storage area, in one embodiment, as Figure 8 shown, the above method further includes:
[0166] S810. Receive the flag bit clearing instruction for the second half area sent by the instruction processing device; the flag bit clearing instruction for the second half area is generated by the instruction processing device based on the operation of sending the scheduling information stored in the second half area to an external computer device.
[0167] Optionally, when the second half area in the circular storage area is full, the embedded device marks the storage flag bit of the second half area as the completion flag. When the instruction processing device receives / reads that the storage flag bit of the second half area is marked as the completion flag, it will obtain the call information stored in the second half area, send the scheduling information stored in the second half area to the external computer device, synchronously generate the flag bit clearing instruction for the second half area, and send it to the embedded device. The embedded device correspondingly receives the flag bit clearing instruction for the second half area sent by the instruction processing device.
[0168] S820. Clear the completion flag in the storage flag bit of the second half area according to the flag bit clearing instruction.
[0169] Optionally, after the embedded device receives the flag bit clearing instruction for the second half area, it clears the completion flag in the storage flag bit of the second half area in response to the flag bit clearing instruction.
[0170] In the embodiments of the present application, receive the flag bit clearing instruction for the second half area sent by the instruction processing device, and clear the completion flag in the storage flag bit of the second half area according to the flag bit clearing instruction; the flag bit clearing instruction for the second half area is generated by the instruction processing device based on the operation of sending the scheduling information stored in the second half area to an external computer device; in the above method, the external sending operation of the scheduling information stored in the second half area in the full state by the instruction processing device triggers the flag bit clearing instruction for the storage flag bit of the second half area, so as to instruct the embedded device to update the storage flag bit of the second half area in time, improve the orderliness of subsequent scheduling information external sending, and correspondingly improve the accuracy of the determined load information, thereby improving the reliability of load monitoring.
[0171] In an optional embodiment, when the instruction processing device sends the scheduling information stored in any half area to an external computer device, the instruction processing device calls the memory access interface to access the address of the circular storage area, reads the scheduling information from the circular storage area through the data read / write register, and sends the read scheduling information to the external computer device.
[0172] Among them, the Memory Access Point (MeM-AP) is a communication interface for realizing memory access between an instruction processing device and an embedded device. The Data Read / Write Register is a data read / write interface for reading raw data in the memory, that is, reading the scheduling information stored in the circular storage area.
[0173] Exemplarily, taking the instruction processing device as a parser, the parser accesses the address of the circular storage area in the embedded device through the MeM-AP, reads the scheduling information stored in the circular storage area through the data read / write register, and sends the read scheduling information to an external computer device.
[0174] In one embodiment, the embodiment of the present application further provides a load monitoring method, as Figure 9 shown, taking the method applied to Figure 1 the external computer device in
[0175] S910. Receive the scheduling information stored in the circular 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 a scheduling program, the scheduling information of each task is alternately stored in different half areas of the circular storage area, and 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 the external computer device.
[0176] Among them, each task (TASK) may include a service task for the embedded device to run the application program to implement the corresponding service function, or may include an idle task (Idle Task) that does not run the application program.
[0177] The scheduling information is the data information obtained by the scheduling program scheduling the tasks. Exemplarily, the scheduling information may include the task identifier (such as ID) or task type (such as periodic task or aperiodic task) of the scheduled task, or may include time information, such as the start time of scheduling, the completion time of scheduling, or the scheduling duration from the start of scheduling to the completion of scheduling, and so on.
[0178] The circular storage area is a temporary storage area in the embedded device, and can also be called a buffer. The process of storing data in the circular storage area is as follows:
[0179] Starting from a storage location in the circular storage area, data is stored along the preset circumferential direction. When the circular storage area is full, continue to use the new data to overwrite the old data starting from this starting point to continuously store data by reusing the storage area.
[0180] A half - area in the circular storage area represents a partial storage area (not the entire storage area) in the circular storage area, and a circular storage area can include at least two half - areas.
[0181] Optionally, when receiving a task execution instruction, the embedded device can enable the scheduler, and schedule each task through this scheduler. For example, schedule each task in the task schedule in sequence. When scheduling, record the scheduling information obtained by the scheduler for scheduling each task, and store this scheduling information in a half - area of the circular buffer area. At the same time, detect the data storage amount of each half - area to mark a completion flag for any one of the half - areas when the data storage amount reaches the full state, that is, when any one of the half - areas in the circular storage area is full. The instruction processing device can receive / obtain the scheduling information stored in different half - areas of the circular storage area and send this scheduling information to an external computer device. The external computer device correspondingly receives the scheduling information sent by the instruction processing device.
[0182] S920. Determine the load information of the embedded device according to the received scheduling information, and send the load information to the embedded device; the load information is used for the embedded device to determine the load monitoring result of the embedded device.
[0183] Among them, the load information of the embedded device is used to characterize the load situation of the MCU in the embedded device when executing tasks. Exemplarily, the load information can include the duration of executing each task, the total duration of executing different / the same tasks within a preset period, the time ratio of executing different / the same tasks in the preset period, and so on.
[0184] Optionally, the external computer device can statistically determine at least one of the duration of the MCU in the embedded device for executing each task, the total duration of executing all / the same tasks within a preset period, and the time ratio of the total duration of executing all / the same tasks within a preset period in the preset period as the load information of the embedded device, and send it to the instruction processing device, and then the instruction processing device sends the load information of the embedded device to the embedded device for the embedded device to determine the load monitoring result of the embedded device.
[0185] In the embodiments of the present application, an external computer device receives scheduling information stored in a circular storage area of an embedded device sent by an instruction processing device, determines the load information of the embedded device according to the received scheduling information, and sends the load information to the embedded device; the scheduling information is that when the embedded device schedules each task by executing a scheduling program, 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 one of the half-areas when any one of the half-areas is full; the completion flag is used to instruct the instruction processing device to send the scheduling information stored in any one of the half-areas to the external computer device; the load information is used for 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 by using the resources available to the external computer device, and then obtains the load monitoring result, realizing the calculation of the off-chip load information without the embedded device consuming its own resources, thus reducing the occupation of the MCU resources of the embedded device, reducing the MCU load, and improving the stability of the operation of the embedded device itself.
[0186] In one embodiment, in order to obtain the load information of the embedded device, as Figure 10 shown, determining the load information of the embedded device according to the received scheduling information in S920 above includes:
[0187] S1010. Determine the load information of different tasks within a reference period according to the received scheduling information.
[0188] Wherein, the reference period is any preset time period.
[0189] Optionally, the external computer device can determine the tasks scheduled within the reference period in the received scheduling information, and then determine the load information of different tasks within the reference period. Among them, the tasks scheduled within the reference period are the tasks that start scheduling and complete scheduling within the reference period.
[0190] Exemplarily, the scheduling information includes a task identifier, an entry timestamp, and an exit timestamp. The scheduling information received by the external computer device is sorted in chronological order 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 represents the entry timestamp, T end represents the exit timestamp, and 1 represents the first scheduling.
[0193] Taking the reference period [T1, T2] as an example, when T1 is earlier than T i-start1 , and T2 is later than T k-end1 , the embedded device can determine that tasks i, j, and k are all scheduled within the reference period [T1, T2]. The embedded device can determine the load information of tasks i, j, and k respectively based on the above scheduling information.
[0194] S1020. Determine the load information of the embedded device according to the load information of different tasks.
[0195] Optionally, after obtaining the load information of each task scheduled within the reference period, the external computer device can determine the load information of the embedded device within the reference period based on the load information of each task.
[0196] Exemplarily, the external computer device can directly use the load information of each task within the reference period as the load information of the embedded device within the reference period, or can obtain the sum of the load information of each task within the reference period as the load information of the embedded device within the reference period.
[0197] In the embodiments of the present application, the load information of different tasks within the reference period is determined according to the received scheduling information, and the load information of the embedded device is determined according to 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 at any time period according to the received scheduling information, so the time limitation is reduced and the flexibility of the time period for determining the load information is improved.
[0198] The load information can be characterized by the time ratio. In the case where the scheduling information includes the task identifier, the entry timestamp, and the exit timestamp, in one of the embodiments, as Figure 11 shown, the above S1010. Determine the load information of different tasks within the reference period according to the received scheduling information, includes:
[0199] S1110. Determine the running duration of each task scheduled within the reference period according to the scheduling information; the running duration is the time difference between the entry timestamp and the exit timestamp of each task scheduled.
[0200] Optionally, the external computer device can determine the tasks scheduled within the reference period from the received scheduling information, and for each task scheduled within the reference period, obtain the time difference between the entry timestamp and the exit timestamp of the task as the running duration of the task.
[0201] S1120. For a task corresponding to the same task identifier, obtain the ratio of the sum of the running durations of each scheduling to the total duration of the reference period as the load information of the task.
[0202] Optionally, after obtaining the running durations of each scheduling of each task within the reference period, an external computer device can calculate the sum of the running durations of each scheduling of the task corresponding to the same task identifier, and obtain the ratio of the running duration to the total duration of the reference period as the load information of the task.
[0203] Exemplarily, taking the total duration T of the reference period, and the tasks within the reference period including TaskA, TaskB, and TaskC as examples, and obtaining that the running duration of TaskA being scheduled is TA1, the running durations of TaskB being scheduled are TB1 and TB2, and the running durations of TaskC being scheduled are TC1, TC2, and TC3 as examples, the embedded device can obtain the load information of TaskA as TA1 / T, the load information of TaskB as (TB1 + TB2) / T, and the load information of TaskC as (TC1 + TC2 + TC3) / T.
[0204] In addition to the load information of the task, the external computer device can also determine the running state of the task. The external computer device can obtain the reference duration of the task corresponding to the same task identifier being called based on the running durations of each task being called within the reference period, so as to determine the running state of the task corresponding to the same task identifier according to the reference duration.
[0205] Exemplarily, the reference duration can be the average running duration, or the maximum running duration or the minimum running duration.
[0206] Optionally, after the external computer device obtains the running durations of each task being called within the reference period, it can extract the running durations of each call of the task corresponding to the same task identifier, calculate the average running duration as the reference duration of the task, and then compare the reference duration with a preset duration range, and determine the running state of the task according to the comparison result. Exemplarily, when the reference duration is within the preset duration range, determine that the running state of the task is normal; otherwise, when the reference duration is not within the preset duration range, determine that the running state of the task is abnormal.
[0207] The external computer device can also determine the scheduling status of the embedded device for task scheduling. The external computer device can obtain the scheduling order of the tasks scheduled according to the reference period, match the scheduling order with the preset order, and determine the scheduling status of the embedded device for task scheduling according to the matching result. Exemplarily, when the scheduling order is the same as the preset order, that is, they match, it is determined that the scheduling status of the embedded device for task scheduling is normal; conversely, when the scheduling order is different from the preset order, that is, they do not match, it is determined that the scheduling status of the embedded device for task scheduling is abnormal.
[0208] It should be noted that the external computer device not only sends load information to the embedded device through the instruction processing device, but also, when obtaining the running status of the task and / or the scheduling status of the embedded device for task scheduling, can synchronously send the running status of the task and / or the scheduling status of the embedded device for task scheduling to the embedded device through the instruction processing device.
[0209] In one embodiment, the present application also provides a load monitoring system, as Figure 1 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 configured to alternately store the scheduling information of each task into different half-areas of the circular storage area when scheduling each task by executing a scheduler, mark a completion flag for any one of the half-areas when any one of the half-areas is full, and receive the load information of the embedded device 102 sent by the external computer device 106, and determine the load monitoring result of the embedded device 102 according to the load information of the embedded device 102;
[0211] The instruction processing device 104 is configured to obtain the scheduling information stored in any one of the half-areas under the indication of the completion flag and send it to the external computer device 106;
[0212] The external computer device 106 is configured to determine the load information of the embedded device 102 based on the received scheduling information and send it to the embedded device 102.
[0213] In the above load monitoring system, the embedded device 102 and the external computer device 106 are respectively used to implement a load monitoring method. The specific process is detailed in the foregoing related embodiments and will not be elaborated here.
[0214] For the convenience of those skilled in the art, the load monitoring method provided by the present application is introduced in detail below, taking the load monitoring system in Figure 1 as an example, asFigure 12 As shown, the method may include:
[0215] S1201. For any task scheduled by the embedded device through the execution of the scheduler, when scheduling the task, call the pre-hook function to obtain the task identifier of the scheduled task, and obtain the moment when the scheduled task starts to be scheduled, denoted as the entry point timestamp, and call the post-hook function to obtain the moment when the scheduled task is scheduled to completion, denoted as the exit point timestamp;
[0216] S1202. When one of the storage flag bits in the first half and the second half of the circular storage area is the completion flag and the other is the non-completion flag, determine the half area with the non-completion flag as the current half area;
[0217] S1203. When the storage flag bits of both the first half and the second half are non-completion flags, determine, according to the storage state pointers of the first half and the second half, the half area in which the storage state pointer points to a non-half area end point as the current half area;
[0218] S1204. Store the task identifier, entry point timestamp, and exit point timestamp of the scheduled task as the scheduling information of the task into the current half area; the first half and the second half alternate as the current half area;
[0219] S1205. When any half area in the circular storage area is full, mark the storage flag bit of that any half area as the completion flag;
[0220] S1206. When the instruction processing device reads that the storage flag bit of the first half area is the completion flag, obtain the scheduling information stored in the first half area and send it to the external computer device;
[0221] S1207. When the instruction processing device reads that the storage flag bit of the second half area is the completion flag, obtain the scheduling information stored in the second half area and send it to the external computer device;
[0222] S1208. The external computer device determines the running duration of each task scheduled each time within the reference period according to the received scheduling information; the running duration is the time difference between the entry point timestamp and the exit point timestamp of each task scheduled each time;
[0223] S1209. For tasks corresponding to the same task identifier, obtain the ratio of the sum of the running durations scheduled each time to the total duration of the reference period as the load information of the task;
[0224] S1210. Determine the load information of the embedded device according to 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 according to the received load information.
[0226] It should be noted that for the descriptions in S1201 - S1211 above, reference can be made to the relevant descriptions in the above embodiments, and their effects are similar. This embodiment will not be elaborated here.
[0227] It should be understood that although the steps in the flowcharts involved in the above - mentioned embodiments are sequentially shown according to the indication of the arrows, these steps do not necessarily execute in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps has no strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above - mentioned embodiments may include multiple steps or multiple stages. These steps or stages do not necessarily execute at the same moment, but can execute at different moments, and the execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.
[0228] In one embodiment, as Figure 13 shown, a load monitoring device is provided, including: a task scheduling module 1301, an information receiving module 1302, and a result determining module 1303; wherein:
[0229] The task scheduling module 1301 is used to alternately store the scheduling information of each task into different half - regions of a circular storage area when scheduling each task by executing a scheduling program, and mark a completion flag for any one of the half - regions when any one of the half - regions is full; the completion flag is used to instruct the instruction processing device to send the scheduling information stored in any one of the half - regions 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 determining module 1303 is used to determine the load monitoring result of the embedded device according to the load information.
[0232] The above - mentioned load monitoring device can be used to implement any of the embodiments of the load monitoring method applied to the embedded device. For the specific process, refer to the foregoing embodiments, which will not be elaborated here.
[0233] In one embodiment, as Figure 14 shown, a load monitoring device is provided, including: a scheduling receiving module 1401 and a load determining module 1402; wherein:
[0234] The scheduling receiving module 1401 is configured to receive the scheduling information stored in the circular storage area of the embedded device sent by the instruction processing device; the scheduling information is obtained by the embedded device alternately storing the scheduling information of each task into different half-areas of the circular storage area when scheduling each task by executing a scheduling program, and marking a completion flag for any one of the half-areas when any one of the half-areas is full; the completion flag is used to instruct the instruction processing device to send the scheduling information stored in any one of the half-areas to an external computer device.
[0235] The load determination module 1402 is configured to determine the load information of the embedded device according to the received scheduling information, and send the load information to the embedded device; the load information is used for the embedded device to determine the load monitoring result of the embedded device.
[0236] The above load monitoring device can be used to implement any of the embodiments of the foregoing load monitoring method applied to an external computer device. For the specific process, please refer to the foregoing embodiments and will not be elaborated here.
[0237] Each module in the above load monitoring device can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0238] In an exemplary embodiment, a computer device is provided. The computer device can be a terminal, and its internal structure diagram can be as Figure 15As shown in the figure. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface, the display unit, and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a load monitoring method. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covering the display screen, or a button, a trackball, or a touchpad provided on the housing of the computer device, or an external keyboard, touchpad, or mouse, etc.
[0239] It should be noted that the computer device can be the embedded device in any of the foregoing embodiments, or the external computer device in any of the foregoing embodiments.
[0240] Those skilled in the art can understand that Figure 15 the structure shown in the figure is only a block diagram of some structures related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0241] In one embodiment, an embedded device is provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, it implements the steps of any of the foregoing load monitoring methods applied to the embedded device.
[0242] In one embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, it implements the steps of any of the foregoing load monitoring methods applied to the external computer device.
[0243] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of any one of the above load monitoring methods are implemented.
[0244] In one embodiment, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the steps of any one of the above load monitoring methods are implemented.
[0245] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memories. 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), magnetoresistive 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 be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., and are not limited thereto. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., and are not limited thereto.
[0246] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, 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, it should be considered to be within the scope described in this specification.
[0247] The embodiments described above merely represent several implementation manners of the present application. The description is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all fall within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.
Claims
1. A load monitoring method, characterized in that, Applied to an embedded device, the method includes: When scheduling each task by executing a scheduler, alternately storing the scheduling information of each task into different half - regions of a circular storage area, and marking a completion flag for any one of the half - regions when it is full; the completion flag is used to instruct an instruction processing device to send the scheduling information stored in any one of the half - regions to an external computer device; Receiving the load information of the embedded device determined by the external computer device according to the scheduling information; Determining the load monitoring result of the embedded device according to the load information.
2. The method according to claim 1, wherein The step of alternately storing the scheduling information of each task into different half - regions of a circular storage area when scheduling each task by executing a scheduler includes: For any one task, when scheduling the task, obtaining the task identifier of the task, the entry - point timestamp when starting to schedule the task, and the exit - point timestamp when completing the scheduling of the task; Determining the current half - region according to the storage status of different half - regions in the circular storage area; Storing the task identifier, the entry - point timestamp, and the exit - point timestamp as the scheduling information of the task into the current half - region.
3. The method according to claim 2, wherein The circular storage area includes a first half - region and a second half - region. The step of determining the current half - region according to the storage status of different half - regions in the circular storage area includes: Obtaining the storage flag bits of the first half - region and the second half - region; When one of the storage flag bits of the first half - region and the second half - region is a completion flag and the other is a non - completion flag, determining the half - region with the non - completion flag as the current half - region; When the storage flag bits of the first half - region and the second half - region are both non - completion flags, determining the current half - region according to the storage status pointers of the first half - region and the second half - region.
4. The method according to claim 3, wherein The step of determining the current half - region according to the storage status pointers of the first half - region and the second half - region includes: According to the storage status pointers of the first half - region and the second half - region, determining the half - region whose storage status pointer points to a non - half - region end point in the first half - region and the second half - region as the current half - region.
5. The method according to any one of claims 2 to 4, characterized in that The step of obtaining the task identifier of the task, the entry - point timestamp when starting to schedule the task, and the exit - point timestamp when completing the scheduling of the task includes: Invoking a pre - hook function to obtain the task identifier of the scheduled task, and obtaining the moment when the scheduled task starts to be scheduled, denoted as the entry - point timestamp; Invoking a post - hook function to obtain the moment when the scheduled task is scheduled to completion, denoted as the exit - point timestamp.
6. The method according to any one of claims 1 to 4, characterized in that The circular storage area includes a first half - region and a second half - region. The step of marking a completion flag for any one of the half - regions when it is full includes: When any one of the half - regions is the first half - region, marking the storage flag bit of the first half - region as the completion flag; When any one of the half - regions is the second half - region, marking the storage flag bit of the second half - region as the completion flag.
7. The method according to claim 6, wherein The method further includes: Receive the flag clearing instruction for the first half area sent by the instruction processing device; the flag clearing instruction for the first half area is generated by the instruction processing device based on the operation of sending the scheduling information stored in the first half area to the external computer device; According to the flag clearing instruction, clear the completion flag in the storage flag of the first half area.
8. The method according to claim 6, wherein The method further includes: Receive the flag clearing instruction for the second half area sent by the instruction processing device; the flag clearing instruction for the second half area is generated by the instruction processing device based on the operation of sending the scheduling information stored in the second half area to the external computer device; According to the flag clearing instruction, clear the completion flag in the storage flag of the second half area.
9. The method according to any one of claims 1 to 4, characterized in that The instruction processing device sends the scheduling information stored in any one of the half areas to the external computer device by the instruction processing device calling the memory access interface to access the address of the circular storage area, reading the scheduling information from the circular storage area through the data read / write register, and sending the read scheduling information to the external computer device.
10. A load monitoring method, characterized in that, Applied to an external computer device, the method includes: Receive the scheduling information stored in the circular 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 a scheduling program, the scheduling information of each task is alternately stored in different half areas of the circular storage area, and when any one of the half areas is full, a completion flag is marked for any one of the half areas; the completion flag is used to instruct the instruction processing device to send the scheduling information stored in any one of the half areas to the external computer device; Determine the load information of the embedded device according to the received scheduling information, and send the load information to the embedded device; the load information is used for the embedded device to determine the load monitoring result of the embedded device.
11. The method according to claim 10, wherein The determining the load information of the embedded device according to the received scheduling information includes: Determine the load information of different tasks within a reference period according to the received scheduling information; Determine the load information of the embedded device according to the load information of different tasks.
12. The method according to claim 11, wherein The scheduling information includes a task identifier, an entry timestamp, and an exit timestamp; the determining the load information of different tasks within a reference period according to the received scheduling information includes: Determine the running duration of each task scheduled within the reference period according to the scheduling information; the running duration is the time difference between the entry timestamp and the exit timestamp of each task scheduled; For tasks corresponding to the same task identifier, obtain the ratio of the sum of the running durations of each scheduling to the total duration of the reference period as the load information of the task.
13. A load monitoring system, characterized in that, The load monitoring system includes an embedded device, an instruction processing device, and an external computer device, and the embedded device and the external computer device are communicatively connected through the instruction processing device; The embedded device is used to alternately store the scheduling information of each task into different half regions of a circular storage area when scheduling each task by executing a scheduler, mark a completion flag for any one of the half regions when any one of the half regions is full, receive the load information of the embedded device sent by the external computer device, and determine the load monitoring result of the embedded device according to the load information of the embedded device; The instruction processing device is used to obtain the scheduling information stored in any one of the half regions under the indication of the completion flag and send it to the external computer device; The external computer device is used to determine the load information of the embedded device based on the received scheduling information and send it to the embedded device.
14. A load monitoring device, characterized in that, The device includes: A task scheduling module, which is used to alternately store the scheduling information of each task into different half regions of a circular storage area when scheduling each task by executing a scheduler, and mark a completion flag for any one of the half regions when any one of the half regions is full; the completion flag is used to instruct the instruction processing device to send the scheduling information stored in any one of the half regions to the external computer device; An information receiving module, which is used to receive the load information of the embedded device determined by the external computer device according to the scheduling information; A result determining module, which is used to determine the load monitoring result of the embedded device according to the load information.
15. A load monitoring device, characterized in that, The device includes: A scheduling receiving module, which is used to receive the scheduling information stored in the circular 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 a scheduler, the scheduling information of each task is alternately stored into different half regions of the circular storage area, and a completion flag is marked for any one of the half regions when any one of the half regions is full; the completion flag is used to instruct the instruction processing device to send the scheduling information stored in any one of the half regions to the external computer device; A load determining module, which is used to determine the load information of the embedded device according to the received scheduling information and send the load information to the embedded device; the load information is used for the embedded device to determine the load monitoring result of the embedded device.
16. An embedded device, characterized in that, The embedded device includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.
17. A computer device, characterized in that, The computer device includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, the steps of the method according to any one of claims 10 to 12 are implemented.
18. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, the steps of the method according to any one of claims 1 to 12 are implemented.
19. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, the steps of the method according to any one of claims 1 to 12 are implemented.
Citation Information
Patent Citations
Log recording method, battery management system, vehicle and electronic equipment
CN110555006A
Multi-core operating system flow task scheduling method and system, computer and medium
CN113918291A
Data backup method, electronic equipment and computer readable storage medium
CN116954996A
Write data storage, search and transmission processing method and system based on PCIe AXI bridge
CN118152310A
Cross-device and cross-channel advertising and remarketing
US20160379245A1