Process monitoring management method, device and equipment and readable storage medium

By obtaining the process collection and the time round associated with monitoring tasks, performing monitoring tasks to obtain process monitoring information, and controlling the process based on the information, the problem of inability to accurately monitor and manage processes in embedded development is solved, and the accuracy of process management is improved.

CN120216281APending Publication Date: 2025-06-27CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510155861.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-12
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

In embedded development, the cropped Linux system cannot fully support Linux components, resulting in the inability to accurately monitor various situations during the software operation and the inability to accurately manage the process.

Method used

By obtaining the process set and the time round associated with monitoring tasks, based on the triggering time and time round, the monitoring task is executed to obtain the monitoring information of the process, and store the information in the process set to control the process based on the monitoring information.

Benefits of technology

It realizes accurate monitoring and management of software processes in embedded systems, improves the accuracy of process management, and is suitable for software process management in embedded systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120216281A_ABST
    Figure CN120216281A_ABST
Patent Text Reader

Abstract

The invention provides a process monitoring management method and device, equipment and a readable storage medium. The method comprises the steps that a process set is acquired; the process set comprises process information of created processes; the process information of different processes is at least partially different; acquiring a time wheel associated with the monitoring task; the time wheel is used for managing a data structure of a monitoring task; the monitoring task has corresponding triggering time; the monitoring tasks with different triggering times are associated to different positions of the time wheel; based on the trigger time and the time wheel, executing a monitoring task in the time wheel to obtain monitoring information of the at least one process; the monitoring information of each process is stored in the process set, and at least one process corresponding to the process set is controlled according to the monitoring information. The accuracy of process management is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present disclosure relate to the field of embedded technology, and in particular, to a method, device, electronic device, and computer-readable storage medium for process monitoring and management. Background Art

[0002] An embedded system can be used to control, monitor, or assist in operating machines and devices, and it is necessary to monitor the software processes running in the embedded system, so as to master the resource utilization of the processes, and then perform fault location and related optimizations.

[0003] However, embedded development is based on a trimmed Linux system and cannot fully support Linux components, resulting in the inability to accurately monitor various situations that occur during software operation in embedded development and the inability to accurately manage processes. Summary of the Invention

[0004] In view of the above problems, embodiments of the present disclosure are proposed to provide a method, device, electronic device, and computer-readable storage medium for process monitoring and management that overcome the above problems or at least partially solve the above problems.

[0005] In a first aspect, embodiments of the present disclosure disclose a method for process monitoring and management, the method including:

[0006] Obtain a process set; the process set includes process information of created processes; at least part of the process information of different processes is different;

[0007] Obtain a time wheel associated with monitoring tasks; the time wheel is a data structure for managing the monitoring tasks; the monitoring tasks have corresponding trigger times; monitoring tasks with different trigger times are associated with different positions of the time wheel;

[0008] Based on the trigger time and the time wheel, execute the monitoring tasks in the time wheel to obtain monitoring information of at least one process;

[0009] Store the monitoring information of each process into the process set respectively, and control at least one process corresponding to the process set according to the monitoring information.

[0010] In a second aspect, embodiments of the present disclosure disclose a method for process monitoring and management, the method including:

[0011] A process set module, configured to obtain a process set; the process set includes process information of created processes; at least part of the process information of different processes is different;

[0012] A monitoring task module, configured to obtain a time wheel associated with a monitoring task; the time wheel is a data structure for managing the monitoring task; the monitoring task has a corresponding trigger time; monitoring tasks with different trigger times are associated with different positions of the time wheel;

[0013] A trigger execution module, configured to execute the monitoring tasks in the time wheel based on the trigger time and the time wheel, so as to obtain monitoring information of at least one process;

[0014] A process management module, configured to separately store the monitoring information of each process into the process set, and control at least one process corresponding to the process set according to the monitoring information.

[0015] In a third aspect, an embodiment of the present disclosure further discloses an electronic device, including a processor and a memory. When the computer program stored in the memory is executed by the processor, the steps of the process monitoring and management method described in the first aspect are implemented.

[0016] In a fourth aspect, an embodiment of the present disclosure further discloses a computer-readable storage medium, on which a program is stored. When the program is executed by a processor, the steps of the process monitoring and management method described in the first aspect are implemented.

[0017] In the embodiments of the present disclosure, a process set is obtained, where the process set includes process information of created processes, and the process information of different processes is at least partially different. A time wheel associated with a monitoring task is obtained. The monitoring task has a corresponding trigger time, and monitoring tasks with different trigger times are associated with different positions of the time wheel. Based on the trigger time and the time wheel, at least one monitoring task in the time wheel is periodically executed to obtain monitoring information of at least one process, the monitoring information is stored corresponding to different processes, and at the same time, according to the monitoring information of each process, the processes in the process set are controlled. It is possible to store process-related process information in the process set, perform unified linked list management on different processes, associate different monitoring tasks with the time wheel, periodically execute monitoring tasks based on the time wheel, and manage processes based on the monitoring information obtained by executing the monitoring tasks, which can be applied to software process management in an embedded system and improve the accuracy of process management. Description of the Drawings

[0018] Figure 1 is a step diagram of a process monitoring and management method provided by an embodiment of the present disclosure;

[0019] Figure 2 is a schematic diagram of a time wheel provided by an embodiment of the present disclosure;

[0020] Figure 3It is a flowchart of another process monitoring and management method provided by an embodiment of the present disclosure;

[0021] Figure 4 It is a schematic diagram of a multi-level time wheel provided by an embodiment of the present disclosure;

