Task scheduling method and device based on resource optimization
By performing task feature analysis and fine-grained resource allocation on PLC program blocks, the allocation and execution order of tasks in each core is optimized, and the problem of underutilization of CPU performance in the PLC system is solved, achieving efficient resource utilization and real-time response.
Patent Information
- Application Number
- CN202510380483.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-28
- Publication Date
- 2025-07-11
AI Technical Summary
Existing PLC systems fail to fully utilize CPU performance in task scheduling, resulting in low execution efficiency and unable to dynamically adjust policies to match new workloads, affecting real-time response requirements.
By performing task feature analysis on PLC program blocks, performing fine-grained time slice calculations and bandwidth resource allocation, building a task scoring model, optimizing the allocation and execution order of tasks in each core, ensuring resource utilization and real-time response.
It improves the overall performance and resource utilization of the PLC system under medium and high loads, meets the real-time response requirements, and maintains low computing overhead without affecting normal program execution.
Smart Images

Figure CN120295732A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of industrial automation, and particularly to a task scheduling method and device based on resource optimization. Background Art
[0002] PLC (Programmable Logic Controller) programs usually adopt a periodic scanning and execution method, and operations such as input sampling, program operation, and output update are sequentially executed in each scanning cycle. In order to improve control accuracy and response speed, modern PLCs often need to complete a large amount of data processing and complex calculation tasks within one scanning cycle.
[0003] In a PLC system, a program usually consists of multiple program blocks (such as function blocks, organization blocks, etc.). There are complex calculation characteristics, data access characteristics, and dependency relationships among these program blocks. Traditional scheduling methods usually execute in a fixed order determined at compile time, failing to fully utilize the performance of the CPU and unable to dynamically adjust the scheduling strategy to match the new workload after changes in input data and configuration status, resulting in low overall execution efficiency.
[0004] In view of this, the present application is specifically proposed. Summary of the Invention
[0005] The object of the present invention is to provide a task scheduling method and device based on resource optimization, which can fully utilize the computing resources, memory bandwidth, and cache resources of the system on the premise of meeting task dependency relationships and real-time requirements. By precisely allocating computing and bandwidth resources within fine-grained time slices, constructing a task scoring model with a higher matching degree, optimizing the allocation and execution order of tasks on each core, improving the overall performance and resource utilization rate of the system to meet the real-time response requirements of PLCs under medium and high loads. At the same time, ensure that the computational overhead of the optimization process remains at a low level to avoid affecting normal program execution.
[0006] The present invention is realized by the following technical solutions:
[0007] In a first aspect, the present invention provides a task scheduling method based on resource optimization, and the method includes:
[0008] Conduct task feature analysis on multiple program blocks in the PLC program to obtain feature information; the feature information includes calculation characteristics, data access characteristics, and dependency relationship characteristics;
[0009] According to the feature information, perform task slicing to obtain multiple subtasks, and each subtask corresponds to the execution of one time slice;
[0010] According to the multiple sliced subtasks, allocate the resource requirements to obtain the computing resource requirements and bandwidth resource requirements;
[0011] Based on the computing resource requirements and bandwidth resource requirements, perform resource matching score calculation to obtain the resource matching degree; the resource matching degree includes the computing resource matching score and the bandwidth resource matching score;
[0012] Based on the resource matching degree, calculate the scores of each subtask based on the task scoring model;
[0013] Based on the scores of each subtask, execute the scheduling algorithm for the task to be scheduled and perform resource constraint checking, assign the subtasks that pass the check to the execution queue, and update the resource status; re-enter the subtasks that do not pass the check into the ready queue.
[0014] Furthermore, the method further includes: storing the feature information in the feature database for use by the runtime scheduling algorithm.
[0015] Furthermore, based on the scores of each subtask, executing the scheduling algorithm for the task to be scheduled and performing resource constraint checking includes:
[0016] For each task to be scheduled, pre-collect or real-time statistics to obtain feature parameters; the feature parameters include task feature parameters and running parameters;
[0017] According to the feature parameters, divide the task to be scheduled into continuous subtasks and assign them to be executed in continuous time slices;
[0018] Based on all time slices t, traverse all cores k within each time slice and maintain a set of ready task queues;
[0019] For each subtask in the set of ready task queues, calculate its task score within core k and time slice t;
[0020] Based on the task score, perform resource constraint checking, assign the subtasks that pass the check to the execution queue, and update the resource status; re-enter the subtasks that do not pass the check into the ready queue.
[0021] Furthermore, the resource constraint checking includes:
[0022] Continuous resource availability check: Ensure that within the continuous time slices required by the task, both the computing resources and bandwidth resources can meet the requirements;
[0023] Cache capacity check: Ensure that the sum of the working set size S of the task and the current cache occupancy does not exceed the L2 cache capacity C of the CPU cache .
[0024] Furthermore, assigning the subtasks that pass the check to the execution queue and updating the resource status includes:
[0025] Allocate the tasks that meet the resource constraints to consecutive time slices \(t, t + 1,\cdots,t+N\) of core \(k\) for execution; and update the resource availability within each time slice, including computing resources and bandwidth resources. t-1 And update the resource availability within each time slice, including computing resources and bandwidth resources.
[0026] Furthermore, the task characteristic parameters include computing demand, bandwidth demand, estimated execution time, data locality, and working set size;
[0027] The operating parameters include CPU core computing power and CPU bandwidth availability.
[0028] Furthermore, the expressions for the computing demand allocation volume and the bandwidth demand allocation volume are:
[0029]
[0030] Among them, is the computing demand allocation volume; is the bandwidth demand allocation volume; \(C\) total is the computing demand; \(B\) total is the bandwidth demand; \(N\) t is the number of time slices required for the task.
[0031] Furthermore, the expression for the computing resource matching score is:
[0032]
[0033] The expression for the bandwidth resource matching score is:
[0034]
[0035] Among them, is the computing demand allocated to time slice \(t\) for the currently scheduled task; is the bandwidth demand allocated to time slice \(t\) for the currently scheduled task; is the CPU core computing power; is the CPU bandwidth availability.
[0036] Furthermore, the expression for the task scoring model is:
[0037]
[0038] Among them, \(\alpha\), \(\beta\), \(\gamma\), \(\delta\) are weight coefficients used to adjust the influence of each score in the total score; \(\eta\times N\) t is the influence of the task duration, \(N\) t is the number of time slices required for the task, and \(\eta\) is the weight coefficient; the higher the task score, the more suitable the task is to be scheduled on the current core and time slice.
[0039] In a second aspect, the present invention further provides a task scheduling device based on resource optimization, which includes:
[0040] A feature analysis unit for performing task feature analysis on multiple program blocks in a PLC program to obtain feature information; the feature information includes calculation features, data access features, and dependency relationship features;
[0041] A task sharding unit for performing task sharding according to the feature information to obtain multiple subtasks, and each subtask corresponds to the execution of a time slice;
[0042] A resource sharing unit for performing resource requirement sharing according to the multiple sharded subtasks to obtain calculation resource requirements and bandwidth resource requirements;
[0043] A resource matching scoring unit for performing resource matching scoring calculation according to the calculation resource requirements and bandwidth resource requirements to obtain a resource matching degree; the resource matching degree includes a calculation resource matching score and a bandwidth resource matching score;
[0044] A task scoring calculation unit for calculating the scores of each subtask based on the task scoring model according to the resource matching degree;
[0045] A task scheduling unit for performing a scheduling algorithm on the tasks to be scheduled and performing resource constraint checks based on the scores of each subtask, allocating the subtasks that pass the checks to the execution queue, and performing resource status updates; re-entering the subtasks that do not pass the checks into the ready queue.
[0046] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0047] The task scheduling method and device based on resource optimization of the present invention can fully utilize the computing resources, memory bandwidth, and cache resources of the system on the premise of meeting the task dependency relationship and real-time requirements. By precisely allocating computing and bandwidth resources within a fine-grained time slice, constructing a task scoring model with a higher matching degree, optimizing the allocation and execution order of tasks on each core, improving the overall performance and resource utilization rate of the system to meet the real-time response requirements of the PLC under medium and high loads. At the same time, ensure that the computational overhead of the optimization process remains at a low level to avoid affecting normal program execution. Description of the Drawings
[0048] The drawings described herein are used to provide a further understanding of the embodiments of the present invention, form a part of this application, and do not constitute a limitation to the embodiments of the present invention. In the drawings:
[0049] Figure 1 is a flowchart of the task scheduling method based on resource optimization of the present invention;
[0050] Figure 2 This is a detailed flowchart of the task scheduling method based on resource optimization of the present invention;
[0051] Figure 3 This is a structural block diagram of the task scheduling device based on resource optimization of the present invention. Specific embodiments
[0052] To make the objectives, technical solutions and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below with reference to the embodiments and the accompanying drawings. The illustrative embodiments of the present invention and their descriptions are only used to explain the present invention and are not intended to limit the present invention.
[0053] The present invention designs a task scheduling method and device based on resource optimization, which has the following advantages:
[0054] (1) Calculation and bandwidth resource allocation within fine-grained time slices: Multiple fine-grained time slices are divided within the execution cycle, and the computing resources and memory bandwidth resources within each time slice are managed separately to ensure that tasks can obtain the required resource support when being scheduled.
[0055] (2) Task scoring model based on resource matching degree: By calculating the computing resource matching score and bandwidth resource matching score of tasks, and combining data locality and working set size, the scheduling priority of tasks within the current core and time slice is evaluated.
[0056] (3) Task scheduling algorithm with resource constraints: During the task scheduling process, resource constraint conditions such as computing resources, memory bandwidth, and cache capacity are strictly checked to ensure the reasonable allocation and efficient utilization of system resources.
[0057] (4) Real-time collection and update of operating parameters: Through the performance monitoring module, system operating parameters are collected in real time, and the computing resource capacity of the core and the memory bandwidth availability of the system are dynamically updated to provide accurate data support for the scheduling algorithm.
[0058] (5) Optimization construction of core task groups: According to the resource requirement characteristics and data locality of tasks, tasks are reasonably allocated to each core to construct a core task group with load balancing and efficient operation.
[0059] (6) Dynamic weight adjustment mechanism: According to the operating state and performance objectives of the system, the weight coefficients of the task scoring model are dynamically adjusted to achieve the adaptive optimization of the scheduling strategy.
[0060] Embodiment 1
[0061] As Figure 1 shown, the task scheduling method based on resource optimization of the present invention includes:
[0062] S1. Analyze the task characteristics of multiple program blocks in the PLC program to obtain characteristic information; the characteristic information includes calculation characteristics, data access characteristics, and dependency relationship characteristics.
[0063] S2. According to the characteristic information, perform task sharding to obtain multiple subtasks, and each subtask corresponds to the execution of a time slice.
[0064] S3. According to the multiple subtasks after sharding, allocate the resource requirements, and obtain the calculation resource requirements and bandwidth resource requirements.
[0065] S4. According to the calculation resource requirements and bandwidth resource requirements, calculate the resource matching score to obtain the resource matching degree; the resource matching degree includes the calculation resource matching score and the bandwidth resource matching score.
[0066] S5. According to the resource matching degree, based on the task scoring model, calculate the scores of each subtask.
[0067] S6. Based on the scores of each subtask, execute the scheduling algorithm for the tasks to be scheduled and perform resource constraint checks, allocate the subtasks that pass the checks to the execution queue, and update the resource status; re-enter the subtasks that do not pass the checks into the ready queue.
[0068] In this embodiment, in step S1, during the program compilation stage, the present invention first performs a comprehensive characteristic analysis on the PLC program, including:
[0069] (1) Program block characteristic analysis
[0070] Analyze each program block to obtain the following characteristic information:
[0071] Calculation characteristics: including indicators such as the number of arithmetic instructions, the number of branch statements, and the complexity of loop structures, which are used to reflect its calculation complexity.
[0072] Data access characteristics: including the data area accessed and the data volume size, which are used to evaluate the frequency of memory access.
[0073] Dependency relationship characteristics: including input data dependency, output data dependency (identifying the data read and write dependency relationships between program blocks), control flow dependency (the order requirement for the execution of program blocks), etc.
[0074] Specifically, the dependency relationship characteristics include:
[0075] 1) Static dependency graph construction: During the compilation stage, analyze each program block and its input and output variables in the PLC program to form a static dependency graph, which depicts the call relationship and data read and write relationship between program blocks. When sharding the program blocks, use the dependency edges as the basic reference for sharding to ensure that each subtask still meets the data flow and control flow requirements after being split.
[0076] 2) Dynamic Dependency Conflict Detection: During the running phase, before each subtask applies for an execution location, it reports its latest dependency status to the scheduler, such as whether there are other subtasks that have not completed the write operation on a critical variable. In addition, additional version control or flag bit techniques can be selected to assign read and write version numbers to critical data. Once a read-write conflict or write-write conflict is detected, the system will prevent the conflicting tasks from executing in the same time slice or reschedule the relevant subtasks when necessary.
[0077] 3) Constraint Checking and Rollback Strategy: If a subtask finds that the dependency relationship has not been satisfied, it is determined as "not executable" during the resource constraint check, and it is sent back to the ready queue to wait for the previous task or data update to complete before applying for execution again. Through this mechanism, the data consistency risk during multi-task parallelism can be significantly reduced, ensuring the accuracy of the results and the stability of the operation.
[0078] (2) Feature Information Storage
[0079] The analyzed feature information is stored in the feature database, and the contents of the feature database are as follows:
[0080] Computational Features:
[0081] Number of Instructions: The total number of instructions contained in the program block, reflecting its computational complexity;
[0082] Operation Type: Such as arithmetic operations, logical operations, data transmission, etc.;
[0083] Loop Depth: The number of nested loops, affecting the execution time;
[0084] Data Access Features:
[0085] Accessed Data Region: Records the data address range read and written by the program block;
[0086] Data Volume Size: The amount of data accessed, affecting the memory bandwidth requirement;
[0087] Dependency Relationship Features:
[0088] Data Dependency: Which program blocks' outputs does the current program block depend on;
[0089] Control Dependency: The sequential constraint of program execution, such as the running priority requirement;
[0090] These feature information will be stored in the feature database for use by the runtime scheduling algorithm.
[0091] In this embodiment, in step S2, task sharding: A task that needs to be executed across multiple time slices is divided into multiple subtasks according to the time slices, and each subtask corresponds to the execution of one time slice.
[0092] Specifically, the fine-grained time slice division is as follows:
[0093] Execution cycle division: The execution cycle of the system (for example, 1 millisecond) is divided into multiple fine-grained time slices (for example, 20 time slices of 50 microseconds).
[0094] Time slice resource management: Within each time slice, the allocation of computing resources and memory bandwidth resources is independently managed; tasks are allowed to be executed across multiple time slices, supporting the scheduling of long-running tasks.
[0095] In this embodiment, in step S3, the calculation of resource demand sharing is as follows:
[0096]
[0097] Among them, is the calculated demand sharing amount; is the bandwidth demand sharing amount; C total is the computing demand; B total is the bandwidth demand; N t is the number of time slices required for the task.
[0098] In this embodiment, in step S4, the computing resource matching score The expression of is:
[0099]
[0100] The bandwidth resource matching score The expression of is:
[0101]
[0102] Among them, is the computing demand allocated to time slice t for the currently scheduled task; is the bandwidth demand allocated to time slice t for the currently scheduled task; is the computing power of the CPU core; is the CPU bandwidth availability.
[0103] It should be noted that: The closer the resource matching score is to 1, the more matching the resource demand of the task is to the available resources of the current time slice.
[0104] In this embodiment, in step S5, considering various characteristics of the task and the resource matching degree, a task scoring model is established; the expression of the task scoring model is:
[0105]
[0106] Among them, α, β, γ, and δ are weight coefficients used to adjust the influence of each score in the total score; η×N t is the influence of the task duration, and N t is the number of time slices required for the task, and η is the weight coefficient;
[0107] According to the running state and performance requirements of the system, the weight coefficients α, β, γ, δ, and η in the task scoring model are dynamically adjusted during operation to adapt to different workloads and optimization goals.
[0108] It should be noted that the higher the task score, the more suitable the task is to be scheduled within the current core and time slice.
[0109] In this embodiment, in step S6, based on the scores of each subtask, a scheduling algorithm is executed on the tasks to be scheduled and resource constraint checks are performed, including:
[0110] For each task to be scheduled, characteristic parameters are obtained by pre-collection or real-time statistics; the characteristic parameters include task characteristic parameters and running parameters;
[0111] According to the characteristic parameters, the tasks to be scheduled are divided into continuous subtasks and assigned to continuous time slices for execution;
[0112] Based on all time slices t, all cores k are traversed within each time slice, and a set of ready task queues is maintained;
[0113] For each subtask in the set of ready task queues, calculate its task score within core k and time slice t;
[0114] Based on the task score, resource constraint checks are performed, and the subtasks that pass the checks are assigned to the execution queue and the resource status is updated; the subtasks that do not pass the checks re-enter the ready queue.
[0115] Among them, the real-time collection of running parameters includes:
[0116] Performance monitoring module: Real-time monitor the usage of computing resources, memory bandwidth occupancy, and cache resource usage of each core.
[0117] Parameter update mechanism: According to the monitoring data, the remaining computing resource capacity of the core is updated in real time and the remaining available memory bandwidth of the system The actual computational requirement C of the task total The memory bandwidth requirement B total and the running time T exec .
[0118] Specifically, first, for each task to be scheduled, the following characteristic parameters are pre-collected or statistically obtained in real time:
[0119] Calculate the demand quantity C total : The amount of computing resources required during the execution of the task, usually expressed in computing time or the number of instructions.
[0120] Bandwidth demand quantity B total : The memory bandwidth required during the execution of the task, usually expressed in data transfer volume or bandwidth occupancy rate.
[0121] Estimated execution time T exec : The total time required to complete the task, which may span multiple time slices.
[0122] Data locality L: Reflects the data access locality of the task, the reuse rate of data in the cache, that is, the consistency of the memory access target address.
[0123] Working set size S: The amount of data required during the operation of the task, which affects the cache occupancy size.
[0124] Second, operating parameters, including:
[0125] CPU core computing power : The remaining computing resource capacity of the k-th core within the time slice t.
[0126] CPU bandwidth availability : The remaining available memory bandwidth of the system within the time slice t.
[0127] During specific implementation, during the operation of the program block, use the performance monitoring unit (PMU) of the CPU to collect the following performance data:
[0128] CPU cycle count: Measure the actual execution time of each program block;
[0129] Instruction count: Statistically count the number of instructions actually executed by the program block;
[0130] Cache performance metrics: Such as the number of cache hits and misses, to evaluate the usage efficiency of the cache;
[0131] Memory access statistics: Record the number of memory read and write operations, bandwidth usage;
[0132] CPU core utilization rate: Monitor the load situation of each core;
[0133] The collected data will be used to evaluate the current scheduling scheme and guide dynamic adjustment; it can also be used alone for independent scheduling optimization in scenarios where the compiler cannot provide characteristic data.
[0134] In the above process, the construction of the core task group is also involved. The specific task grouping strategy is as follows:
[0135] Computing resource matching: Allocate tasks with a high degree of matching between computing requirements and core computing capabilities to the corresponding cores to make full use of computing resources.
[0136] Data locality consideration: Allocate tasks with similar data access and high data locality to the same core or a core group sharing a cache to improve cache hit rate.
[0137] Load balancing: Balance the loads of all cores globally to prevent individual cores from being overloaded.
[0138] In specific implementation, the scheduling algorithm process of step S6 is as follows:
[0139] (1) Task preprocessing
[0140] Slice tasks: For tasks that require multiple time slices to complete, divide them into consecutive subtasks and allocate them to consecutive time slices for execution.
[0141] (2) Time slice and core iteration
[0142] For each execution cycle, traverse all time slices t. For tasks that need to span multiple time slices, ensure that these time slices are consecutive and the resources are available.
[0143] Within each time slice, traverse all cores k.
[0144] (3) Maintain the ready task queue. At time slice t and core k, maintain the set Q of all tasks whose dependencies are satisfied and have not been scheduled. k,t 。
[0145] (4) Task score calculation
[0146] For each task in Q k,t calculate its task score within core k and time slice t k,t , and at the same time consider the resource availability of subsequent consecutive time slices.
[0147] (5) Resource constraint check
[0148] Continuous resource availability check: Ensure that within the consecutive time slices required by the task, both computing resources and bandwidth resources can meet the requirements;
[0149] Cache capacity check: Ensure that the sum of the working set size S of the task and the current cache occupancy does not exceed the L2 cache capacity C of the CPU cache 。
[0150] (6) Task allocation and resource update
[0151] Allocate the tasks that meet the resource constraints to consecutive time slices t, t + 1, …, t + N of core k t-1 for execution;
[0152] And update the resource availability within each time slice, including computing resources and bandwidth resources.
[0153] (7) Task execution deferral
[0154] For tasks for which no consecutive time segment that meets the resource requirements can be found on the current time slice and core, defer them to subsequent time slices or adjust them to other cores for scheduling.
[0155] An operating example of the present invention is as follows:
[0156] System environment: A multi-core real-time system with an execution period of 1 millisecond, divided into 20 time slices of 50 microseconds each, and a total of 4 cores.
[0157] Task set: A number of tasks with different computing requirements and bandwidth requirements, having dependency relationships.
[0158] Scheduling process:
[0159] (1) Initialization: Collect task characteristic parameters and system resource status.
[0160] (2) Time slice and core iteration: Schedule each time slice and core according to the above scheduling algorithm process.
[0161] (3) Task allocation: Allocate tasks to appropriate cores and time slices according to task scores and resource constraints.
[0162] (4) Execution and monitoring: During the task execution process, the resource monitoring module updates the system resource status in real time.
[0163] The algorithm of the present invention can also be used for the case of a single core, that is, k = 1. In addition to real-time scheduling, at the beginning of each cycle, a program block execution queue for each core in this cycle can be generated, and the execution process is carried out in the order of the queue without further scheduling in the middle.
[0164] Embodiment 2
[0165] As Figure 3 shown, the difference between this embodiment and Embodiment 1 is that this embodiment provides a task scheduling device based on resource optimization, and the functions of this device correspond one-to-one with those of the task scheduling method based on resource optimization in Embodiment 1; this device includes:
[0166] A feature analysis unit for performing task feature analysis on multiple program blocks in the PLC program to obtain feature information; the feature information includes computing features, data access features, and dependency relationship features;
[0167] A task sharding unit, which is used to perform task sharding according to feature information to obtain multiple subtasks, and each subtask corresponds to the execution of a time slice;
[0168] A resource allocation unit, which is used to perform resource requirement allocation according to the multiple subtasks after sharding to obtain computing resource requirements and bandwidth resource requirements;
[0169] A resource matching scoring unit, which is used to perform resource matching scoring calculation according to the computing resource requirements and bandwidth resource requirements to obtain a resource matching degree; the resource matching degree includes a computing resource matching score and a bandwidth resource matching score;
[0170] A task scoring calculation unit, which is used to calculate the scores of each subtask based on the resource matching degree and the task scoring model;
[0171] A task scheduling unit, which is used to perform a scheduling algorithm on the task to be scheduled and perform resource constraint checking based on the scores of each subtask, allocate the subtasks that pass the check to the execution queue, and update the resource status; re-enter the subtasks that do not pass the check into the ready queue.
[0172] Among them, the execution process of each unit can be carried out according to the process steps of the resource-optimized task scheduling method in Embodiment 1, and will not be elaborated one by one in this embodiment.
[0173] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0174] The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram can be implemented by computer program instructions, and the combination of the processes and / or blocks in the flowchart and / or block diagram can also be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the specified functions in one Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0175] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to work in a particular manner, such that the instructions stored in the computer-readable memory produce a manufacture including an instruction device that implements the functions specified in one process or more processes and / or one block or more blocks in the process Figure 1 one process or more processes and / or Figure 1 one block or more blocks.
[0176] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus, such that a series of operational steps are performed on the computer or other programmable apparatus to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable apparatus provide steps for implementing the functions specified in one process or more processes and / or one block or more blocks in the process Figure 1 one process or more processes and / or Figure 1 one block or more blocks.
[0177] The specific embodiments described above further elaborate the objective, technical solution and beneficial effects of the present invention. It should be understood that the above description is only the specific embodiments of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A task scheduling method based on resource optimization, characterized in that The method includes: Performing task feature analysis on multiple program blocks in the PLC program to obtain feature information; the feature information includes calculation features, data access features, and dependency relationship features; According to the feature information, performing task sharding to obtain multiple subtasks, and each subtask corresponds to the execution of a time slice; According to the multiple subtasks after sharding, performing resource requirement sharing to obtain calculation resource requirements and bandwidth resource requirements; According to the calculation resource requirements and bandwidth resource requirements, performing resource matching score calculation to obtain a resource matching degree; the resource matching degree includes a calculation resource matching score and a bandwidth resource matching score; According to the resource matching degree, based on a task scoring model, calculating the scores of each subtask; Based on the scores of each subtask, performing a scheduling algorithm on the task to be scheduled and performing resource constraint checks, allocating the subtasks that pass the checks to the execution queue, and performing resource status updates; re-entering the subtasks that do not pass the checks into the ready queue.
2. The task scheduling method based on resource optimization according to claim 1, wherein The method further includes: storing the feature information in a feature database for use by the runtime scheduling algorithm.
3. The task scheduling method based on resource optimization according to claim 1, wherein Based on the scores of each subtask, performing a scheduling algorithm on the task to be scheduled and performing resource constraint checks, including: For each task to be scheduled, pre-collecting or real-time statistics to obtain feature parameters; the feature parameters include task feature parameters and operation parameters; According to the feature parameters, dividing the task to be scheduled into continuous subtasks and allocating them to be executed in continuous time slices; Based on all time slices t, traversing all cores k within each time slice and maintaining a set of ready task queues; For each subtask in the set of ready task queues, calculating its task score within core k and time slice t; Based on the task score, performing resource constraint checks, allocating the subtasks that pass the checks to the execution queue, and performing resource status updates; re-entering the subtasks that do not pass the checks into the ready queue.
4. The task scheduling method based on resource optimization according to claim 3, wherein The resource constraint checks include: Continuous resource availability check: ensuring that within the continuous time slices required by the task, both the calculation resources and bandwidth resources can meet the requirements; Cache capacity check: ensuring that the sum of the working set size S of the task and the current cache occupancy does not exceed the L2 cache capacity of the CPU.
5. The task scheduling method based on resource optimization according to claim 3, wherein Allocating the subtasks that pass the checks to the execution queue and performing resource status updates, including: Allocate the tasks that meet the resource constraints to the consecutive time slices t, t + 1, …, t + N of core k for execution; and update the resource availability within each time slice, including computing resources and bandwidth resources. t-1 6. The task scheduling method based on resource optimization according to claim 3, wherein The task feature parameters include calculation requirements, bandwidth requirements, estimated execution time, data locality, and working set size; The operation parameters include CPU core calculation ability and CPU bandwidth availability.
7. The task scheduling method based on resource optimization according to claim 1, characterized in that The expressions for the calculation requirement sharing amount and the bandwidth requirement sharing amount are: Among them, is the calculated demand sharing amount; is the bandwidth demand sharing amount; C total is the computing demand; B total is the bandwidth demand; N t is the number of time slices required for the task.
8. The task scheduling method based on resource optimization according to claim 1, characterized in that The calculation resource matching score has the following expression: The bandwidth resource matching score has the following expression: Among them, is the computing demand allocated to the current scheduled task in time slice t; is the bandwidth demand allocated to the current scheduled task in time slice t; is the computing power of the CPU core; is the CPU bandwidth availability.
9. The task scheduling method based on resource optimization according to claim 1, wherein, The expression of the task scoring model is: Among them, α, β, γ, and δ are weight coefficients used to adjust the influence of each score in the total score; η×N t is the influence of the task duration, N t is the number of time slices required for the task, and η is a weight coefficient; the higher the task score, the more suitable the task is to be scheduled within the current core and time slice.
10. A task scheduling device based on resource optimization, characterized in that, The device includes: A feature analysis unit for performing task feature analysis on multiple program blocks in the PLC program to obtain feature information; the feature information includes calculation features, data access features, and dependency relationship features; A task sharding unit for performing task sharding according to the feature information to obtain multiple subtasks, and each subtask corresponds to the execution of a time slice; A resource sharing unit for performing resource requirement sharing according to the multiple subtasks after sharding to obtain calculation resource requirements and bandwidth resource requirements; A resource matching scoring unit, configured to perform resource matching scoring calculation according to the computing resource requirement and the bandwidth resource requirement, so as to obtain a resource matching degree; the resource matching degree includes a computing resource matching score and a bandwidth resource matching score; A task scoring calculation unit, configured to calculate scores of each subtask according to the resource matching degree and based on a task scoring model; A task scheduling unit, configured to execute a scheduling algorithm on the task to be scheduled and perform resource constraint checking based on the scores of each subtask, allocate the subtasks that pass the check to an execution queue, and update the resource status; re-enter the subtasks that do not pass the check into a ready queue.
Citation Information
Cited By
Production line resource regulation and control method and device, electronic equipment and storage medium
CN120806566A