A priority scheduling and resource preemption method and system for concurrent multi-AI tasks of a handheld terminal
Patent Information
- Application Number
- CN202611100471.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-23
- Publication Date
- 2026-10-23
AI Technical Summary
[0003]现有手持终端的AI任务调度普遍采用先来先服务的串行调度方式,部分方案引入了基础的优先级调度,但仍存在多维度的技术缺陷,无法适配油田工业场景的复杂调度需求:
1. 本发明构建了三级静态基准+双维度动态调整的优先级调度体系:针对油田巡检任务的安全等级差异划分三级基准优先级,同时设计等待老化提升与异常置信度升级的双维度动态调整规则,既避免低优先级任务饥饿,又能响应设备异常风险的动态变化,实现优先级调度的灵活性与可靠性平衡。
Smart Images

Figure CN122963783A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of task scheduling for industrial edge computing terminals, embedded artificial intelligence computing power management, and optimization technology for oil explosion-proof terminal systems. Specifically, it relates to a method and system for priority scheduling and resource preemption of multiple concurrent AI tasks on a handheld terminal. Background Technology
[0002] With the construction of intelligent inspection systems in oilfields, oilfield explosion-proof handheld terminals have integrated multiple functions such as multimodal data acquisition, multi-type AI fault detection, data uploading, and report generation. A single terminal needs to run multiple AI inference tasks simultaneously. In field inspection operations, the terminal needs to simultaneously handle multiple concurrent tasks such as oil and gas leak detection, equipment infrared thermal imaging fault diagnosis, pipeline weld defect identification, and inspection data uploading. The computational load, real-time requirements, and safety levels of these tasks vary significantly.
[0003] Current handheld AI task scheduling generally adopts a first-come, first-served serial scheduling method. Some solutions have introduced basic priority scheduling, but there are still many technical defects that cannot adapt to the complex scheduling needs of oilfield industrial scenarios. 1. Delayed response to emergency tasks poses a safety hazard: Under the first-come, first-served scheduling mode, emergency safety tasks such as oil and gas leak detection and fire alarms must wait for low-priority tasks in the queue to be completed, and cannot obtain computing resources first. The average response time of emergency tasks exceeds 5.5 seconds, which cannot meet the second-level response requirements of high-risk anomalies in oil fields, and directly affects production safety.
[0004] 2. Static and fixed priorities can lead to starvation for low-priority tasks: The existing priority scheduling scheme uses static predefined rules, and the priority of a task is fixed after it is created. Tasks with lower importance, such as inspection reports and log uploads, are often preempted by high-priority tasks, which may result in starvation problems that cannot be executed for a long time. At the same time, when some tasks detect an increase in abnormal risks, they cannot dynamically upgrade their priorities, making it difficult to respond in a timely manner to sudden risks such as equipment degradation.
[0005] 3. Scheduling decisions rely solely on the current state, lacking predictability and leading to response delays: The existing scheduling mechanism makes scheduling decisions based solely on the current task queue state, failing to predict the resource requirements of upcoming high-priority tasks. It must wait for the tasks to arrive before preemption and resource reclamation are performed, which adds to the response delay of urgent tasks and cannot further reduce the response time of high-risk tasks.
[0006] 4. Only supports single-level preemption; high-priority tasks may be blocked in extreme scenarios: Existing preemptive scheduling only supports single-level preemption. When multiple tasks of different priorities trigger preemption simultaneously on the terminal, multi-level nested preemption is not supported. In scenarios where important tasks have already preempted general tasks, urgent tasks cannot quickly interrupt important tasks, and in extreme scenarios, there is still a delay in the response of security tasks. Furthermore, the context uses unified storage, which can easily lead to context data corruption under multi-level preemption, making it impossible to correctly recover task execution.
[0007] 5. Fixed resource quotas and timeout thresholds, poor compatibility with multiple hardware: The resource quotas and timeout thresholds of the existing solutions are fixed values and are designed only for specific hardware terminals. When the computing power and memory configuration of the terminal hardware changes, or the amount of task input data fluctuates, the fixed parameters cannot be adapted, which will either waste resources or cause the task to be misjudged and time out, making it difficult to adapt to different models of domestic edge terminals.
[0008] 6. Only supports single-terminal scheduling, resulting in unbalanced load in shift operation scenarios: The existing scheduling mechanism only targets resource scheduling within a single terminal. In the scenario of oilfield well station shift inspection, when multiple terminals are operating in the same area, some terminals have intensive tasks and insufficient computing power, while some terminals are idle and have idle resources. It is impossible to achieve task offloading and computing power collaboration between terminals, thus limiting the overall shift operation efficiency.
[0009] 7. Lack of task timeout control mechanism and insufficient reliability of critical tasks: The existing scheduling mechanism does not have a fault tolerance and handling mechanism for task execution timeout. When a single task is stuck due to data abnormality or temporary hardware failure, it will continue to occupy computing resources, causing subsequent critical tasks to be blocked. The execution timeout rate of critical tasks exceeds 8%, and the risk of task failure is high.
[0010] 8. Undifferentiated resource allocation leads to low overall system efficiency: Low-priority data upload and report generation tasks consume a large amount of CPU, NPU computing power, and memory resources, resulting in insufficient resource supply for high-priority tasks. Hardware resources cannot be allocated to core security tasks, leading to an imbalance between the overall system computing power utilization and task execution efficiency.
[0011] In summary, existing technologies cannot meet the industrial-grade scheduling requirements of "prioritizing safety tasks, ensuring the reliability of critical tasks, enabling efficient concurrent operation of multiple tasks, and facilitating collaborative operation of multiple terminals" in oilfield inspection scenarios. They lack complete technical solutions for graded priority scheduling, dynamic adaptive adjustment, predictive resource management, multi-level preemption and fault tolerance, and multi-terminal collaboration for oilfield explosion-proof handheld terminals, which has become the core technical bottleneck restricting the improvement of the reliability of intelligent inspection terminals in oilfields. Summary of the Invention
[0012] To address the aforementioned shortcomings of existing technologies, the present invention aims to provide a method and system for priority scheduling and resource preemption of multiple AI tasks concurrently on handheld terminals. Through an integrated design that incorporates three-level task priority grading and dynamic adaptive adjustment, predictive resource reservation scheduling, multi-level nested preemption and stack-based context management, graded timeout fault tolerance and parameter adaptive models, and cross-terminal collaborative scheduling, this invention solves industry pain points such as slow emergency task response, static priority starvation, high latency due to lack of prediction, poor adaptability of fixed parameters, and single-terminal load bottlenecks under existing scheduling models. It comprehensively ensures the priority execution and high reliability of high-risk safety tasks in oilfield inspection scenarios, and improves the overall efficiency of multi-terminal team operations.
[0013] To achieve the above objectives, the present invention provides the following technical solution: This invention provides a method for priority scheduling and resource preemption of multiple concurrent AI tasks on a handheld terminal, the method comprising the following steps: Step 1: Divide all AI tasks of oilfield inspection into three static priority levels, set up independent three-level ready queues of urgent, important and general tasks, and dynamically adjust the real-time priority of tasks based on waiting aging dynamic promotion rules and abnormal confidence trigger upgrade rules to complete the task classification and queuing sorting. Step 2: Based on the independent task ready queues established in Step 1 that correspond one-to-one with the three priority levels, manage tasks according to the basic scheduling rules of the hierarchical queue scheduling; use a sliding window weighted average model to predict task resource consumption based on historical execution data, combine terminal GPS positioning and pipeline risk map to make scenario predictions, reclaim computing power of low priority tasks in a hierarchical manner, and reserve hardware resources in advance for urgent and important tasks to achieve predictive scheduling. Step 3: Perform multi-level nested preemptive scheduling based on the real-time priority of the task, configure preset nested preemptive trigger rules to determine whether to initiate preemption; use a stack-style hierarchical structure to complete the context storage of the preempted task, and perform hierarchical context restoration operation after the high-priority task has finished executing; Step 4: Construct an adaptive calculation model for resource quotas and an adaptive calculation model for timeout thresholds; dynamically allocate hardware resource quotas for tasks at all levels and adaptively generate timeout thresholds for tiered tasks; monitor task running status in real time and use differentiated tiered fault-tolerant processing strategies to handle timeout tasks. Step 5: In the scenario of collaborative inspection by oilfield teams, load data of multiple handheld terminals is periodically collected through the regional edge gateway. Based on the preset unloading judgment conditions, the low-priority tasks of the source terminal are encrypted and migrated to the idle terminal for execution. After the execution is completed, the detection results are sent back to the source terminal for aggregation.
[0014] Furthermore, in step 1 of the present invention: The static three-level priority division rule is as follows: Priority value P=1 is the emergency level task, including oil and gas leak detection, fire alarm, and high-pressure equipment fault early warning; P=2 is the important level task, including equipment fault diagnosis, pipeline weld defect detection, and infrared thermal imaging temperature measurement; P=3 is the general level task, including inspection data upload, inspection report generation, and system log recording. The dynamic aging enhancement rule is expressed by the following formula:
[0015] in, This is the static baseline priority for the task. The cumulative waiting time of the task in the queue. For aging cycle, This is a floor function; The minimum value is 1; The specific rules for triggering escalation based on abnormal confidence levels are as follows: when the confidence level of a defect detected in real time during task execution exceeds a preset threshold, the priority of the task is automatically upgraded to the emergency level, and a preemption mechanism is immediately triggered to ensure execution.
[0016] Furthermore, in step 2 of the present invention: The basic rules of hierarchical queue scheduling are as follows: the scheduler prioritizes the execution of tasks in the emergency queue, and only when the emergency queue is empty will it execute tasks in the important queue. Only when there are no tasks in the emergency and important queues will the general queue tasks be scheduled. Within the same queue, tasks are sorted from high to low according to their dynamic priority. If the dynamic priorities are the same, tasks are scheduled according to the order in which they arrive. The sliding window weighted average model is as follows:
[0017] in, For predicted values, Let N be the actual value of the i-th historical execution, and N be the size of the historical data window. The weights correspond to the historical data.
[0018] Furthermore, in step 3 of the present invention: The nested preemption triggering rule is as follows: the determination condition is met. Preemption is triggered on time, and a maximum of two levels of nested preemption are supported based on the three-level priority system; when a general-level task is running, it can be preempted by a first-level important-level task, and when an important-level task is running, it can be preempted by a second-level urgent-level task. The stack-based hierarchical structure for storing context is as follows: a stack structure is used to store the context of the preempted task. The maximum depth of the context stack is set to 2. Each stack node stores the task ID, task priority, context data pointer, and preemption timestamp. After preemption is triggered, the current task is paused, and the complete context is encapsulated as a node and pushed onto the context stack. The context saving time is controlled within 10ms. The hierarchical context recovery operation process is as follows: after the high-priority task is completed, the preempted task nodes are popped out from the top of the context stack in sequence, the stored context data is read to restore the task breakpoint and continue execution, and the popping and recovery is continuously looped until the context stack is empty.
[0019] Furthermore, in step 4 of the present invention: The expression for the adaptive calculation model of resource quotas is:
[0020]
[0021] in, Total computing power of the terminal / total memory resources As the priority benchmark coefficient, For hardware compatibility coefficients, The actual NPU computing power of the terminal. This serves as the standard computing power benchmark.
[0022] Furthermore, in step 4 of the present invention: The expression for the adaptive calculation model of the timeout threshold is:
[0023]
[0024] in, Based on the timeout threshold, For data volume coefficient, The amount of input data for the current task. The standard input data volume for this type of task, This represents the hardware performance coefficient.
[0025] Furthermore, in step 5 of this invention: The hierarchical fault tolerance strategy is as follows: emergency-level tasks are forced to restart after timeout, and hardware self-checks are triggered and reported to the operation and maintenance platform after 3 consecutive failures; important-level tasks are moved to the tail of the corresponding queue after timeout and wait for rescheduling; general-level tasks are marked as failed after timeout and automatically retried during system idle periods.
[0026] Based on the same inventive concept, the priority scheduling and resource preemption method for concurrent multi-AI tasks on a handheld terminal described in this invention can be entirely implemented using computer software. Therefore, correspondingly, this invention also provides a priority scheduling and resource preemption system for concurrent multi-AI tasks on a handheld terminal.
[0027] Furthermore, the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the aforementioned method for priority scheduling and resource preemption of multiple AI tasks concurrently on a handheld terminal.
[0028] Furthermore, the present invention also provides a computer device including a memory and a processor, wherein the memory stores a computer program, and when the processor runs the computer program stored in the memory, the processor executes the priority scheduling and resource preemption method for concurrent multi-AI tasks on a handheld terminal described above.
[0029] The beneficial effects of this invention are as follows: 1. This invention constructs a priority scheduling system with a three-level static benchmark and a two-dimensional dynamic adjustment: the priority is divided into three levels based on the safety level differences of oilfield inspection tasks, and a two-dimensional dynamic adjustment rule of waiting aging enhancement and anomaly confidence upgrade is designed. This avoids starvation of low-priority tasks and can respond to the dynamic changes in equipment anomaly risks, achieving a balance between the flexibility and reliability of priority scheduling.
[0030] 2. This invention proposes a predictive scheduling mechanism that integrates historical data prediction and scenario prediction: a sliding window weighted average model is used to predict task resource requirements, and oilfield pipeline risk maps and terminal positioning information are combined to reserve resources in high-risk areas in advance, thereby bringing forward the response to emergency tasks, further reducing the response delay of high-risk tasks, and breaking through the performance bottleneck of traditional passive scheduling.
[0031] 3. This invention designs a multi-level nested preemption and stack-based context hierarchical management mechanism: it supports up to two levels of nested preemption, adapting to extreme scenarios where multiple tasks overlap in oil fields; it adopts a stack-based structure to store task context hierarchically, ensuring that tasks can be restored correctly in order under multi-level preemption, which not only improves the response capability of emergency tasks in extreme scenarios, but also avoids the duplication and waste of computing resources.
[0032] 4. This invention establishes a parameter adaptive mathematical model for hardware adaptation: a general adaptive calculation model is designed for resource quotas and timeout thresholds, which can dynamically adjust scheduling parameters according to the actual hardware computing power of the terminal and the amount of task input data, solving the problem of poor adaptability of fixed parameters, and can be seamlessly adapted to different models of domestically produced edge AI terminals.
[0033] 5. This invention expands the cross-terminal collaborative scheduling mechanism for oilfield work team scenarios: targeting oilfield well station work team inspection scenarios, load monitoring and task offloading between multiple terminals are realized through edge gateways, extending single-terminal scheduling to regional multi-terminal collaborative scheduling, solving the single-terminal computing power bottleneck problem, and improving the overall inspection operation efficiency of the work team.
[0034] 6. This invention is deeply adapted to the industrial scenario of oilfield inspection: all scheduling rules and parameters are customized around the safety requirements of oilfield inspection, and can be directly adapted to the hardware architecture of domestically produced oilfield explosion-proof handheld terminals, meeting the high reliability scheduling requirements in harsh industrial environments.
[0035] This invention is specifically applied to the concurrent scheduling of multiple AI inference tasks on domestically produced handheld terminals in oilfield field inspection scenarios. In particular, it relates to a mechanism for priority scheduling, dynamic adaptive adjustment, and resource preemption of multiple AI tasks for oilfield inspection handheld terminals. This mechanism can ensure the priority execution and high reliability of high-priority tasks such as oil and gas leak detection and equipment fault alarms. It is compatible with the heterogeneous computing power scheduling requirements of domestically produced edge AI chips such as RK3588, and supports multi-terminal team collaborative scheduling and adaptive configuration of hardware parameters, meeting the full-scenario scheduling requirements of complex field operation environments in oilfields. Attached Figure Description
[0036] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0037] Figure 1 This is an overall flowchart of the priority scheduling and resource preemption method for concurrent multi-AI tasks on a handheld terminal according to the present invention. Figure 2 This is a flowchart illustrating the core workflow of the present invention; Figure 3 This invention provides a comparison of the average waiting time for low-priority users. Figure 4 This is a pie chart comparing the hunger rate of general-level tasks in this invention; Figure 5 This invention provides a comparison of response times for high-confidence defective tasks. Figure 6 This is a comparison of the average response time for emergency tasks in this invention; Figure 7 A line chart showing the hit rate reserved for resources in this invention; Figure 8 This is the task response time distribution in high-risk areas of the present invention; Figure 9 This invention provides a comparison of emergency task response times under two levels of nesting. Figure 10 This is a line graph showing the distribution of context switching time in this invention. Figure 11 This is a comparison of the accuracy of task breakpoint recovery in this invention. Figure 12 This invention provides a comparison of task timeout false positive rates under different hardware conditions. Figure 13 This invention provides a comparison of task timeout false positive rates under different data volumes. Figure 14 This is a line graph comparing the computing power utilization of different hardware in this invention; Figure 15 This invention provides a comparison of the overall task completion time for the work teams. Figure 16 This is a bar chart comparing the peak computing power usage of each terminal in this invention; Figure 17 This is a line graph showing the success rate of task migration and the data transmission time of this invention. Detailed Implementation
[0038] The specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings. The following examples will help those skilled in the art to further understand the present invention, but do not limit the present invention in any way. It should be noted that those skilled in the art can make several changes and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention.
[0039] Example 1: To address the aforementioned shortcomings of existing technologies, this example aims to provide a priority scheduling and resource preemption method for concurrent multi-AI tasks on handheld terminals. Through a three-level task priority classification and dynamic adaptive adjustment, predictive resource reservation scheduling, multi-level nested preemption and stack-based context management, hierarchical timeout fault tolerance and parameter adaptive model, and cross-terminal collaborative scheduling integrated design, this method solves industry pain points in existing scheduling models such as slow emergency task response, static priority prone to starvation, high latency due to lack of prediction, poor adaptability of fixed parameters, and single-terminal load bottlenecks. It comprehensively ensures the priority execution and high reliability of high-risk safety tasks in oilfield inspection scenarios, improving the overall efficiency of multi-terminal team operations.
[0040] The method includes the following steps: Step 1: Divide all AI tasks of oilfield inspection into three static priority levels, set up independent three-level ready queues of urgent, important and general tasks, and dynamically adjust the real-time priority of tasks based on waiting aging dynamic promotion rules and abnormal confidence trigger upgrade rules to complete the task classification and queuing sorting. Step 2: Based on the independent task ready queues established in Step 1 that correspond one-to-one with the three priority levels, manage tasks according to the basic scheduling rules of the hierarchical queue scheduling; use a sliding window weighted average model to predict task resource consumption based on historical execution data, combine terminal GPS positioning and pipeline risk map to make scenario predictions, reclaim computing power of low priority tasks in a hierarchical manner, and reserve hardware resources in advance for urgent and important tasks to achieve predictive scheduling. Step 3: Perform multi-level nested preemptive scheduling based on the real-time priority of the task, configure preset nested preemptive trigger rules to determine whether to initiate preemption; use a stack-style hierarchical structure to complete the context storage of the preempted task, and perform hierarchical context restoration operation after the high-priority task has finished executing; Step 4: Construct an adaptive calculation model for resource quotas and an adaptive calculation model for timeout thresholds; dynamically allocate hardware resource quotas for tasks at all levels and adaptively generate timeout thresholds for tiered tasks; monitor task running status in real time and use differentiated tiered fault-tolerant processing strategies to handle timeout tasks. Step 5: In the scenario of collaborative inspection by oilfield teams, load data of multiple handheld terminals is periodically collected through the regional edge gateway. Based on the preset unloading judgment conditions, the low-priority tasks of the source terminal are encrypted and migrated to the idle terminal for execution. After the execution is completed, the detection results are sent back to the source terminal for aggregation.
[0041] Furthermore, in one specific embodiment, combined with Figure 1 and Figure 2 The method is described in its entirety; This invention constructs a technical solution based on a closed-loop scheduling logic of "tiered queuing - dynamic optimization - predictive reservation - preemptive scheduling - fault tolerance - cross-platform collaboration". It achieves priority scheduling and resource preemption for multiple AI tasks from three dimensions: system-level architecture, core functional modules, and full-process execution logic. The specific details are as follows: 1. System Overall Architecture The system architecture of this invention is divided into six layers from bottom to top, with data interconnection and collaborative operation at each layer, fully covering the entire link management from hardware resources to cross-terminal collaboration: Hardware resource layer: includes four types of core hardware resources for handheld terminals: ARM CPU computing power, RK3588 NPU computing power, RAM, and storage bandwidth, providing a platform for AI tasks to run. Resource quota layer: Based on the parameter adaptive mathematical model, it dynamically allocates hardware resource quota limits to tasks of different priority levels according to task priority level and terminal hardware capabilities, so as to tilt computing power and memory resources towards high priority tasks. Task queue layer: Set up three independent task ready queues of urgent, important and general, support dynamic adjustment of task priority and queue reordering, realize hierarchical classification and dynamic management of tasks; Predictive scheduling layer: Based on historical task execution data and scene location information, predict the resource requirements of future tasks, make resource reservation and scheduling decisions in advance, and reduce the response latency of high-priority tasks; Scheduling and execution layer: Executes multi-level nested preemptive scheduling logic, where higher priority tasks can preempt the hardware resources of lower priority tasks in turn, and achieves automatic saving and breakpoint recovery of task context through stack-based context management; Fault tolerance management layer: Sets adaptive timeout thresholds for tasks of different priorities, monitors task execution status in real time, and performs hierarchical fault tolerance processing on timeout tasks; it also supports cross-terminal collaborative scheduling to achieve task offloading and load balancing among multiple terminals.
[0042] 2. Core Functional Module Design (1) Three-level task priority and dynamic adaptive adjustment mechanism Based on the static three-level priority system, a two-dimensional dynamic priority adjustment rule is introduced to avoid starvation of low-priority tasks and adapt to scenarios with dynamically changing task risks. The core design is as follows: ① Static priority benchmark division Based on the safety level and real-time requirements of oilfield inspection tasks, all AI tasks are divided into three priority baseline levels: Emergency-level tasks (priority value P=1): These include three types of AI tasks directly related to production safety: oil and gas leak detection, fire alarm, and high-voltage equipment failure early warning, with a baseline resource quota of 100%. Important tasks (priority value P=2): These include AI tasks related to the operational safety of three types of equipment: equipment fault diagnosis, pipeline weld defect detection, and infrared thermal imaging temperature measurement, with a base resource quota of 50%. General-level tasks (priority value P=3): include three types of non-real-time and non-security background tasks: inspection data upload, inspection report generation, and system log recording, with a base resource quota of 20%.
[0043] ② Waiting for aging dynamic improvement rules To avoid the starvation problem of low-priority tasks remaining unschedulable for extended periods, the execution priority of tasks waiting in the queue is aged up and increased: Dynamic priority calculation formula:
[0044] in, This is the static baseline priority for the task. The cumulative waiting time of the task in the queue. The aging cycle is set to 10 seconds. This is a floor function; The minimum value is 1, meaning the highest level that can be raised is emergency.
[0045] When a task is scheduled for execution, its priority is restored to the original static priority; after the task is completed, it is removed from the queue and the aging count is cleared to zero.
[0046] ③ Abnormal confidence level triggers upgrade rules For critical tasks such as equipment fault diagnosis and weld defect detection, when the confidence level of a defect detected in real time during task execution exceeds a preset threshold (e.g., confidence level ≥ 0.8), the priority of the task is automatically upgraded to the emergency level, and the preemption mechanism is immediately triggered to ensure execution, so as to ensure that suspected serious equipment defects can be identified and confirmed first and avoid failure to be detected.
[0047] (2) Hierarchical task queue and predictive resource reservation scheduling mechanism Set up independent task ready queues corresponding one-to-one with the three priority levels, and combine historical execution data prediction and scenario prediction to achieve predictive scheduling with advance resource reservation: ① Basic rules of hierarchical queue scheduling The scheduler follows the principle of "absolute priority for high-priority queues, dynamic priority sorting within the same queue, and first-come, first-served for queues of the same priority": When a new task arrives, it is placed into the corresponding ready queue according to the static priority label; The scheduler prioritizes retrieving tasks from the urgent task queue for execution. If the urgent task queue is empty, it then retrieves tasks from the important task queue for execution. Only when both of the first two queues are empty will tasks from the general task queue be executed. Tasks within the same queue are sorted from highest to lowest dynamic priority. If dynamic priorities are the same, they are sorted by arrival time.
[0048] ②Task resource requirement forecasting methods Based on the sliding window weighted average model, predictions are made using historical execution data of similar tasks: Data collection dimensions: Record the input data volume (image resolution, number of frames), average NPU computing power utilization, peak memory usage, actual execution time, and whether timeout occurred for each type of task; Weighted prediction formula:
[0049] in, These are predicted values (execution time / computing power usage / memory usage). Let N be the actual value of the i-th historical execution, and N be the size of the historical data window (taken as 10). The weights are assigned to historical data, with more recent historical data having higher weights.
[0050] ③Scenario-based resource reservation By combining GPS positioning information from oilfield inspection terminals with pipeline risk level maps, when the terminal enters high-risk well sites or high-risk pipeline sections, it is predicted that high-priority tasks such as oil and gas leak detection and equipment fault diagnosis will be triggered intensively, and resource recovery will be performed in advance. Predictive trigger: When the terminal location matches a high-risk area, immediately initiate the resource reservation process; Reserved operations: Pause the scheduling and execution of general-level tasks, reclaim idle computing resources allocated to general-level tasks, and reserve at least 60% of NPU computing power for upcoming urgent / important tasks; Recovery mechanism: After the terminal leaves the high-risk area, resource reservation is lifted and normal hierarchical scheduling is restored.
[0051] (3) Multi-level nested preemption and stack-based context hierarchical management mechanism It supports up to two levels of nested preemption and ensures correct task recovery under multi-level preemption through a stack-based context storage mechanism. The specific design is as follows: ① Nested preemption triggering rules Strictly adhering to the rule that the lower the priority value, the higher the level, preemption is triggered as long as the priority of a newly arrived task is higher than that of the currently executing task, regardless of whether the task is currently in a preemption state.
[0052] in, Prioritize newly arriving tasks. This indicates the priority of the currently executing task.
[0053] This scheme has three priority levels, corresponding to a maximum of two levels of nesting: when a general-level task is executed, it can be preempted by an important-level task (first-level preemption); when an important-level task is executed, it can be preempted by an urgent-level task (second-level nesting preemption).
[0054] ② Stack-based context hierarchical storage A stack data structure is used to manage the context of preempted tasks, and a push operation is performed each time preemption is triggered: Stack node structure: Each stack node stores the task ID, task priority, context data pointer (including computing power register status, memory data status, task execution progress parameters), and preemption timestamp; Push operation: After preemption is triggered, the current task is paused, its complete context is encapsulated as a node and pushed onto the context stack. The saving process takes less than 10 milliseconds. After saving, the computing resources occupied by the task are released and allocated to new high-priority tasks. Stack depth limit: The maximum depth of the context stack is 2, which matches the three-level priority, to avoid excessive system overhead caused by infinite nesting.
[0055] ③ Hierarchical context recovery Once a high-priority task has completed execution, a stack pop and recovery operation is performed: Pop the most recently preempted task node from the top of the context stack, read the context data, restore the task's execution state, and resume execution from the paused progress breakpoint; The stack is popped and restored sequentially until the context stack is empty, returning to the initial task execution state; The recovery process only reallocates computing resources, and context data is read directly from the stack memory without reloading, ensuring recovery speed.
[0056] (4) Graded timeout fault tolerance and parameter adaptive adjustment model Adaptive timeout thresholds are set for tasks of different priorities, and dynamically adjusted based on hardware capabilities and task data volume to perform tiered fault tolerance processing. ① Resource quota adaptive calculation model Resource quotas are dynamically adjusted based on the computing power of the terminal hardware, using the following formula:
[0057]
[0058] in: Total computing power of the terminal / total memory resources; As the priority baseline coefficient, the urgency level Importance level General level ; For hardware compatibility coefficients, The actual NPU computing power of the terminal. The standard computing power benchmark is 6 TOPS for RK3588. The adjustment index is set to 0.5. Physical meaning: When the computing power of the terminal hardware is higher than the standard value, the upper limit of the resource quota for low-priority tasks is appropriately increased to improve resource utilization; when the computing power is lower than the standard value, the low-priority quota is reduced to ensure the resource supply for high-priority tasks.
[0059] ②Adaptive calculation model for timeout threshold The timeout threshold is dynamically adjusted based on the amount of task data and hardware capabilities, as shown in the following formula:
[0060]
[0061] in: The basic timeout thresholds are: 1 second for emergency level, 5 seconds for important level, and 30 seconds for general level. For data volume coefficient, The amount of input data for the current task. This represents the standard input data volume for this type of task; This is a hardware performance coefficient; the lower the hardware computing power, the longer the timeout threshold, in order to avoid false timeouts. Physical meaning: Taking into account both the data scale of the task itself and the performance of the terminal hardware, it can achieve more accurate timeout judgment and avoid false termination or missed fault judgment caused by fixed thresholds.
[0062] ③ Hierarchical fault tolerance strategy Emergency-level tasks: If the timeout occurs, the task will be forcibly terminated and restarted immediately. If the restart fails three times in a row, the system will trigger a self-check of hardware resources and report to the operation and maintenance platform. Important tasks: Forced termination upon timeout, moved to the tail of the corresponding task queue to await the next scheduling; General-level tasks: Forcefully terminate and mark as failed after timeout, and automatically retry when the system is idle.
[0063] (5) Cross-terminal collaborative scheduling and task offloading mechanism For oilfield team inspection scenarios, an edge gateway is used to achieve task collaboration and load balancing among multiple terminals. The specific design is as follows: ① Applicable Scenarios It is suitable for collaborative inspection scenarios of oilfield well stations and pipeline sections. 3-5 handheld terminals are networked in the same work area. When a single terminal has a large number of urgent tasks and insufficient computing power, non-core tasks are offloaded to nearby idle terminals to ensure the computing power supply for the terminal's safety tasks.
[0064] ② Communication method The communication architecture adopts an industrial-grade Wi-Fi 6 LAN as the main network and LoRa wireless communication as a backup. Portable edge gateways are set up in the area as collaborative scheduling nodes. Each terminal maintains periodic heartbeat communication with the gateway, reporting its own load status and task queue information. The communication latency is less than 50 milliseconds, meeting the reliability requirements of industrial sites.
[0065] ③Task migration execution process 1. Load monitoring: Each terminal reports CPU / NPU utilization, task queue length at each level, and priority of the currently executing task to the edge gateway every 2 seconds; 2. Scheduling decision: The edge gateway coordinating scheduler monitors the load of each terminal in real time. When a terminal meets the offloading trigger condition of "emergency task count ≥ 2 and NPU utilization > 80%", it selects idle terminals with NPU utilization < 30% in the area as target terminals. 3. Task Migration: General-level tasks (inspection report generation, system log processing, etc.) from the source terminal are migrated to the target terminal. The migration includes task input data, model weight files, and task execution context. The migrated data is encrypted using AES-256 industrial encryption to ensure the security of oilfield inspection data. 4. Result feedback: After the target terminal completes the task, it sends the result data back to the source terminal through the edge gateway. The source terminal then summarizes the inspection data to ensure the integrity of the inspection data.
[0066] Example 2: This example illustrates the technical solution of the present invention in conjunction with a specific application scenario; (I) Implementation Scenarios and Hardware Environment This embodiment is applied to the field pipeline inspection team operation scenario in Daqing Oilfield. The terminal equipped with this dispatch mechanism is a domestically produced oilfield explosion-proof handheld terminal. The hardware and system configuration are as follows: Core computing chip: Rockchip RK3588, integrating an 8-core ARM CPU and a 6-TOPS computing power NPU; RAM: 8GB LPDDR 4X; Operating system: OpenEuler 22.03 LTSSP3 Industrial Edition; Networking equipment: One portable industrial edge gateway, supporting dual-mode communication of Wi-Fi 6 and LoRa; Number of terminals: 4 explosion-proof handheld terminals form an inspection team; Concurrent AI tasks: Oil and gas leak detection (emergency level), infrared thermal imaging fault diagnosis (important level), pipeline weld defect detection (important level), inspection data upload (general level), and inspection report generation (general level).
[0067] (II) Specific Implementation Process of the Scheduling Mechanism Step 1: System Initialization and Parameter Configuration Upon system startup, the initial configuration of three-level priority baseline parameters, adaptive model, context stack, and cooperative communication is completed. Define the static priority mapping rules for tasks: Oil and gas leak detection and fire alarm tasks are marked as emergency level (priority 1), with a baseline resource quota of 100% and a basic timeout threshold of 1 second; Equipment fault diagnosis and weld defect detection are marked as important level (priority 2), with a baseline resource quota of 50% and a basic timeout threshold of 5 seconds; Data upload and report generation are marked as general level (priority 3), with a baseline resource quota of 20% and a basic timeout threshold of 30 seconds.
[0068] Initialize three independent task ready queues: urgent, important, and general. Initialize a stack-style context buffer, reserve 256MB of dedicated memory for storing stack-style context data, and set the maximum stack depth to 2.
[0069] The parameter adaptive model is loaded, and the hardware adaptation coefficient α_hw=1.0 of the current terminal is calculated based on the 6TOPS computing power of RK3588.
[0070] Start the scheduling daemon process to monitor the task queue status, task execution status, and hardware resource utilization in real time; start the cross-terminal collaborative communication process to establish a heartbeat connection with the regional edge gateway.
[0071] Step 2: Task enqueuing and dynamic priority scheduling When the inspection terminal starts its routine operations, each AI task is generated sequentially and enters its corresponding priority queue, with the dynamic priority mechanism running synchronously: During routine terminal inspections, pipeline weld inspection and report generation tasks are sequentially placed into the important queue and the general queue. The scheduler executes the weld inspection task first, allocating no more than 50% of the NPU computing power, according to priority. The remaining idle resources are used to run the report generation task, allocating no more than 20% of the computing power.
[0072] If a report generation task waits in the general queue for more than 10 seconds without being scheduled, the waiting aging rule is triggered, the dynamic priority is increased to 2, and it is moved to the tail of the important queue to obtain a higher scheduling priority, thus avoiding prolonged starvation.
[0073] During the execution of a weld inspection task, if a defect confidence level of 0.85 is detected in a certain weld section, exceeding the abnormal threshold, the confidence level escalation rule is immediately triggered, the task priority is upgraded to emergency level, it is moved into the emergency queue, and it obtains the highest scheduling authority.
[0074] Step 3: Predictive resource reservation and multi-level nested preemption (1) Scene prediction and resource reservation When the inspection terminal enters a high-risk pipeline section area via GPS positioning, predictive resource reservation is triggered: The system immediately pauses the execution of general-level report generation tasks, reclaims the NPU computing resources they occupy, and reserves 65% of the NPU computing power for the upcoming oil and gas leak detection task.
[0075] Once the terminal arrives at the detection point, the oil and gas leak detection task is generated and enters the emergency queue. The system directly uses the reserved resources to start the task execution without the need for additional preemption and recovery, further reducing response latency.
[0076] (2) Multi-level nested preemptive execution In extreme scenarios, the terminal triggers multiple levels of tasks simultaneously, executing two levels of nested preemption: The current terminal is executing a general-level report generation task. At this time, a pipeline weld defect detection task (important level) is generated, triggering a first-level preemption: the report generation task is paused, its context is pushed onto the context stack, and resources are released to execute the weld detection task.
[0077] During the execution of the weld inspection task, the oil and gas leak detection task is triggered (emergency level), triggering a second-level nested preemption: the weld inspection task is paused, its context is pushed onto the context stack (the stack depth is 2 at this time), and all resources are released to execute the oil and gas leak detection task.
[0078] After the oil and gas leak detection task is completed, the context of the weld seam detection task is popped from the top of the stack and execution resumes; after the weld seam detection task is completed, the context of the report generation task is popped and execution resumes.
[0079] Both context saves took less than 8 milliseconds, and task recovery continued from the breakpoint without duplicate calculations.
[0080] Step 4: Adaptive Timeout Fault Tolerance The scheduling daemon tracks the execution time of each task in real time and uses adaptive thresholds to implement tiered fault tolerance. A general-level report generation task was affected by a doubling of the monthly inspection data volume, with the input data volume being twice the standard value. The system automatically calculated the data volume coefficient γ_data=2 and adjusted the timeout threshold to 60 seconds. The task ultimately took 45 seconds to execute, without triggering the timeout judgment, thus avoiding accidental termination caused by the fixed threshold.
[0081] If an emergency leak detection task takes close to the 1-second threshold due to a temporary hardware failure, the system will prioritize the supply of computing power to the task. If the task is not completed within 1 second, it will be forcibly terminated and immediately restarted. If the task fails 3 times in a row, the system will trigger a hardware self-check and report to the oilfield operation and maintenance platform.
[0082] Step 5: Unload cross-device collaborative tasks When the work team was inspecting a large well site, terminal 1 triggered multiple detection tasks simultaneously, resulting in excessive load and triggering collaborative scheduling. Terminal 1's NPU utilization reached 87%, and there were 2 tasks to be executed in the emergency queue, which met the offload triggering conditions. The load status was reported to the gateway.
[0083] The edge gateway found that the NPU utilization of terminal 3 was only 22%, indicating that it was in an idle state, and issued an unload command to terminal 1.
[0084] Terminal 1 encrypts the two general-level report generation tasks to be executed and then migrates them to Terminal 3. Terminal 3 receives the data and starts execution.
[0085] After completing its task, Terminal 3 sends the results back to Terminal 1, which then aggregates the inspection data and completes the well site inspection.
[0086] (III) Verification of Implementation Results In the aforementioned Daqing Oilfield inspection scenario, the complete scheduling mechanism of this embodiment underwent a 72-hour continuous stability test. Simultaneously, 100 emergency task scenarios and 50 multi-task nesting scenarios were simulated. The results were compared with the traditional first-come, first-served scheduling mode and the basic three-level priority scheduling mode. The test results are as follows:
[0087] Test results show that, based on the original three-level scheduling, this invention further improves the emergency task response speed, system stability, and scenario adaptability by adding five extended mechanisms, fully meeting the industrial-grade application requirements of oilfield field inspection.
[0088] In summary, this invention addresses the multi-AI task concurrency scenario of handheld terminals for oilfield inspections. Through the synergistic effects of hierarchical priority dynamic scheduling, predictive resource reservation, multi-level nested preemption, adaptive parameter configuration, and cross-terminal collaboration, it achieves the following quantitative technical effects: 1. Significantly improved emergency task response speed: The average response time for emergency tasks has been reduced from 5.7 seconds under the traditional first-come, first-served scheduling to less than 0.6 seconds, with a response speed improvement of 89.5%. Among them, predictive resource reservation can further reduce the response delay by 0.15 seconds, which fully meets the second-level response requirements of high-risk anomalies in oil fields.
[0089] 2. Significantly reduced task timeout risk: The overall task timeout rate decreased from 8.3% to 0.25%, a reduction of 97.0%; among them, emergency tasks had zero timeouts, completely eliminating the safety hazard of timeout failure for critical tasks; the adaptive threshold model reduced the task timeout misjudgment rate by 92%.
[0090] 3. Significantly improved success rate of critical tasks: The success rate of core safety tasks in the oilfield increased from 91.5% to 99.95%, and the reliability of task execution reached the industrial-grade high availability standard; the multi-level nested preemption mechanism reduced the blocking rate of emergency tasks to 0 in extreme multi-task scenarios.
[0091] 4. More rational use of hardware resources: The resource guarantee rate of high-priority tasks reaches 100%, while avoiding excessive resource consumption by low-priority tasks, and the overall computing power utilization rate of the system is improved by 35%; dynamic priority adjustment reduces the starvation rate of low-priority tasks by 98%, while taking into account scheduling fairness.
[0092] 5. Improved efficiency of multi-terminal collaboration: In the scenario of team inspection, cross-terminal collaborative scheduling reduces the peak computing power pressure of a single terminal by 40% and improves the overall task processing efficiency of the team by 28%, effectively solving the single-terminal load bottleneck problem during centralized inspection of well sites.
[0093] Example 3, Combination Figures 3 to 17 This embodiment illustrates the technical advantages of the present invention through five experiments. All experiments were designed based on real business data and scenarios of field inspections in Daqing Oilfield. The hardware used was the RK3588 explosion-proof handheld terminal used in the oilfield. The test dataset contained 1,000 sets of real oilfield inspection images and task sequences, covering all scenarios such as routine inspections, sudden anomalies, and team operations. Through comparative testing with existing technologies, the technological progress of this invention was quantitatively demonstrated.
[0094] Experiment 1: Performance Comparison Experiment of Dynamic Priority Adjustment Mechanism (1) Experimental objective The effectiveness and rationality of the dynamic priority adjustment mechanism in improving the starvation problem of low-priority tasks and the improvement of the response speed of equipment defect identification by the upgrade of anomaly confidence are verified.
[0095] (2) Experimental conditions Hardware platform: RK3588 explosion-proof handheld terminal, 8GB memory; Test tasks: 2 urgent tasks, 5 important tasks, and 8 general tasks, simulating a high-load inspection scenario for 2 consecutive hours; Defect Samples: Contains 20 sets of high-confidence weld defect samples, used to trigger anomaly escalation.
[0096] (3) Control group Control group A: Static three-level priority scheduling (original scheme); Experimental group B: Dynamic priority scheduling scheme of the present invention.
[0097] The results are as follows Figures 3 to 5 As shown, during field inspections in oilfields, safety-related tasks consistently have the highest priority, while report and log tasks often remain unexecuted for several hours, leading to delays in data aggregation. Furthermore, failure to prioritize the identification of initial equipment defects can easily trigger subsequent production risks. This mechanism reduces the average waiting time for general-level tasks from 42 seconds to 11 seconds and lowers the starvation rate from 3.5% to 0.12%, ensuring timely data aggregation. The response speed for high-confidence defect tasks is improved by 65%, enabling priority identification in the early stages of equipment degradation, significantly reducing the risk of missed fault detection in oilfield equipment, and aligning with the oilfield's scheduling requirements of "safety first, efficiency second."
[0098] Experiment 2: Performance Comparison Experiment of Predictive Scheduling Mechanisms (1) Experimental objective Verify the effect of predictive scheduling based on historical data prediction and scenario forecasting on reducing emergency task response time, and verify the hit rate and accuracy of resource reservation.
[0099] (2) Experimental conditions Hardware platform: RK3588 explosion-proof handheld terminal, 8GB memory; Test scenario: Simulates the inspection terminal traveling along a high-risk pipeline section, periodically triggering oil and gas leak detection tasks, with a total of 100 emergency task triggers; Input data: Real GPS trajectory and risk map data of a high-risk pipeline section in Daqing Oilfield.
[0100] (3) Control group Control group A: Unpredictable passive preemptive scheduling (original scheme); Experimental group B: Predictive scheduling scheme of the present invention.
[0101] The results are as follows Figures 6 to 8 As shown, high-risk areas such as oilfield wellheads and gathering pipelines are frequent sites of oil and gas leaks. Traditional passive scheduling requires resources to be secured only after a task is triggered, adding hundreds of milliseconds of delay and making it impossible to complete detection quickly in the early stages of a leak. This solution combines pipeline risk maps and terminal positioning, reserving computing power in advance upon entering high-risk areas. This reduces the average response time for emergency tasks from 0.72 seconds to 0.58 seconds, achieving a resource reservation hit rate of 94% and improving leak detection initiation speed by 19.4%. This mechanism is deeply adapted to the route-oriented and regionalized operation characteristics of oilfield inspections, prioritizing safety assurance, further compressing the response window for high-risk anomalies, and improving the inherent safety level of field inspections.
[0102] Experiment 3: Verification Experiment of Multi-level Nested Preemption Mechanism (1) Experimental objective Verify the correctness of task context saving and restoration under multi-level nested preemption, test the response speed and system overhead of emergency tasks in nested scenarios, and verify the scheduling reliability under extreme scenarios.
[0103] (2) Experimental conditions Hardware platform: RK3588 explosion-proof handheld terminal, 8GB memory; Test scenario: Simulate extreme multi-task overlay, construct a two-level nested preemption scenario of "general level - important level - urgent level", and repeat the test 50 times; Monitoring metrics: context saving / restoration time, task breakpoint recovery accuracy, and emergency task response time.
[0104] (3) Control group Control group A: Single-level preemptive scheduling (original scheme); Experimental group B: Multi-level nested preemptive scheme of the present invention.
[0105] like Figures 9 to 11 As shown, during the inspection of large well sites in oilfields, the terminal needs to simultaneously perform multiple tasks such as weld inspection, infrared thermography, and leak detection. This can easily lead to overlapping scenarios where multiple tasks are triggered sequentially. Under single-level preemption, emergency tasks must wait for important tasks to complete their preemption process, resulting in response delays. This solution supports two-level nested preemption, allowing emergency tasks to directly interrupt ongoing important tasks. This reduces the emergency task response time from 1.2 seconds to 0.6 seconds in extreme scenarios, improving response speed by 50%. Context stack management ensures 100% task recovery accuracy, eliminating redundant computation. This mechanism guarantees zero-latency response for the highest-level safety tasks in complex well site inspection scenarios, preventing the risk of safety detection delays caused by overlapping multiple tasks.
[0106] Experiment 4: Adaptive Model Fit Experiment (1) Experimental objective Verify the adaptability of the parameter adaptive mathematical model to different hardware terminals and tasks with different data volumes, and compare the timeout false judgment rate and resource utilization rate of the fixed parameter scheme.
[0107] (2) Experimental conditions Hardware platform: The terminals use two domestically produced edge computing chips, RK3588 (6TOPS) and RK3568 (2TOPS). Test tasks: 30 sets of each level of tasks with standard data volume and double the data volume; Monitoring indicators: task timeout misjudgment rate, resource utilization rate, and average task execution time.
[0108] (3) Control group Control group A: Fixed quota + fixed timeout threshold (original scheme); Experimental group B: Adaptive parameter scheme of the present invention.
[0109] like Figures 12 to 14 As shown, oilfield inspection terminals exist in different generations and with varying computing power. Furthermore, the amount of inspection data varies significantly between different well stations. Fixed-parameter solutions are prone to frequent task timeouts for low-spec terminals and resource waste for high-spec terminals. This adaptive model reduces the task timeout misjudgment rate of the RK3568 low-spec terminal from 12.3% to 0.8%, and increases the computing power utilization rate of the RK3588 high-spec terminal from 68% to 78%, reducing the timeout misjudgment rate by 92% under different data volumes. This mechanism allows the scheduling scheme to seamlessly adapt to multiple models of domestically produced terminals in oilfields, eliminating the need for individual parameter tuning for each hardware model, significantly reducing on-site operation and maintenance costs, and meeting the needs of large-scale deployment of oilfield terminals.
[0110] Experiment 5: Cross-Terminal Collaborative Scheduling Team Efficiency Experiment (1) Experimental objective Verify the effect of cross-terminal collaborative scheduling on improving the overall efficiency of team inspections, and verify the reliability and data security of task unloading.
[0111] (2) Experimental conditions Hardware platform: 4 RK3588 explosion-proof handheld terminals + 1 portable edge gateway, Wi-Fi 6 networking; Test scenario: Simulates a large-scale well station team inspection, with single terminal peak load overload, a total of 10 well station inspection tasks; Monitoring indicators: overall task processing time of the work team, peak computing power usage of a single terminal, and task migration success rate.
[0112] (3) Control group Control group A: Single terminal independent scheduling (original scheme, no collaboration); Experimental group B: Cross-terminal collaborative scheduling scheme of the present invention.
[0113] like Figures 15 to 17 As shown, the inspection tasks at large joint stations and metering stations in oilfields are intensive. Within work teams, some terminals have concentrated tasks and insufficient computing power, while others have small task loads and idle resources, resulting in low overall inspection efficiency. This collaborative solution reduces the overall task processing time of the work team by 22%, decreases the peak computing power utilization of a single terminal from 92% to 55%, achieves a task migration success rate of 99.5%, and reduces data transmission time to less than 200 milliseconds. This mechanism is suitable for the work team-based operation mode in oilfields, solving the single-terminal computing power bottleneck through regional computing power sharing. It is particularly suitable for centralized inspection scenarios in large well sites and densely packed pipeline sections, improving work team inspection efficiency without increasing hardware costs, thus meeting the production needs of oilfields for cost reduction and efficiency improvement.
[0114] Example 4: The priority scheduling and resource preemption method for concurrent multi-AI tasks on a handheld terminal described above can be entirely implemented using computer software. Therefore, this example provides a priority scheduling and resource preemption system for concurrent multi-AI tasks on a handheld terminal.
[0115] Furthermore, in one specific embodiment, this embodiment provides a computer-readable storage medium storing a computer program, which is executed by a processor to perform the priority scheduling and resource preemption method for concurrent multi-AI tasks on a handheld terminal described above.
[0116] Those skilled in the art will understand that implementing all or part of the processes in the above embodiments can be accomplished by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk drive (HDD), or solid-state drive (SSD), etc.; the storage medium can also include combinations of the above types of memory.
[0117] Furthermore, in one specific embodiment, this embodiment provides a computer device, which includes a memory and a processor. The memory stores a computer program. When the processor runs the computer program stored in the memory, the processor executes the priority scheduling and resource preemption method for concurrent multi-AI tasks on a handheld terminal described above.
[0118] This embodiment provides a computer device. The hardware device in this part is a general model and is not shown in the figure. The system includes a processor and a memory, which can be connected by a bus or other means. The memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs and modules, as well as corresponding program instructions / modules. The processor executes various functional applications and data processing by running the non-transitory software programs, instructions and modules stored in the memory, so as to realize the above-mentioned methods and steps.
[0119] The memory may include a program storage area and a data storage area, wherein the program storage area may store the operating system and applications required for at least one function; the data storage area may store data created by the processor, etc. Furthermore, the memory may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory may optionally include memory remotely located relative to the processor, which can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, mobile communication networks, and combinations thereof.
[0120] One or more modules are stored in the memory. When the processor executes, it performs the method steps in the embodiments. In this way, the invention objective can be achieved through the method, apparatus and process of the present invention. The specific details of the computer device described above can be understood by referring to the relevant descriptions and effects in the embodiments, and will not be repeated here.
[0121] The above description of the technical solution provided by the present invention through several specific embodiments is intended to highlight the advantages and benefits of the technical solution provided by the present invention. However, the above-described specific embodiments are not intended to limit the present invention. Any reasonable modifications and improvements to the present invention, reasonable combinations of implementation methods and equivalent substitutions based on the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for priority scheduling and resource preemption for concurrent multi-AI tasks on a handheld terminal, characterized in that, The method includes the following steps: Step 1: Divide all AI tasks of oilfield inspection into three static priority levels, set up independent three-level ready queues of urgent, important and general tasks, and dynamically adjust the real-time priority of tasks based on waiting aging dynamic promotion rules and abnormal confidence trigger upgrade rules to complete the task classification and queuing sorting. Step 2: Based on the independent task ready queues established in Step 1 that correspond one-to-one with the three priority levels, manage tasks according to the basic scheduling rules of the hierarchical queue scheduling; use a sliding window weighted average model to predict task resource consumption based on historical execution data, combine terminal GPS positioning and pipeline risk map to make scenario predictions, reclaim computing power of low priority tasks in a hierarchical manner, and reserve hardware resources in advance for urgent and important tasks to achieve predictive scheduling. Step 3: Execute multi-level nested preemptive scheduling based on the real-time priority of the task, and configure preset nested preemptive trigger rules to determine whether to initiate preemption; A stack-based hierarchical structure is used to store the context of preempted tasks, and a hierarchical context recovery operation is performed after the high-priority tasks have finished executing. Step 4: Construct an adaptive calculation model for resource quotas and an adaptive calculation model for timeout thresholds; dynamically allocate hardware resource quotas for tasks at all levels and adaptively generate timeout thresholds for tiered tasks; monitor task running status in real time and use differentiated tiered fault-tolerant processing strategies to handle timeout tasks. Step 5: In the scenario of collaborative inspection by oilfield teams, load data of multiple handheld terminals is periodically collected through the regional edge gateway. Based on the preset unloading judgment conditions, the low-priority tasks of the source terminal are encrypted and migrated to the idle terminal for execution. After the execution is completed, the detection results are sent back to the source terminal for aggregation.
2. The method according to claim 1, characterized in that, In step 1: The static three-level priority division rule is as follows: Priority value P=1 is the emergency level task, including oil and gas leak detection, fire alarm, and high-pressure equipment fault early warning; P=2 is the important level task, including equipment fault diagnosis, pipeline weld defect detection, and infrared thermal imaging temperature measurement; P=3 is the general level task, including inspection data upload, inspection report generation, and system log recording. The dynamic aging enhancement rule is expressed by the following formula: in, This is the static baseline priority for the task. The cumulative waiting time of the task in the queue. For aging cycle, This is a floor function; The minimum value is 1; The specific rules for triggering escalation based on abnormal confidence levels are as follows: when the confidence level of a defect detected in real time during task execution exceeds a preset threshold, the priority of the task is automatically upgraded to the emergency level, and a preemption mechanism is immediately triggered to ensure execution.
3. The method according to claim 1, characterized in that, In step 2: The basic rules of hierarchical queue scheduling are as follows: the scheduler prioritizes the execution of tasks in the emergency queue, and only when the emergency queue is empty will it execute tasks in the important queue. Only when there are no tasks in the emergency and important queues will the general queue tasks be scheduled. Within the same queue, tasks are sorted from high to low according to their dynamic priority. If the dynamic priorities are the same, tasks are scheduled according to the order in which they arrive. The sliding window weighted average model is as follows: in, For predicted values, Let N be the actual value of the i-th historical execution, and N be the size of the historical data window. The weights correspond to the historical data.
4. The method according to claim 1, characterized in that, In step 3: The nested preemption triggering rule is as follows: the determination condition is met. Preemption is triggered on time, and a three-level priority system supports up to two levels of nested preemption. A normal-level task can be preempted by a first-level important task, and an important task can be preempted by a second-level nested urgent task. The stack-based hierarchical structure for storing context is as follows: a stack structure is used to store the context of the preempted task. The maximum depth of the context stack is set to 2. Each stack node stores the task ID, task priority, context data pointer, and preemption timestamp. After triggering preemption, the current task is paused, the complete context is encapsulated as a node and pushed onto the context stack, and the context saving time is controlled within 10ms; The hierarchical context recovery operation process is as follows: after the high-priority task is completed, the preempted task nodes are popped out from the top of the context stack in sequence, the stored context data is read to restore the task breakpoint and continue execution, and the popping and recovery is continuously looped until the context stack is empty.
5. The method according to claim 1, characterized in that, In step 4: The expression for the adaptive calculation model of resource quotas is: in, Total computing power of the terminal / total memory resources As the priority benchmark coefficient, For hardware compatibility coefficients, For the actual NPU computing power of the terminal, This serves as the standard computing power benchmark.
6. The method according to claim 1, characterized in that, In step 4: The expression for the adaptive calculation model of the timeout threshold is: in, Based on the basic timeout threshold, For data volume coefficient, The amount of input data for the current task. The standard input data volume for this type of task, This represents the hardware performance coefficient.
7. The method according to claim 1, characterized in that, In step 4: The graded fault tolerance processing strategy is as follows: emergency-level tasks are forced to restart after timeout, and hardware self-check is triggered and reported to the operation and maintenance platform after 3 consecutive failures; important-level tasks are moved to the tail of the corresponding queue after timeout and wait for rescheduling; general-level tasks are marked as failed after timeout and automatically retried during system idle periods.
8. A priority scheduling and resource preemption system for concurrent multi-AI tasks on a handheld terminal, characterized in that, The system is used to implement the priority scheduling and resource preemption method for concurrent multi-AI tasks on a handheld terminal as described in any one of claims 1-7.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs a priority scheduling and resource preemption method for concurrent multi-AI tasks on a handheld terminal, as described in any one of claims 1-7.
10. A computer device, characterized in that, The device includes a memory and a processor. The memory stores a computer program. When the processor runs the computer program stored in the memory, the processor executes the priority scheduling and resource preemption method for concurrent multi-AI tasks in a handheld terminal as described in any one of claims 1-7.