[0022] Figure 5 It is a schematic diagram of a process monitoring and management architecture provided by an embodiment of the present disclosure;

[0023] Figure 6 It is a block diagram of a process monitoring and management device provided by an embodiment of the present disclosure;

[0024] Figure 7 It is a block diagram of an electronic device provided by an embodiment of the present disclosure. Detailed implementation manners

[0025] Hereinafter, exemplary embodiments of the present application will be described in more detail with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present application can be more thoroughly understood and the scope of the present application can be fully conveyed to those skilled in the art.

[0026] Figure 1 It is a flowchart of a process monitoring and management method provided by an embodiment of the present disclosure, and the method includes:

[0027] Step 101, obtaining a process set; the process set includes process information of created processes; at least part of the process information of different processes is different.

[0028] In the embodiments of the present disclosure, software is a collection including programs, data, documents, etc., and a process is an execution process of a program in a computer. When executing software, one or more processes can be generated. For example, when opening office software, the operating system will create one or more processes for this office software to execute the program code in the software, so as to implement various functions of the software, such as word processing, table making, etc.

[0029] Process information can be some characteristics of a process to be created. Process information can be specific types of signals that need to be specially processed by the process to be created, related callback functions, reset times, and other information. Among them, the callback function in the process information refers to a function that is automatically called when a specific event occurs during the execution of the process; the reset time refers to the time when the process restarts execution. In some scenarios, the process can restart execution after a specific time interval, and the reset time can make the process execute at a predetermined time interval. Here, the quantity, type, and specific content of the process information are not specifically limited.

[0030] Different process information can be used to create different processes. Each process can correspond to a node, and each node includes the process information corresponding to a single process. Different processes can be created one by one based on the process information included in different nodes. New processes can be created through the fork operation, or through other creation operations such as vfork. After the process is created, it can have a corresponding process identifier, i.e., the Process Identifier (PID).

[0031] In addition, when creating at least one process, it can be carried out based on a specific order. Since there may be certain business logics between the software corresponding to the processes, for example, during the data transmission process, it may be necessary to transfer data sequentially between different software and processes. Therefore, different processes can be created in accordance with the corresponding order based on specific business logics to ensure the normal operation of the business timing.

[0032] It can be understood that the process of monitoring and managing processes can also be achieved through a monitoring process (monitor). The monitoring process is the process corresponding to the monitoring software. The monitoring process can be used as the parent process. The parent process (monitoring process) can create child processes based on the preset process information, and the child processes can obtain copies of the resources such as the code segment, data segment, heap, and stack of the parent process.

[0033] The different process information of different processes can be stored in different positions in the process set respectively. For example, all the process information corresponding to Process 1 is stored in the same position in the process set, and all the process information corresponding to Process 2 is stored in another position in the process set. Among them, the process set can be implemented as a process linked list. The process linked list can be used as the process set to manage the processes of the software. The process set can also be data structures such as arrays and queues, which are not limited here.

[0034] The process of creating processes based on process information can be completed in advance, and then a process set including the process information corresponding to the created processes can be directly obtained.

[0035] Step 102: Obtain a time wheel associated with a monitoring task; the time wheel is a data structure for managing the monitoring task; the monitoring task has a corresponding trigger time; monitoring tasks with different trigger times are associated with different positions of the time wheel.

[0036] In the embodiments of the present disclosure, for different monitoring tasks, the processes to be monitored and the types of information to be monitored can be different. Monitoring tasks can be constructed according to the information and information types of specific processes. The processes monitored by the monitoring tasks can be one or more, and the types of information monitored can be one or more.

[0037] The information type can be, for example, the usage rate of the central processing unit (CPU), the usage of random access memory (RAM), the read / write speed or response time of disk input / output (I / O), etc. There is no limitation here.

[0038] Among them, the CPU usage rate refers to the proportion of CPU resources occupied by a process during operation. The memory usage of a process can include the amount of memory used, the amount of available memory, etc. The read / write speed of disk I / O represents the amount of data read and written per second, and the response time can represent the time from issuing a read / write request to completing the operation. These monitoring information respectively reflect the running status of the process from different aspects.

[0039] The monitoring task corresponds to a trigger time and a trigger period. The trigger time refers to the specific time point when the task starts to execute, and the trigger period represents the time interval for task execution. For example, if the trigger time of the monitoring task is 10 am and the trigger period is once a day, then the monitoring task will be executed at 10 am every day.

[0040] The time wheel can be implemented as a circular data structure. The time wheel can be divided into multiple time slots, and one slot represents a time interval. Therefore, according to the trigger time of the monitoring task, the corresponding time slot can be calculated and determined, and then the monitoring task can be associated with this time slot.

[0041] Among them, the association method can be that the time slot stores pointers to the head and tail of a doubly linked list. The pointers represent memory locations. Based on the pointers to the head and tail of the doubly linked list, the corresponding linked list can be determined in memory. Each doubly linked list can store multiple monitoring tasks, thereby establishing the association between the time slot and the monitoring task.

[0042] Figure 2 is a schematic diagram of the time wheel provided by the embodiments of the present disclosure; Figure 2 includes the overall time wheel 20, and multiple time slots 201 on the time wheel 20, Figure 2 shows that the 3rd time slot 201 corresponds to the task linked list 2011 storing the monitoring task.

[0043] Step 103, based on the trigger time and the time wheel, execute the monitoring tasks in the time wheel to obtain the monitoring information of at least one process.

[0044] In the embodiments of the present disclosure, the operation of the time wheel is completed by four parts: the time wheel disk, the pointer, the monitoring task, and the time driver.

