A thread scheduling method and a computer-readable storage medium
By calculating device priorities and allocating thread resources differently, the problem of uneven device urgency in the thread pool is solved, enabling efficient data collection and optimized resource utilization within the time limit.
Patent Information
- Application Number
- CN202611544237.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-30
- Publication Date
- 2026-11-17
AI Technical Summary
In industrial data acquisition scenarios, the existing thread pool thread allocation method fails to distinguish the differences in the urgency of data acquisition between devices. This results in devices with longer acquisition times occupying threads, causing other devices to wait, affecting data acquisition latency and monitoring of upper-level systems.
By acquiring device attribute and operating status data, the device priority is calculated, and exclusive, shared, or elastic threads are bound to the device according to the priority. Exclusive threads are only used for critical devices, shared threads are used for medium-critical devices, and elastic threads can be preempted, thus realizing differentiated allocation of thread resources.
It enables dynamic adjustment of device priority based on operational status, ensuring that critical devices complete data collection within the time limit, reducing device waiting time, and optimizing thread resource utilization.
Smart Images

Figure CN123114773A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data acquisition technology, and more specifically, to a thread scheduling method and a computer-readable storage medium. Background Technology
[0002] In industrial data acquisition scenarios, the acquisition server typically maintains a thread pool. Threads in the pool read data from the programmable logic controllers (PLCs) of various field devices according to the acquisition cycle. In related technologies, the number of threads in the thread pool is fixed, and each device is assigned to a thread based on its access order or by an average distribution of the number of devices. Multiple devices bound to the same thread complete data acquisition sequentially.
[0003] However, this allocation method determines the correspondence between devices and threads solely based on the access order or the number of devices, without distinguishing the differences in the urgency of data collection among the devices. When a thread is simultaneously bound to both devices with longer collection times and devices that need to complete collection within a shorter timeframe, since a thread can only perform collection for one device at a time, the device with the longer collection time will continuously occupy the thread, causing other devices to only begin collection after the current collection is completed, resulting in mutual waiting between the two types of devices. Furthermore, this correspondence does not change with the device's operating status; even if the collection urgency of a device increases, the thread it occupies will not change accordingly. This leads to data from highly urgent devices failing to be collected within the required timeframe, increasing collection latency, and even causing collection timeouts, affecting the upper-level system's timely monitoring of the operational status of field devices.
[0004] Therefore, how to allocate thread resources differently for different devices when multiple devices share a thread pool is a technical problem that needs to be solved by those skilled in the art. Summary of the Invention
[0005] The purpose of this application is to provide a thread scheduling method and a computer-readable storage medium, which enables differentiated allocation of thread resources for different devices when multiple devices share a thread pool.
[0006] To achieve the above objectives, this application provides a thread scheduling method, including: Acquire device attribute data and operating status data of each device to be collected, and determine the device priority of each device to be collected based on the device attribute data and the operating status data according to the preset priority calculation rules; Based on the device priority of each device to be collected, threads in the thread pool are bound to each device to be collected; wherein, the first type of devices to be collected are bound to an exclusive thread, the second type of devices to be collected are bound to a shared thread, and the third type of devices to be collected are bound to an elastic thread. The device priority of the first type of devices to be collected is higher than that of the second type of devices to be collected, and the device priority of the second type of devices to be collected is higher than that of the third type of devices to be collected. The exclusive thread is only used to collect data from the bound first type of devices to be collected. The shared thread is used to collect data from multiple bound second type devices to be collected. The elastic thread is used to collect data from multiple bound third type devices to be collected. The data collection task of the third type of devices to be collected executed on the elastic thread can be preempted by the data collection task of the first type of devices to be collected. The preempted data collection task of the third type of devices to be collected is abandoned. Data from each of the devices to be collected is collected by a thread bound to each of the devices to be collected.
[0007] Optionally, the device attribute data includes device criticality and / or the number of points to be collected, and the operating status data includes device health and / or the network latency of the network where the device to be collected is located. The device priority is positively correlated with the device criticality, positively correlated with the number of points, positively correlated with the device health, and negatively correlated with network latency.
[0008] Optionally, before binding threads in the thread pool to each of the devices to be collected according to their device priorities, the method further includes: The target number of threads in the thread pool is determined based on the preset base number of threads, the number of data collection points for each of the devices to be collected, the estimated collection time, and the collection cycle duration. The estimated collection time is the estimated time required to complete a single data collection task for the device to be collected, and the collection cycle duration is the time interval between the start times of two adjacent data collection tasks for the same device. The target number of threads is positively correlated with the number of devices to be collected, positively correlated with the number of data collection points, positively correlated with the estimated collection time, and negatively correlated with the collection cycle duration. By comparing the target number of threads with a preset lower limit and a preset upper limit, when the target number of threads is less than the preset lower limit, the preset lower limit is determined as the actual number of threads in the thread pool; when the target number of threads is greater than the preset upper limit, the preset upper limit is determined as the actual number of threads; when the target number of threads is greater than or equal to the preset lower limit and less than or equal to the preset upper limit, the target number of threads is determined as the actual number of threads. The number of threads in the thread pool is adjusted based on the actual number of threads.
[0009] Optionally, adjusting the number of threads in the thread pool based on the actual number of threads includes: When the difference between the actual number of threads and the current number of threads in the thread pool meets a preset deviation condition, a new thread is created in the thread pool until the number of threads in the thread pool reaches the actual number of threads. When the difference between the current number of threads in the thread pool and the actual number of threads meets the preset deviation condition, a thread to be destroyed is determined in the thread pool and released until the number of threads in the thread pool reaches the actual number of threads.
[0010] Optionally, the step of binding threads in a thread pool to each of the devices to be collected according to their device priorities includes: According to the device priority from high to low, the current devices to be collected that need to be bound to threads are determined in turn, and the threads in the thread pool are bound to the current devices to be collected in turn. The process of binding a thread from the thread pool to the current device to be collected includes: Based on the category of the current device to be collected, candidate threads for the current device to be collected are determined in the thread pool; wherein, if the current device to be collected is the first type of device to be collected, the candidate thread is an idle thread in the thread pool that is not bound to a device to be collected; if the current device to be collected is the second type or the third type of device to be collected, the candidate thread is a thread in the thread pool other than the exclusive thread that is bound to the first type of device to be collected. Based on the number of data points of the devices to be collected that have been bound to each candidate thread, the estimated data collection time, and the data collection cycle duration, the thread load of each candidate thread is determined according to a preset thread load calculation rule; wherein, the thread load of the candidate thread is positively correlated with the number of data points of the devices to be collected that have been bound to the candidate thread, the thread load of the candidate thread is positively correlated with the estimated data collection time, and the thread load of the candidate thread is negatively correlated with the data collection cycle duration; Compare the thread load of each candidate thread, and bind the candidate thread with the lowest thread load to the current data acquisition device.
[0011] Optionally, the preset thread load calculation rule includes: for each candidate thread, summing the product of the number of points of each device to be collected that has been bound to the candidate thread and the estimated collection time, and then dividing the summation result by the collection cycle duration, the result of which is the thread load of the candidate thread.
[0012] This rule indicates that the more devices, locations, or estimated collection times bound to a candidate thread, the higher the thread load; conversely, the longer the collection cycle, the lower the thread load. The thread load is recalculated for each collection cycle and immediately upon changes in the binding relationship.
[0013] Optionally, after collecting data from each of the devices by means of a thread bound to each device, the method further includes: The current acquisition result of each of the devices to be acquired is obtained; wherein, the current acquisition result is used to characterize whether the current data acquisition of the device to be acquired is successful. When a complete response data frame is received within a preset timeout period, the verification information of the response data frame passes and the protocol error code indicates no error, the current acquisition result is determined to be successful; when at least one of the following occurs: no response data frame is received within the timeout period, the response data frame is incomplete, the verification information fails, the protocol error code indicates an error, or the communication connection is broken, the current acquisition result is determined to be unsuccessful. The device health of each device is updated based on the current collection result of the current collection, and the number of consecutive failures of each device is recorded. The number of consecutive failures is the cumulative number of collection failures since the most recent successful collection result of the device. When the current collection result of the device is successful, the device health of the device is increased and the number of consecutive failures of the device is cleared to zero. When the current collection result of the device is failed, the device health of the device is decreased and the number of consecutive failures of the device is incremented by one. The device to be collected is identified as the target device, and the target device is set to an isolated state. The thread of the target device is released in the thread pool to stop data collection from the target device.
[0014] Optionally, updating the device health status of each device to be collected based on the current collection result of each device includes: Obtain the current health status of the device to be collected, and determine the collection result value corresponding to the current collection result of the device to be collected; wherein, the collection result value is a first value when the current collection result is successful, and a second value when the current collection result is unsuccessful, and the first value is greater than the second value; The sum of the product of the current device health and the first weight coefficient and the product of the collected result value and the second weight coefficient is determined as the updated device health of the device to be collected; wherein the sum of the first weight coefficient and the second weight coefficient is one, and the first weight coefficient is greater than the second weight coefficient.
[0015] Optionally, after setting the target device to be collected to an isolated state and releasing the thread bound to the target device to be collected in the thread pool, the method further includes: The register value of a preset status register in the target device to be collected is read at preset probe intervals; wherein, the status register is a register used to characterize whether the target device to be collected is online; If the register value is not read within the preset response time after the request to read the register value is sent, or the read register value fails the verification, or the connection with the target device to be collected is broken, then the probe collection is determined to have failed, and the isolation state of the target device to be collected is maintained. If the register value is read within the preset response time and the register value passes the verification, the probe acquisition is determined to be successful, and the consecutive successful probe acquisition count of the target device is incremented by one; wherein, the consecutive successful probe acquisition count is the number of successful probe acquisitions accumulated since the most recent failed probe acquisition of the target device. When the number of consecutive successful probe acquisitions of the target device reaches the preset number of successful acquisitions, the isolation state of the target device is released, the device health of the target device is set to the preset initial value, the number of consecutive failures of the target device is cleared to zero, and the thread is re-bound to the target device according to the current device priority.
[0016] Optionally, the method further includes: In response to the registration event of a newly added device to be collected, the device priority of the newly added device to be collected is determined according to the device attribute data and running status data of the newly added device to be collected, and a thread in the thread pool is bound to the newly added device to be collected according to the device priority of the newly added device to be collected; Threads in the thread pool are bound to each of the devices to be collected based on the device priority of each device to be collected; wherein, each of the devices to be collected includes the newly added device to be collected; A scheduling snapshot is created based on the binding relationship between each of the devices to be collected and the threads in the thread pool, so that threads are allocated to each of the devices to be collected in the next collection cycle according to the scheduling snapshot.
[0017] To achieve the above objectives, this application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the thread scheduling method described above.
[0018] The thread scheduling method provided in this application determines the device priority of each device to be collected by a combination of device attribute data and operating status data, rather than solely by the access order or the number of devices. Therefore, the device priority can change with the current operating status of the device. When the collection urgency of a device increases due to its operating status change, its device priority increases accordingly, thereby obtaining thread resources in thread allocation that match its urgency. Because the degree to which thread resources are divided among devices varies depending on device priority, the first type of device has its own dedicated thread for data collection, and its collection latency is determined solely by itself, no longer affected by the collection time of other devices on the same thread. Thus, the most critical devices receive undivided thread resources. The second type of device shares a common thread, with each device receiving a defined execution time within a round-robin cycle, preventing situations where one device continuously occupies a thread while others wait indefinitely. The third type of device shares a flexible thread, which can be preempted by the first type of device when it is bound to a thread. Therefore, when thread resources are scarce, the third type of device relinquishes its occupied flexible thread, allowing thread resources to flow preferentially to the more critical first type of device. Based on this, different types of devices are differentiated in their thread usage; highly critical devices no longer queue for the same thread as devices with long collection times, ensuring their data is collected within the required timeframe. Simultaneously, the shared thread reuse between the second and third types of devices reduces thread idleness. Therefore, this application allocates threads with different usage methods to different categories of devices to be collected based on device priority, so that the use of thread resources matches the collection needs of each device, and realizes differentiated allocation of thread resources for different devices when multiple devices share a thread pool. This application also discloses a computer-readable storage medium that can achieve the above-mentioned technical effects.
[0019] It should be understood that the above general description and the following detailed description are merely exemplary and do not limit this application. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. The drawings are used to provide a further understanding of this disclosure and constitute a part of the specification. They are used together with the following detailed description to explain this disclosure, but do not constitute a limitation of this disclosure. In the drawings: Figure 1 This is a flowchart illustrating a thread scheduling method according to an exemplary embodiment; Figure 2 A flowchart illustrating another thread scheduling method according to an exemplary embodiment; Figure 3 This is a structural diagram illustrating a thread scheduling device according to an exemplary embodiment; Figure 4 This is a structural diagram of an electronic device according to an exemplary embodiment. Detailed Implementation
[0021] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0022] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0023] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0024] The thread scheduling method provided in this application can be applied to an equipment feedback control platform, which refers to a software platform used for data acquisition and reverse control of non-standard equipment in industrial sites. This platform is deployed on an industrial control computer and communicates with the programmable logic controllers (PLCs) of each device via a network. A programmable logic controller is an industrial control computer installed on the equipment side, used to control equipment operation and store equipment operation data. The data acquisition server obtains the equipment's operating data by reading the register addresses of the programmable logic controller; one register address corresponds to one data acquisition point.
[0025] This application discloses a thread scheduling method, in which the execution entity is a data acquisition server running a thread pool. See also... Figure 1 A flowchart illustrating a thread scheduling method according to an exemplary embodiment is shown below. Figure 1 As shown, it includes: S101: Obtain device attribute data and operating status data of each device to be collected, and determine the device priority of each device to be collected based on the device attribute data and the operating status data; In this context, "device to be collected" refers to industrial equipment connected to the equipment feedback platform that requires periodic data collection. Each device to be collected corresponds to one programmable logic controller (PLC). Device attribute data refers to data determined by the device's configuration and remaining relatively stable across multiple data collection sessions, such as device type, device criticality, and the number of data collection points. Operating status data refers to data that dynamically changes during device operation, such as device health and network latency. Device priority is a numerical value representing the importance of the device to be collected in this thread allocation; a higher priority value indicates that the device should have priority in obtaining thread resources.
[0026] In this step, the acquisition server reads the scheduling snapshot generated in the previous cycle at the beginning of each acquisition cycle. It retrieves the device attribute data and running status data of each device to be acquired from the scheduling snapshot and maps these two types of data to the device priority of each device in the current acquisition cycle according to pre-configured priority calculation rules. The acquisition cycle duration refers to the time interval between the start times of two adjacent data acquisition tasks for the same device to be acquired; in this embodiment, the acquisition cycle duration can be 500 milliseconds. The scheduling snapshot is a data set that records the binding relationship between each device to be acquired and threads in the thread pool, as well as the device attribute data and running status data of each device to be acquired. The scheduling snapshot is generated by the previous acquisition cycle and is read in the current acquisition cycle. The device status of each device to be acquired also records the target cycle for that device. The target cycle refers to the maximum allowed time interval between the start times of two adjacent data acquisition tasks required by the device to be acquired. The acquisition server ensures that the acquisition cycle duration is not longer than the minimum value among the target cycles of each device to be acquired, thereby satisfying the time limit requirements of a single device.
[0027] As a feasible implementation, the device attribute data includes device criticality and / or the number of points to be collected; the operating status data includes device health and / or the network latency of the network where the device to be collected is located; the device priority is positively correlated with the device criticality, the device priority is positively correlated with the number of points, the device priority is positively correlated with the device health, and the device priority is negatively correlated with the network latency.
[0028] In this context, "equipment criticality" refers to a coefficient characterizing the urgency of the services carried by the device being collected. For example, the criticality of an alarm device can be 1.0, the criticality of a device used for statistical analysis of overall device efficiency can be 0.8, and the criticality of a device used only for general monitoring can be 0.5. "Collection points" refers to the register addresses that need to be read from the device, and the number of points refers to the total number of register addresses that a device needs to read in a single collection. "Network latency" refers to the round-trip time delay of communication data between the collection server and the programmable logic controller of the device being collected. A higher network latency indicates a longer time required for the data from the device to reach the collection server. In this embodiment, network latency is used in the calculation of device priority in the form of network latency levels. Network latency levels are categories derived from the range of network latency, with values ranging from one to five. Higher network latency results in higher network latency levels. The network latency penalty coefficients corresponding to these levels are 1.0, 0.95, 0.85, 0.70, and 0.50, respectively, for network latency levels one, two, three, four, and five. It should be noted that the network latency level is the value of network latency in this embodiment. In other embodiments, the measured network latency value can also be used directly in the calculation of device priority.
[0029] In practice, the data sources and update timing for the above-mentioned data are as follows: the device criticality coefficient is determined by a fixed attribute in the device configuration file, which is stored in JSON format and entered by the system administrator when the device is connected. It is manually updated after the device is modified. The normalized value of the number of points is dynamically obtained from the point table in the device registration information and is updated whenever a point is added or deleted. The device health is updated after each data collection is completed. The network latency is determined by the background thread measuring it every 5 seconds and taking the average of the last 3 measurements. When the measurement result changes, a recalculation is triggered, and the network latency level of the device to be collected is determined by the interval to which the measurement result belongs.
[0030] As a feasible implementation method, device priority is calculated according to the following formula: ; in, This indicates the device priority of device i at time t. This represents the criticality coefficient of device i to be collected. This represents the normalized value of the number of points for device i to be collected. This represents the health status of device i at time t. This indicates the network latency level of the network where the device i to be collected is located, that is, the interval level to which the network latency belongs in this embodiment. This represents the network latency penalty coefficient corresponding to the network latency level. This is the keyness weighting coefficient. This is the weighting coefficient for the location size. This is the weighting coefficient for health status.
[0031] As shown in the formula, device priority is positively correlated with device criticality, number of points, and device health, and negatively correlated with network latency. Specifically, the health value increases with increasing device health; therefore, devices with lower health have smaller health values, resulting in lower device priority and avoiding wasting thread resources on frequently failing devices. The network latency penalty coefficient decreases with increasing network latency, meaning that devices spanning different factory areas or floors are assigned lower device priorities, while local devices receive priority.
[0032] The values of each weighting coefficient are determined through offline calibration. First, historical data is collected, including equipment criticality, number of locations, equipment health, network latency, and actual data acquisition success rate. Then, aiming to maximize the data acquisition cycle compliance rate, a grid search can be performed within the ranges of 0.8 to 1.5 for criticality weighting coefficients, 1.0 to 2.0 for location size weighting coefficients, and 1.5 to 2.5 for health weighting coefficients. In this embodiment, the criticality weighting coefficient can be 1.2, the location size weighting coefficient can be 1.5, and the health weighting coefficient can be 2.0. It should be noted that the health weighting coefficient should not exceed 2.5; otherwise, the priority penalty for devices with a health of 0.8 will be too severe. In workshops with a high proportion of alarm devices, adjusting the criticality weighting coefficient to 1.4 can increase the priority of alarm devices by approximately 15%.
[0033] S102: Based on the device priority of each device to be collected, a thread in the thread pool is bound to each device to be collected; wherein, the first type of device to be collected is bound to an exclusive thread, the second type of device to be collected is bound to a shared thread, and the third type of device to be collected is bound to an elastic thread. The device priority of the first type of device to be collected is higher than that of the second type of device to be collected, and the device priority of the second type of device to be collected is higher than that of the third type of device to be collected. The larger the device priority value, the higher the priority. The exclusive thread is only used to collect data from the bound first type of device to be collected. The shared thread is used to collect data from multiple bound second type of devices to be collected. The elastic thread is used to collect data from multiple bound third type of devices to be collected. The data collection task of the third type of device to be collected executed on the elastic thread can be preempted by the data collection task of the first type of device to be collected. The preempted data collection task of the third type of device to be collected is abandoned. As one feasible implementation, the first type of device to be collected is a device with a device priority greater than or equal to a first preset threshold, the second type of device to be collected is a device with a device priority less than the first preset threshold but greater than or equal to a second preset threshold, and the third type of device to be collected is a device with a device priority less than the second preset threshold, wherein the first preset threshold is greater than the second preset threshold.
[0034] Among them, an exclusive thread refers to a thread that provides data acquisition services for only one device to be acquired. Each device of the first type is bound to a different exclusive thread, and this thread will not be bound to other devices after binding. A shared thread refers to a thread that provides data acquisition services for multiple devices to be acquired simultaneously. This thread performs data acquisition for the multiple devices to be acquired in a time-slice round-robin manner. An elastic thread refers to a thread that provides data acquisition services for multiple devices to be acquired simultaneously, and the stability of the service provided is lower than that of a shared thread. When the data acquisition task of the third type of device to be acquired executed on the elastic thread is preempted by the data acquisition task of the first type of device to be acquired, the elastic thread abandons the current task. The sent PLC read instructions are not canceled, and the thread waits for timeout or completion, but the acquisition results are discarded. Thus, the elastic thread switches to execute the data acquisition task of the first type of device to be acquired. The first preset threshold and the second preset threshold are two boundary values used to divide the priority categories of devices. In this embodiment, the first preset threshold can be 7.0, and the second preset threshold can be 4.0.
[0035] In this step, the acquisition server allocates threads to each device to be acquired in descending order of device priority. For the first category of devices with a priority greater than or equal to the first preset threshold, the acquisition server allocates an exclusive thread to the device, sets the flag indicating whether the thread is an exclusive thread to true, and places it in a dedicated pool. The idle start time of the thread is recorded in the idle timestamp of the thread state. Even if the thread is idle for more than 2 seconds, it will not be preempted by other devices until the device goes offline or is downgraded. If the number of the first category of devices exceeds the number of threads that can be allocated in the thread pool, an alarm is triggered and the excess devices are downgraded to the second category of devices to be acquired. For the second category of devices with a priority greater than or equal to the second preset threshold and less than the first preset threshold, the acquisition server binds two to three devices to the same shared thread. The time slice length is equal to the acquisition cycle length divided by the number of shared devices. The thread maintains a circular queue and executes sequentially. When the first category of devices needs to acquire data, the current time slice can be interrupted. The interrupted device saves the offset of the read registers and resumes the acquisition after the first category of devices has completed the acquisition. For third-category devices whose priority is less than the second preset threshold, the acquisition server binds multiple devices to elastic threads. During the process of binding a thread to a first-category device, if there is no idle thread in the thread pool that is not bound to a device, the first-category device will preempt the elastic thread, and the elastic thread will be converted into an exclusive thread for the first-category device. The third-category device originally bound to the elastic thread will relinquish the elastic thread and enter the waiting queue. When an idle thread appears in the thread pool, the thread will be re-bound according to its current device priority. During preemption, a semaphore is used to notify the thread to abandon the current task. The programmable logic controller read instructions that have been sent will not be revoked. The results will be discarded after the timeout or completion of the instruction.
[0036] It should be noted that when the device priority of a device to be collected changes across a threshold, the mapping relationship between the device and the thread is recalculated in the scheduling snapshot of the next collection cycle. During the migration process, the old thread continues to complete the collection in the current collection cycle, and the new thread takes over from the next collection cycle. The scheduling snapshot is switched atomically when the cycle is switched, and the collection process is not interrupted.
[0037] As can be seen, this step allocates threads with different occupancy methods to different categories of devices to be collected, so that the most urgent devices can obtain undivided thread resources, while intermediate and low-priority devices can reuse threads in a shared manner, thus avoiding the problem of devices waiting for each other under a fixed allocation method.
[0038] As a feasible implementation, before binding threads in the thread pool to each of the devices to be collected according to their device priorities, the method further includes: determining the target number of threads in the thread pool based on a preset base number of threads, the number of data collection points on each device, the estimated collection time, and the collection cycle duration, according to a preset target thread number calculation rule; the preset target thread number calculation rule is: using the preset base number of threads as a base, adding a load increment to obtain the target thread number, where the load increment is determined by the number of data collection points on each device, the estimated collection time, and the collection cycle duration; wherein, the estimated collection time is the estimated time for completing a single data collection task on the device to be collected, and the collection cycle duration is the time between the start times of two adjacent data collection tasks on the same device to be collected. The time interval between data collection points is positively correlated with the number of target threads, the number of target threads with the number of data points, the estimated data collection time, and negatively correlated with the data collection cycle duration. The target thread count is compared with a preset lower limit and a preset upper limit. When the target thread count is less than the preset lower limit, the preset lower limit is determined as the actual thread count of the thread pool. When the target thread count is greater than the preset upper limit, the preset upper limit is determined as the actual thread count. When the target thread count is greater than or equal to the preset lower limit and less than or equal to the preset upper limit, the target thread count is determined as the actual thread count. The thread count of the thread pool is adjusted based on the actual thread count.
[0039] The target number of threads refers to the number of threads required by the thread pool in this collection cycle, calculated based on the current collection workload of each device to be collected. The actual number of threads refers to the number of threads that actually take effect after the target number of threads is constrained by upper and lower limits. The preset lower limit and preset upper limit are boundary values that are preset according to the size of the thread pool. In this embodiment, the preset lower limit can be 4 and the preset upper limit can be 200.
[0040] In practice, the target number of threads and the actual number of threads are determined according to the following formula: ; ; in, This represents the target number of threads at time t. This represents the preset base number of threads, which can be twice the number of CPU cores. For example, if the CPU has 8 cores, the preset base number of threads would be 16. In a container environment, the preset base number of threads is determined by reading the processor quota file from the control group (cgroup). When the container platform adjusts the processor quota in place, the system listens for control group events and dynamically updates the preset base number of threads. θ represents the load factor, which can be 1.2. M represents the number of currently online devices waiting to be collected. This represents the normalized value of the number of points for device i to be collected. This represents the estimated time required for device i to complete a single data acquisition task. Indicates the duration of the data collection period. Indicates the actual number of threads. This indicates the preset lower limit value. This represents the preset upper limit. As can be seen from this formula, when the collection cycle duration is fixed, the more devices to be collected, the larger the number of points, or the longer the estimated collection time, the larger the target thread count; conversely, the longer the collection cycle duration, the smaller the target thread count.
[0041] The estimated data collection time is obtained by smoothing historical data collection times, and is updated according to the following formula: ; in, This represents the estimated acquisition time of device i at time t. This indicates the estimated data collection time since the last update. This indicates the actual time taken for this data collection. The smoothing coefficient can be set to 0.7, at which point the weight of the last 10 collections accounts for approximately 95%. The estimated collection time is updated immediately after each collection is completed, and write operations use atomic variables, eliminating the need for locking.
[0042] When the number of target threads exceeds a preset upper limit, the data collection server suspends data collection from third-category devices whose device priority is lower than the second preset threshold, and extends the collection cycle duration, for example, to 1000 milliseconds, until the load decreases and then resumes. For newly added devices to be collected after the number of threads reaches the preset upper limit, if they are first-category devices, the elastic thread will be preempted if there are no idle threads in the thread pool that are not bound to a device to be collected. This will convert the elastic thread into an exclusive thread for the first-category device, and the third-category devices that relinquish the elastic thread will enter the waiting queue. If the newly added device to be collected is not a first-category device, it will wait in the waiting queue.
[0043] As a feasible implementation method, adjusting the number of threads in the thread pool based on the actual number of threads includes: when the difference between the actual number of threads and the current number of threads in the thread pool meets a preset deviation condition, creating new threads in the thread pool until the number of threads in the thread pool reaches the actual number of threads; when the difference between the current number of threads in the thread pool and the actual number of threads meets the preset deviation condition, identifying threads to be destroyed in the thread pool and releasing the threads to be destroyed until the number of threads in the thread pool reaches the actual number of threads.
[0044] The preset deviation condition is determined according to the following formula: ; in, Indicates the target number of threads. This indicates the current number of threads in the thread pool. When the absolute value of the difference between these two values is greater than 20% of the current number of threads, the thread pool will be expanded or contracted.
[0045] In practical implementation, during expansion, the acquisition server creates a new thread, initializes the driver library, and establishes a Transmission Control Protocol (TCP) or User Datagram Protocol (UDP) connection with the programmable logic controller (PLC). If the initialization time exceeds a preset duration (e.g., 5 seconds), the device to be acquired is temporarily placed in a waiting queue until the thread is ready before binding. Therefore, the hot-loading time being less than or equal to the preset duration only refers to the time from device registration to thread allocation completion, excluding the connection establishment time. During scaling down, a preset duration (e.g., 30 seconds) is delayed after the device to be acquired goes offline, triggered by an independent timer thread. Threads to be destroyed are gracefully shut down after completing the current acquisition cycle without forced interruption. If a thread to be destroyed is bound to a device to be acquired, the binding is first removed before the thread is released. When creating a new thread, the acquisition server records the thread's creation timestamp as the current time. When a thread is identified as a thread to be destroyed, its recycling timestamp is recorded as the current time. The thread is released when the difference between the recycling timestamp and the current time reaches a preset delay duration.
[0046] As can be seen, the above implementation method, by setting a deviation dead zone and a shrinkage delay, ensures that changes in the thread pool size are triggered by continuous load changes, thus avoiding the repeated creation and destruction of threads caused by occasional jitter.
[0047] As a feasible implementation method, binding threads from a thread pool to each of the devices to be collected according to their device priorities includes: sequentially determining the current devices to be collected that require thread binding in descending order of device priority, and sequentially binding threads from the thread pool to each current device to be collected; wherein, the process of binding threads from the thread pool to the current device to be collected includes: determining candidate threads for the current device to be collected in the thread pool according to the category of the current device to be collected; wherein, if the current device to be collected is a first type of device to be collected, the candidate thread is an idle thread in the thread pool that is not bound to any device to be collected, and if the current device to be collected is a second type or a third type of device to be collected, the candidate thread is an idle thread in the thread pool that is not bound to any device to be collected, and so on. The candidate threads are the threads in the thread pool other than the exclusive threads already bound to the first type of device to be collected. The thread load of each candidate thread is determined based on the number of device locations already bound to each candidate thread, the estimated collection time, and the collection cycle duration. The thread load of each candidate thread is positively correlated with the number of device locations already bound to it, positively correlated with the estimated collection time, and negatively correlated with the collection cycle duration. The thread loads of each candidate thread are compared, and the candidate thread with the lowest thread load is bound to the current device to be collected.
[0048] Among them, the current device to be collected refers to the device to be collected that needs to be bound to a thread, determined in descending order of device priority; the candidate thread refers to the thread in the thread pool that can be bound to the current device to be collected; and the thread load refers to the degree to which a thread is occupied by the bound device to be collected within a collection cycle.
[0049] In practice, the data acquisition server first determines candidate threads: if the device to be acquired is a first-type device, the candidate threads are idle threads in the thread pool that are not bound to any acquired device, ensuring that the device receives undivided thread resources; if the device to be acquired is a second- or third-type device, the candidate threads are threads in the thread pool other than those exclusively bound to first-type devices, to avoid occupying threads already assigned to high-priority devices. Subsequently, the data acquisition server calculates the thread load of each candidate thread using the following formula: ; in, This represents the thread load of thread j. This represents the set of devices to be collected that are bound to thread j. This represents the number of data points for device k to be collected. This represents the estimated acquisition time for device k. This represents the duration of the data collection cycle. As can be seen from this formula, the more devices, locations, or estimated collection time bound to this thread, the higher the thread load; conversely, the longer the data collection cycle, the lower the thread load. The thread load is recalculated every data collection cycle, and immediately recalculated when the binding relationship changes. During the calculation, read-write locks are used, shared locks are used for query operations, and exclusive locks are used for binding and update operations.
[0050] Subsequently, the data acquisition server selects a thread for the current device to be acquired from the candidate threads according to the following formula: ; in, This indicates the thread number assigned to device i to be collected. This indicates that the thread number j is the one that minimizes the value within the parentheses. This represents the thread load of thread j. This indicates the device priority of device i to be collected. This indicates the highest device priority among all devices currently being collected. The priority affinity factor can be set to 0.3. Since the second term in parentheses is a constant for a given device to be acquired, this formula selects the thread with the lowest thread load from the candidate threads.
[0051] Each device to be acquired is configured into a priority queue according to the following formula, and threads are allocated sequentially according to the queue order: ;in, Indicates a sorting operation. to This indicates the IDs of the M devices to be collected in this allocation, with the sorting key being the device priority of each device. The sorting direction is from largest to smallest, so the device with the highest priority is selected first.
[0052] S103: Collect data from each of the devices to be collected by using threads bound to each of the devices to be collected.
[0053] In this step, each thread reads data from the bound device through a unified driver interface, which takes the form of PlcDriver.read(List <registeraddress>Each programmable logic controller (PLC) brand implements its own corresponding driver class. If the number of points read in a single operation exceeds the upper limit of a single read, the thread automatically splits the read into multiple batches. The estimated acquisition time required to complete one data acquisition is the sum of the times of each batch. Each thread maintains an independent PLC connection. If the connection is broken, it is automatically reconnected. If the reconnection fails, only the log is recorded, and isolation is not triggered. Retry within the driver layer of each brand is not counted in the consecutive failure count; only the final failure is counted.
[0054] In addition, the data acquisition server can record the acquisition time and the number of successful or failed acquisitions for each thread in real time. It outputs the acquisition time, device health, and thread status to the thread status section and uses these records as the data source for updating device priority and health in the next acquisition cycle. The thread status includes thread number, current load, set of bound devices, recent acquisition time, queue depth, a marker indicating whether it is an exclusive thread, creation timestamp, and recycling timestamp. Queue depth refers to the number of acquisition tasks waiting to be executed in the thread; the acquisition server prioritizes executing waiting acquisition tasks in the thread when the queue depth is greater than zero. The creation timestamp is the moment the thread was created; the recycling timestamp is the moment the thread was determined to be destroyed, used to determine whether the thread has reached the point where it can be released.
[0055] In a preferred embodiment, this embodiment further includes: responding to a registration event of a newly added device to be collected, determining the device priority of the newly added device to be collected based on the device attribute data and running status data of the newly added device to be collected, and binding a thread in the thread pool to the newly added device to be collected based on the device priority of the newly added device to be collected; binding a thread in the thread pool to each of the devices to be collected based on the device priority of each device to be collected; wherein, each device to be collected includes the newly added device to be collected; creating a scheduling snapshot based on the binding relationship between each device to be collected and the thread in the thread pool, so as to allocate threads to each device to be collected according to the scheduling snapshot in the next collection cycle.
[0056] In practice, the device registration center uses an in-memory concurrent hash table to maintain the metadata of each device to be collected, and receives registration requests from new devices via Hypertext Transfer Protocol or Remote Procedure Call interface. When insufficient CPU or memory resources cause thread creation to fail, the collection server rejects the new device access and issues an alarm; existing threads are unaffected. The registration event of a new device to be collected immediately triggers a device priority evaluation and thread allocation, without waiting for the next collection cycle.
[0057] The scheduling snapshot uses an immutable structure with an incrementing 64-bit integer version number. Configuration changes first generate a new version, and then atomically switch at the start of the next collection cycle. The switch uses double-buffered pointers; during the switch, the currently executing thread uses the previous scheduling snapshot to complete the current cycle's collection, thus avoiding half-updated mappings during hot reloading. When multiple configuration changes occur within a short period, such as adding 3 devices within 5 seconds, these changes are merged into a single new snapshot, requiring only one switch. The scheduling snapshot includes the version number, the device priority of each device to be collected in this collection cycle, the target thread count and the actual thread count, a mapping table between each device to be collected and its threads, an isolation list, and the next probe time. The target thread count refers to the number of threads determined based on the collection workload of this cycle, while the actual thread count refers to the number of threads that actually take effect after the target thread count is constrained by preset lower and upper limits. The mapping table records the correspondence between each device to be collected and the threads bound to it in this collection cycle. The isolation list records the device numbers of devices to be collected that are in an isolated state. The next probe time is the time when the register value of the status register of the device to be collected will be read next.
[0058] As can be seen, the above preferred implementation triggers incremental evaluation by registering events and atomically switches at the cycle boundary using immutable snapshots, so that the access of new devices does not require service restart and does not affect ongoing data collection.
[0059] The thread scheduling method provided in this application determines the device priority of each device to be collected by a combination of device attribute data and operating status data, rather than solely by the access order or the number of devices. Therefore, the device priority can change with the current operating status of the device. When the importance of a device for data collection increases due to its changing operating status, its device priority increases accordingly, thereby obtaining thread resources that match its importance in thread allocation. Because the degree to which thread resources are divided among devices varies depending on device priority, the first type of device has an exclusive thread for data collection, and its collection latency is determined solely by itself, no longer affected by the collection time of other devices on the same thread. Thus, the most critical devices obtain undivided thread resources. The second type of device shares a shared thread in a time-slice rotation, with each device receiving a defined execution time within a rotation cycle, preventing situations where one device continuously occupies a thread while others wait indefinitely. The third type of device shares an elastic thread, and this elastic thread, when bound to a first-type device, can be preempted and converted into an exclusive thread. Therefore, when thread resources are scarce, the third type of device relinquishes its occupied elastic thread, allowing thread resources to flow preferentially to the more critical first-type devices. Based on this, different types of devices are differentiated in thread usage; highly critical devices no longer queue for the same thread as devices with long collection times, ensuring their data is collected within the required timeframe. Simultaneously, the shared thread reuse between the second and third types of devices reduces thread idleness. Therefore, this application embodiment allocates threads with different usage methods to different categories of devices to be collected based on device priority, so that the use of thread resources matches the collection needs of each device, and realizes differentiated allocation of thread resources for different devices when multiple devices share a thread pool.
[0060] This application discloses a thread scheduling method. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. Specifically: See Figure 2 A flowchart illustrating another thread scheduling method according to an exemplary embodiment, such as... Figure 2 As shown, it includes: S201: Obtain device attribute data and operating status data of each device to be collected, and determine the device priority of each device to be collected based on the device attribute data and the operating status data; wherein, the operating status data includes device health. S202: Bind threads in a thread pool to each of the devices to be collected according to their device priorities; wherein, the first type of devices to be collected are bound to exclusive threads, the second type of devices to be collected are bound to shared threads, and the third type of devices to be collected are bound to elastic threads. The first type of devices to be collected are those with device priorities greater than or equal to a first preset threshold, the second type of devices to be collected are those with device priorities less than the first preset threshold but greater than or equal to a second preset threshold, and the third type of devices to be collected are those with device priorities less than the second preset threshold. The exclusive thread is used only to collect data from the bound first type of devices to be collected, the shared thread is used to collect data from multiple bound second type devices to be collected, and the elastic thread is used to collect data from multiple bound third type devices to be collected. Moreover, the elastic thread can be preempted by the first type of devices to be collected and converted into an exclusive thread when binding a thread to the first type of devices to be collected. The first preset threshold is greater than the second preset threshold. S203: Collect data from each of the devices to be collected by using a thread bound to each of the devices to be collected.
[0061] S204: Obtain the current acquisition result of each of the devices to be acquired; wherein, the current acquisition result is used to characterize whether the current data acquisition of the devices to be acquired is successful. When a complete response data frame is received within a preset timeout period, the verification information of the response data frame passes and the protocol error code indicates no error, the current acquisition result is determined to be successful; when at least one of the following occurs: no response data frame is received within the timeout period, the response data frame is incomplete, the verification information fails, the protocol error code indicates an error, or the communication connection is disconnected, the current acquisition result is determined to be unsuccessful. The current acquisition result refers to the result obtained by performing a data acquisition on the device to be acquired within this acquisition cycle, and its value is used to characterize whether the data acquisition on the device to be acquired was successful.
[0062] In this step, the acquisition result is considered successful when a complete response data frame is received from the device under test within the preset timeout period, the verification information of the response data frame passes, and the protocol error code indicates no error. The acquisition result is considered unsuccessful if at least one of the following occurs: no response data frame is received within the timeout period, the received response data frame is incomplete, the verification information fails, the protocol error code indicates an error, or the communication connection with the device under test is broken. The response data frame refers to the data frame returned by the programmable logic controller (PLC) of the device under test in response to the data acquisition request. The verification information refers to the result of Cyclic Redundancy Check (CRC) on the response data frame; passing the verification information means the response data frame passes the CRC check. A protocol error code indicating no error means the response data frame does not carry an error code or the error code it carries is a predefined value indicating no error. Error codes from different PLC brands are uniformly mapped to this value before judgment; for example, this value can be zero, indicating no error. The preset timeout period can be twice the acquisition cycle length of the device under test. Both network layer errors and application layer timeouts are considered data collection failures, but they are recorded differently in the logs. The number of consecutive failures is stored as an atomic integer, and its increment and reset operations are guaranteed to be atomic when multiple threads access it simultaneously.
[0063] S205: Update the device health of each device according to the current collection result of each device, and record the number of consecutive failures of each device; wherein, the number of consecutive failures is the cumulative number of collection results that have failed since the most recent collection result of the device was successful. When the current collection result of the device is successful, increase the device health of the device and clear the number of consecutive failures of the device to zero. When the current collection result of the device is failed, decrease the device health of the device and increment the number of consecutive failures of the device by one. Among them, device health refers to a value used to characterize the recent successful data collection of the device under test. Its value ranges from zero to one, and the higher the value, the higher the recent successful data collection rate of the device under test. The consecutive failure count is the cumulative number of data collection failures since the most recent successful data collection result of the device under test. This count is reset to zero when the current data collection result is successful.
[0064] In this step, the device health and consecutive failure count of each device are updated based on the current collection result. When the current collection result of a device is successful, the device health is increased and the consecutive failure count is reset to zero. When the current collection result of a device is a failure, the device health is decreased and the consecutive failure count is incremented by one.
[0065] As a feasible implementation, updating the device health of each device to be collected based on the current collection result of each device to be collected includes: obtaining the current device health of the device to be collected, and determining the collection result value corresponding to the current collection result of the device to be collected; wherein, the collection result value is a first value when the current collection result is successful, and a second value when the current collection result is unsuccessful, and the first value is greater than the second value; the sum of the product of the current device health and a first weight coefficient and the product of the collection result value and a second weight coefficient is determined as the updated device health of the device to be collected; wherein, the sum of the first weight coefficient and the second weight coefficient is one, and the first weight coefficient is greater than the second weight coefficient.
[0066] In practice, the updated device health status is determined according to the following formula: ; in, This indicates the health status of device i after this data collection is completed. This indicates the health status of device i before this data collection, i.e., the current health status of the device. This represents the acquisition result value corresponding to the acquisition result of device i in this acquisition. This value is 1 when the acquisition is successful and 0 when the acquisition fails. As the second weighting coefficient, 1 and The difference is the first weighting coefficient, in this embodiment We can take 0.3, so the first weight coefficient is 0.7. The first weight coefficient is greater than the second weight coefficient, and the sum of the two is one.
[0067] This formula is a recursive form of a first-order low-pass filter. It means that the updated device health is obtained by a weighted sum of the previous device health and the current acquisition result. The previous device health has a greater weight in the summation than the current acquisition result. Therefore, a single acquisition failure will not cause a sudden drop in device health; only multiple consecutive failures will cause a continuous decline in device health. Occasional network jitter is smoothly filtered out. It should be noted that the value of the smoothing coefficient affects the rate of change in health. An excessively large smoothing coefficient will lead to drastic fluctuations in device health, while an excessively small smoothing coefficient will result in a sluggish response. In this embodiment, a value of 0.3 can be used.
[0068] S206: Identify the devices to be collected whose health is lower than a preset health threshold and whose consecutive failure count reaches a preset failure count threshold as target devices to be collected, set the target devices to be collected to an isolated state, and release the threads bound to the target devices to be collected in the thread pool to stop data collection from the target devices to be collected.
[0069] The preset health threshold is a boundary value used to determine whether the device's health is too low, and can be set to 0.3; the preset failure count threshold is a boundary value used to determine whether the number of consecutive failures has reached the upper limit, and can be set to 5. Isolation status refers to the state where the device to be collected is removed from the normal collection path. Devices in isolation status are not assigned threads, and their corresponding data bits are marked as null. The host system can query the isolation status of the device through the status interface.
[0070] In this step, the isolation determination is performed according to the following formula: ; in, This represents the isolation flag of device i at time t. A value of 1 indicates that the device i is isolated, and a value of 0 indicates that the device i is not isolated. This indicates the preset health threshold. This represents the number of consecutive failures of the device i to be collected; This represents the preset failure threshold. Both conditions in the formula must be met simultaneously. This means that the device to be collected will only be switched to isolation mode if it has experienced continuous failures recently and the smoothed value of its health has also dropped below the preset health threshold, thus avoiding false isolation caused by a single network fluctuation.
[0071] Each device status identifier for a data acquisition device can be one of three values: active, isolated, or probe. Devices in the active state participate in thread allocation and data acquisition; devices in the isolated state are removed from the normal acquisition path, do not participate in thread allocation, and their corresponding data bits are marked as null; devices in the probe state only have their status register values read by threads in the probe thread pool at preset probe intervals, without reading other data points. The acquisition server updates the device status identifier of the data acquisition device after each isolation determination and queries the device status identifier of each data acquisition device through the status interface. After a data acquisition device transitions from the active state to the isolated state, the acquisition server releases the thread occupied by the data acquisition device, clears the thread's binding table, and marks the thread as available, without destroying the thread object.
[0072] As can be seen, this step triggers isolation based on both device health and the number of consecutive failures, and releases the threads occupied by the isolated device, so that the failure of a single device no longer continuously occupies thread resources.
[0073] As a feasible implementation, after setting the target device to be collected to an isolated state and releasing the thread bound to the target device to be collected in the thread pool, the method further includes: reading the register value of a preset status register in the target device to be collected at a preset probe interval; wherein, the status register is a register used to characterize whether the target device to be collected is online; if the register value is not read within a preset response time after sending the request to read the register value, or the read register value fails verification, or the connection with the target device to be collected is broken, then the probe collection is determined to have failed, and the isolated state of the target device to be collected is maintained; if within the preset response time... If the register value is read and the register value verification passes, the probe acquisition is determined to be successful, and the consecutive successful probe acquisition count of the target device is incremented by one; wherein, the consecutive successful probe acquisition count is the cumulative number of successful probe acquisitions since the most recent failed probe acquisition of the target device; when the consecutive successful probe acquisition count of the target device reaches a preset number, the isolation state of the target device is released, the device health of the target device is set to a preset initial value, the consecutive failure count of the target device is cleared to zero, and the thread is re-bound to the target device according to the current device priority.
[0074] In practice, probe acquisition is performed by threads in a dedicated probe thread pool. The number of threads in the probe thread pool can be fixed at 5 to avoid affecting normal acquisition and to prevent probe storms. The probe acquisition only reads the register value stored in the preset status register of the device under test, i.e., a one-word length of data, rather than all points, thus reducing probe overhead. The status register is a register pre-defined by the programmable logic controller (PLC) of the device under test to store status variables indicating whether the device is online. After the read request is sent via the driver interface, the PLC returns a one-word data stored in the register. Therefore, confirmation of whether the target device is online can be completed with a single read. The probe interval can be 30 seconds, implemented using a timer, allowing for a certain duration of jitter (e.g., ±2 seconds). The preset response time is used to determine whether the probe read has timed out, i.e., the maximum allowable waiting time from sending the request to read the register value. In this embodiment, it can be 1000 milliseconds. If the register value is not read within the preset response time, it is considered a timeout, a type of probe acquisition failure. Since the consecutive successful probe acquisition count is accumulated since the last probe acquisition failure of the target device, this count restarts when a probe acquisition failure is determined. The target device needs to accumulate a preset number of successful probe acquisitions since that failure before the isolation state can be lifted. When the number of consecutive successful probe acquisitions reaches the preset number (e.g., 3 times), the acquisition server lifts the isolation state of the target device, resets its device health to a preset initial value (e.g., 0.5) instead of the last value before isolation, and clears the consecutive failure count to zero. Then, it reallocates threads to the target device based on its current device priority. When setting a target device to isolation, the acquisition server writes the device number of the target device to the isolation list of the scheduling snapshot and sets the next probe time to the sum of the current time and the preset probe interval. After each probe acquisition is completed, the next probe time is updated to the sum of the current probe time and the preset probe interval.
[0075] As can be seen, the above implementation method verifies whether the device to be collected has recovered by using a low-frequency probe, so that the faulty device can be automatically reconnected to the thread pool after recovery without the need for manual service restart.
[0076] In this embodiment, the health status of each device to be collected is updated based on the results of each collection. The weight of the device health status before the update in the weighted summation is greater than the weight of the current collection result. Therefore, a single collection failure only reduces the device health status by a limited value; the decline in device health status is accumulated from continuous failures. Occasional network jitter will not cause the device health status to drop below the preset health status threshold. Since isolation is determined by both a device health status below the preset health status threshold and a consecutive failure count reaching the preset failure count threshold, the device health status reflects the overall situation of recent successful collections, while the consecutive failure count reflects the continuity of recent failures. Only when both conditions are met is the device to be collected switched to an isolated state. Therefore, this avoids stopping collection on a device due to a single collection failure and also prevents devices with long-term failures from remaining in the normal collection path.
[0077] The following describes an application embodiment provided by this application. There are 48 non-standard devices distributed across different factory areas. Each device is controlled by a programmable logic controller (PLC) of a different brand. The number of data collection points per device ranges from 200 to 1000, totaling approximately 35,200 data collection points. The system deployment configuration is as follows: The device layer comprises 48 non-standard devices, including 12 from brand a, 10 from brand b, 14 from brand c, 8 from brand d, and 4 from brand e; the factory area distribution is: 20 devices in factory A, 18 in factory B, and 10 in factory C; the thread pool configuration is a preset basic thread count of 16, a preset lower limit of 4, and a preset upper limit of 200; the data collection cycle time is 500 milliseconds.
[0078] Fault Isolation Example: In Plant C, a Huichuan brand programmable logic controller (PLC) device, serial number DEV-038, experienced five consecutive data acquisition failures due to network fluctuations. Its health status changed as follows: initial 0.72, 0.58 after one failure, 0.41 after two failures, 0.29 after three failures, and finally 0.29 after five failures. At this point, the device's health status of 0.29 was less than the health threshold of 0.30, and the number of consecutive failures was five, meeting the isolation criteria. The data acquisition server released thread number 29, which was occupied by this device, and started probe mode. The thread status dashboard showed that this device was isolated, and the data acquisition of the remaining 47 devices was unaffected. The automatic recovery process is as follows: Device isolation is triggered at 15:12:05; the probe fails to detect for the first time at 15:12:35; the probe succeeds at 15:13:35, and the device health level rises to 0.45; two consecutive successful probes at 15:14:05, and the device health level is 0.58; three consecutive successful probes at 15:14:35, and the device automatically reconnects to the thread pool without any manual intervention.
[0079] On the same industrial control computer, using the exact same programmable logic controller (PLC) model and bit table, the thread scheduling method of this application was compared with the fixed 48-thread first-in-first-out scheme in related technologies. The hardware environment was an 8-core CPU and 16GB of memory. The comparison results are shown in Table 1. Table 1
[0080] In addition to the metrics listed in Table 1, dynamic task mapping reduces the time spent allocating devices and threads from approximately 500 milliseconds to approximately 50 milliseconds, decreases the data loss rate of critical devices from 5.2% to 0.3%, and reduces maintenance workload by approximately 80% through automatic fault isolation and recovery.
[0081] Boundary stress testing: When the number of devices to be collected increases to 300, exceeding the preset upper limit, the system automatically suspends low-priority devices and extends the collection cycle to 1000 milliseconds, ensuring that the collection cycle compliance rate of high-priority devices is not less than 90%. In the event of a network-wide failure (i.e., all devices have a health score below 0.3), only devices with 5 consecutive failures are isolated; those with fewer than 5 failures are not isolated. The maximum concurrency of the probe thread pool is set to 5 to avoid probe storms. When the number of points on a single device increases to 5000, the normalized value of the number of points is truncated to 1.0 to avoid triggering an exception. Simultaneously, the upper limit of device priority is dynamically adjusted, and all devices are re-evaluated. When insufficient CPU or memory resources cause thread creation failure, new device access is rejected and an alarm is triggered, without affecting existing threads. When a network partition occurs, the network latency of devices across different areas increases, and the network latency level is dynamically upgraded to level five. The thread pool shrinks to the target number of threads within the partition, i.e., calculated only based on the reachable devices to be collected.
[0082] The following describes a thread scheduling device provided in an embodiment of this application. The thread scheduling device described below and the thread scheduling method described above can be referred to each other.
[0083] See Figure 3 A structural diagram of a thread scheduling device according to an exemplary embodiment is shown, such as... Figure 3 As shown, it includes: The first acquisition module 100 is used to acquire device attribute data and operating status data of each device to be acquired, and to determine the device priority of each device to be acquired based on the device attribute data and the operating status data. The thread binding module 200 is used to bind threads from a thread pool to each of the devices to be collected based on their device priorities. Specifically, a first type of device to be collected is bound to an exclusive thread, a second type is bound to a shared thread, and a third type is bound to an elastic thread. The first type of device to be collected consists of devices with a device priority greater than or equal to a first preset threshold. The second type of device to be collected consists of devices with a device priority less than the first preset threshold but greater than or equal to a second preset threshold. The third type of device to be collected consists of devices with a device priority less than the second preset threshold. The exclusive thread is used only to collect data from the bound first type of device to be collected. The shared thread is used to collect data from multiple bound second type devices to be collected. The elastic thread is used to collect data from multiple bound third type devices to be collected. Furthermore, the elastic thread can be preempted by the first type of device to be collected and converted into an exclusive thread when binding a thread to it. The first preset threshold is greater than the second preset threshold. The data acquisition module 300 is used to acquire data from each of the devices to be acquired through a thread bound to each device to be acquired.
[0084] The thread scheduling device provided in this application provides that the device priority of each device to be collected is determined by both device attribute data and operating status data, rather than solely by the access order or the number of devices. Therefore, the device priority can change with the current operating status of the device. When the importance of a device's collection increases due to its changing operating status, its device priority increases accordingly, thereby obtaining thread resources that match its importance in thread allocation. Because the degree to which thread resources are divided among devices varies depending on device priority, the first type of device has an exclusive thread for data collection, and its collection latency is determined solely by itself, no longer affected by the collection time of other devices on the same thread. Thus, the most critical devices obtain undivided thread resources. The second type of device shares a shared thread in a time-slice rotation, with each device receiving a defined execution time within a rotation cycle, preventing situations where one device continuously occupies a thread while others wait indefinitely. The third type of device shares an elastic thread, and this elastic thread, when bound to a first-type device, can be preempted and converted into an exclusive thread. Therefore, when thread resources are scarce, the third type of device relinquishes its occupied elastic thread, allowing thread resources to flow preferentially to the more critical first-type devices. Based on this, different types of devices are differentiated in thread usage; highly critical devices no longer queue for the same thread as devices with long collection times, ensuring their data is collected within the required timeframe. Simultaneously, the shared thread reuse between the second and third types of devices reduces thread idleness. Therefore, this application embodiment allocates threads with different usage methods to different categories of devices to be collected based on device priority, so that the use of thread resources matches the collection needs of each device, and realizes differentiated allocation of thread resources for different devices when multiple devices share a thread pool.
[0085] Based on the above embodiments, as a preferred embodiment, the device attribute data includes device criticality and / or the number of points to be collected, and the operating status data includes device health and / or the network latency of the network where the device to be collected is located. The device priority is positively correlated with the device criticality, positively correlated with the number of points, positively correlated with the device health, and negatively correlated with network latency.
[0086] Based on the above embodiments, as a preferred embodiment, it further includes: The first determining module is used to determine the target number of threads in the thread pool based on a preset basic number of threads, the number of data collection points for each of the devices to be collected, the estimated collection time, and the collection cycle duration. The estimated collection time is the estimated time required to complete a single data collection task for the device to be collected, and the collection cycle duration is the time interval between the start times of two adjacent data collection tasks for the same device. The target number of threads is positively correlated with the number of devices to be collected, positively correlated with the number of data collection points, positively correlated with the estimated collection time, and negatively correlated with the collection cycle duration. The second determining module is used to compare the target number of threads with a preset lower limit and a preset upper limit. When the target number of threads is less than the preset lower limit, the preset lower limit is determined as the actual number of threads in the thread pool. When the target number of threads is greater than the preset upper limit, the preset upper limit is determined as the actual number of threads. When the target number of threads is greater than or equal to the preset lower limit and less than or equal to the preset upper limit, the target number of threads is determined as the actual number of threads. An adjustment module is used to adjust the number of threads in the thread pool based on the actual number of threads.
[0087] Based on the above embodiments, as a preferred implementation, the adjustment module is specifically used for: when the difference between the actual number of threads and the current number of threads in the thread pool meets a preset deviation condition, creating new threads in the thread pool until the number of threads in the thread pool reaches the actual number of threads; when the difference between the current number of threads in the thread pool and the actual number of threads meets the preset deviation condition, determining threads to be destroyed in the thread pool and releasing the threads to be destroyed until the number of threads in the thread pool reaches the actual number of threads.
[0088] Based on the above embodiments, as a preferred implementation, the thread binding module 200 is specifically used to: determine the current devices to be collected that need to be bound to threads in descending order of device priority, and bind the threads in the thread pool to the current devices to be collected in sequence; The process of binding threads in the thread pool to the current device to be collected includes: determining candidate threads for the current device to be collected in the thread pool according to the category of the current device to be collected; wherein, if the current device to be collected is a first type of device to be collected, the candidate thread is an idle thread in the thread pool that is not bound to a device to be collected; if the current device to be collected is a second type or a third type of device to be collected, the candidate thread is a thread in the thread pool other than the exclusive thread that is bound to the first type of device to be collected; based on the devices to be collected that are bound to each of the candidate threads... The thread load of each candidate thread is determined by the number of collection points, the estimated collection time, and the collection cycle duration. The thread load of a candidate thread is positively correlated with the number of collection points bound to that candidate thread, positively correlated with the number of collection points of that device, positively correlated with the estimated collection time, and negatively correlated with the collection cycle duration. The thread loads of each candidate thread are compared, and the candidate thread with the lowest thread load is assigned to the current collection device.
[0089] Based on the above embodiments, as a preferred embodiment, it further includes: The second acquisition module is used to acquire the current acquisition result of each of the devices to be acquired; wherein, the current acquisition result is used to characterize whether the data acquisition of the device to be acquired was successful. When a complete response data frame is received within a preset timeout period, the verification information of the response data frame passes and the protocol error code indicates no error, the current acquisition result is determined to be successful; when at least one of the following occurs: no response data frame is received within the timeout period, the response data frame is incomplete, the verification information fails, the protocol error code indicates an error, or the communication connection is broken, the current acquisition result is determined to be unsuccessful. The update module is used to update the device health of each device according to the current collection result of each device, and to record the number of consecutive failures of each device; wherein, the number of consecutive failures is the cumulative number of collection results that have failed since the most recent collection result of the device was successful. When the current collection result of the device is successful, the device health of the device is increased and the number of consecutive failures of the device is cleared to zero. When the current collection result of the device is failed, the device health of the device is decreased and the number of consecutive failures of the device is incremented by one. An isolation module is used to identify devices whose health level is lower than a health level threshold and whose consecutive failure count reaches a failure count threshold as target devices to be collected, set the target devices to be collected to an isolated state, and release the threads bound to the target devices to be collected in the thread pool to stop data collection from the target devices.
[0090] Based on the above embodiments, as a preferred implementation, the update module is specifically used to: obtain the current device health of the device to be collected, and determine the collection result value corresponding to the current collection result of the device to be collected; wherein, the collection result value is a first value when the current collection result is successful, and a second value when the current collection result is unsuccessful, and the first value is greater than the second value; the sum of the product of the current device health and the first weight coefficient and the product of the collection result value and the second weight coefficient is determined as the updated device health of the device to be collected; wherein, the sum of the first weight coefficient and the second weight coefficient is one, and the first weight coefficient is greater than the second weight coefficient.
[0091] Based on the above embodiments, as a preferred embodiment, it further includes: The reading module is used to read the register value of a preset status register in the target device at preset probe intervals; wherein the status register is a register used to indicate whether the target device is online; if the register value is not read within a preset response time after sending the register value read request, or the read register value fails verification, or the connection with the target device is broken, then the probe acquisition is determined to have failed, and the target device is kept in an isolated state; if the register value is read within the preset response time and the register value passes verification, then the probe acquisition is determined to have succeeded, and the consecutive successful probe acquisition count of the target device is incremented by one; wherein the consecutive successful probe acquisition count is the number of successful probe acquisitions accumulated since the most recent failed probe acquisition of the target device. The release module is used to release the isolation state of the target device when the number of consecutive successful probe acquisitions of the target device reaches a preset number, set the device health of the target device to a preset initial value, clear the number of consecutive failures of the target device, and reallocate a thread to the target device according to the current device priority.
[0092] Based on the above embodiments, as a preferred embodiment, it further includes: The registration module is used to respond to a registration event of a newly added device to be collected, determine the device priority of the newly added device to be collected based on the device attribute data and running status data of the newly added device to be collected, and bind a thread in the thread pool to the newly added device to be collected based on the device priority; and bind a thread in the thread pool to each of the devices to be collected based on the device priority of each device to be collected; wherein, each device to be collected includes the newly added device to be collected; A creation module is used to create a scheduling snapshot based on the binding relationship between each of the devices to be collected and the threads in the thread pool, so as to allocate threads to each of the devices to be collected in the next collection cycle according to the scheduling snapshot.
[0093] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0094] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiments of this application, the embodiments of this application also provide an electronic device. Figure 4 This is a structural diagram of an electronic device according to an exemplary embodiment, such as... Figure 4 As shown, the electronic device includes: Communication interface 1 enables information exchange with other devices, such as network devices; Processor 2 is connected to communication interface 1 to enable information exchange with other devices and, when running a computer program, executes the thread scheduling methods provided by one or more of the above-mentioned technical solutions. The computer program is stored in memory 3.
[0095] Of course, in practical applications, the various components in an electronic device are coupled together through bus system 4. It can be understood that bus system 4 is used to achieve communication and connection between these components. In addition to the data bus, bus system 4 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 4 The general will label all buses as Bus System 4.
[0096] The memory 3 in this embodiment is used to store various types of data to support the operation of the electronic device. Examples of such data include any computer program used to operate on the electronic device.
[0097] It is understood that memory 3 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memory 3 described in the embodiments of this application is intended to include, but is not limited to, these and any other suitable types of memory.
[0098] The methods disclosed in the embodiments of this application can be applied to processor 2, or implemented by processor 2. Processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 2 or by instructions in the form of software. The processor 2 may be a general-purpose processor, DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 2 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in memory 3. Processor 2 reads the program in memory 3 and completes the steps of the aforementioned method in combination with its hardware.
[0099] When processor 2 executes the program, it implements the corresponding processes in the various methods of the embodiments of this application. For the sake of brevity, these will not be described in detail here.
[0100] In an exemplary embodiment, this application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, such as a memory 3 that stores a computer program, which can be executed by a processor 2 to complete the steps described in the aforementioned method. The computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM.
[0101] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0102] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0103] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.< / registeraddress>
Claims
1. A thread scheduling method, characterized by, include: Acquire device attribute data and operating status data of each device to be collected, and determine the device priority of each device to be collected based on the device attribute data and the operating status data according to the preset priority calculation rules; Based on the device priority of each device to be collected, threads in the thread pool are bound to each device to be collected; wherein, the first type of devices to be collected are bound to an exclusive thread, the second type of devices to be collected are bound to a shared thread, and the third type of devices to be collected are bound to an elastic thread. The device priority of the first type of devices to be collected is higher than that of the second type of devices to be collected, and the device priority of the second type of devices to be collected is higher than that of the third type of devices to be collected. The exclusive thread is only used to collect data from the bound first type of devices to be collected. The shared thread is used to collect data from multiple bound second type devices to be collected. The elastic thread is used to collect data from multiple bound third type devices to be collected. The data collection task of the third type of devices to be collected executed on the elastic thread can be preempted by the data collection task of the first type of devices to be collected. The preempted data collection task of the third type of devices to be collected is abandoned. Data from each of the devices to be collected is collected by a thread bound to each of the devices to be collected.
2. The thread scheduling method of claim 1, wherein, The device attribute data includes at least one of device criticality and the number of points to be collected; the operating status data includes at least one of device health and network latency of the network where the device to be collected is located. The device priority is positively correlated with the device criticality, positively correlated with the number of points, positively correlated with the device health, and negatively correlated with network latency.
3. The thread scheduling method of claim 1, wherein, Before binding threads in the thread pool to each of the devices to be collected according to their device priorities, the process further includes: Based on the preset base number of threads, the number of data collection points on each of the devices to be collected, and the estimated collection time and collection cycle duration, the target number of threads in the thread pool is determined according to the preset target thread number calculation rules. The estimated collection time is the estimated time required to complete a single data collection task on the device to be collected, and the collection cycle duration is the time interval between the start times of two adjacent data collection tasks on the same device. The target thread number is positively correlated with the number of devices to be collected, positively correlated with the number of data collection points, positively correlated with the estimated collection time, and negatively correlated with the collection cycle duration. By comparing the target number of threads with a preset lower limit and a preset upper limit, when the target number of threads is less than the preset lower limit, the preset lower limit is determined as the actual number of threads in the thread pool; when the target number of threads is greater than the preset upper limit, the preset upper limit is determined as the actual number of threads; when the target number of threads is greater than or equal to the preset lower limit and less than or equal to the preset upper limit, the target number of threads is determined as the actual number of threads. The number of threads in the thread pool is adjusted based on the actual number of threads.
4. The thread scheduling method of claim 3, wherein, Adjusting the number of threads in the thread pool based on the actual number of threads includes: When the actual number of threads is greater than the current number of threads in the thread pool, and the ratio of the absolute value of the difference between the two to the current number of threads is greater than a preset ratio threshold, a new thread is created in the thread pool until the number of threads in the thread pool reaches the actual number of threads. When the current number of threads in the thread pool is greater than the actual number of threads, and the ratio of the absolute value of the difference between the two to the current number of threads is greater than a preset ratio threshold, threads whose idle time exceeds the preset time are identified as threads to be destroyed, and the threads to be destroyed are destroyed until the number of threads in the thread pool reaches the actual number of threads.
5. The thread scheduling method of claim 3, wherein, The step of binding threads in a thread pool to each of the devices to be collected based on their device priorities includes: According to the device priority from high to low, the current devices to be collected that need to be bound to threads are determined in turn, and the threads in the thread pool are bound to the current devices to be collected in turn. The process of binding a thread from the thread pool to the current device to be collected includes: Based on the category of the current device to be collected, candidate threads for the current device to be collected are determined in the thread pool; wherein, if the current device to be collected is the first type of device to be collected, the candidate thread is an idle thread in the thread pool that is not bound to a device to be collected; if the current device to be collected is the second type of device to be collected or the third type of device to be collected, the candidate thread is a thread in the thread pool other than the exclusive thread that is bound to the first type of device to be collected. Based on the number of data points of the devices to be collected that have been bound to each candidate thread, the estimated data collection time, and the data collection cycle duration, the thread load of each candidate thread is determined according to a preset thread load calculation rule; wherein, the thread load of the candidate thread is positively correlated with the number of data points of the devices to be collected that have been bound to the candidate thread, positively correlated with the estimated data collection time, and negatively correlated with the data collection cycle duration; Compare the thread load of each candidate thread, and bind the candidate thread with the lowest thread load to the current data acquisition device.
6. The thread scheduling method according to claim 2, characterized in that, After collecting data from each of the devices by means of a thread bound to each device, the process further includes: The current acquisition result of each of the devices to be acquired is obtained; wherein, the current acquisition result is used to characterize whether the current data acquisition of the device to be acquired is successful. When a complete response data frame is received within a preset timeout period, the verification information of the response data frame passes and the protocol error code indicates no error, the current acquisition result is determined to be successful; when at least one of the following occurs: no response data frame is received within the timeout period, the response data frame is incomplete, the verification information fails, the protocol error code indicates an error, or the communication connection is broken, the current acquisition result is determined to be unsuccessful. The device health of each device is updated based on the current collection result of the current collection, and the number of consecutive failures of each device is recorded. The number of consecutive failures is the cumulative number of collection failures since the most recent successful collection result of the device. When the current collection result of the device is successful, the device health of the device is increased and the number of consecutive failures of the device is cleared to zero. When the current collection result of the device is failed, the device health of the device is decreased and the number of consecutive failures of the device is incremented by one. Devices whose health level is lower than a preset health level threshold and whose consecutive failure count reaches a preset failure count threshold are identified as target devices to be collected. The target devices to be collected are set to an isolated state, and the threads bound to the target devices to be collected in the thread pool are released to stop data collection from the target devices to be collected.
7. The thread scheduling method of claim 6, wherein, The step of updating the device health status of each device to be collected based on the current collection results of each device to be collected includes: Obtain the current health status of the device to be collected, and determine the collection result value corresponding to the current collection result of the device to be collected; wherein, the collection result value is a first value when the current collection result is successful, and a second value when the current collection result is unsuccessful, and the first value is greater than the second value; The sum of the product of the current device health and the first weight coefficient and the product of the collected result value and the second weight coefficient is determined as the updated device health of the device to be collected; wherein the sum of the first weight coefficient and the second weight coefficient is one, and the first weight coefficient is greater than the second weight coefficient.
8. The thread scheduling method of claim 6, wherein, After setting the target device to be collected to an isolated state and releasing the thread bound to the target device to be collected in the thread pool, the method further includes: The register value of a preset status register in the target device to be collected is read at preset probe intervals; wherein, the status register is a register used to characterize whether the target device to be collected is online; If the register value is not read within the preset response time after the request to read the register value is sent, or the read register value fails the verification, or the connection with the target device to be collected is broken, then the probe collection is determined to have failed, and the isolation state of the target device to be collected is maintained. If the register value is read within the preset response time and the register value passes the verification, the probe acquisition is determined to be successful, and the consecutive successful probe acquisition count of the target device is incremented by one; wherein, the consecutive successful probe acquisition count is the number of successful probe acquisitions accumulated since the most recent failed probe acquisition of the target device. When the number of consecutive successful probe acquisitions of the target device reaches the preset number of successful acquisitions, the isolation state of the target device is released, the device health of the target device is set to the preset initial value, the number of consecutive failures of the target device is cleared to zero, and the thread is re-bound to the target device according to the current device priority.
9. The thread scheduling method of claim 1, wherein, The method further includes: In response to a registration event of a newly added device to be collected received through the device registration center, the device priority of the newly added device to be collected is determined according to the device attribute data and running status data of the newly added device to be collected, and a thread in the thread pool is bound to the newly added device to be collected according to the device priority of the newly added device to be collected. Threads in the thread pool are bound to each of the devices to be collected based on the device priority of each device to be collected; wherein, each of the devices to be collected includes the newly added device to be collected; A scheduling snapshot is created based on the binding relationship between each of the devices to be collected and the threads in the thread pool. The scheduling snapshot is used to record the binding relationship between each of the devices to be collected and the threads in the thread pool, so that threads are allocated to each of the devices to be collected in the next collection cycle according to the scheduling snapshot.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the thread scheduling method as described in any one of claims 1 to 9.
