A method, device, equipment and medium for dynamic task allocation
By dynamically adjusting the resource allocation of operating system tasks in the automotive open system architecture, the inefficiency and operational complexity caused by static allocation are solved, and the system flexibility and response speed are improved.
Patent Information
- Application Number
- CN202510051741.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2024-10-24
- Filing Date
- 2025-01-13
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2045-01-13
AI Technical Summary
The existing AUTOSAR task allocation uses static allocation, which makes the system unable to dynamically adjust according to real-time load changes during operation, which is inefficient, and frequent resource adjustments require repeated cumbersome operation processes.
Provide a dynamic task allocation method, which can achieve dynamic adjustment of operating system tasks by obtaining the resource usage of operating system tasks in the automotive open system architecture, using preset optimization algorithms to determine the target task allocation strategy, and perform dynamic configuration operations through the graphical user interface.
It realizes the flexibility and response speed of the system, and users can dynamically adjust task allocation without reloading and compiling, significantly reducing operational complexity and time cost.
Smart Images

Figure CN119473561B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer software technology, and in particular to a task dynamic allocation method, device, equipment and medium. Background Art
[0002] AUTOSAR (Automotive Open System Architecture) is a standardized automotive open system architecture that aims to provide an open and modular platform for automotive electronic control systems. Currently, AUTOSAR tasks are mainly assigned statically, and users use AUTOSAR tools to statically assign Tasks and Runnables. This process usually includes the following steps:
[0003] 1. Open the AUTOSAR tool and load the existing project;
[0004] 2. Adjust the configuration of Task and Runnable according to needs and make allocations;
[0005] 3. Save the changes and regenerate the code manually;
[0006] 4. Compile the generated code and burn it into the target device.
[0007] As can be seen, static allocation uses a fixed allocation method. Once the Task and Runnable are allocated, the system will keep these configurations unchanged during operation. If the user needs to reallocate or adjust resources, the above process must be repeated, that is, opening the project and reallocating them. This is not only time-consuming, but also prone to errors, especially when frequent adjustments are required, which is very inefficient.
[0008] Therefore, how to provide a solution to the above technical problems is a problem that those skilled in the art need to solve at present. Summary of the invention
[0009] In view of this, the purpose of the present invention is to provide a method, device, equipment and medium for dynamic task allocation, which supports real-time configuration update and does not require reloading and compiling when reallocating resources; it can dynamically allocate tasks and improve the flexibility and response speed of the system. The specific scheme is as follows:
[0010] In a first aspect, the present application discloses a method for dynamic task allocation, comprising:
[0011] Obtaining resource occupancy of all operating system tasks in an automotive open system architecture in an executable state; wherein each of the operating system tasks includes at least one executable entity;
[0012] According to the resource occupancy situation, a target task allocation strategy of the operating system task is determined by using a preset optimization algorithm, and a target executable entity that needs to perform a configuration operation is determined according to the target task allocation strategy;
[0013] When the configuration operation is performed on the target executable entity on the graphical user interface in a target operation manner, a function corresponding to the target executable entity is called through a pointer according to the configuration operation.
[0014] Optionally, the obtaining of resource usage of all operating system tasks in the automobile open system architecture in an executable state includes:
[0015] Detecting all operating system tasks in the automotive open system architecture and recording basic information of the operating system tasks; wherein the basic information includes the execution priority and ideal execution time of the operating system tasks;
[0016] The resource occupancy of each operating system task in different time periods in an executable state is recorded based on the basic information; wherein the resource occupancy includes the actual execution time, waiting time and real-time load data of the operating system task.
[0017] Optionally, determining the target task allocation strategy of the operating system task by using a preset optimization algorithm according to the resource occupancy situation includes:
[0018] Obtaining different task allocation strategies for allocating the operating system tasks, and determining resource occupancy corresponding to the operating system tasks under the different task allocation strategies;
[0019] According to the resource occupancy situation, the task allocation strategy corresponding to the least occupied resource is determined as the target task allocation strategy.
[0020] Optionally, performing the configuration operation on the target executable entity on a graphical user interface in a target operation manner includes:
[0021] An event-driven model is used to capture user operations to determine a target operation mode, and the configuration operation is performed on the target executable entity on a graphical user interface through the target operation mode.
[0022] Optionally, after performing the configuration operation on the target executable entity on the graphical user interface in a target operation manner, the method further includes:
[0023] The current task configuration of the operating system task is determined, and the current task configuration is written into the electronic control unit in real time using a unified calibration protocol to update the electronic control unit.
[0024] Optionally, the method for dynamic task allocation further includes:
[0025] A configuration file is generated using the current task configuration, and the configuration file is stored in a pre-built configuration management module so that the configuration file can be managed and rolled back through the configuration management module.
[0026] Optionally, the calling, according to the configuration operation, a function corresponding to the target executable entity through a pointer includes:
[0027] Setting a preset number of empty first executable entities for the operating system task;
[0028] Acquire function functions and address information corresponding to each executable entity in the operating system task by using a controller area network protocol, and write the function functions and the address information into the first executable entity by using the controller area network protocol to obtain a second executable entity;
[0029] According to the configuration operation, the target executable entity is used as the executable entity with the highest execution priority among the second executable entities, and the target executable entity is pointed to by a pointer according to the address information to call a function corresponding to the target executable entity.
[0030] In a second aspect, the present application discloses a task dynamic allocation device, comprising:
[0031] A resource status acquisition module, used to acquire the resource occupancy status of all operating system tasks in the automotive open system architecture in an executable state; wherein each of the operating system tasks contains at least one executable entity;
[0032] An allocation strategy determination module is used to determine the target task allocation strategy of the operating system task according to the resource occupancy situation using a preset optimization algorithm, and determine the target executable entity that needs to perform the configuration operation according to the target task allocation strategy;
[0033] The dynamic allocation module is used to call the function corresponding to the target executable entity through a pointer according to the configuration operation when the configuration operation is performed on the target executable entity on the graphical user interface through a target operation mode.
[0034] In a third aspect, the present application discloses an electronic device, comprising a processor and a memory; wherein the memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the dynamic task allocation method as described above.
[0035] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the above-mentioned method for dynamic task allocation.
[0036] The present application provides a task dynamic allocation method, comprising: obtaining resource occupancy of all operating system tasks in an automotive open system architecture in an executable state; wherein each of the operating system tasks contains at least one executable entity; according to the resource occupancy, determining a target task allocation strategy for the operating system task using a preset optimization algorithm, and determining a target executable entity that needs to perform a configuration operation according to the target task allocation strategy; when performing the configuration operation on the target executable entity on a graphical user interface through a target operation mode, calling a function corresponding to the target executable entity through a pointer according to the configuration operation.
[0037] The beneficial technical effects of the present application are: by analyzing the resource occupancy of the operating system tasks, the optimal task allocation strategy is determined to reduce resource conflicts and improve the system response speed and stability; in the dynamic task allocation process, the target executable entity and the configuration operation performed by the target executable entity are first determined according to the task allocation strategy; secondly, a graphical user interface is provided for the user, and the target executable entity can be allocated by performing configuration operations on the graphical user interface through the target operation mode. Specifically, when the target executable entity performs the corresponding configuration operation, the corresponding function function is called through the pointer according to the configuration operation to realize the dynamic adjustment of the executable entity contained in the operating system task to adapt to the real-time changing workload and system status. The user can immediately observe the effect after the adjustment, which greatly improves the flexibility of resource management. This intuitive operation method reduces the user's learning curve and reduces the complexity of operation, which is in sharp contrast to the cumbersome operation of existing tools. Users can efficiently manage task allocation without in-depth understanding.
[0038] In addition, the present application provides a task dynamic allocation device, equipment and storage medium, which correspond to the above-mentioned task dynamic allocation method and have the same effect as above. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0040] Figure 1A flow chart of a method for dynamic task allocation disclosed in this application;
[0041] Figure 2 A pointer calling schematic diagram disclosed in this application;
[0042] Figure 3 A schematic diagram of a graphical user interface disclosed in this application;
[0043] Figure 4 A schematic diagram of dragging an executable entity in a graphical user interface disclosed in the present application;
[0044] Figure 5 A schematic diagram of a dragged executable entity in a graphical user interface disclosed in the present application;
[0045] Figure 6 This is a schematic diagram of the structure of a task dynamic allocation device disclosed in this application;
[0046] Figure 7 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] Currently, users use AUTOSAR tools to statically allocate Tasks and Runnables. Although this tool provides certain functions for allocating Tasks and Runnables, it has the following defects:
[0049] 1. Complicated operation: Every time the user wants to adjust the task allocation, they must go through a series of tedious steps: open the project, modify the configuration, regenerate the code, and compile and burn. This repetitive operation process reduces work efficiency, especially in the scenario of rapid iteration and debugging.
[0050] 2. Lack of flexibility: Static allocation means that the system cannot dynamically adjust according to real-time load changes during operation. If the load of a task suddenly increases, the system cannot respond immediately, which may lead to excessive or insufficient CPU (Central Processing Unit) resources, affecting the performance and stability of the overall system;
[0051] 3. Time cost of reconfiguration: In actual projects, especially in the early stages of product development, frequent configuration changes are common. However, the fixed allocation method of existing tools requires each change to go through a complete compilation and burning process, which not only increases the time cost but also slows down the development progress. In real AUTOSAR projects, domain controller projects are usually large in scale, so even small modifications take a long time to generate, compile and debug, which greatly reduces development efficiency;
[0052] 4. Security risks: Frequent compilation and burning processes may introduce new software defects, thereby increasing the risk of system instability. This risk is particularly serious in environments with high safety requirements, such as automotive control systems. In addition, due to the large scale of the project, any small modification may affect the overall situation, which adds a lot of uncertainty. When the operating system needs to be reconfigured to reduce the CPU load, the team must also solve various problems that were accidentally introduced, which leads to constant repeated confirmation and configuration modifications back and forth. In the actual project development process, this not only consumes a lot of manpower and material resources, but may also cause serious project overtime.
[0053] In summary, due to the nature of static allocation and the cumbersomeness of operation, resource management is inefficient and inflexible. To this end, this application provides a task dynamic allocation solution that supports real-time configuration updates and does not require reloading and compiling when reallocating resources; it can dynamically allocate tasks, thereby improving the flexibility and response speed of the system.
[0054] The embodiment of the present invention discloses a method for dynamically allocating tasks. Figure 1 As shown, the method includes:
[0055] Step S11: Obtain resource occupancy status of all operating system tasks in the automotive open system architecture in an executable state; wherein each of the operating system tasks includes at least one executable entity.
[0056] In the Automotive Open System Architecture (AUTOSAR) framework, Task is defined as the basic unit of execution, and Runnable is the specific operation within a Task. Each Task can contain multiple Runnables, and their properties and scheduling strategies are defined through configuration files.
[0057] In the embodiment of the present application, task identification and data collection are first performed. During the operation phase of the ECU (Electronic Control Unit), the resource occupancy of all OS Tasks (operating system tasks) in the project in their runnable state (Runnable) is accurately identified and monitored based on the real-time multitasking (RTM) technology. It should be pointed out that in the runnable state, the OS Task contains at least one Runnable. The resource occupancy can be the proportion of CPU resources occupied, memory resource occupancy, etc.
[0058] In a specific implementation, first, task identification is performed; basic information of each OS Task, such as priority, execution time, etc., is detected and recorded. Specifically, all operating system tasks in the automotive open system architecture are detected, and basic information of the operating system tasks is recorded; wherein, the basic information includes the execution priority and ideal execution time of the operating system tasks. Secondly, data collection is performed; in the actual operation stage, the resource occupancy of each task in different time periods, such as CPU usage, is monitored and recorded. This usually involves the actual execution time, waiting time, and CPU load data of the task. Specifically, based on the basic information, the resource occupancy of each operating system task in the executable state in different time periods is recorded; wherein, the resource occupancy includes the actual execution time, waiting time, and real-time load data of the operating system task.
[0059] Exemplarily, the following is an algorithm fragment for performing task identification and data collection:
[0060] from xcp import XCP
[0061] import time
[0062] def get_performance_data(xcp_interface, timeout=10):
[0063] """
[0064] Get performance data from the ECU.
[0065] parameter:
[0066] xcp_interface (str): XCP interface name.
[0067] timeout (int): Data collection timeout.
[0068] return:
[0069] dict: performance data.
[0070] """
[0071] xcp = XCP(xcp_interface)
[0072] xcp.connect()
[0073] # Define the performance data address to be read (such as task execution time, CPU usage, etc.)
[0074] performance_data = {}
[0075] start_time = time.time()
[0076] while time.time() - start_time < timeout:
[0077] try:
[0078] Read task performance data (example address, the specific address needs to be determined according to ECU configuration)
[0079] task_exec_time = xcp.read('TASK_EXEC_TIME_ADDRESS')
[0080] cpu_usage = xcp.read('CPU_USAGE_ADDRESS')
[0081] performance_data['task_exec_time'] = task_exec_time
[0082] performance_data['cpu_usage'] = cpu_usage
[0083] time.sleep(1) # read once per second
[0084] except Exception as e:
[0085] print(f"Error reading data: {e}")
[0086] xcp.disconnect()
[0087] return performance_data
[0088] # Example
[0089] if __name__ == "__main__":
[0090] performance_data = get_performance_data('CAN_INTERFACE')
[0091] print("Performance Data:", performance_data).
[0092] Step S12: according to the resource occupancy situation, a preset optimization algorithm is used to determine a target task allocation strategy for the operating system task, and a target executable entity that needs to perform a configuration operation is determined according to the target task allocation strategy.
[0093] In the embodiment of the present application, it is intended to calculate and solve the optimal configuration corresponding to the minimum resource occupancy, so as to determine the optimal allocation plan for OS Task and task execution. Specifically, the algorithm is first used to comprehensively identify and collect the actual resource occupancy data of each OSTask at runtime, including its detailed usage in the Runnable state. Subsequently, through complex data analysis and calculation models, a preset optimization algorithm is used to intelligently evaluate the impact of different task allocation schemes on resource occupancy, and predict the best task scheduling and allocation strategy, which will ensure the reasonable allocation of resources, avoid the situation where some Task resources are overloaded while other Task resources are idle, reduce resource conflicts, and improve system response speed, stability and resource utilization.
[0094] The following is an exemplary data analysis algorithm fragment for resource usage:
[0095] import numpy as np
[0096] def analyze_performance_data(performance_data):
[0097] """
[0098] Analyze performance data to identify task bottlenecks.
[0099] parameter:
[0100] performance_data (dict): Contains data on task execution time and CPU usage.
[0101] return:
[0102] dict: Load analysis results of each task.
[0103] """
[0104] task_analysis = {}
[0105] for task_id, data in performance_data.items():
[0106] exec_time = np.array(data['execution_times'])
[0107] cpu_usage = np.array(data['cpu_usages'])
[0108] avg_exec_time = np.mean(exec_time)
[0109] avg_cpu_usage = np.mean(cpu_usage)
[0110] # Calculate resource utilization, load, etc.
[0111] task_analysis[task_id] = {
[0112] 'average_execution_time': avg_exec_time,
[0113] 'average_cpu_usage': avg_cpu_usage
[0114] }
[0115] return task_analysis
[0116] # Example data
[0117] performance_data = {
[0118] 'task1': {'execution_times': [10, 12, 11], 'cpu_usages': [20, 22,21]},
[0119] 'task2': {'execution_times': [8, 9, 8], 'cpu_usages': [15, 14, 16]},
[0120] }
[0121] task_analysis = analyze_performance_data(performance_data)
[0122] print("Task Analysis:", task_analysis).
[0123] It is understandable that resource occupancy is not the same under different task allocation strategies. Therefore, in order to determine the best target task allocation strategy, it is necessary to calculate the resource occupancy under different task allocation schemes, and then determine the optimal task scheduling scheme. Specifically, different task allocation strategies for the operating system tasks are obtained, and the resource occupancy corresponding to the operating system tasks under the different task allocation strategies is determined; according to the resource occupancy, the task allocation strategy corresponding to the least resource occupancy is determined as the target task allocation strategy.
[0124] In a specific implementation, the preset optimization algorithm can be used to implement the following method: First, a mathematical model, such as linear programming or dynamic programming, is established to solve the optimal task scheduling solution. The model considers factors such as task priority, execution order, and resource conflicts. Secondly, task scheduling is performed; the execution order and priority of tasks are optimized to ensure that the system remains stable under high load. Finally, the resource allocation of tasks is adjusted to avoid excessive competition for resources, thereby improving the overall system performance.
[0125] The following is an exemplary section of a preset optimization algorithm:
[0126] from scipy.optimize import minimize
[0127] def optimize_task_allocation(task_analysis, initial_priorities):
[0128] """
[0129] Optimize task distribution to reduce CPU load.
[0130] parameter:
[0131] task_analysis (dict): Load analysis results of each task.
[0132] initial_priorities (dict): Initial task priorities.
[0133] return:
[0134] dict: Optimized task priorities.
[0135] """
[0136] def objective_function(priorities):
[0137] total_cpu_usage = 0
[0138] for task_id, priority in priorities.items():
[0139] avg_cpu_usage = task_analysis[task_id]['average_cpu_usage']
[0140] total_cpu_usage += avg_cpu_usage / priority
[0141] return total_cpu_usage
[0142] def constraint_function(priorities):
[0143] # Constraint to limit the sum of task priorities (adjustable)
[0144] return sum(priorities.values()) - 10
[0145] initial_priorities_values = list(initial_priorities.values())
[0146] result = minimize(
[0147] objective_function,
[0148] initial_priorities_values,
[0149] constraints={'type': 'eq', 'fun': constraint_function},
[0150] bounds=[(1, 10)] * len(initial_priorities_values) )
[0152] optimized_priorities = dict(zip(initial_priorities.keys(), result.x))
[0153] return optimized_priorities
[0154] # Example initial priority
[0155] initial_priorities = {
[0156] 'task1': 5,
[0157] 'task2': 4,
[0158] }
[0159] optimized_priorities = optimize_task_allocation(task_analysis,initial_priorities)
[0160] print("Optimized Priorities:", optimized_priorities).
[0161] Step S13: when the configuration operation is performed on the target executable entity on the graphical user interface in a target operation manner, a function corresponding to the target executable entity is called through a pointer according to the configuration operation.
[0162] There are often two pain points in task scheduling. One is "abnormal content", which may cause big problems for the ECU because the content it receives is wrong, so the actions taken later must also be problematic. The second is that since task scheduling has not been optimized, there will be many unreasonable task allocation phenomena when assigning tasks. For example, the priority of task A is higher than that of task B, but since task A is triggered first, that is, task A is received first, but task B received later is responded to first, which will not achieve our ideal effect and lead to logic problems.
[0163] In the embodiment of the present application, a dynamic resource allocation tool based on a visual graphical user interface (GUI) is proposed, which integrates the general OS configuration into the GUI tool. The user can easily select the Runnable and assign it to other Tasks according to the determined target task allocation strategy through target operation methods, such as dragging or double-clicking. While performing the operation, the function corresponding to the selected target executable entity is called through the pointer to achieve flexible and efficient task scheduling and management. In this way, if you want to call a different function, you only need to change the pointer.
[0164] It should be noted that the event-driven programming model is used to capture user operations. When the user drags or double-clicks the Runnable, the system can capture and process these events in real time, immediately reflect them on the interface and update the task configuration. Specifically, the event-driven model is used to capture user operations to determine the target operation mode, and the configuration operation is performed on the target runnable entity on the graphical user interface through the target operation mode.
[0165] The present application provides a task dynamic allocation method, comprising: obtaining resource occupancy of all operating system tasks in an automotive open system architecture in an executable state; wherein each of the operating system tasks contains at least one executable entity; according to the resource occupancy, determining a target task allocation strategy for the operating system task using a preset optimization algorithm, and determining a target executable entity that needs to perform a configuration operation according to the target task allocation strategy; when performing the configuration operation on the target executable entity on a graphical user interface through a target operation mode, calling a function corresponding to the target executable entity through a pointer according to the configuration operation.
[0166] The beneficial technical effects of the present application are: by analyzing the resource occupancy of the operating system tasks, the optimal task allocation strategy is determined to reduce resource conflicts and improve the system response speed and stability; in the dynamic task allocation process, the target executable entity and the configuration operation performed by the target executable entity are first determined according to the task allocation strategy; secondly, a graphical user interface is provided for the user, and the target executable entity can be allocated by performing configuration operations on the graphical user interface through the target operation mode. Specifically, when the target executable entity performs the corresponding configuration operation, the corresponding function function is called through the pointer according to the configuration operation to realize the dynamic adjustment of the executable entity contained in the operating system task to adapt to the real-time changing workload and system status. The user can immediately observe the effect after the adjustment, which greatly improves the flexibility of resource management. This intuitive operation method reduces the user's learning curve and reduces the complexity of operation, which is in sharp contrast to the cumbersome operation of existing tools. Users can efficiently manage task allocation without in-depth understanding.
[0167] In a specific implementation, the step of calling a function corresponding to the target executable entity through a pointer according to the configuration operation includes the following steps:
[0168] Setting a preset number of empty first executable entities for the operating system task;
[0169] Acquire function functions and address information corresponding to each executable entity in the operating system task by using a controller area network protocol, and write the function functions and the address information into the first executable entity by using the controller area network protocol to obtain a second executable entity;
[0170] According to the configuration operation, the target executable entity is used as the executable entity with the highest execution priority among the second executable entities, and the target executable entity is pointed to by a pointer according to the address information to call a function corresponding to the target executable entity.
[0171] In this embodiment, the GUI tool includes multiple periodic tasks (Task), and each periodic Task includes a preset number of empty runnable entities (Runnable). Periodic Task includes commonly used periods, such as 1ms, 2ms, 5ms, 10ms, 20ms, etc. It is assumed that the periodic Task includes ten empty Runnables. The controller area network (CAN) protocol is used to obtain the various function functions and their addresses in the project; the address corresponding to the known function is written into the empty Runnable in the periodic Task through the Can protocol, and added to the GUI tool, that is, the task function in the project is called through the function pointer, so as to realize flexible and efficient task scheduling and management. You can double-click to select to add address information. After selecting Task, you can also change Task by dragging and dropping; the actual operation of double-clicking or dragging is to write the address information to the empty Runnable of Task. It should be pointed out that after adding the known function address information to the GUI tool, the first runnable entity is renamed, such as Runnable1.
[0172] Further, such as Figure 2 As shown, the left side is the program initialization, and the right side is the empty function. After initialization, the pointer can be changed through the XCP protocol (Universal Calibration Protocol). In this way, the pointer can be used to point to different addresses to enter the corresponding function. If you want to call different functions, you only need to change the pointer. In this way, you can sort the priorities of the tasks that need to be responded to. For example, if you want to respond to a function first, you only need to bring its address to the front and point to it through the pointer.
[0173] It can be seen that the present invention uses the Can protocol to write the function address into the project in real time without recompiling and burning. After the user performs task scheduling, he can immediately see the feedback of the system and observe the impact of the adjustment on resource allocation in real time. This is in contrast to the fixed configuration method of existing AUTOSAR tools, which requires reopening the project, modifying the configuration, and completing the cumbersome compilation and burning process, increasing the time cost and the risk of error. In contrast, the present invention supports real-time configuration updates, and users can immediately observe the effect after adjustment, which greatly improves the flexibility of resource management.
[0174] For example, Figure 3The figure shows a schematic diagram of a visual GUI structure provided as an example in this embodiment. The GUI tool can display the core (Core), Task and Runnable information. Except for the title bar at the top, which cannot be dragged, the other title options can be dragged, and the data below changes when dragging. The visual interface and real-time feedback mechanism enable users to flexibly adjust task allocation to adapt to different application requirements. It is able to optimize task allocation under complex multi-core structures, improve overall system performance, and avoid resource waste or overload, which is in sharp contrast to the existing static configuration method. Specifically, the Runnable to be reallocated is placed on the corresponding Task by dragging, such as Figure 4 As shown in the figure, after the dragging is completed, Runnable 2 is placed in Task n. In fact, the data information of Runnable 2 is placed after the address of Task n, and the address is written into the data through the Can protocol. Figure 5 shown.
[0175] It can be seen that compared with the existing AUTOSAR tools that rely on cumbersome operating procedures, users need to manually open the project and reconfigure it. The present invention dynamically adjusts the visual interface through the function call pointer, which greatly simplifies the operation. At the same time, the time for task configuration and scheduling is significantly reduced, and users can complete the dynamic adjustment of tasks in a short time, improving the overall development efficiency. Users can easily select Runnable and assign it to other Tasks by dragging or double-clicking, flexibly schedule Runnable, and realize dynamic resource allocation. This intuitive operation method reduces the user's learning curve and reduces the complexity of operation. Users no longer rely on static task configuration, which is in sharp contrast to the cumbersome operation of existing tools. Users do not need to have a deep understanding to efficiently manage task allocation and respond to system status changes more quickly, avoiding performance bottlenecks caused by fixed configurations.
[0176] In a specific implementation, the GUI tool will also integrate the XCP protocol, allowing users to write modified task configurations to the ECU project in real time without stopping the system. Every adjustment made by the user in the GUI will be sent to the ECU via the XCP protocol to ensure instant updates of the configuration.
[0177] Specifically, the current task configuration of the operating system task is determined, and the current task configuration is written into the electronic control unit in real time using a unified calibration protocol to update the electronic control unit.
[0178] It can be seen that when tasks are assigned according to the target task allocation strategy, the current task configuration corresponds to the optimal solution for occupying resources when assigning tasks. At this time, the XCP communication protocol is used to safely and accurately input the carefully designed OS Task and the optimal task allocation plan into the engineering system. With its standard interface and powerful command set, the XCP protocol not only ensures the reliability and real-time performance of data transmission, but also greatly simplifies the online update, debugging and performance analysis process of the ECU. Through this comprehensive solution, not only can the operating efficiency of the ECU be significantly improved and the CPU load pressure be reduced, but also a strong guarantee can be provided for the overall performance and reliability of the automotive system. At the same time, it also provides automotive engineers with more flexible and efficient tools to help them achieve accurate task scheduling and resource management in complex engineering environments.
[0179] In a specific implementation, a configuration management module is pre-constructed to implement configuration file management and version control. It should be noted that each time a configuration is completed, a corresponding configuration file after the current configuration will be obtained, and each modification by the user will be recorded and saved. The configuration file is stored in the configuration management module for subsequent management and rollback. This module ensures the security and traceability of the project. Specifically, the configuration file is generated using the current task configuration, and the configuration file is stored in the pre-constructed configuration management module so that the configuration file can be managed and rolled back through the configuration management module.
[0180] Below, based on changing a task allocation once, the time occupied by static allocation and dynamic allocation in this application is compared. As shown in Table 1, the present invention identifies the best resource allocation scheme by deeply analyzing and evaluating the resource occupancy. In the process of dynamic task allocation, the system can dynamically adjust the resources occupied by each task to adapt to the real-time changing workload and system status. In this way, the verified optimal resource allocation scheme is effectively integrated into the mass production project, which can not only improve the overall performance and response speed of the system, but also enhance resource utilization, thereby providing strong support for the market competitiveness of the product. It can be seen that the efficiency ratio of static allocation to dynamic allocation is 365:10. The dynamic allocation in the present invention significantly reduces the time for task configuration and scheduling, and users can complete the dynamic adjustment of tasks in a short time, thereby improving the overall development efficiency. Compared with the prior art, users can respond to changes in system status more quickly, avoiding performance bottlenecks caused by fixed configuration.
[0181] Table 1
[0182]
[0183] Correspondingly, the present application also discloses a task dynamic allocation device, see Figure 6 As shown, the device comprises:
[0184] The resource status acquisition module 11 is used to acquire the resource occupancy status of all operating system tasks in the automotive open system architecture in an executable state; wherein each of the operating system tasks contains at least one executable entity;
[0185] An allocation strategy determination module 12 is used to determine the target task allocation strategy of the operating system task according to the resource occupancy situation using a preset optimization algorithm, and determine the target executable entity that needs to perform the configuration operation according to the target task allocation strategy;
[0186] The dynamic allocation module 13 is used to call the function corresponding to the target executable entity through a pointer according to the configuration operation when the configuration operation is performed on the target executable entity on the graphical user interface through a target operation mode.
[0187] Among them, for more specific working processes of the above-mentioned modules, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.
[0188] It can be seen that the above scheme of this embodiment includes: obtaining the resource occupancy of all operating system tasks in the automotive open system architecture in an executable state; wherein each of the operating system tasks contains at least one executable entity; according to the resource occupancy, determining the target task allocation strategy of the operating system task using a preset optimization algorithm, and determining the target executable entity that needs to perform the configuration operation according to the target task allocation strategy; when the configuration operation is performed on the target executable entity on the graphical user interface through the target operation mode, calling the function corresponding to the target executable entity through a pointer according to the configuration operation.
[0189] The beneficial technical effects of the present application are: by analyzing the resource occupancy of the operating system tasks, the optimal task allocation strategy is determined to reduce resource conflicts and improve the system response speed and stability; in the dynamic task allocation process, the target executable entity and the configuration operation performed by the target executable entity are first determined according to the task allocation strategy; secondly, a graphical user interface is provided for the user, and the target executable entity can be allocated by performing configuration operations on the graphical user interface through the target operation mode. Specifically, when the target executable entity performs the corresponding configuration operation, the corresponding function function is called through the pointer according to the configuration operation to realize the dynamic adjustment of the executable entity contained in the operating system task to adapt to the real-time changing workload and system status. The user can immediately observe the effect after the adjustment, which greatly improves the flexibility of resource management. This intuitive operation method reduces the user's learning curve and reduces the complexity of operation, which is in sharp contrast to the cumbersome operation of existing tools. Users can efficiently manage task allocation without in-depth understanding.
[0190] Furthermore, the present application also discloses an electronic device. Figure 7 This is a structural diagram of an electronic device 20 according to an exemplary embodiment, and the content in the diagram cannot be considered as any limitation on the scope of use of the present application.
[0191] Figure 7 A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the task dynamic allocation method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be a computer.
[0192] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0193] In addition, the memory 22 as a carrier for resource storage may be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon may include an operating system 221, a computer program 222 and data 223, etc. The data 223 may include various data. The storage method may be temporary storage or permanent storage.
[0194] The operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, and can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the task dynamic allocation method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.
[0195] Furthermore, the embodiment of the present application also discloses a computer-readable storage medium, wherein the computer-readable storage medium mentioned here includes a random access memory (Random Access Memory, RAM), a memory, a read-only memory (Read-Only Memory, ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a magnetic disk or an optical disk, or any other form of storage medium known in the technical field. Wherein, when the computer program is executed by the processor, the aforementioned task dynamic allocation method is implemented. For the specific steps of the method, reference can be made to the corresponding contents disclosed in the aforementioned embodiment, and no further description will be given here.
[0196] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0197] The steps of the task dynamic allocation method or algorithm described in conjunction with the embodiments disclosed herein can be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module can be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the technical field.
[0198] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0199] The above is a detailed introduction to a task dynamic allocation method, device, equipment and medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A task dynamic allocation method, characterized in that: include: Obtaining resource occupancy of all operating system tasks in an automotive open system architecture in an executable state; wherein each of the operating system tasks includes at least one executable entity; According to the resource occupancy, a target task allocation strategy of the operating system task is determined by using a preset optimization algorithm, and a target executable entity that needs to perform a configuration operation is determined according to the target task allocation strategy; the target task allocation strategy is a task allocation strategy corresponding to the least occupied resources; the preset optimization algorithm is implemented in a manner of establishing a mathematical model to solve the optimal task scheduling scheme, performing task scheduling to optimize the execution order and priority of tasks, and adjusting the resource allocation of tasks; When the configuration operation is performed on the target executable entity on the graphical user interface through a target operation mode, a function corresponding to the target executable entity is called through a pointer according to the configuration operation; the target operation mode uses an event-driven model to capture user operation determination; The step of calling a function corresponding to the target executable entity through a pointer according to the configuration operation includes: Setting a preset number of empty first executable entities for the operating system task; Acquire function functions and address information corresponding to each executable entity in the operating system task by using a controller area network protocol, and write the function functions and the address information into the first executable entity by using the controller area network protocol to obtain a second executable entity; According to the configuration operation, the target executable entity is used as the executable entity with the highest execution priority among the second executable entities, and the target executable entity is pointed to by a pointer according to the address information to call a function corresponding to the target executable entity.
2. The task dynamic allocation method according to claim 1, characterized in that: The obtaining of resource usage of all operating system tasks in the automotive open system architecture in an executable state includes: Detecting all operating system tasks in the automotive open system architecture and recording basic information of the operating system tasks; wherein the basic information includes the execution priority and ideal execution time of the operating system tasks; Based on the basic information, the resource occupancy of each operating system task in the executable state in different time periods is recorded; wherein the resource occupancy includes the actual execution time, waiting time and real-time load data of the operating system task.
3. The task dynamic allocation method according to claim 1, characterized in that: Determining the target task allocation strategy of the operating system task by using a preset optimization algorithm according to the resource occupancy situation includes: Obtaining different task allocation strategies for allocating the operating system tasks, and determining resource occupancy corresponding to the operating system tasks under the different task allocation strategies; According to the resource occupancy situation, the task allocation strategy corresponding to the least occupied resource is determined as the target task allocation strategy.
4. The task dynamic allocation method according to claim 1, characterized in that: After performing the configuration operation on the target executable entity on the graphical user interface in a target operation manner, the method further includes: The current task configuration of the operating system task is determined, and the current task configuration is written into the electronic control unit in real time using a unified calibration protocol to update the electronic control unit.
5. The task dynamic allocation method according to claim 4, characterized in that: Also includes: A configuration file is generated using the current task configuration, and the configuration file is stored in a pre-built configuration management module so that the configuration file can be managed and rolled back through the configuration management module.
6. A task dynamic allocation device, characterized in that: include: A resource status acquisition module, used to acquire the resource occupancy status of all operating system tasks in the automotive open system architecture in an executable state; wherein each of the operating system tasks contains at least one executable entity; An allocation strategy determination module is used to determine the target task allocation strategy of the operating system task according to the resource occupancy situation using a preset optimization algorithm, and determine the target executable entity that needs to perform the configuration operation according to the target task allocation strategy; the target task allocation strategy is the task allocation strategy corresponding to the least occupied resources; the preset optimization algorithm is implemented in a manner of establishing a mathematical model to solve the optimal task scheduling solution, performing task scheduling to optimize the execution order and priority of tasks, and adjusting the resource allocation of tasks; A dynamic allocation module, configured to call a function corresponding to the target executable entity through a pointer according to the configuration operation when the configuration operation is performed on the target executable entity on the graphical user interface through a target operation mode; the target operation mode is determined by capturing user operations using an event-driven model; The dynamic allocation module is specifically used for: Setting a preset number of empty first executable entities for the operating system task; Acquire function functions and address information corresponding to each executable entity in the operating system task by using a controller area network protocol, and write the function functions and the address information into the first executable entity by using the controller area network protocol to obtain a second executable entity; According to the configuration operation, the target executable entity is used as the executable entity with the highest execution priority among the second executable entities, and the target executable entity is pointed to by a pointer according to the address information to call a function corresponding to the target executable entity.
7. An electronic device, characterized in that: The electronic device comprises a processor and a memory; wherein the memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the task dynamic allocation method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: Used to store computer programs; wherein the computer program, when executed by a processor, implements the task dynamic allocation method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Task scheduling method and device
CN112513814A
Load balancing method and device based on multi-core processor, vehicle and storage medium
CN118295802A