[0045] The time wheel is composed of a certain number of time slots (wheelSize), and each time slot corresponds to a time span (tickMS). The maximum time span of the time wheel is wheelSize * tickMS. For example, if the basic time unit of the time wheel is 1 second and the wheel has 60 time slots, then this wheel can represent the time span within 1 minute. The maximum trigger time of the monitoring task cannot exceed the maximum time span, and the minimum trigger time cannot be lower than tickMS.

[0046] The pointer moves on the array at a certain speed, and as time goes by, the pointer will keep moving. Since the monitoring tasks have been associated with the corresponding time slots according to the trigger time, when the pointer points to a time slot, the monitoring tasks in the time slot pointed to by the pointer will be triggered and executed regularly. The monitoring tasks after execution can be stored back into the time wheel according to the trigger period or can be deleted.

[0047] The time driver can be implemented based on a separate thread through the epoll mechanism. The time driver is used to push the pointer to move on the time wheel to trigger the execution of tasks. The time driver limits the running speed of the time wheel, that is, it will affect the time accuracy of the time wheel and the frequency of task scheduling.

[0048] When the monitoring task is executed, relevant process and related type of monitoring information can be obtained according to the process information used to create the monitoring task, such as PID, information type, etc. The monitoring information can be the CPU usage rate, memory occupancy rate, disk I / O read and write speed or disk I / O response time of the process, as well as other information.

[0049] Step 104, store the monitoring information of each process into the process set respectively, and control at least one process corresponding to the process set according to the monitoring information.

[0050] In the embodiment of the present disclosure, the monitoring information of each process can be obtained, and the monitoring information corresponding to each process is stored into the process set. The monitoring information and process information of each process can be stored at the same position in the process set.

[0051] Based on the monitoring information of each process, the processes that need to be managed and controlled can be determined. For example, when the monitoring information indicates that the current process occupies a high level of hardware resources, the current process can be controlled. The control operations for the process can be, for example, re-creating, pausing the process, and other control operations.

[0052] In summary, in the embodiments of the present disclosure, a process set is obtained, where the process set includes process information of created processes, and the process information of different processes is at least partially different. A time wheel associated with monitoring tasks is obtained. The monitoring tasks have corresponding trigger times, and monitoring tasks with different trigger times are associated with different positions on the time wheel. Based on the trigger times and the time wheel, at least one monitoring task in the time wheel is periodically executed to obtain monitoring information of at least one process, and the monitoring information is stored corresponding to different processes. At the same time, according to the monitoring information of each process, the processes in the process set are controlled. It is possible to store process-related process information in the process set, perform unified linked list management on different processes, associate different monitoring tasks with the time wheel, periodically execute the monitoring tasks based on the time wheel, and manage the processes based on the monitoring information obtained from executing the monitoring tasks, which is applicable to software process management in an embedded system and improves the accuracy of process management.

[0053] Reference Figure 3 , which shows a step diagram of a process monitoring and management method provided by an embodiment of the present disclosure. The method includes:

[0054] Step 301, obtain a process set; the process set includes process information of created processes; the process information of different processes is at least partially different;

[0055] Step 302, obtain a time wheel associated with monitoring tasks; the time wheel is a data structure for managing the monitoring tasks; the monitoring tasks have corresponding trigger times; monitoring tasks with different trigger times are associated with different positions on the time wheel;

[0056] Step 303, based on the trigger times and the time wheel, execute the monitoring tasks in the time wheel to obtain monitoring information of at least one process;

[0057] Step 304, store the monitoring information of each process into the process set respectively, and control at least one process corresponding to the process set according to the monitoring information.

[0058] The above steps 301-304 can refer to the content of the above Figure 1 embodiments and will not be elaborated here.

[0059] Multiple processes can run in the system. When running, processes will occupy relevant resources. For example, they will occupy the time slice of the CPU, which may cause some processes to affect the use of the CPU by other processes, as well as memory occupation and network bandwidth occupation, etc. In addition, there may be conflicts between processes, resulting in abnormal process operation.

[0060] Optionally, the process information in the process set includes a process identifier; the method further includes:

[0061] Step A1: Based on the information access interface, obtain the first process identifier corresponding to each of at least one running process.

[0062] Step A2: Determine the first identifier set corresponding to the first process identifier, and determine the second identifier set corresponding to the second process identifier in the process set.

[0063] Step A3: In the case where there is no matching relationship between the first process identifier in the first identifier set and any second process identifier in the second identifier set, determine the first process identifier as the target process identifier.

[0064] Step A4: Terminate the process corresponding to the target process identifier.

[0065] In the embodiments of the present disclosure, the information access interface may be a proc interface. Based on the information access interface, a user can obtain important data structure information in the kernel by reading files, such as process-related information. It may also be based on other newly developed interfaces. The type of the interface is not specifically limited herein, as long as it can obtain process-related information.

[0066] The process-related information recorded in a specific file can be obtained by reading the corresponding specific file through the information access interface. The process-related information may be information such as the process name and process identifier of a running process.

[0067] Determine the first identifier set according to the first process identifier of at least one running process. Similarly, after a process is created according to the process information, the corresponding process identifier, i.e., the second process identifier, can be obtained, and then the corresponding second identifier set can be determined.

[0068] It can be understood that the first identifier set can represent which processes are actually running currently, i.e., the actual running situation; the second identifier set can represent which processes are expected to run, i.e., the expected running situation.

