A scheduling policy determination method, electronic device, and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-11
- Publication Date
- 2026-08-11
AI Technical Summary
[0003]但是,上述方法中,由于任务的静态优先级是固定并且长期不变的,可能会导致某些任务长时间得不到执行,影响了系统的实时性和响应速度
[0038] The scheduling strategy determination method, electronic device, and storage medium provided in this application, because the task information of the task to be scheduled can characterize the execution status of the task in the electronic device, allow the electronic device to dynamically determine the priority of the task to be scheduled based on its execution status and task type. This enables the dynamic determination of the target scheduling strategy, i.e., the scheduling order of the tasks, according to the priority of the tasks. This avoids tasks remaining inactive for extended periods due to unchanging priorities, thus improving system response speed.
Smart Images

Figure CN122547469A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method for determining scheduling strategies, an electronic device, and a storage medium. Background Technology
[0002] Currently, for multiple tasks, the server can assign static priorities to each task, and then execute the tasks sequentially according to their respective static priorities.
[0003] However, in the above method, since the static priority of the task is fixed and remains unchanged for a long time, some tasks may not be executed for a long time, affecting the real-time performance and response speed of the system. Summary of the Invention
[0004] This application provides a scheduling strategy determination method, an electronic device, and a storage medium, which can avoid the long-term non-execution of tasks due to unchanging priorities and can improve the system's response speed.
[0005] In a first aspect, this application provides a scheduling strategy determination method, comprising: obtaining the task type of a task to be scheduled and the task information to be scheduled, the task information being used to characterize the execution status of the task to be scheduled in an electronic device; determining the priority of the task to be scheduled based on the task type of the task to be scheduled and the task information of the task to be scheduled; and determining a target scheduling strategy based on the priority of the task to be scheduled, the target scheduling strategy being used to characterize the scheduling order of the task to be scheduled.
[0006] Optionally, determining the priority of the task to be scheduled based on its task type and task information specifically includes: if the task type is a periodic task, inputting the task information into the trained response time model to obtain the response time of the task to be scheduled; obtaining the service quality of the task to be scheduled; and determining the priority of the task to be scheduled based on its response time and service quality.
[0007] Optionally, the above-mentioned inputting the task information of the task to be scheduled into the trained response time model to obtain the response time of the task to be scheduled specifically includes: determining that the response time of the task to be scheduled satisfies the following formula:
[0008] h(t)=o(t)·tanh(c(t))
[0009] o(t)=σ(W[o]·[h(t-1),x(t)]+b[o])
[0010] Where h(t) represents the response time of the task to be scheduled, o(t) represents the output of the output gate, c(t) represents the current state of the memory cell, σ represents the sigmoid function, W[o] represents the weight of the output gate, h(t-1) represents the hidden layer state of the previous time step, x(t) represents the task information of the task to be scheduled, b[o] represents the bias term of the output gate, and t is a positive integer.
[0011] Optionally, determining the priority of the task to be scheduled based on its response time and service quality specifically includes: performing fuzzy processing on both the response time and service quality of the task to be scheduled to determine its response time level and service quality level; determining the priority of the task to be scheduled based on its response time level and service quality level; and the priority of the task to be scheduled is positively correlated with its response time level and service quality level.
[0012] Optionally, when the task type of the task to be scheduled is a non-periodic task, the task information of the task to be scheduled includes the start time of the task and the event type corresponding to the task. The determination of the priority of the task to be scheduled based on its task type and task information specifically includes: determining that the priority of the task to be scheduled satisfies the following formula:
[0013] p = w1*s1 + w2*s2
[0014] Where p represents the priority of the task to be scheduled, s1 represents the start time of the task to be scheduled, s2 represents the event type of the task to be scheduled, w1 represents the first weight, w2 represents the second weight, 0 < w1 ≤ 1, 0 < w2 ≤ 1.
[0015] Optionally, when there are multiple tasks to be scheduled, determining the target scheduling strategy based on the priority of the tasks to be scheduled includes: if the first number is greater than the second number, adding the tasks to be scheduled to the task queue according to their priority, where the first number is the number of tasks that can be executed in parallel among the multiple tasks to be scheduled, and the second number is the number of idle resources included in the electronic device; determining the target scheduling strategy includes allocating the first M tasks to be scheduled in the task queue to the second number of idle resources for execution, where M is equal to the second number.
[0016] Optionally, the above method further includes: obtaining the average response time, the proportion of timed-out tasks, and the average CPU utilization corresponding to the target scheduling policy; determining the evaluation result of the target scheduling policy based on the average response time, the proportion of timed-out tasks, and the average CPU utilization; and updating the target scheduling policy based on the evaluation result.
[0017] Optionally, determining the evaluation result of the target scheduling strategy based on the average response time, the proportion of timed-out tasks, and the average CPU utilization of the target scheduling strategy specifically includes: determining that the evaluation result of the target scheduling strategy satisfies the following formula:
[0018] E = w3*I1 + w4*I2 + w5*I3
[0019] Where E represents the evaluation result of the target scheduling strategy, I1 represents the average response time corresponding to the target scheduling strategy, I2 represents the proportion of timed-out tasks corresponding to the target scheduling strategy, I3 represents the average CPU utilization corresponding to the target scheduling strategy, w3 represents the third weight, w4 represents the fourth weight, w5 represents the fifth weight, 0 < w3 ≤ 1, 0 < w4 ≤ 1, 0 < w5 ≤ 1.
[0020] Secondly, this application provides a scheduling strategy determination device, comprising: an acquisition module and a determination module; the acquisition module is configured to acquire the task type of the task to be scheduled and the task information to be scheduled, the task information being used to characterize the execution status of the task to be scheduled in an electronic device; the determination module is configured to determine the priority of the task to be scheduled based on the task type of the task to be scheduled and the task information of the task to be scheduled; the determination module is further configured to determine a target scheduling strategy based on the priority of the task to be scheduled, the target scheduling strategy being used to characterize the scheduling order of the task to be scheduled.
[0021] Optionally, the scheduling strategy determination device further includes a processing module; the processing module is used to input the task information of the task to be scheduled into the trained response time model when the task type of the task to be scheduled is a periodic task, and obtain the response time of the task to be scheduled; the acquisition module is also used to acquire the service quality of the task to be scheduled; the determination module is specifically used to determine the priority of the task to be scheduled based on the response time of the task to be scheduled and the service quality of the task to be scheduled.
[0022] Optionally, the determining module is also specifically used to determine whether the response time of the task to be scheduled satisfies the following formula:
[0023] h(t)=o(t)·tanh(c(t))
[0024] o(t)=σ(W[o]·[h(t-1),x(t)]+b[o])
[0025] Where h(t) represents the response time of the task to be scheduled, o(t) represents the output of the output gate, c(t) represents the current state of the memory cell, σ represents the sigmoid function, W[o] represents the weight of the output gate, h(t-1) represents the hidden layer state of the previous time step, x(t) represents the task information of the task to be scheduled, b[o] represents the bias term of the output gate, and t is a positive integer.
[0026] Optionally, the processing module is further configured to perform fuzzy processing on the response time and service quality of the task to be scheduled, respectively, to determine the response time level and service quality level of the task to be scheduled; the determining module is further configured to determine the priority of the task to be scheduled based on the response time level and the service quality level; the priority of the task to be scheduled is positively correlated with the response time level and the service quality level.
[0027] Optionally, when the task type of the task to be scheduled is a non-periodic task, the task information of the task to be scheduled includes the start time of the task and the event type corresponding to the task. The determining module is also specifically used to determine the priority of the task to be scheduled, which satisfies the following formula:
[0028] p = w1*s1 + w2*s2
[0029] Where p represents the priority of the task to be scheduled, s1 represents the start time of the task to be scheduled, s2 represents the event type of the task to be scheduled, w1 represents the first weight, w2 represents the second weight, 0 < w1 ≤ 1, 0 < w2 ≤ 1.
[0030] Optionally, when there are multiple tasks to be scheduled, the processing module is used to add the tasks to be scheduled to the task queue according to their priority if the first number is greater than the second number. The first number is the number of tasks that can be executed in parallel among the multiple tasks to be scheduled, and the second number is the number of idle resources included in the electronic device. The determining module is specifically used to determine that the target scheduling strategy includes allocating the first M tasks to be scheduled in the task queue to the second number of idle resources for execution, where M is equal to the second number.
[0031] Optionally, the acquisition module is further configured to acquire the average response time, the proportion of timed-out tasks, and the average CPU utilization corresponding to the target scheduling strategy; the determination module is further configured to determine the evaluation result of the target scheduling strategy based on the average response time, the proportion of timed-out tasks, and the average CPU utilization corresponding to the target scheduling strategy; and the processing module is further configured to update the target scheduling strategy based on the evaluation result.
[0032] Optionally, a determining module is specifically used to determine whether the evaluation result of the target scheduling strategy satisfies the following formula:
[0033] E = w3*I1 + w4*I2 + w5*I3
[0034] Where E represents the evaluation result of the target scheduling strategy, I1 represents the average response time corresponding to the target scheduling strategy, I2 represents the proportion of timed-out tasks corresponding to the target scheduling strategy, I3 represents the average CPU utilization corresponding to the target scheduling strategy, w3 represents the third weight, w4 represents the fourth weight, w5 represents the fifth weight, 0 < w3 ≤ 1, 0 < w4 ≤ 1, 0 < w5 ≤ 1.
[0035] Thirdly, this application provides an electronic device, including: a processor and a memory configured to store processor-executable instructions; wherein the processor is configured to execute the instructions to implement any of the optional scheduling strategy determination methods in the first aspect described above.
[0036] Fourthly, this application provides a computer-readable storage medium storing instructions that, when executed by an electronic device, enable the electronic device to perform any of the optional scheduling strategy determination methods described in the first aspect above.
[0037] Fifthly, this application provides a computer program product, including a computer program or instructions, which, when executed on an electronic device, cause the electronic device to perform any of the optional scheduling strategy determination methods described in the first aspect above.
[0038] The scheduling strategy determination method, electronic device, and storage medium provided in this application, because the task information of the task to be scheduled can characterize the execution status of the task in the electronic device, allow the electronic device to dynamically determine the priority of the task to be scheduled based on its execution status and task type. This enables the dynamic determination of the target scheduling strategy, i.e., the scheduling order of the tasks, according to the priority of the tasks. This avoids tasks remaining inactive for extended periods due to unchanging priorities, thus improving system response speed. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below.
[0040] Figure 1 A flowchart illustrating a scheduling strategy determination method provided in an embodiment of this application;
[0041] Figure 2 A flowchart illustrating another scheduling strategy determination method provided in an embodiment of this application;
[0042] Figure 3 A flowchart illustrating another scheduling strategy determination method provided in an embodiment of this application;
[0043] Figure 4 A flowchart illustrating another scheduling strategy determination method provided in an embodiment of this application;
[0044] Figure 5 A flowchart illustrating another scheduling strategy determination method provided in an embodiment of this application;
[0045] Figure 6 A flowchart illustrating another scheduling strategy determination method provided in an embodiment of this application;
[0046] Figure 7 This is a schematic diagram of the structure of a scheduling strategy determination device provided in an embodiment of this application;
[0047] Figure 8 This is a schematic diagram of another scheduling strategy determination device provided in an embodiment of this application. Detailed Implementation
[0048] The scheduling strategy determination method, electronic device, and storage medium provided in the embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0049] The terms "first" and "second," etc., in the specification and drawings of this application are used to distinguish different objects, rather than to describe a specific order of objects. For example, "first quantity" and "second quantity," etc., are used to distinguish different quantities, rather than to describe a specific order of quantities.
[0050] Furthermore, the terms “comprising” and “having”, and any variations thereof, used in the description of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the steps or units listed, but may optionally include other steps or units not listed, or may optionally include other steps or units inherent to such processes, methods, products, or apparatus.
[0051] It should be noted that in the embodiments of this application, the words "exemplary" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of the words "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0052] The term "and / or" as used in this application includes using either one of two methods or using both methods simultaneously.
[0053] In the description of this application, unless otherwise stated, "a plurality of" means two or more.
[0054] Programmable logic controllers (PLCs) are widely used automation control devices that can control various types of digital or analog input / output devices according to programmed instructions. However, in practice, various tasks are often encountered, which may be periodic or non-periodic, and each task differs in its time sensitivity and complexity. Therefore, how to effectively schedule tasks to achieve efficient and stable control is a crucial issue in PLC controller design.
[0055] Traditional PLC controller task scheduling typically sorts tasks according to static priority and then executes them in descending order of priority. However, this method often only considers task priority and neglects other factors such as task execution time and frequency. This can lead to some tasks not being executed for extended periods, affecting the system's real-time performance and response speed.
[0056] Furthermore, traditional task scheduling strategies typically have a fixed sequence of task execution. For non-periodic tasks requiring rapid response, such strategies often fail to meet the demands. For example, in certain emergency situations, it may be necessary to immediately interrupt the current task and quickly execute a new one, which traditional scheduling strategies often cannot do.
[0057] To address these issues, scholars have begun to explore new scheduling strategies, such as those used in real-time operating systems, fuzzy logic, and machine learning. However, effectively applying these theories to PLC controllers remains an engineering challenge.
[0058] In actual operation, PLC controllers need to handle multiple tasks simultaneously, which may include periodic tasks (such as routine data acquisition) and non-periodic tasks (such as fault alarm handling). These different types of tasks may affect different levels of system functions, such as critical production processes or safety assurance, thus requiring different processing priorities. Therefore, this application aims to address how to distinguish between different task types and reasonably set their priorities.
[0059] Furthermore, task scheduling strategies affect system performance and stability; improper scheduling may lead to delayed processing of important tasks or waste of system resources. How to achieve efficient system resource utilization while meeting requirements such as real-time performance and priority is another important problem that this application aims to solve.
[0060] Furthermore, various unforeseen events may occur in real-time systems, such as equipment failures or sudden increases in load. These events may require immediate system response and handling; otherwise, serious system failures may result. Therefore, this application also needs to address how to improve the system's response speed and processing capabilities to unforeseen events.
[0061] In summary, the core technical problem that this application needs to solve is how to maximize the utilization of system resources and improve the system's operating efficiency and stability while ensuring the real-time performance of PLC controller task scheduling, reasonable priority judgment, and efficient response to emergencies.
[0062] As described in the background art, in related technologies, the static priority of tasks is fixed and remains unchanged for a long time, which may cause some tasks to remain unexecuted for extended periods, affecting the real-time performance and response speed of the system. Therefore, this application provides a scheduling strategy determination method, an electronic device, and a storage medium. Since the task information of the task to be scheduled can characterize the execution status of the task in the electronic device, the electronic device can dynamically determine the priority of the task to be scheduled based on its execution status and task type. Thus, the target scheduling strategy can be dynamically determined based on the priority of the task, i.e., the scheduling order of the tasks can be determined. This avoids the long-term inactivity of tasks due to unchanging priorities, thereby improving the system's response speed.
[0063] For example, the electronic device executing the scheduling strategy determination method provided in this application embodiment can be a mobile phone, tablet computer, desktop computer, laptop computer, handheld computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, as well as cellular phone, personal digital assistant (PDA), augmented reality (AR) / virtual reality (VR) device. This application embodiment does not impose special limitations on the specific form of the electronic device. It can interact with the user through one or more methods such as keyboard, touchpad, touch screen, remote control, voice interaction, or handwriting devices.
[0064] Optionally, the aforementioned electronic device may be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery network (CDN) acceleration services, as well as big data and artificial intelligence platforms.
[0065] like Figure 1 As shown, the scheduling strategy determination method provided in this application embodiment may include S101-S103.
[0066] S101, The electronic device obtains the task type and task information of the task to be scheduled.
[0067] The task information is used to characterize the execution status of the scheduled task in the electronic device.
[0068] It should be understood that the task types in this application may include periodic tasks and non-periodic tasks. Periodic tasks are those that must be executed at a fixed frequency, such as data acquisition; non-periodic tasks are those that need to be executed only when a specific event is triggered, such as alarm processing.
[0069] In one optional implementation, the task information of the task to be scheduled includes at least one of the following: the start time of the task to be scheduled, the end time of the task to be scheduled, the central processing unit (CPU) utilization rate of the task to be scheduled, and the event type corresponding to the task to be scheduled.
[0070] Optionally, the event type corresponding to the task to be scheduled includes at least one of the following types: equipment failure, alarm handling, input / output (I / O) operation, and interrupt request.
[0071] It is understood that the number of tasks to be scheduled can be one or more, and the embodiments of this application do not specifically limit the number of tasks to be scheduled.
[0072] S102. The electronic device determines the priority of the task to be scheduled based on the task type and task information of the task to be scheduled.
[0073] S103. The electronic equipment determines the target scheduling strategy based on the priority of the task to be scheduled.
[0074] The target scheduling strategy is used to characterize the scheduling order of tasks to be scheduled.
[0075] The technical solution provided by the above embodiments can bring at least the following beneficial effects: As shown in S101-S103, since the task information of the task to be scheduled can characterize the execution status of the task to be scheduled in the electronic device, the electronic device can dynamically determine the priority of the task to be scheduled based on the execution status of the task to be scheduled in the electronic device and the task type of the task to be scheduled. Therefore, the target scheduling strategy can be dynamically determined according to the priority of the task to be scheduled, that is, the scheduling order of the task to be scheduled can be determined. This avoids the long-term inaction of tasks due to unchanging priorities, and can improve the system's response speed.
[0076] Combination Figure 1 ,like Figure 2 As shown. In one implementation of this application embodiment, the determination of the priority of the task to be scheduled based on the task type and task information of the task to be scheduled may specifically include S1021-S1023.
[0077] S1021. When the task type of the task to be scheduled is a periodic task, the electronic device inputs the task information of the task to be scheduled into the trained response duration model to obtain the response duration of the task to be scheduled.
[0078] In some embodiments, the electronic device may determine that the response time of the task to be scheduled satisfies the following formula:
[0079] h(t)=o(t)·tanh(c(t))
[0080] o(t)=σ(W[o]·[h(t-1),x(t)]+b[o])
[0081] Where h(t) represents the response time of the task to be scheduled, o(t) represents the output of the output gate, c(t) represents the current state of the memory cell, σ represents the sigmoid function, W[o] represents the weight of the output gate, h(t-1) represents the hidden layer state of the previous time step, x(t) represents the task information of the task to be scheduled, b[o] represents the bias term of the output gate, and t is a positive integer.
[0082] It should be understood that for periodic tasks, the response time of the task to be scheduled can be obtained based on a predictive model using machine learning. This model focuses on learning from known periodic task patterns. By applying deep learning to the scheduling algorithm, it no longer relies purely on time slices or EDF for scheduling, but allows the electronic device to learn and adjust itself during operation, achieving more optimized task scheduling. For example, by analyzing factors such as the response time of historical tasks and CPU utilization, the response time of future tasks (e.g., the task to be scheduled) can be predicted, thereby optimizing the task scheduling strategy and improving CPU utilization efficiency.
[0083] In this embodiment of the application, the training and application process of the prediction model (specifically the response time model) may include steps A-E.
[0084] Step A: Data collection and preprocessing.
[0085] Specifically, the electronic device first collects relevant data on the execution of historical tasks, including but not limited to the start and end times of historical tasks, CPU utilization, and I / O operations. This data forms the basis for the machine learning model's learning. The electronic device then preprocesses this data, such as cleaning up invalid data and standardizing it.
[0086] Step B: Construct a prediction model.
[0087] It should be understood that, for the response time of the task that needs to be predicted, the embodiments of this application adopt a long short-term memory (LSTM) network model. This model can use deep learning to extract abstract features and establish complex mapping relationships, and is suitable for handling more complex tasks.
[0088] Specifically, the process of the LSTM model satisfies the following formula:
[0089] (1) Forget gate: f(t) = σ(W[f]·[h(t-1), x(t)] + b[f])
[0090] (2) Input gate: i(t) = σ(W[i]·[h(t-1), x(t)] + b[i])
[0091] (3) Output gate: o(t)=σ(W[o]·[h(t-1),x(t)]+b[o])
[0092] (4) New memory: n(t) = tanh(W[n]·[h(t-1), x(t)]+b[n])
[0093] (5) Final memorization: c(t) = f(t)·c(t-1) + i(t) ? n(t)
[0094] (6) Final output: h(t) = o(t) · tanh(c(t))
[0095] Where f(t) represents the output of the forget gate, σ represents the sigmoid function, W[f] represents the weight of the forget gate, h(t-1) represents the hidden layer state at the previous time step, x(t) represents the task information of the task to be scheduled (which can also be understood as the input of the model at the current time step), b[o] represents the bias term of the forget gate, i(t) represents the output of the input gate, W[i] represents the weight of the input gate, b[i] represents the bias term of the input gate, o(t) represents the output of the output gate, W[o] represents the weight of the output gate, b[o] represents the bias term of the output gate, n(t) represents the output of the new memory, W[n] represents the weight of the new memory, b[n] represents the bias term of the new memory, c(t) represents the state of the memory unit at the current time step, c(t-1) represents the state of the memory unit at the previous time step, and represents the response time of the task to be scheduled (which can also be understood as the output of the model at the current time step), and t is a positive integer.
[0096] Specifically, the memory unit is used to store long-term states, and the hidden layer is used to store short-term states. The forget gate determines which information to discard from the cell state, the input gate determines which new information to update the cell state, and the output gate determines the current hidden state (i.e., the output) based on the information in the cell state.
[0097] Step C: Model training and optimization.
[0098] Specifically, a selected model can be trained using historical data, while continuously optimizing the model's parameters. This step typically involves training on a training set and validating the results on a validation set. Common optimization algorithms in machine learning include stochastic gradient descent (SGD) and Adam.
[0099] The mathematical formula for model training can be simply expressed as:
[0100] minimizeL(Y,f(X;θ))+λR(θ)
[0101] Where L is the loss function, which measures the difference between the predicted value (f(X; θ), i.e. the predicted response time of the historical task) and the actual response time Y of the historical task; R is the regularization term, which is used to prevent the model from overfitting; λ is the regularization coefficient; and θ represents the model parameters.
[0102] Step D: Model prediction.
[0103] Specifically, after obtaining a trained model (i.e., a trained response time model), electronic devices can input new task feature values X (specifically, task information of the task to be scheduled) to predict the response time of the task, providing a basis for the final scheduling decision.
[0104] Step E: Schedule tasks based on the predicted response time.
[0105] Specifically, after the electronic device predicts the response time of the tasks to be scheduled based on the trained response time model, it can sort and schedule the tasks. For example, it can prioritize scheduling tasks with the shortest / smallest response time, thereby improving the CPU utilization of the electronic device.
[0106] S1022. Electronic devices obtain the quality of service for tasks to be scheduled.
[0107] S1023. The electronic device determines the priority of the task to be scheduled based on the response time and service quality of the task to be scheduled.
[0108] Combination Figure 2 ,like Figure 3 As shown. In one implementation of this application embodiment, the determination of the priority of the task to be scheduled based on the response time and service quality of the task to be scheduled may specifically include S1023a-S1023b.
[0109] S1023a. The electronic device performs fuzzy processing on the response time of the task to be scheduled and the service quality of the task to be scheduled, respectively, to determine the response time level and the service quality level of the task to be scheduled.
[0110] Specifically, the electronic device first determines the metrics for evaluating task priorities, namely response time and service quality in this embodiment. Then, the electronic device defines fuzzy sets and sets fuzzy rules for each metric (or evaluation metric). For example, for response time, it can define very fast, fast, average, slow, and very slow. Each fuzzy set needs to be quantified using a membership function, such as a triangle.
[0111] Below is an example using the membership function of the motivation function. If "A" represents a fast response with a range of [a1, a2, a3], and X is the response time, the membership function can be expressed as:
[0112]
[0113] S1023b: Electronic equipment determines the priority of tasks to be scheduled based on response time level and service quality level.
[0114] The priority of the task to be scheduled is positively correlated with the response time level and the service quality level.
[0115] Specifically, electronic devices can set fuzzy rules based on actual needs. For example, if the service quality is good and the response time is fast, then the task to be scheduled has a high priority. The words "good," "fast," and "high" in the rules are all fuzzy terms, and each rule needs to be processed by fuzzy reasoning.
[0116] Furthermore, fuzzy reasoning is performed based on fuzzy rules to obtain fuzzy results. Then, defuzzification methods (such as the centroid method or the maximum membership method) are used to transform the fuzzy results into specific numerical values, which are the task priorities. This process allows for more flexible and comprehensive task priority determination, rather than relying solely on a single evaluation metric, making it suitable for handling more complex system situations.
[0117] In another implementation of this application, when the task type of the task to be scheduled is a non-periodic task, the task information of the task to be scheduled includes the start time of the task and the event type corresponding to the task. Combined with... Figure 1 ,like Figure 4 As shown, the priority of the task to be scheduled is determined based on the task type and task information of the task to be scheduled, specifically including S1024. S1024: The electronic device determines the priority of the task to be scheduled according to the following formula:
[0118] p = w1*s1 + w2*s2
[0119] Where p represents the priority of the task to be scheduled, s1 represents the start time of the task to be scheduled, s2 represents the event type of the task to be scheduled, w1 represents the first weight, w2 represents the second weight, 0 < w1 ≤ 1, 0 < w2 ≤ 1.
[0120] It should be understood that for non-periodic tasks, an event-driven scheduling approach can be used. This means that when a corresponding event occurs, the currently executing task is interrupted, and the task corresponding to that event is executed instead. In this case, a priority threshold can be set; only events with a priority higher than this threshold can interrupt the current task.
[0121] Specifically, the event listening process involves continuously monitoring various events in the system, such as device malfunctions and user requests. For each event, its trigger time, event type, and other attributes are recorded. Furthermore, each event should have a corresponding priority, which can be predefined or based on event attributes (such as start time and event type). It should be understood that the first and second weights mentioned above represent the importance of two attributes in determining priority, and these weights can be set according to the specific application environment and requirements.
[0122] In some embodiments, the electronic device determines a target scheduling policy based on the priority of the task to be scheduled. Specifically, if the priority of the task to be scheduled is higher than the priority of the current task, the electronic device determines that the target scheduling policy includes interrupting the execution of the current task.
[0123] Specifically, when the task to be scheduled is a non-periodic task, the electronic device can compare the priority of the currently executing task (i.e., the current task) with the priority of the task to be scheduled. If the priority of the task to be scheduled is higher than that of the current task, the electronic device can interrupt the current task and execute the task to be scheduled. When a new event / task occurs, we can determine whether the current task needs to be interrupted by comparing the priority of the event with the priority of the currently executing task. Specifically, if the priority P(E) of event E is greater than the priority P(T) of the current task T, then the current task is interrupted.
[0124] This event-driven and priority-based scheduling method can be used to handle non-periodic tasks, such as exception handling, where real-time performance and priority requirements are relatively high.
[0125] It should be understood that in real-time systems, various reasons may lead to task interruption, such as I / O operations and interrupt requests. To address these events, this application introduces a novel strategy: an adaptive scheduling algorithm that dynamically adjusts priorities during execution or considers distributed task processing, allocating parallelizable tasks to other resources to reduce the overall system load.
[0126] To address task interruption and execution, electronic devices can first perform event monitoring. Specifically, in real-time systems, many events can potentially interrupt tasks, such as I / O operations and interrupt requests. Therefore, we need to continuously monitor these events in the system.
[0127] Afterward, the electronic device can adjust the priority of tasks / events. Specifically, the processing priority of each task / event may change due to various reasons, such as changes in system state, the frequency of event occurrence, and the urgency of the event. We can define a priority adjustment function g, whose input is the current priority of the event and other relevant parameters, and whose output is the adjusted priority. For example:
[0128] g(P(E),params)=P(E)+α*δ(param1,param2)
[0129] Where P(E) is the current priority of event E, param1 and param2 are other parameters that affect the priority of events, δ is a certain functional relationship between them, and α is a parameter that affects the adjustment range.
[0130] In addition, when an event occurs, the electronic device compares the priority of the event with the priority of the currently executing task. If the event priority is higher than the task priority, the current task is interrupted and the processing task corresponding to the event is executed.
[0131] In other embodiments, combined with Figure 1 ,like Figure 5 As shown, when there are multiple tasks to be scheduled, the target scheduling strategy is determined based on the priority of the tasks to be scheduled, specifically including S1031-S1032.
[0132] S1031. If the first quantity is greater than the second quantity, the electronic device adds the tasks to be scheduled to the task queue according to the priority of the tasks to be scheduled.
[0133] The first quantity is the number of tasks that can be executed in parallel among multiple scheduled tasks, and the second quantity is the number of idle resources included in the electronic device.
[0134] S1032, The electronic device determines the target scheduling strategy by allocating the first M tasks to be scheduled in the task queue to the second number of idle resources for execution.
[0135] Where M is equal to the second quantity.
[0136] It should be understood that for tasks that can be processed concurrently, we can distribute them to be executed on idle resources to reduce the overall load on the system.
[0137] If we define M as the number of idle resources / available resources, and N as the number of tasks that can be parallelized, when N > M, the following preprocessing steps can be taken:
[0138] (1) Sort N tasks according to a certain strategy to obtain task queue Q.
[0139] (2) Assign the first M tasks of queue Q to M idle resources for execution.
[0140] In summary, the key to task execution and interrupt handling lies in the rational scheduling of system resources so that the overall performance of the system can be optimized under various constraints.
[0141] Combination Figure 1 ,like Figure 6 As shown. The scheduling strategy determination method provided in this application embodiment may further include S104-S106.
[0142] S104. The electronic device obtains the average response time, the proportion of timed-out tasks, and the average CPU utilization corresponding to the target scheduling policy.
[0143] S105. The electronic device determines the evaluation result of the target scheduling strategy based on the average response time, the proportion of timed-out tasks, and the average CPU utilization rate corresponding to the target scheduling strategy.
[0144] In one alternative implementation, the electronic device can determine the evaluation result of the target scheduling policy by summing the average response time corresponding to the target scheduling policy, the proportion of timed-out tasks corresponding to the target scheduling policy, and the average CPU utilization corresponding to the target scheduling policy.
[0145] In another alternative implementation, the electronic device can determine that the evaluation result of the target scheduling strategy satisfies the following formula:
[0146] E = w3*I1 + w4*I2 + w5*I3
[0147] Where E represents the evaluation result of the target scheduling strategy, I1 represents the average response time corresponding to the target scheduling strategy, I2 represents the proportion of timed-out tasks corresponding to the target scheduling strategy, I3 represents the average CPU utilization corresponding to the target scheduling strategy, w3 represents the third weight, w4 represents the fourth weight, w5 represents the fifth weight, 0 < w3 ≤ 1, 0 < w4 ≤ 1, 0 < w5 ≤ 1.
[0148] In this embodiment, by establishing a system model and simulation, scheduling strategies can be simulated and evaluated. Assuming a target scheduling strategy π has been obtained, simulation is used to conduct experiments and obtain various evaluation metrics. For example, multiple evaluation metrics I can be used. j To measure the performance of the strategy, including average response time, percentage of timed-out tasks, CPU utilization, etc. j (π) represents the evaluation index I under strategy π. j The overall evaluation function is set as a linear weighted average:
[0149] E(π)=∑w j *I j (π)
[0150] Among them, w j It is the weight of the j-th evaluation indicator, and the weight w j The setting can be determined according to the actual situation, reflecting our emphasis on different indicators, where j is a positive integer.
[0151] S106. The electronic equipment updates the target scheduling strategy based on the evaluation results of the target scheduling strategy.
[0152] In this embodiment, the electronic device can update the target scheduling strategy based on previous evaluation results (or simulation evaluation results). If the optimization results meet the requirements, they can be applied directly; otherwise, if the optimization results are still not ideal, the strategy can be further analyzed and improved.
[0153] In other embodiments, electronic devices can also update the target scheduling strategy through parameter tuning.
[0154] Specifically, parameter tuning can be used to optimize parameters involved in scheduling strategies, such as priority weights and priority thresholds, and can be optimized using particle swarm optimization.
[0155] Each parameter constitutes a particle in a solution space, and the evaluation function is the objective function for optimization.
[0156] For particle i, its position X (current parameter value) and velocity V (rate of change of parameter value) are updated as follows:
[0157] V[i]=w*V[i]+c1*r1*(pbest[i]-X[i])+c2*r2*(gbest-X[i])
[0158] Update location:
[0159] X[i] = X[i] + V[i]
[0160] Where V[i] is the velocity of particle i, X[i] is the position of particle i, w is the inertia weight used to control the particle's search ability, c1 and c2 are learning factors that control how close the particle is to the individual optimal solution pbest[i] and the global optimal solution gbest, and r1 and r2 are random factors that are randomly generated in each iteration.
[0161] In this embodiment, by introducing fuzzy logic and machine learning prediction models, the priority and execution time of tasks can be evaluated more comprehensively and accurately. This makes the scheduling strategy more flexible and precise, thereby greatly improving task scheduling efficiency and system performance. Furthermore, through event-driven and priority-based scheduling, it is possible to quickly respond to unexpected events in the system, thereby improving the system's response speed and accuracy. In addition, by utilizing adaptive scheduling and distributed task processing strategies, the utilization rate of system resources can be improved, the system burden can be reduced, and the system operation can be more stable. Moreover, by optimizing the scheduling strategy, the system can operate stably even in the face of unexpected events, possessing good coping strategies for abnormal situations, thereby improving system stability.
[0162] This application embodiment can divide electronic devices and the like into functional modules according to the above method examples. For example, each function can be divided into its own functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.
[0163] When dividing each function into modules according to its corresponding function. Figure 7 A possible structural schematic diagram of the scheduling strategy determination device involved in the above embodiments is shown, such as... Figure 7 As shown, the scheduling strategy determination device 20 may include an acquisition module 201 and a determination module 202.
[0164] The acquisition module 201 is used to acquire the task type of the task to be scheduled and the task information to be scheduled. The task information is used to characterize the execution status of the task to be scheduled in the electronic device.
[0165] The determination module 202 is used to determine the priority of the task to be scheduled based on the task type and task information of the task to be scheduled.
[0166] The determining module 202 is further configured to determine a target scheduling strategy based on the priority of the task to be scheduled, the target scheduling strategy being used to characterize the scheduling order of the task to be scheduled.
[0167] Optionally, the scheduling strategy determination device 20 further includes a processing module 203.
[0168] The processing module 203 is used to input the task information of the task to be scheduled into the trained response duration model when the task type of the task to be scheduled is a periodic task, so as to obtain the response duration of the task to be scheduled.
[0169] The acquisition module 201 is also used to acquire the service quality of the task to be scheduled.
[0170] The determination module 202 is specifically used to determine the priority of the task to be scheduled based on the response time and service quality of the task to be scheduled.
[0171] Optionally, the determining module 202 is further specifically used to determine that the response time of the task to be scheduled satisfies the following formula:
[0172] h(t)=o(t)·tanh(c(t))
[0173] o(t)=σ(W[o]·[h(t-1),x(t)]+b[o])
[0174] Where h(t) represents the response time of the task to be scheduled, o(t) represents the output of the output gate, c(t) represents the current state of the memory cell, σ represents the sigmoid function, W[o] represents the weight of the output gate, h(t-1) represents the hidden layer state of the previous time step, x(t) represents the task information of the task to be scheduled, b[o] represents the bias term of the output gate, and t is a positive integer.
[0175] Optionally, the processing module 203 is further configured to perform fuzzy processing on the response time and service quality of the task to be scheduled, respectively, to determine the response time level and service quality level of the task to be scheduled.
[0176] The determination module 202 is also specifically used to determine the priority of the task to be scheduled based on the response duration level and the service quality level; the priority of the task to be scheduled is positively correlated with the response duration level and the service quality level.
[0177] Optionally, when the task type of the task to be scheduled is a non-periodic task, the task information of the task to be scheduled includes the start time of the task and the event type corresponding to the task. The determining module 202 is further specifically used to determine the priority of the task to be scheduled, which satisfies the following formula:
[0178] p = w1*s1 + w2*s2
[0179] Where p represents the priority of the task to be scheduled, s1 represents the start time of the task to be scheduled, s2 represents the event type of the task to be scheduled, w1 represents the first weight, w2 represents the second weight, 0 < w1 ≤ 1, 0 < w2 ≤ 1.
[0180] Optionally, when there are multiple tasks to be scheduled, the processing module 203 is used to add the task to be scheduled to the task queue according to the priority of the task to be scheduled if the first number is greater than the second number. The first number is the number of tasks that can be executed in parallel among the multiple tasks to be scheduled, and the second number is the number of idle resources included in the electronic device.
[0181] The determination module 202 is specifically used to determine the target scheduling strategy, which includes allocating the first M tasks to be scheduled in the task queue to the second number of idle resources for execution, where M is equal to the second number.
[0182] Optionally, the acquisition module 201 is further configured to acquire the average response time corresponding to the target scheduling strategy, the proportion of timed-out tasks corresponding to the target scheduling strategy, and the average CPU utilization corresponding to the target scheduling strategy.
[0183] The determining module 202 is further configured to determine the evaluation result of the target scheduling strategy based on the average response time corresponding to the target scheduling strategy, the proportion of timed-out tasks corresponding to the target scheduling strategy, and the average CPU utilization corresponding to the target scheduling strategy.
[0184] The processing module 203 is also used to update the target scheduling strategy based on the evaluation results of the target scheduling strategy.
[0185] Optionally, the determining module 202 is specifically used to determine whether the evaluation result of the target scheduling strategy satisfies the following formula:
[0186] E = w3*I1 + w4*I2 + w5*I3
[0187] Where E represents the evaluation result of the target scheduling strategy, I1 represents the average response time corresponding to the target scheduling strategy, I2 represents the proportion of timed-out tasks corresponding to the target scheduling strategy, I3 represents the average CPU utilization corresponding to the target scheduling strategy, w3 represents the third weight, w4 represents the fourth weight, w5 represents the fifth weight, 0 < w3 ≤ 1, 0 < w4 ≤ 1, 0 < w5 ≤ 1.
[0188] When using integrated units, Figure 8 A possible structural schematic diagram of the scheduling strategy determination device involved in the above embodiments is shown. For example... Figure 8 As shown, the scheduling strategy determination device 30 may include a processing module 301 and a communication module 302. The processing module 301 can be used to control and manage the actions of the scheduling strategy determination device 30. The communication module 302 can be used to support communication between the scheduling strategy determination device 30 and other entities. Optionally, as shown... Figure 8As shown, the scheduling strategy determination device 30 may further include a storage module 303 for storing the program code and data of the scheduling strategy determination device 30.
[0189] The processing module 301 can be a processor or a controller. The communication module 302 can be a transceiver, transceiver circuit, or communication interface, etc. The storage module 303 can be a memory.
[0190] In this configuration, when the processing module 301 is a processor, the communication module 302 is a transceiver, and the storage module 303 is a memory, the processor, transceiver, and memory can be connected via a bus. The bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc.
[0191] It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0192] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0193] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0194] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0195] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented using software programs, implementation can be, in whole or in part, in the form of a computer program product. This computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device containing one or more servers, data centers, etc., that can be integrated with the medium. The available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
[0196] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for determining a scheduling strategy, characterized in that, The method includes: Obtain the task type of the task to be scheduled and the task information to be scheduled, wherein the task information is used to characterize the execution status of the task to be scheduled in the electronic device; The priority of the task to be scheduled is determined based on the task type and task information of the task to be scheduled. Based on the priority of the tasks to be scheduled, a target scheduling strategy is determined, which is used to characterize the scheduling order of the tasks to be scheduled.
2. The method according to claim 1, characterized in that, The step of determining the priority of the task to be scheduled based on the task type and task information of the task to be scheduled includes: If the task to be scheduled is a periodic task, the task information of the task to be scheduled is input into the trained response time model to obtain the response time of the task to be scheduled. Obtain the service quality of the task to be scheduled; The priority of the task to be scheduled is determined based on the response time and service quality of the task to be scheduled.
3. The method according to claim 2, characterized in that, The step of inputting the task information of the task to be scheduled into the trained response time model to obtain the response time of the task to be scheduled includes: The response time of the task to be scheduled is determined to satisfy the following formula: h(t)=o(t)·tanh(c(t)) o(t)=σ(W[o]·[h(t-1),x(t)]+b[o]) Where h(t) represents the response time of the task to be scheduled, o(t) represents the output of the output gate, c(t) represents the current state of the memory cell, σ represents the sigmoid function, W[o] represents the weight of the output gate, h(t-1) represents the hidden layer state of the previous time step, x(t) represents the task information of the task to be scheduled, b[o] represents the bias term of the output gate, and t is a positive integer.
4. The method according to claim 2, characterized in that, The step of determining the priority of the task to be scheduled based on its response time and service quality includes: The response time and service quality of the task to be scheduled are respectively subjected to fuzzy processing to determine the response time level and service quality level of the task to be scheduled. The priority of the task to be scheduled is determined based on the response time level and the service quality level; the priority of the task to be scheduled is positively correlated with the response time level and the service quality level.
5. The method according to claim 1, characterized in that, When the task to be scheduled is a non-periodic task, the task information of the task to be scheduled includes the start time of the task and the event type corresponding to the task. Determining the priority of the task to be scheduled based on its task type and task information includes: The priority of the task to be scheduled is determined to satisfy the following formula: p = w1*s1 + w2*s2 Where p represents the priority of the task to be scheduled, s1 represents the start time of the task to be scheduled, s2 represents the event type corresponding to the task to be scheduled, w1 represents the first weight, w2 represents the second weight, 0 < w1 ≤ 1, 0 < w2 ≤ 1.
6. The method according to claim 1, characterized in that, When there are multiple tasks to be scheduled, determining the target scheduling strategy based on the priority of the tasks to be scheduled includes: If the first quantity is greater than the second quantity, the tasks to be scheduled are added to the task queue according to their priority. The first quantity is the number of tasks that can be executed in parallel among the multiple tasks to be scheduled, and the second quantity is the number of idle resources included in the electronic device. Determining the target scheduling strategy includes allocating the first M tasks to be scheduled in the task queue to the second number of idle resources for execution, where M is equal to the second number.
7. The method according to any one of claims 1-6, characterized in that, The method further includes: Obtain the average response time, the proportion of timed-out tasks, and the average CPU utilization rate corresponding to the target scheduling policy; The evaluation result of the target scheduling strategy is determined based on the average response time, the proportion of timed-out tasks, and the average CPU utilization corresponding to the target scheduling strategy. The target scheduling strategy is updated based on the evaluation results.
8. The method according to claim 7, characterized in that, The step of determining the evaluation result of the target scheduling strategy based on the average response time, the proportion of timed-out tasks, and the average CPU utilization corresponding to the target scheduling strategy includes: The evaluation result of the target scheduling strategy is determined to satisfy the following formula: E = w3*I1 + w4*I2 + w5*I3 Where E represents the evaluation result of the target scheduling strategy, I1 represents the average response time corresponding to the target scheduling strategy, I2 represents the proportion of timed-out tasks corresponding to the target scheduling strategy, I3 represents the average CPU utilization corresponding to the target scheduling strategy, w3 represents the third weight, w4 represents the fourth weight, w5 represents the fifth weight, 0 < w3 ≤ 1, 0 < w4 ≤ 1, 0 < w5 ≤ 1.
9. An electronic device, characterized in that, The electronic device includes: processor; A memory configured to store processor-executable instructions; The processor is configured to execute the instructions to implement the scheduling policy determination method as described in any one of claims 1-8.
10. A computer-readable storage medium storing instructions thereon, characterized in that, When the instructions in the computer-readable storage medium are executed by an electronic device, the electronic device is able to perform the scheduling policy determination method as described in any one of claims 1-8.