Task scheduling method and device suitable for virtualized automotive electronic system
By using container-based mapping kernels in virtualized automotive electronic systems to pre-allocate time slices and operation cycles, and dynamic scheduling and resource redistribution according to resource usage, the problem that traditional strategies cannot improve hardware utilization while ensuring system predictability is solved, and more efficient resource utilization and real-time performance are achieved.
Patent Information
- Application Number
- CN202411923242.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2044-12-25
AI Technical Summary
In virtualized automotive electronic systems, traditional task allocation strategies cannot effectively improve hardware utilization while ensuring predictability of system behavior, especially when task preemption among containers is frequent, which will lead to context switching overhead and runtime violations, reducing the real-time performance of the system.
The container-based mapping kernel is used to pre-allocate the time slice and run cycle, and periodically allocate or recycle resources according to the resource usage of the container. When the kernel has no resources, container migration is carried out. If the migration fails, the resources of other containers are deprived and allocated to the migration failed container. The above operations are performed cycled to realize task scheduling.
Through dynamic scheduling and resource redistribution, the system's utilization rate of hardware resources is improved, while ensuring the real-time and predictability of the system, and enhancing compatibility and processing capabilities for different task types.
Smart Images

Figure CN119862031A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of real-time scheduling of automobile tasks, and in particular to a task scheduling method and device suitable for a virtualized automobile electronic system. Background Art
[0002] As users' demands for automotive functions grow, the computing power of automotive electronic systems is also increasing. This trend has led to a sharp increase in the complexity of automotive electronic systems. Therefore, multiple ECUs can be integrated into a large computing power platform such as a multi-core processor to reduce the number of physical hardware. This measure can effectively simplify the electronic and electrical architecture of the car. At the same time, in order to improve the hardware resource utilization efficiency, software and hardware compatibility, and system security of the large computing power platform used, virtualization technology is introduced into the multi-processor hardware platform. Each ECU is abstracted as a container running on the platform. The Hypervisor allocates hardware resources to each container and then executes tasks. This is a platform virtualization-based solution that can provide a well-isolated virtualization environment, and each ECU code base can run in the virtual machine with almost no modification. The application of virtualization technology has made the automotive electronic system a complex system composed of applications with mixed criticality. Tasks of different criticality will be executed on the same physical hardware. The traditional task allocation strategy is no longer applicable, so a new allocation strategy needs to be sought.
[0003] In the above mixed criticality system, how to improve hardware utilization while ensuring the predictability of system behavior is a key issue. Due to the limited isolation provided by container-based virtualization, inter-container task preemption will occur between containers co-located on the same kernel. Too frequent inter-container task preemption will not only bring unexpected context switching overhead, but also cause runtime violations, thereby reducing the real-time performance of the system. Using the Hierarchical Real-Time Scheduling framework (HRTS), we can first consider only the task scheduling rules at the container level, that is, task-level scheduling, which ensures that each container is schedulable; then consider the entire hardware platform level, allocate and schedule resources for each container, that is, container-level scheduling, which can effectively eliminate performance interference between containers, thereby ensuring the real-time and predictability of the entire system.
[0004] In past studies, scheduling methods based on this framework are mostly static, that is, resources are allocated relatively pessimistically in order to ensure the schedulability of each container, which limits the utilization of hardware to a certain extent. In addition, this type of scheduling method can only ensure that the CPU bandwidth allocated to the container is sufficient, but cannot guarantee that each task can be completed within the deadline. Therefore, it is necessary to optimize the traditional real-time scheduling framework, not only to ensure that the allocated resources can meet the needs of container schedulability, but also to be able to dynamically optimize the use of computing resources by each container at runtime, and adaptively adjust the scheduling parameters of different containers and kernels, so as to improve the utilization of hardware and ensure the real-time and predictability of the system.
[0005] At present, a considerable number of researchers have optimized the scheduling method based on the above framework, making it dynamic in resource allocation. However, the disadvantage is that most dynamic scheduling strategies are only applied to soft real-time scenarios and do not have the ability to schedule hard real-time tasks. The dynamic adjustment strategies they adopt have obvious time lags and cannot be applied to hard real-time scenarios.
[0006] In summary, the current research on task scheduling methods in virtualized automotive electronic systems is still not perfect. Therefore, it is necessary to propose a task scheduling method and system suitable for virtualized automotive electronic systems. Summary of the invention
[0007] In order to solve the deficiencies mentioned in the above background technology, an object of the present invention is to provide a task scheduling method and device suitable for a virtualized automotive electronic system.
[0008] In a first aspect, the purpose of the present invention can be achieved by the following technical solution: a task scheduling method and device suitable for a virtualized automotive electronic system, the method comprising the following steps:
[0009] Obtaining a mapping kernel of the container, and pre-allocating a time slice and an operation cycle for the container based on the mapping kernel of the container, wherein computing resources and storage resources are pre-allocated to the container;
[0010] Obtain the resource usage of the container. The kernel periodically allocates or reclaims resources for the container based on the resource usage of the container. When the kernel has no resources, the container is migrated.
[0011] If the migration fails, the kernel deprives the resources of other containers except the container where the migration failed, and allocates the resources of other containers except the migration container to the container where the migration failed, and repeats the above operation in a loop to implement task scheduling.
[0012] In combination with the first aspect, in certain implementations of the first aspect, the method further includes: resource adjustment in the dynamic scheduling phase of the container is dynamic adjustment of time slice resources, including periodic adjustment of time slices, time slice deprivation of LC containers and container migration, and the periodic adjustment of time slices and time slice deprivation of LC containers are the responsibility of the controller of the kernel.
[0013] In combination with the first aspect, in some implementations of the first aspect, the method further includes: the migration of the container is the migration of the LC container deprived of the time slice in the core in the critical state, which is the responsibility of the migration controller in the computing node.
[0014] In combination with the first aspect, in some implementations of the first aspect, the method further includes: assuming that the automotive electronic system has a task set Γ, the task set Γ including the HC task set Γ HI and LC task set Γ LO , both types of tasks are periodically triggered tasks, and each task in the task set is denoted as τ i ∈Γ, defined as:
[0015] τ i ={T i ,A i ,C i ,D i ,p i} Formula (1)
[0016] Among them, T i For the task τ i The cycle of A i For the task τ i The average execution time of C i For the task τ i The worst execution time, D i For the task τ i The deadline, p i is a binary value, indicating the task τ i system criticality;
[0017] For container π k is defined as follows:
[0018] π k =(Γ k ,P k ,Q k ,CLM k ,Me k ) Formula (2)
[0019] Among them, container π k According to the different included task sets, they are divided into two categories: one is the HC task set. HC container One type only contains LC task sets LC Containers P k For container π k The operating cycle, Q k For each operation cycle P k The available time slice size within CLM k is a measure of the container π k Real-time parameters, Me k For container π k Memory usage of
[0020] For kernel N j is defined as follows:
[0021]
[0022] Where m is the kernel N j The total number of containers allocated, for mapping in kernel N j HC container on have Numbered from 1 to m h , for mapping in kernel N j LC container on have Number is m h +1 to m,f j Represents kernel N j Memory capacity, Crt j Is a binary value representing the kernel N j Is it in a critical state?
[0023] The definition of the entire multi-core computing node S is as follows:
[0024] S={n,Π HI ,Π LO MigCtrl} formula (4)
[0025] Where n is the number of cores in the entire node, Π HI and Π LO The mapping relationship between HC containers and LC containers and each core is recorded respectively. MigCtrl is the migration controller responsible for container migration in the node;
[0026] The kernel controller is responsible for the container-level scheduling between containers. The scheduling strategy is to schedule according to the rate monotonic algorithm. Each container is scheduled in Q k The kernel usage right is abandoned after use. The task-level scheduling within the container is the responsibility of the container controller. The scheduling strategy is to schedule according to the rate monotonic algorithm with the task cycle as the priority. Among them, the kernel controller has a higher priority than the container controller.
[0027] In combination with the first aspect, in some implementations of the first aspect, the method further includes: the process of pre-allocating the time slice and the operating cycle of the container by the container-based mapping kernel is as follows:
[0028] Using binary variable sets Indicates whether the container is mapped to kernel N j On, we have:
[0029]
[0030] Among them, T overhead is the switching overhead in the system, c1 and c2 are parameters to balance the two requirements;
[0031] To ensure the schedulability of container-level scheduling, add hardware resource constraints to the model:
[0032]
[0033] When the system is running, To ensure that tasks τ1 to τ i In the worst case, the following conditions need to be met to complete the project on time:
[0034]
[0035] Among them, ρ i is a set of time points, consisting of the deadlines of each task. If the time point satisfies formula (8), it means that the system is schedulable for the current task set. i The values of are as follows:
[0036]
[0037] Get container π k The task set Γ in k ={τ1,...,τ r The worst-case schedulable condition is:
[0038]
[0039] According to formula (10), the following constraints are obtained:
[0040]
[0041] Since multiple containers are deployed on each core, container π needs to be considered k The kernel occupancy α k and delay Δ k , where the kernel occupancy α k Can be determined by αk =Q k / P k The calculated delay Δ k Calculate according to the worst case scenario of the system, that is, Δ k =2·(P k -Q k ), combined with the above content, formula (10) is improved to obtain:
[0042]
[0043] Formula (12) limits Q k The lower bound and P k The upper bound of
[0044] Then, based on the above objective function and constraints, the time slice and memory allocation model of the container can be obtained, that is, formula (5) is used as the objective function, and formulas (6), (7) and (12) are used as constraints:
[0045] According to the above formula, time slices and memory resources are allocated. It is necessary to consider the real-time performance of the HC task in each single core in the worst case, and consider the optimization goal of maximizing the single core utilization, and allocate resources according to the ACET of the task.
[0046] In combination with the first aspect, in some implementations of the first aspect, the method further includes: a process in which the kernel periodically allocates or reclaims resources to the container based on resource usage of the container includes the following steps:
[0047] In the dynamic scheduling phase, the remaining available time slices on the kernel need to be updated when allocating or reclaiming time slices, using To track kernel N j The remaining available time slice is defined as follows:
[0048]
[0049] In formula (13), For kernel N j The total amount of available time slices, if updated That is, kernel N j When there is no remaining available time slice, Crt j The value is set to 1, indicating that the kernel N j Entering a critical state, if after updating Then the kernel N j The critical state is set to 0;
[0050] Use the real-time parameter CLM k To measure the container π k Real-time performance, assuming that container π kThe execution sequence of tasks is τ1 to τ r , then:
[0051]
[0052] Among them, E i For the task τ i The actual execution time, CLM k (i) represents the task τ i Whether the actual execution time is ahead of schedule or overtime, if there is CLM k (r)>0, indicating that there is a task that has been completed overtime. In this case, additional time slices need to be allocated. If there is CLM k (r)<0, indicating that all tasks are completed ahead of schedule, so some time slices are recycled;
[0053] If CLM k (r)<0, the kernel controller will recycle container resources based on the integral controller strategy, that is:
[0054] Q k (λ) = K l *[Q k (λ-1)+CLM k (r)]+Q k (λ-1) Formula (15)
[0055] Among them, K l The parameter representing the intensity of the resource recovery link’s response to the controller. The formula uses the container π k Real-time parameter CLM of the last operation cycle k and available time slice Q k , to quantify the amount of resources that the kernel needs to reclaim;
[0056] CLM needs to be considered k (r)>0, when the container π k Available time slice Q k When exhausted, the kernel controller allocates additional time slices Q tsp , if it is a HC container, then Q tsp =CLM k (r) and the kernel controller will allow the kernel to continue to be used until the additional time slice Q tsp is also exhausted, if it is an LC container, then But further use of the kernel is not allowed:
[0057] When a container operation cycle ends, the kernel controller will use the integral controller strategy and refer to Q tsp The value of Q in the next operation cycle is used to update the container k The value of, that is:
[0058] Q k (λ) = K m *[Q k (λ-1)+Q tsp ]+Q k (λ-1) Formula (16)
[0059] Among them, K m It represents the parameter of the controller response strength in the time slice allocation link, Q k (λ) represents the container π k The available time slice Q allocated to the λth operation cycle k .
[0060] In combination with the first aspect, in some implementations of the first aspect, the method further includes: a process in which the kernel deprives resources of other containers except the container that failed to migrate:
[0061] First calculate the time slice size Q that needs to be deprived req , and its calculation formula is:
[0062]
[0063] Determine the deprivation object and allocate the LC container according to the available time slice Q k Arrange by size, giving priority to Q k Larger containers as objects of deprivation;
[0064] Deprive time slices in order until the time slice requirement Q can be met req ;
[0065] According to the time slice deprivation situation, update the available time slice Q of each container k ;
[0066] View kernel N j Has it entered a critical state? If kernel N j In a critical state, it is necessary not only to deprive the LC container of its time slice, but also to send a migration request to the container migration controller of the node.
[0067] In combination with the first aspect, in some implementations of the first aspect, the method further includes: the process of performing the migration operation on the container:
[0068] The node's container migration controller MigCtrl obtains the remaining available time slices of each core at the end of each operation cycle. and remaining available memory Then with the container to be migrated π k The migration request is rejected if there is no core with sufficient resources. If the requirements are met, the next step is entered.
[0069] MigCtrl and The kernel with the largest value is used as the target kernel for migration, and the container π is recorded at the same time. k Parameters of
[0070] Before executing container migration, MigCtrl will migrate the container π k Available time slice Q k Set the value to 0, blocking container π k Execution of tasks in
[0071] Before creating a new container, k Destroy and release the occupied kernel resources;
[0072] MigCtrl will follow the recorded original container π k Pull and start a new container π on the target kernel with the relevant parameters k .
[0073] In a second aspect, in order to achieve the above-mentioned purpose, the present invention discloses a task scheduling system suitable for a virtualized automotive electronic system, comprising:
[0074] A resource pre-allocation module, used for obtaining a mapping kernel of a container, and pre-allocating time slices and operating cycles for the container based on the mapping kernel of the container, wherein computing resources and storage resources are pre-allocated to the container;
[0075] The container migration module is used to obtain the resource usage of the container. The kernel periodically allocates or reclaims resources for the container based on the resource usage of the container. When the kernel has no resources, the container is migrated.
[0076] The resource reallocation module is used to deprive the kernel of resources of other containers except the container where the migration failed, and allocate the resources of other containers except the migration container to the container where the migration failed, if the migration fails, and repeat the above operations in a loop to realize task scheduling.
[0077] In another aspect of the present invention, in order to achieve the above-mentioned purpose, a terminal device is disclosed, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the memory stores a computer program capable of running on the processor, and when the processor loads and executes the computer program, a task scheduling method suitable for a virtualized automotive electronic system as described above is adopted.
[0078] Beneficial effects of the present invention:
[0079] The present invention adopts a task management and scheduling method based on a container, which can effectively ensure the security and isolation of the automotive electronic system, and also has good scalability, and can easily adapt to future technological development and demand changes. When pre-allocating resources for the container, scheduling rules are formulated from the task level and the container level respectively, which ensures the schedulability of the container at the task level, reduces the occurrence of preemption between containers at the container level, reduces unnecessary context switching overhead, and improves the performance of the system. For a mixed task set consisting of HC tasks and LC tasks, the schedulability of HC tasks and the QoS of LC tasks are guaranteed while improving the kernel utilization, thereby enhancing the compatibility and processing capacity of the system for different task types. The kernel controller periodically monitors the resource usage of the container, so that resources can be dynamically allocated and adjusted according to the real-time needs of the container, making resource utilization more flexible, and can effectively cope with the changes in task load that may occur during the operation of the system. A migration controller is set on the computing platform to realize the container migration mechanism, that is, when the container's demand for resources exceeds the processing capacity of the current kernel, the system can automatically migrate tasks to other idle kernels, which not only ensures the real-time performance of the task, but also realizes load balancing between kernels. Through the redundant resource deprivation mechanism, the LC container is deprived of resources when the system is under high load, so as to ensure that the system can still guarantee the real-time performance of hard real-time constraint tasks in extreme cases. BRIEF DESCRIPTION OF THE DRAWINGS
[0080] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0081] Figure 1 It is a schematic flow chart of the method of the present invention;
[0082] Figure 2 It is a schematic diagram of the system model architecture of the present invention.
[0083] Figure 3 It is a schematic diagram of the container scheduling mechanism of the present invention.
[0084] Figure 4 It is a schematic diagram of the container migration process of the present invention.
[0085] Figure 5 It is a schematic diagram of the system module of the present invention;
[0086] Figure 6 It is a schematic diagram of the system structure of the present invention. DETAILED DESCRIPTION
[0087] 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.
[0088] Embodiment 1:
[0089] like Figure 1 As shown, a task scheduling method applicable to a virtualized automotive electronic system comprises the following steps:
[0090] Obtaining a mapping kernel of the container, and pre-allocating a time slice and an operation cycle for the container based on the mapping kernel of the container, wherein computing resources and storage resources are pre-allocated to the container;
[0091] Specifically, it includes: system design stage and dynamic scheduling stage;
[0092] The system design phase is responsible for pre-allocating computing resources and storage resources for containers, including mapping containers to various cores of the computing platform and allocating a certain length of time slice and operating cycle to each container;
[0093] The dynamic scheduling stage is responsible for the periodic adjustment of real-time time slices, time slice deprivation of LC containers and container migration. Through these three steps, resource allocation is optimized and the real-time performance of the system is guaranteed;
[0094] When the method works, firstly, time slices and memory resources are pre-allocated for each container in the system design phase. Then, in the dynamic scheduling phase, the kernel controller monitors the execution time of the container in real time with the help of the container real-time parameters. If the actual execution time is less than the pre-allocated value, it indicates that the container has completed execution ahead of schedule. Otherwise, it has completed execution overtime. The kernel controller recovers or allocates part of the time slices according to the specific values of the ahead of schedule or overtime completion. The HC container with timeout execution is allowed to execute for an additional period of time. If the time slice requirement of the HC container cannot be met, the kernel controller will deprive the LC container of the time slice in addition to allocating all the remaining time slices to fully meet its requirement. If the kernel has no remaining available time slices, the kernel enters a critical state. If the time slice deprivation occurs in the kernel in the critical state, the kernel controller requests the migration controller of the computing node to migrate the LC container deprived of the time slice. The migration controller responds to and processes the migration request according to the remaining time slices and memory resource status of each kernel.
[0095] First, assume that the automotive electronic system has a task set Γ, which includes the HC task set Γ HI and LC task set Γ LO, both types of tasks are periodically triggered tasks, and each task in the task set is denoted as τ i ∈Γ, defined as:
[0096] τ i ={T i ,A i ,C i ,D i ,p i}Formula (1)
[0097] In, T i For the task τ i The cycle of A i For the task τ i Average Case Execution Time (ACET), C i For the task τ i Worst-Case Execution Times (WCET), D i For the task τ i The deadline, p i is a binary value, indicating the task τ i system criticality;
[0098] Secondly, for the container π k is defined as follows:
[0099] π k =(Γ k ,P k ,Q k ,CLM k ,Me k )Formula (2)
[0100] Among them, container π k According to the different included task sets, they are divided into two categories: one is the HC task set. HC container One type only contains LC task sets LC Containers The set of tasks contained in each container is determined in advance. k For container π k The operating cycle, Q k For each operation cycle P k The available time slice size within CLM k is a measure of the container π k Real-time parameters are mainly used for the allocation and recovery of time slices. Their specific definitions will be mentioned later. k For container π k Memory usage of
[0101] Next, for kernel N j is defined as follows:
[0102]
[0103] Where m is the kernel N j The total number of containers allocated, for mapping in kernel N j HC container on have Numbered from 1 to m h , for mapping in kernel N j LC container on have Number is m h +1 to m,f j Represents kernel N j The memory capacity of each core is equal for homogeneous multi-core processors. j Is a binary value representing the kernel N j Is it in a critical state?
[0104] Then the definition of the entire multi-core computing platform is as follows S:
[0105] S={n,Π HI ,Π LO MigCtrl}Formula (4)
[0106] Where n is the number of cores in the entire node, Π HI and Π LO The mapping relationship between HC containers and LC containers and each core is recorded respectively. MigCtrl is the migration controller responsible for container migration in the node;
[0107] Finally, the kernel controller is responsible for the container-level scheduling between containers. Its scheduling strategy is to schedule according to the Rate Monotonic Scheduling (RMS) algorithm. Each container is scheduled in Q k After use, the kernel usage right is abandoned. The task-level scheduling in the container is the responsibility of the container controller. Its strategy is also based on the RMS principle, and the task cycle is used as the priority for scheduling. Among them, the kernel controller has a higher priority than the container controller.
[0108] First, we need to determine the objective function of the model. In this method, the optimization goal of the system design phase is to maximize the utilization of each single core. Therefore, two requirements must be considered in the objective function. One is that the container π k Available time slice Q k It should be as small as possible so as not to waste the total capacity of a single core. Second, the container π k The operating cycle Pk It should be as large as possible, otherwise too many context switches will be performed in each single core. As we will mention below, Q k The lower bound and P k The upper bound of is limited by the schedulability condition at the task level, so the obtained Q k and P k It can ensure the real-time performance of the system and maximize the single-core utilization. If the binary variable set is used Indicates whether the container is mapped to kernel N j On, we have:
[0109]
[0110] Among them, T overhead is the context switching overhead in the system, which is a fixed constant. c1 and c2 are parameters that balance the above two requirements. The parameters can be flexibly adjusted in a biased system.
[0111] Secondly, we need to ensure the schedulability of container-level scheduling, that is, add hardware resource constraints to the model, namely:
[0112]
[0113] Among them, formula (6) ensures the availability of memory resources of each core, and formula (7) ensures that the occupancy rate of each single core is less than 1;
[0114] Next, we need to ensure the schedulability of task-level scheduling. Before conducting schedulability analysis, we need to make the following four assumptions: First, assume that the system is started at time zero; second, for container π k The task set Γ in k ={τ1,...,τ r}, assuming that the task set Γ k All tasks in the set have arrived at time zero. Third, since the task set is scheduled by the RMS algorithm according to a fixed priority, it can be assumed that the execution order of the tasks is τ1 to τ r ,Fourth, the running time of all tasks will not exceed their WCET;
[0115] When the system is running, To ensure that tasks τ1 to τ i In the worst case scenario, the following conditions must be met to complete the project on time:
[0116]
[0117] Among them, ρ i is a set of time points, consisting of the deadlines of each task. If formula (8) is satisfied at these time points, it means that the system is schedulable for the current task set.i The values of are as follows:
[0118]
[0119] From this we can get the container π k The task set Γ in k ={τ1,...,τ r The worst-case schedulable condition is:
[0120]
[0121] According to formula (10), the following constraints can be obtained:
[0122]
[0123] Since multiple containers are deployed on each core, we also need to consider container π k The kernel occupancy α k and delay Δ k , where the kernel occupancy α k Can be determined by α k =Q k / P k The calculated delay Δ k Calculate according to the worst case scenario of the system, that is, Δ k =2·(P k -Q k ), combined with the above content, formula (8) is improved to obtain:
[0124]
[0125] Formula (12) limits Q k The lower bound and P k The upper bound of Q k Too small and P k Any allocation result that is too large cannot satisfy the constraints of formula (12) and will be discarded by the model;
[0126] Then, based on the above objective function and constraints, the time slice and memory allocation model of the container can be obtained, that is, formula (5) is used as the objective function, and formulas (6), (7) and (12) are used as constraints:
[0127] Finally, according to the above model, time slices and memory resources can be allocated. When allocating, we need to consider two steps. The first step is to ensure the real-time performance of the HC task in each single core in the worst case. The second step is to consider the optimization goal of maximizing the single core utilization and allocate the above resources according to the ACET of the task.
[0128] Specifically, the first step is to ensure that the sum of the core occupancy rates of the HC containers allocated to each single core is less than 1 in the worst case. To ensure this, we allocate all resources to the HC containers according to the worst case, and obtain a pre-allocation scheme, namely the binary variable set arrive The value of (j=1,...,n) can be solved by the Satisfiability Modulo Theories (SMT) solver according to the model in S24. The pre-allocation scheme mainly limits the number of HC containers allocated to each single core, so that even if the tasks in all HC containers in each single core run in the worst case, the resources of the single core can meet the needs of these containers;
[0129] The second step aims to minimize the number of occupied cores. The model established in S24 is still used for solution. The difference is that the WCET in formula (7) is replaced by ACET, that is, the schedulability within the container is guaranteed under average conditions. The container allocation scheme and the Q of each container are obtained according to the ACET of the task. k and P k value;
[0130] Obtain the resource usage of the container. The kernel periodically allocates or reclaims resources for the container based on the resource usage of the container. When the kernel has no resources, the container is migrated.
[0131] First, when allocating or reclaiming time slices, the remaining available time slices on the kernel need to be updated. We use To track kernel N j The remaining available time slice is defined as follows:
[0132]
[0133] in, For kernel N j The total amount of available time slices, if updated That is, kernel N j When there is no remaining available time slice, Crt j The value is set to 1, indicating that the kernel N j Entering a critical state, if after updating Then the kernel N j The critical state is set to 0;
[0134] Secondly, use the real-time parameter CLM k To measure the container π k The real-time performance of the container π k The time when the task is executed ahead of schedule or overtime, let container π kThe execution sequence of tasks is τ1 to τ r , then:
[0135]
[0136] Among them, E i For the task τ i The actual execution time, CLM k (i) represents the task τ i Whether the actual execution time is ahead of schedule or overtime, if there is CLM k (r)>0, indicating that there is a task that has been completed overtime. In this case, additional time slices need to be allocated. If there is CLM k (r)<0, indicating that all tasks are completed ahead of schedule and some time slices can be recovered;
[0137] Then if CLM k (r)<0, the kernel controller will recycle container resources based on the integral controller strategy, that is:
[0138] Q k (λ) = K l *[Q k (λ-1)+CLM k (r)]+Q k (λ-1) Formula (15)
[0139] Among them, K l The parameter representing the intensity of the resource recovery link’s response to the controller. This formula uses the container π k Real-time parameter CLM of the last operation cycle k and available time slice Q k , to quantify the amount of resources that the kernel needs to reclaim;
[0140] Then we consider CLM k (r)>0, when the container π k Available time slice Q k When exhausted, the kernel controller allocates additional time slices Q tsp , if it is a HC container, then Q tsp =CLM k (r) and the kernel controller will allow it to continue using the kernel until the additional time slice Q tsp Also exhausted, if it is an LC container, then But further use of the kernel is not allowed:
[0141] Finally, when a running cycle of the container ends, the kernel controller will use the integral controller strategy and refer to Q tsp The value of Q in the next operation cycle is used to update the container k The value of, that is:
[0142] Q k (λ) = K m *[Q k (λ-1)+Q tsp ]+Q k (λ-1) Formula (16)
[0143] Among them, K m It indicates the parameter of the controller response strength in the time slice allocation link, and its value range is between (0,1). k (λ) represents the container π k The available time slice Q allocated to the λth operation cycle k ;
[0144] For HC containers, the kernel controller not only allocates all remaining time slices, but also deprives LC containers of time slices to fully meet their needs.
[0145] First calculate the time slice size Q that needs to be deprived req , and its calculation formula is:
[0146]
[0147] Secondly, determine the deprivation object and allocate the LC container according to the available time slice Q k Arrange by size, giving priority to Q k Larger containers as objects of deprivation;
[0148] Then deprive the time slices in order until the time slice demand Q can be met req ;
[0149] Then, according to the time slice deprivation situation, update the available time slice Q of each container k ;
[0150] Finally check kernel N j Has it entered a critical state? If kernel N j In a critical state, not only does it need to deprive the LC container of its time slice, but it also needs to send a migration request to the node's container migration controller.
[0151] If time slice deprivation occurs in a core in a critical state, the core controller requests the migration controller of the computing node to migrate the LC container that has been deprived of time slices. The migration controller responds to and processes the migration request based on the remaining time slices and memory resource status of each core.
[0152] First, the node's container migration controller MigCtrl obtains the remaining available time slices of each core at the end of each operation cycle. and remaining available memory Then combine it with the container to be migrated into π k The migration request is compared with the resource requirements. If there is no core with sufficient resources, the migration request is rejected. If the requirements can be met, the migration request is executed.
[0153] Then MigCtrl will and The kernel with the largest value is used as the target kernel for migration, and the container π is recorded at the same time. k Parameters of
[0154] Before executing container migration, in order to avoid adverse effects of container migration on system stability, MigCtrl will migrate the container to be migrated k Available time slice Q k Set the value to 0, thereby blocking container π k Execution of tasks in
[0155] To prevent deadlock, the original container needs to be π before creating a new container. k Destroy and release the kernel resources it occupies;
[0156] Finally, MigCtrl will record the original container π k Pull and start a new container π in the target kernel with the relevant parameters k ;
[0157] Embodiment 2: In a second aspect, in order to achieve the above-mentioned purpose, the present invention discloses a task scheduling system suitable for a virtualized automotive electronic system, comprising:
[0158] A resource pre-allocation module 11 is used to obtain a mapping kernel of a container, and pre-allocate time slices and operating cycles for the container based on the mapping kernel of the container, wherein computing resources and storage resources are pre-allocated to the container;
[0159] The container migration module 12 is used to obtain the resource usage of the container. The kernel periodically allocates or reclaims resources for the container based on the resource usage of the container. When the kernel has no resources, the container is migrated.
[0160] The resource reallocation module 13 is used for, if the migration fails, the kernel deprives the resources of other containers except the container where the migration fails, and allocates the resources of other containers except the migration container to the container where the migration fails, and repeats the above operations in a loop to implement task scheduling.
[0161] Based on the same inventive concept, the present invention also provides a computer device, which includes: one or more processors, and a memory for storing one or more computer programs; the program includes program instructions, and the processor is used to execute the program instructions stored in the memory. The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. It is the computing core and control core of the terminal, which is used to implement one or more instructions, specifically for loading and executing one or more instructions in a computer storage medium to implement the above method.
[0162] It needs to be further explained that, based on the same inventive concept, the present invention also provides a computer storage medium, on which a computer program is stored, and the computer program is executed by a processor to execute the above method. The storage medium can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electrical, magnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0163] In the description of this specification, the description with reference to the terms "one embodiment", "example", "specific example", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present disclosure. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0164] The above shows and describes the basic principles, main features and advantages of the present disclosure. Those skilled in the art should understand that the present disclosure is not limited by the above embodiments, and the above embodiments and descriptions are only for explaining the principles of the present disclosure. Without departing from the spirit and scope of the present disclosure, the present disclosure may have various changes and improvements, and these changes and improvements fall within the scope of the present disclosure to be protected.
Claims
1. A task scheduling method suitable for a virtualized automotive electronic system, characterized in that: The method comprises the following steps: Obtaining a mapping kernel of the container, and pre-allocating a time slice and an operation cycle for the container based on the mapping kernel of the container, wherein computing resources and storage resources are pre-allocated to the container; Obtain the resource usage of the container. The kernel periodically allocates or reclaims resources for the container based on the resource usage of the container. When the kernel has no resources, the container is migrated. If the migration fails, the kernel deprives the resources of other containers except the container where the migration failed, and allocates the resources of other containers except the migration container to the container where the migration failed, and repeats the above operation in a loop to implement task scheduling.
2. The task scheduling method for a virtualized automotive electronic system according to claim 1, characterized in that: The resource adjustment in the dynamic scheduling stage of the container is the dynamic adjustment of time slice resources, including time slice periodic adjustment, time slice deprivation of LC container and container migration. The controller of the kernel is responsible for the time slice periodic adjustment and time slice deprivation of LC container.
3. The task scheduling method for a virtualized automotive electronic system according to claim 1, characterized in that: The container migration is the migration of the LC container deprived of time slices in the core in the critical state, which is the responsibility of the migration controller in the computing node.
4. The task scheduling method for a virtualized automotive electronic system according to claim 1, characterized in that: Assume that the automotive electronic system has a task set Γ, which includes the HC task set Γ HI and LC task set Γ LO , both types of tasks are periodically triggered tasks, and each task in the task set is denoted as τ i ∈Γ, defined as: τ i J{T i ,A i ,C i ,D i ,p i }Location(1) Among them, T i For the task τ i The cycle of A i For the task τ i The average execution time of C i For the task τ i The worst execution time, D i For the task τ i The deadline, p i is a binary value, indicating the task τ i system criticality; For container π k is defined as follows: π k =(Γ k ,P k ,Q k ,CLM k ,Me k ) formula (2) Among them, container π k According to the different included task sets, they are divided into two categories: one is the HC task set. HC container One type only contains LC task sets LC Containers P k For container π k The operating cycle, Q k For each operation cycle P k The available time slice size within CLM k is a measure of the container π k Real-time parameters, Me k For container π k Memory usage of For kernel N j is defined as follows: Where m is the kernel N j The total number of containers allocated, for mapping in kernel N j HC container on have Numbered from 1 to m h , for mapping in kernel N j LC container on have Number is m h +1 to m,f j Represents kernel N j Memory capacity, Crt j Is a binary value representing the kernel N j Is it in a critical state? The definition of the entire multi-core computing node S is as follows: S = {n, Π HI , Π LO MigCtrl} Equation (4) Where n is the number of cores in the entire node, Π HI and Π LO The mapping relationship between HC containers and LC containers and each core is recorded respectively. MigCtrl is the migration controller responsible for container migration in the node; The kernel controller is responsible for the container-level scheduling between containers. The scheduling strategy is to schedule according to the rate monotonic algorithm. Each container is scheduled in Q k The kernel usage right is abandoned after use. The task-level scheduling within the container is the responsibility of the container controller. The scheduling strategy is to schedule according to the rate monotonic algorithm with the task cycle as the priority. Among them, the kernel controller has a higher priority than the container controller.
5. The task scheduling method for a virtualized automotive electronic system according to claim 1, characterized in that: The process of pre-allocating time slices and operating cycles for containers based on the container-based mapping kernel is as follows: Using binary variable sets Indicates whether the container is mapped to kernel N j On, we have: Among them, T overhead is the switching overhead in the system, c1 and c2 are parameters to balance the two requirements; To ensure the schedulability of container-level scheduling, add hardware resource constraints to the model: When the system is running, To ensure that tasks τ1 to τ i In the worst case, the following conditions need to be met to complete the project on time: Among them, ρ i is a set of time points, consisting of the deadlines of each task. If the time point satisfies formula (8), it means that the system is schedulable for the current task set. i The values of are as follows: Get container π k The task set Γ in k ={τ1,...,τ r The worst-case schedulable condition is: According to formula (10), the following constraints are obtained: Since multiple containers are deployed on each core, container π needs to be considered k The kernel occupancy α k and delay Δ k , where the kernel occupancy α k Can be determined by α k =Q k / P k The calculated delay Δ k Calculate according to the worst case scenario of the system, that is, Δ k =2·(P k -Q k ), combined with the above content, formula (10) is improved to obtain: Formula (12) limits Q k The lower bound and P k The upper bound of Then, based on the above objective function and constraints, the time slice and memory allocation model of the container can be obtained, that is, formula (5) is used as the objective function, and formulas (6), (7) and (12) are used as constraints: According to the above formula, time slices and memory resources are allocated. It is necessary to consider the real-time performance of the HC task in each single core in the worst case, and consider the optimization goal of maximizing the single core utilization, and allocate resources according to the ACET of the task.
6. The task scheduling method for a virtualized automotive electronic system according to claim 1, characterized in that: The process of the kernel periodically allocating or reclaiming resources from a container based on the resource usage of the container includes the following steps: In the dynamic scheduling phase, the remaining available time slices on the kernel need to be updated when allocating or reclaiming time slices, using To track kernel N j The remaining available time slice is defined as follows: In formula (13), For kernel N j The total amount of available time slices, if updated That is, kernel N j When there is no remaining available time slice, Crt j The value is set to 1, indicating that the kernel N j Entering a critical state, if after updating Then the kernel N j The critical state is set to 0; Use the real-time parameter CLM k To measure the container π k Real-time performance, assuming that container π k The execution sequence of tasks is τ1 to τ r , then: Among them, E i For the task τ i The actual execution time, CLM k (i) represents the task τ i Whether the actual execution time is ahead of schedule or overtime, if there is CLM k (r)>0, indicating that there is a task that has been completed overtime. In this case, additional time slices need to be allocated. If there is CLM k (r)<0, indicating that all tasks are completed ahead of schedule, so some time slices are recycled; If CLM k (r)<0, the kernel controller will recycle container resources based on the integral controller strategy, that is: Q k (λ)=K l *[Q k (λ-1)+CLM k (r)]+Q k (λ-1) formula (15) Among them, K l The parameter representing the intensity of the resource recovery link’s response to the controller. The formula uses the container π k Real-time parameter CLM of the last operation cycle k and available time slice Q k , to quantify the amount of resources that the kernel needs to reclaim; CLM needs to be considered k (r)>0, when the container π k Available time slice Q k When exhausted, the kernel controller allocates additional time slices Q tsp , if it is a HC container, then Q tsp =CLM k (r) and the kernel controller will allow the kernel to continue to be used until the additional time slice Q tsp is also exhausted, if it is an LC container, then But further use of the kernel is not allowed: When a container operation cycle ends, the kernel controller will use the integral controller strategy and refer to Q tsp The value of Q in the next operation cycle is used to update the container k The value of, that is: Q k (λ)=K m *[Q k (λ-1)+Q tsp ]+Q k (l-1) formula(16) Among them, K m It represents the parameter of the controller response strength in the time slice allocation link, Q k (λ) represents the container π k The available time slice Q allocated to the λth operation cycle k .
7. The task scheduling method for a virtualized automotive electronic system according to claim 1, characterized in that: The kernel deprives the resources of other containers except the container that failed to migrate: First calculate the time slice size Q that needs to be deprived req , and its calculation formula is: Determine the deprivation object and allocate the LC container according to the available time slice Q k Arrange by size, giving priority to Q k Larger containers as objects of deprivation; Deprive time slices in order until the time slice requirement Q can be met req ; According to the time slice deprivation situation, update the available time slice Q of each container k ; View kernel N j Has it entered a critical state? If kernel N j In a critical state, it is necessary not only to deprive the LC container of its time slice, but also to send a migration request to the container migration controller of the node.
8. The task scheduling method for a virtualized automotive electronic system according to claim 1, characterized in that: The process of migrating the container: The node's container migration controller MigCtrl obtains the remaining available time slices of each core at the end of each operation cycle. and remaining available memory Then with the container to be migrated π k The migration request is rejected if there is no core with sufficient resources. If the requirements are met, the next step is entered. MigCtrl and The kernel with the largest value is used as the target kernel for migration, and the container π is recorded at the same time. k Parameters of Before executing container migration, MigCtrl will migrate the container π k Available time slice Q k Set the value to 0, blocking container π k Execution of tasks in Before creating a new container, k Destroy and release the occupied kernel resources; MigCtrl will follow the recorded original container π k Pull and start a new container π in the target kernel with the relevant parameters k .
9. A task scheduling system suitable for virtualized automotive electronic systems, characterized in that: include: A resource pre-allocation module, used for obtaining a mapping kernel of a container, and pre-allocating time slices and operating cycles for the container based on the mapping kernel of the container, wherein computing resources and storage resources are pre-allocated to the container; The container migration module is used to obtain the resource usage of the container. The kernel periodically allocates or reclaims resources for the container based on the resource usage of the container. When the kernel has no resources, the container is migrated. The resource reallocation module is used to deprive the kernel of resources of other containers except the container where the migration failed, and allocate the resources of other containers except the migration container to the container where the migration failed, if the migration fails, and repeat the above operations in a loop to realize task scheduling.
10. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, characterized in that: The memory stores a computer program that can be run on the processor. When the processor loads and executes the computer program, a task scheduling method suitable for a virtualized automotive electronic system according to any one of claims 1 to 8 is adopted.
Citation Information
Patent Citations
Electric power system supercomputing platform task scheduling method based on Docker container
CN110457131A
Container cloud scheduling method based on periodic characteristics
CN111367632A
Cloud platform container scheduling method and device, electronic equipment and storage medium
CN117472505A
Deterministic scheduling method of embedded container operating system
CN117909065A
Online service computing power optimization method and system based on cloud computing
CN118484267A