[0069] Match the first identifier set and the second identifier set. It can be to compare each first process identifier in the first identifier set with the second process identifiers in the second identifier set. If a first process identifier is the same as a second process identifier in the second identifier set, it can be considered that there is a matching relationship between the first process identifier and the second process identifier. For example, if there is a first process identifier A in the first identifier set and a second process identifier A in the second identifier set, and the two are the same, it means that process A is expected to run and actually process A is also running.

[0070] If there is no matching second process identifier in the second identifier set for a certain first process identifier, then there is no matching relationship between the first process identifier and any second process identifier, and the first process identifier can be used as the target process identifier. For example, in the first identifier set, there is a first process identifier B, but there is no second process identifier in the second identifier set that is B, and the first process identifier B fails to match, which means that process B is not expected to run, but in fact process B is running. The reason for the problem may be that an incorrect process B is created additionally or other reasons.

[0071] The process determined based on the target process identifier does not belong to the processes recorded in the process set, and the corresponding process can be ended. The end command can be used to end the process. For example, based on the target process identifier, the "kill -9" command is used to forcibly terminate the process. It is also possible to use tools such as a process manager or a system monitor to find the process corresponding to the target process identifier and then send an end signal.

[0072] Implementing the embodiments of the present disclosure, based on the information access interface, obtaining the first process identifiers corresponding to at least one running process respectively, determining the first identifier set, and determining the second identifier set corresponding to the second process identifiers in the process set. If there is no matching relationship between the first process identifiers in the first identifier set and any second process identifiers in the second identifier set, then the first process identifier is determined as the target process identifier, and the process corresponding to the target process identifier is ended. It is possible to control other processes outside the processes corresponding to the process set, avoid interference of redundant processes on the normal processes under management, and improve the accuracy of process management and the stability of process operation.

[0073] Optionally, the time wheel includes n levels; the trigger time includes n levels; the nth-level time corresponds to the nth-level time wheel; different time slots in the nth-level time wheel correspond to different nth-level times, where n is a positive integer; the method further includes:

[0074] According to the nth-level time of the trigger time, associate the monitoring task with the corresponding time slot of the nth-level time wheel.

[0075] In the embodiments of the present disclosure, the time wheel can have multiple levels, such as including a first-level time wheel, a second-level time wheel, a third-level time wheel, and so on. The time spans of each level of the time wheel are different, and there will be a certain multiple relationship between the time wheels of each level. For example, the time wheel can have 3 levels. The first level can be in seconds, the second level can be in minutes, and the third level can be in hours, that is, 60 (seconds) * 60 (minutes) * 24 (hours); the relationship between the 3-level time wheels can also be defined by a 32-bit integer or by an 8-bit integer, that is, 256 * 256 * 256, which is not specifically limited here.

[0076] The trigger time can also have multiple levels. For example, it is the 3-level time wheel corresponding to 60 * 60 * 24, and the corresponding trigger time can be 12:08:01. The hour "12" in the trigger time corresponds to the third-level time wheel, the minute "08" corresponds to the second-level time wheel, and the second "01" corresponds to the first-level time wheel, that is, the nth-level time corresponds to the nth-level time wheel.

[0077] In addition, in Figure 2 the corresponding embodiments, it is described that the time wheel can be divided into different time slots. For example, for the 3-level time wheel corresponding to 60 * 60 * 24, the second-level time wheel has 60 time slots. When the trigger time is 12:08:01, "08" corresponds to the 8th time slot in the second-level time wheel. That is, different time slots in the nth-level time wheel correspond to different nth-level times, where n is a positive integer.

[0078] When associating a monitoring task with the time wheel, it can be to first associate the monitoring task with the corresponding time slot of the nth-level time wheel based on the nth-level time. For example, for the 3-level time wheel corresponding to 60 * 60 * 24, when the trigger time is 12:08:01, the monitoring task can be associated with the 12th time slot of the third-level time wheel.

[0079] Implementing the embodiments of the present disclosure, through the time wheel including n levels, the trigger time including n levels, the nth-level time corresponding to the nth-level time wheel, different time slots in the nth-level time wheel corresponding to different nth-level times, and associating the monitoring task with the corresponding time slot of the nth-level time wheel according to the nth-level time of the trigger time. It is possible to separately associate monitoring tasks with different trigger times, improve the orderliness of the monitoring tasks, make the monitoring tasks easy to find, and is beneficial to improving the efficiency of executing the monitoring tasks.

[0080] Optionally, n is a positive integer greater than 1; the step of executing the monitoring task in the time wheel based on the trigger time and the time wheel includes:

[0081] In the nth-level time wheel, determine the target time slot corresponding to the current time;

[0082] When the trigger time of the monitoring task associated with the target time slot is the same as the current time, execute the monitoring task;

[0083] When there is a difference between the trigger time of the monitoring task in the target time slot and the current time, according to the (n - 1)th-level time of the trigger time, associate the monitoring task with the corresponding time slot of the (n - 1)th-level time wheel;

[0084] In the (n - 1)th-level time wheel, continue to determine the target time slot corresponding to the current time until the monitoring task is executed.

[0085] In the embodiments of the present disclosure, since the monitoring task can be first associated with the highest-level time wheel, when there are n levels of time wheels, in the nth-level time wheel, determine the target time slot corresponding to the current time.

[0086] For example, there are 3 levels of time wheels, which respectively include the third-level time wheel corresponding to hours, the second-level time wheel corresponding to minutes, and the first-level time wheel corresponding to seconds. Since a day can be divided into 24 hours, the third-level time wheel corresponding to hours can have 24 time slots. If the current time is 12:00:00, the target time slot corresponding to the current time is the 12th time slot.

[0087] When comparing the trigger time of the monitoring task associated with the target time slot with the current time, the monitoring tasks in the task linked list can be compared with the current time one by one. If the trigger time of the monitoring task is the same as the current time, it means that the monitoring task is due, and then execute the monitoring task.

[0088] For example, the current time is 12:00:00, and the trigger time of monitoring task A is also 12:00:00. Then this monitoring task A can be mounted on the execution linked list. Executing the monitoring task can refer to executing a predefined callback function.

[0089] However, the trigger time of the monitoring task can also be different from the current time. For example, the trigger time of monitoring task B is 12:08:00. Since the third-level time is "12", this monitoring task B is also initially associated with the 12th time slot. Therefore, when the current time is 12:00:00, the trigger time of monitoring task B will also be compared with the current time, and then it is judged that there is a difference.

[0090] When there is a difference between the trigger time and the current time, since n is a positive integer greater than 1, the trigger time is at two levels, three levels or more. Similarly, the time wheel also includes two levels, three levels or more. Then, according to the second-level time of the trigger time, the monitoring task can be placed on the second-level time wheel.

[0091] For example, if the trigger time of monitoring task A is 12:00:00 and the trigger time of control task B is 12:08:00, then monitoring tasks A and B can be first associated with the 12th time slot of the third-level time wheel. When the current time reaches 12:00:00, all monitoring tasks with a trigger time exactly of 12:00:00 can be executed. Therefore, monitoring task A can be executed, but the trigger time of monitoring task B, 12:08:00, has not actually been reached yet.

[0092] Then, monitoring task B can be re-stored in the next level, that is, the 8th time slot of the second-level time wheel.

[0093] After the current time reaches the above-mentioned 12:00:00, the time pointer of the third-level time wheel will not immediately move to 13:00:00. Instead, similar to the hours, minutes and seconds in daily life, the time pointer of the first-level time wheel will rotate to 13:00:01, 13:00:02... After the time pointer of the first-level time wheel rotates to 13:00:59, immediately afterwards, the time pointer of the second-level time wheel will rotate to 13:01:00. Based on this process, when the current time comes to 12:08:00, the time pointer of the second-level time wheel also points to the 8th time slot. At this time, the current time is the same as the trigger time of monitoring task B, and monitoring task B is executed.

[0094] Similarly, if the trigger time is 12:08:01, continue to judge whether the trigger time of the monitoring task associated with the target time slot is the same as the current time. If they are the same, execute the monitoring task. If they are not the same, continue to associate the monitoring task with the corresponding time slot on the first-level time wheel according to the first-level time. The subsequent process is similar and will not be elaborated here.

[0095] It can be understood that the above example is based on a time wheel with 3 levels corresponding to 60*60*24, and it can also be a time wheel with other multiple relationships and other numbers of levels.

[0096] Figure 4 It is a schematic diagram of the multi-level time wheel provided by the embodiments of the present disclosure; Figure 4 Taking the 3-level time wheel as an example, when the first-level time wheel 401 rotates one week, the second-level time wheel 402 rotates one unit; when the second-level time wheel 402 rotates one week, the third-level time wheel 403 rotates one unit.

[0097] Implementing the embodiments of the present disclosure, by determining a target time slot corresponding to the current time in the nth-level time wheel; when the trigger time of the monitoring task associated with the target time slot is the same as the current time, executing the monitoring task; when there is a difference between the trigger time and the current time, according to the (n - 1)th-level time of the trigger time, associating the monitoring task with the corresponding time slot of the (n - 1)th-level time wheel, and in the (n - 1)th-level time wheel, continuing to determine the target time slot corresponding to the current time until the monitoring task is executed. Since the time wheel is implemented based on a circular data structure, only the expired tasks need to be processed each time, which can efficiently manage a large number of timed monitoring tasks, and will not occupy more memory even when the time increases and the number of monitoring task events increases; even when dealing with a large number of monitoring tasks, since the corresponding monitoring tasks can be easily found in the time slot without complex data operations, it can also maintain a low latency, thus improving the efficiency of process management as a whole.

[0098] Executing the monitoring task based on the time wheel in the above embodiments also avoids the following problems of using timers to manage timed tasks:

[0099] Performance overhead: For a large number of timed tasks, the timer will generate more system calls, thus affecting performance; Memory occupancy: As the number of timed tasks increases, the memory occupancy will also increase; Management complexity: When there are a large number of timed tasks, the complexity of managing these timers is high and difficult to maintain.

[0100] Optionally, the step of controlling at least one process corresponding to the process set according to the monitoring information includes:

[0101] Dividing the monitoring information of each process into at least one sub-monitoring information according to the information type of the monitoring information; different sub-monitoring information corresponds to different monitoring conditions;

[0102] When the sub-monitoring information meets the corresponding monitoring conditions, determining the target process corresponding to the sub-monitoring information and terminating the target process.

[0103] In the embodiments of the present disclosure, there can be various information types of the monitoring information, and there can also be various monitoring information obtained by executing the monitoring task. Among them, each monitoring task can be used to obtain the monitoring information of one or more information types of all processes, or can be used to obtain the monitoring information of all information types of one process, or can be used to obtain the monitoring information of one information type of one process. The processes and information types targeted by each monitoring task are not specifically limited here.

[0104] When the monitoring information includes multiple information types, the monitoring information is an information set. According to the information type, the monitoring information of each process corresponding to the process set can be divided into at least one sub-monitoring information. For example, the sub-monitoring information can be CPU occupancy rate, memory occupancy rate, and so on.

[0105] Different sub-monitoring information corresponds to different monitoring conditions. For example, for the CPU occupancy rate, the corresponding monitoring condition can be greater than the CPU occupancy rate threshold. When the sub-monitoring information meets the corresponding monitoring condition, determine the target process corresponding to the sub-monitoring information and terminate the target process.

[0106] It can be understood that for different monitoring information, it is respectively determined whether it meets different monitoring conditions. For some processes, there may be only one sub-monitoring information that meets the corresponding monitoring condition, or there may be multiple sub-monitoring information that meet the corresponding monitoring condition. If a sub-monitoring information of a process meets the monitoring condition, the process is taken as the target process. It can also be that a preset number, for example, 2 sub-sub-monitoring information need to meet the monitoring condition before the process is taken as the target process, without specific limitation.

[0107] Implementing the embodiments of the present disclosure, dividing the monitoring information of each process into at least one sub-monitoring information according to the information type of the monitoring information; when the sub-monitoring information meets the corresponding monitoring condition, determining the target process corresponding to the sub-monitoring information and terminating the target process. It is possible to make a judgment based on the monitoring information of different information types and the corresponding monitoring conditions to determine the processes that need to be terminated, improving the accuracy of process management.

[0108] During the running of the process, abnormal situations or errors may occur, and the abnormal situations or errors may cause problems in the software or system functions. For example, when a process accesses an illegal memory address or executes an invalid instruction, the process may suddenly terminate, data may be lost, and it is necessary to start processing again; the abnormality of the process may affect other related processes or system services.

[0109] Optionally, the method further includes:

[0110] When creating at least one process, set a first signal processing function in the process; the first signal processing function is used to perform an error signal acquisition operation;

[0111] When there is a running error in the process, call the first signal processing function to obtain the error signal of the process.

[0112] In the embodiments of the present disclosure, for the created process, the first signal processing function may be set in a specific process or all processes. The first signal processing function may be defined to obtain an error signal when a running error occurs in the process, and then the first signal processing function is registered to complete the setting of the first signal processing function in the process.

[0113] When a running error occurs in the process, the first signal processing function is triggered to be called, and the first signal processing function performs an error signal acquisition operation, so that the error signal of the process can be obtained.

[0114] Among them, the error signal may include the following signals:

[0115] Segmentation fault signal (SIGSEGV, Segmentation Violation), SIGSEGV is a signal generated when the process attempts to access an unallocated or invalid memory address; Bus error signal (SIGBUS, Signal Bus Error), which is generated when the process attempts to access an invalid memory address, or when the access fails due to a memory alignment problem; Floating-point exception signal (SIGFPE, Floating Point Exception), which is generated when the process encounters an error during floating-point operations. Other error signals may also be involved in the process operation, and the specific types of error signals are not specifically limited here.

[0116] The error signal can indicate various abnormal or error situations, and the process takes corresponding operations according to these signals. In addition to the above error signal acquisition operation, operations such as recording error information and cleaning up resources may also be included, which are not specifically limited here.

[0117] Implementing the embodiments of the present disclosure, when creating at least one process, the first signal processing function is set in the process. When a running error occurs in the process, the first signal processing function is called to obtain the error signal of the process. It can accurately monitor whether the process runs with errors, improving the accuracy of process monitoring; at the same time, it also helps to quickly locate the cause of the problem and fix the problem, so it also improves the stability of the process operation.

[0118] In some business scenarios, some processes may be used to perform some important operations and cannot be terminated. If the process is terminated, data may be lost and need to be processed again, or the termination of the process may affect related other processes or system services.

[0119] Optionally, the method further includes:

[0120] When creating at least one process, a second signal processing function is set in the process; the second signal processing function is an empty function;

[0121] When a termination operation is triggered for the process, the second signal processing function is called to block the termination signal of the process.

[0122] In the embodiments of the present disclosure, similar to setting the first signal processing function in a process, the second signal processing function can also be registered to set the second signal processing function. The second signal processing function can be an empty function, indicating that no operation to be executed is defined within the second signal processing function.

[0123] The user can trigger a termination operation, which can be an operation of triggering a preset button, a voice operation, a text input operation, etc. For example, the termination operation can be a pressing operation on the button "ctrl+c". When a termination operation is triggered for the process, the second signal processing function is called. Since it is an empty function, the second signal processing function does not execute an operation, so the termination signal of the process is actually blocked.

[0124] It can be understood that the shielding effect can also be achieved through other second signal processing functions. For example, by setting the second signal processing function to SIG_IGN, the termination signal can also be blocked.

[0125] Implementing the embodiments of the present disclosure, when creating at least one process, setting a second signal processing function in the process, and calling the second signal processing function when a termination operation is triggered for the process to block the termination signal of the process. This can avoid directly closing the process through the termination operation, and avoid negative consequences such as other processes or system services being terminated due to the termination of the relevant process, improving the stability of the process and the system.

[0126] It can be understood that the above Figures 1 to 3 In the embodiments, the monitoring information, error information, and other relevant information involved can all be stored in the error log. The information stored in the error log can be used to quickly locate the cause of the problem, discover the performance bottleneck of the process, and for subsequent problem solving and optimization processes.

[0127] Figure 5 is a schematic diagram of the process monitoring and management architecture provided by the embodiments of the present disclosure; Figure 5The first layer 501 of the process monitoring and management architecture shown is the operating system, which may include operating systems such as Linux and Android; the second layer 502 includes library files and the Portable Operating System Interface (POSIX) of UNIX; the third layer 503 includes a signal management module, a process management module, a time wheel module, and a log module. Among them, the signal management module is used to process signals, such as obtaining error signals and masking termination signals. The process management module is mainly used to create processes and manage process sets. The time wheel module is mainly used to manage monitoring tasks. The log module is mainly used to record monitoring information and error signals; the fourth layer 504 includes multiple processes.

[0128] In summary, in the embodiments of the present disclosure, a process set is obtained, where the process set includes process information of created processes, and the process information of different processes is at least partially different. A time wheel associated with monitoring tasks is obtained. The monitoring tasks have corresponding trigger times, and monitoring tasks with different trigger times are associated with different positions on the time wheel. Based on the trigger time and the time wheel, at least one monitoring task in the time wheel is periodically executed to obtain monitoring information of at least one process, and the monitoring information is stored corresponding to different processes. At the same time, according to the monitoring information of each process, the processes in the process set are controlled. It is possible to store process-related process information in the process set, perform unified linked list management on different processes, associate different monitoring tasks with the time wheel, periodically execute monitoring tasks based on the time wheel, and manage processes based on the monitoring information obtained from the execution of the monitoring tasks, which can be applied to software process management in embedded systems and improve the accuracy of process management.

[0129] Figure 6 A process monitoring and management device 60 provided by an embodiment of the present disclosure includes:

[0130] A process set module 601, configured to obtain a process set; the process set includes process information of created processes; the process information of different processes is at least partially different;

[0131] A monitoring task module 602, configured to obtain a time wheel associated with monitoring tasks; the time wheel is a data structure for managing the monitoring tasks; the monitoring tasks have corresponding trigger times; monitoring tasks with different trigger times are associated with different positions on the time wheel;

[0132] A trigger execution module 603, configured to execute the monitoring tasks in the time wheel based on the trigger time and the time wheel to obtain monitoring information of at least one process;

[0133] The process management module 604 is used to separately store the monitoring information of each process into the process set, and control at least one process corresponding to the process set according to the monitoring information.

[0134] Optionally, the process information in the process set includes a process identifier; the apparatus further includes:

[0135] The interface access module is used to obtain, based on an information access interface, the first process identifier corresponding to at least one running process respectively;

[0136] The identifier set module is used to determine a first identifier set corresponding to the first process identifier, and determine a second identifier set corresponding to a second process identifier in the process set;

[0137] The identifier comparison module is used to determine the first process identifier as the target process identifier when there is no matching relationship between the first process identifier in the first identifier set and any second process identifier in the second identifier set;

[0138] The process end module is used to end the process corresponding to the target process identifier.

[0139] Optionally, the time wheel includes n levels; the trigger time includes n levels; the nth-level time corresponds to the nth-level time wheel; different time slots in the nth-level time wheel correspond to different nth-level times, where n is a positive integer; the apparatus further includes:

[0140] The task storage module is used to associate the monitoring task with the corresponding time slot of the nth-level time wheel according to the nth-level time of the trigger time.

[0141] Optionally, n is a positive integer greater than 1; the trigger execution module includes:

[0142] The first target sub-module is used to determine the target time slot corresponding to the current time in the nth-level time wheel;

[0143] The task execution sub-module is used to execute the monitoring task when the trigger time of the monitoring task associated with the target time slot is the same as the current time;

[0144] The update storage sub-module is used to, when there is a difference between the trigger time of the monitoring task in the target time slot and the current time, associate the monitoring task with the corresponding time slot of the (n - 1)th-level time wheel according to the (n - 1)th-level time of the trigger time;

[0145] The loop execution sub-module is used to continue to determine the target time slot corresponding to the current time in the (n - 1)th-level time wheel until the monitoring task is executed.

[0146] Optionally, the process management module includes:

[0147] A monitoring condition sub-module, configured to divide the monitoring information of each process into at least one sub-monitoring information according to the information type of the monitoring information; different sub-monitoring information corresponds to different monitoring conditions;

[0148] A process control sub-module, configured to determine a target process corresponding to the sub-monitoring information and terminate the target process when the sub-monitoring information meets the corresponding monitoring condition.

[0149] Optionally, the apparatus further includes:

[0150] A first function module, configured to set a first signal processing function in the process when creating at least one process; the first signal processing function is used to perform an error signal acquisition operation;

[0151] An error capture module, configured to call the first signal processing function to obtain an error signal of the process when the process has a running error.

[0152] Optionally, the apparatus further includes:

[0153] A second function module, configured to set a second signal processing function in the process when creating at least one process; the second signal processing function is an empty function;

[0154] A signal shielding module, configured to call the second signal processing function to shield the termination signal of the process when a termination operation is triggered for the process.

[0155] In summary, in the embodiments of the present disclosure, a process set is obtained, where the process set includes process information of created processes, and the process information of different processes is at least partially different. A time wheel associated with monitoring tasks is obtained, the monitoring tasks have corresponding trigger times, and monitoring tasks with different trigger times are associated with different positions of the time wheel. Based on the trigger time and the time wheel, at least one monitoring task in the time wheel is periodically executed to obtain monitoring information of at least one process. According to the monitoring information corresponding to each process and preset monitoring conditions, the processes in the process set are controlled. The process information related to the process can be stored in the process set, different processes can be managed uniformly in a linked list, different monitoring tasks can be managed on the time wheel, the monitoring tasks are periodically executed based on the time wheel, and the processes are managed based on the monitoring information obtained by executing the monitoring tasks, so that the software processes in the embedded system can be accurately managed, and the accuracy of process management is improved.

[0156] An embodiment of the present application further provides an electronic device, such asFigure 7 As shown, it includes a processor 1001, a communication interface 1002, a memory 1003, and a communication bus 1004. Among them, the processor 1001, the communication interface 1002, and the memory 1003 complete mutual communication through the communication bus 1004.

[0157] The memory 1003 is used to store computer programs.

[0158] When the processor 1001 is used to execute the program stored on the memory 1003, the steps of the above process monitoring and management method are implemented, which will not be elaborated here.

[0159] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0160] The communication interface is used for the communication between the above electronic device and other systems.

[0161] The memory may include a Random Access Memory (RAM), or may also include a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.

[0162] The above-mentioned processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0163] In another embodiment provided by the present application, a computer-readable storage medium is further provided, on which a computer program is stored, and when the program is executed by a processor, the process monitoring and management method described in the above embodiment is implemented.

[0164] In another embodiment provided by the present application, a computer program product including instructions is further provided, and when it runs on a computer, the computer is caused to execute the process monitoring and management method described in the above embodiment.

[0165] In the above embodiment, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website, computer, server, or data center to another website, computer, server, or data center in a wired manner (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wirelessly (such as infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage system such as a server, data center, etc. that includes one or more integrated available media. The available medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (SSD)).

[0166] It should be noted that in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover a non-exclusive inclusion, so that a process, method, article or system including a series of elements not only includes those elements, but also includes other elements not expressly listed, or elements inherent to such process, method, article or system. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or system including the element.

[0167] Each embodiment in this specification is described in a related manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. For the embodiments of the device, electronic device, computer-readable storage medium, and computer program product containing instructions, since they are basically similar to the method embodiments, the description is relatively simple, and for the relevant parts, reference can be made to the partial description of the method embodiments.

[0168] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.

Claims

1. A process monitoring management method, characterized in that: The method comprises: Acquire a process set; the process set includes process information of created processes; the process information of different processes is at least partially different; Acquire a time wheel associated with a monitoring task; the time wheel is a data structure for managing the monitoring task; the monitoring task has a corresponding trigger time; monitoring tasks with different trigger times are associated with different positions of the time wheel; Based on the trigger time and the time wheel, executing the monitoring task in the time wheel to obtain monitoring information of at least one process; The monitoring information of each process is stored in the process set respectively, and at least one process corresponding to the process set is controlled according to the monitoring information.

2. The method according to claim 1, characterized in that The process information in the process set includes a process identifier; the method further includes: Based on the information access interface, obtaining first process identifiers corresponding to at least one running process; Determine a first identification set corresponding to the first process identification, and determine a second identification set corresponding to a second process identification in the process set; In the case that there is no matching relationship between a first process identifier in the first identifier set and any second process identifier in the second identifier set, determining the first process identifier as a target process identifier; End the process corresponding to the target process identifier.

3. The method according to claim 1, characterized in that The time wheel includes n levels; the trigger time includes n levels; the nth level time corresponds to the nth level time wheel; Different time slots in the n-th level time wheel correspond to different n-th level times, where n is a positive integer; the method further includes: According to the n-th level time of the trigger time, the monitoring task is associated with a corresponding time slot of the n-th level time wheel.

4. The method according to claim 3, characterized in that n is a positive integer greater than 1; the step of executing the monitoring task in the time wheel based on the trigger time and the time wheel comprises: In the n-th level time wheel, determining a target time slot corresponding to the current time; When the trigger time of the monitoring task associated with the target time slot is consistent with the current time, executing the monitoring task; When there is a difference between the trigger time of the monitoring task in the target time slot and the current time, the monitoring task is associated with the corresponding time slot of the n-1th level time wheel according to the n-1th level time of the trigger time; In the n-1th level time wheel, the target time slot corresponding to the current time continues to be determined until the monitoring task is executed.

5. The method according to claim 1, characterized in that The step of controlling at least one process corresponding to the process set according to the monitoring information includes: According to the information type of the monitoring information, the monitoring information of each process is divided into at least one sub-monitoring information; different sub-monitoring information corresponds to different monitoring conditions; When the sub-monitoring information meets the corresponding monitoring conditions, a target process corresponding to the sub-monitoring information is determined, and the target process is terminated.

6. The method according to claim 1, characterized in that The method further comprises: In the case of creating at least one process, setting a first signal processing function in the process; the first signal processing function is used to perform an error signal acquisition operation; When a running error occurs in the process, the first signal processing function is called to obtain an error signal of the process.

7. The method according to claim 1, characterized in that The method further comprises: In the case of creating at least one process, setting a second signal processing function in the process; the second signal processing function is an empty function; When a termination operation is triggered for the process, the second signal processing function is called to shield the termination signal of the process.

8. A process monitoring and management device, characterized in that: The device comprises: A process set module, used to obtain a process set; the process set includes process information of created processes; the process information of different processes is at least partially different; A monitoring task module, used to obtain a time wheel associated with a monitoring task; the time wheel is a data structure used to manage the monitoring task; the monitoring task has a corresponding trigger time; monitoring tasks with different trigger times are associated with different positions of the time wheel; A trigger execution module, configured to execute the monitoring task in the time wheel based on the trigger time and the time wheel, so as to obtain monitoring information of at least one process; The process management module is used to store the monitoring information of each process in the process set respectively, and control at least one process corresponding to the process set according to the monitoring information.

9. An electronic device, characterized in that: include: A processor, a communication interface, a memory and a communication bus; wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; The processor is used to implement the steps of the process monitoring management method as described in any one of claims 1 to 7 when executing the program stored in the memory.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the process monitoring and management method as described in any one of claims 1 to 7 are implemented.