Resource-aware task allocation method for hybrid-critical partitioned real-time operating system

By using a resource-aware task allocation and migration method, the problem of long task blocking time in hybrid critical systems is solved, the schedulability of the system is improved, and the effective execution of high and low critical tasks in their respective modes is ensured.

CN116244073BActive Publication Date: 2026-03-17SUN YAT SEN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-06
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Existing task allocation algorithms for hybrid critical systems fail to effectively consider the impact of shared resource access, resulting in long task blocking times and low system schedulability.

Method used

A resource-aware task allocation method is adopted, which groups tasks according to resource access status and allocates tasks in high-criticality and low-criticality system modes respectively. The system mode switching is combined with a task migration method to ensure that tasks are schedulable in each mode.

Benefits of technology

By reducing the blocking time of shared resources, the overall schedulability of the hybrid critical system is improved, ensuring the effective operation of the system under different criticality levels.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116244073B_ABST
    Figure CN116244073B_ABST
Patent Text Reader

Abstract

This invention discloses a resource-aware task allocation method for a hybrid critical partition real-time operating system, comprising: grouping tasks according to resource access status; allocating high-critical-level tasks based on the task grouping results, ensuring that the allocation results are schedulable in high-critical-level system mode; allocating low-critical-level tasks based on the task grouping results, ensuring that the allocation results are schedulable in low-critical-level system mode; and using a task migration method to schedule system mode switching based on the allocated high-critical-level and low-critical-level tasks, thus completing the task allocation. This invention can improve the overall schedulability of the system and can be widely applied in the field of computer technology.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a resource-aware task allocation method for a hybrid critical partition real-time operating system. Background Technology

[0002] A hybrid critical system is an embedded real-time system that performs multiple functions on a single computing platform while meeting space, power, and cost constraints. Such systems are widely used in the automotive, aerospace, and other industries. In such integrated systems, applications with different certification requirements and varying degrees of importance (criticality) can coexist and share system resources. Hybrid critical systems must ensure that high-criticality tasks are executed correctly and meet time constraints, while low-criticality tasks can be abandoned under certain circumstances to ensure the operation of high-criticality tasks. Hybrid critical systems typically have two operating modes: low-criticality and high-criticality. The system starts in low-criticality mode. In this mode, low-criticality tasks run alongside high-criticality tasks at their low-criticality execution times. When a task times out, the system switches to high-criticality mode, suspending the low-criticality task, while the high-criticality task runs with a longer execution time.

[0003] In multi-core hybrid critical systems, low-criticality tasks share various platform resources with high-criticality tasks, such as code segments, data, memory, and I / O devices. To ensure data integrity and consistency, tasks need to access these shared resources using locks in a mutually exclusive manner. Spin locks, as defined in the AUTOSAR standard, are widely used to protect the computational correctness of shared resources. Real-time systems use spin lock-based resource sharing protocols to manage access to shared resources and provide upper bounds on the time tasks spend waiting for and executing shared resources. However, due to the application of spin locks, when tasks request the same resource on different processors, they will busy-wait on their respective processors until they successfully acquire the requested resource. This phenomenon will introduce high blocking times for tasks and severely compromise system schedulability.

[0004] In real-time systems, response time analysis is a mainstream schedulability analysis method. This method first predicts the worst-case response time for each task and then compares this value with the task's deadline. Currently, in the schedulability analysis of spinlock-based shared resource protocols, by analyzing resource access blocking within a given time period, three types of blocking times (direct spin blocking, indirect spin blocking, and arrival blocking) can be precisely constrained. This provides an upper bound on the time for tasks to wait for and execute shared resources. Fitting this time term into the response time analysis equation can provide more accurate analysis results.

[0005] In recent years, resource-aware task allocation methods have received widespread attention in multiprocessor systems to reduce resource contention between processors. The idea behind this approach is to reduce contention by localizing shared resources, that is, assigning tasks accessing the same shared resource to the same core whenever possible. However, in hybrid critical systems, few studies have focused on resource-aware task allocation algorithms. Furthermore, the frequent access to shared resources prevalent in real-world systems leads to problems such as long task blocking times and low system schedulability.

[0006] Currently, the main problems with task allocation algorithms in hybrid critical systems are as follows:

[0007] Existing research generally uses heuristic algorithms to allocate tasks. The task allocation rules mainly consider task utilization and deadlines, and usually only consider tasks at their highest critical level (i.e., maximum utilization). This leads to a pessimistic estimate of system utilization, thereby reducing system schedulability.

[0008] Some studies have considered the utilization differences at multiple critical levels, which can improve the overall schedulability of the system. However, none of the above solutions have taken into account the impact of shared resource access, resulting in the system becoming unschedulable due to excessive blocking latency during actual operation. Summary of the Invention

[0009] In view of this, embodiments of the present invention provide a resource-aware task allocation method for a hybrid critical partition real-time operating system to improve system schedulability.

[0010] One aspect of this invention provides a resource-aware task allocation method for a hybrid critical partition real-time operating system, comprising:

[0011] Group the tasks according to resource access information;

[0012] Based on the task grouping results, allocate high-critical-level tasks while ensuring that the allocation results are schedulable in the high-critical-level system mode.

[0013] Based on the task grouping results, low-critical tasks are allocated while ensuring that the allocation results are schedulable in the low-critical-level system mode.

[0014] Based on the assigned high-criticality and low-criticality tasks, the system mode switching is scheduled using the task migration method to complete the task allocation.

[0015] Optionally, grouping tasks based on resource access includes:

[0016] Sort the shared resources in descending order of the total number of times they have been accessed to obtain the resource sorting results;

[0017] Tasks are grouped according to the resource sorting results;

[0018] Based on the criticality level of the task, each resource task group and independent task group is further subdivided.

[0019] Optionally, the step of grouping tasks according to the resource sorting result includes:

[0020] Starting with the first resource, if a task needs to request that resource, it is added to the task group corresponding to that resource; if a task has already been added to a group, it is not added to any other task groups; tasks that do not request any resources are treated as a separate group.

[0021] The process of further subdividing each resource task group and independent task group based on the criticality level of the task includes:

[0022] Each resource task group and independent task group is further divided to obtain a high-criticality task group and a low-criticality task group corresponding to each resource, as well as an independent high-criticality task group and an independent low-criticality task group.

[0023] Optionally, the step of allocating high-critical tasks based on the task grouping results, while ensuring that the allocation results are schedulable in the high-criticality system mode, includes:

[0024] Based on the task grouping results, a high-criticality task group and an independent high-criticality group are obtained for each resource. The tasks in the task group corresponding to each resource are sorted in ascending order according to their utilization rate under the high-criticality level.

[0025] Start iterating from the task group corresponding to the resource with the highest total number of visits;

[0026] Sort the processors by utilization rate in the high-criticality category from smallest to largest;

[0027] Tasks within the current task group are assigned sequentially, and tasks are assigned to the first schedulable processor in processor order, until task assignments for all high-critical task groups corresponding to all resources are completed.

[0028] Tasks within an independent task group are sorted in descending order of utilization under high criticality. Before each independent task is assigned, processors are sorted in ascending order of utilization under high criticality and assigned to the first schedulable processor in that order.

[0029] Optionally, the step of allocating low-critical tasks based on the task grouping results, while ensuring that the allocation results are schedulable in the low-criticality system mode, includes:

[0030] Based on the task grouping results, each resource has a corresponding low-criticality task group and an independent low-criticality task group. The tasks in each resource's task group are sorted in ascending order of utilization rate under the low-criticality level.

[0031] Start iterating from the task group corresponding to the resource with the highest total number of visits;

[0032] The processors are sorted, with those having high-critical-level tasks accessing the current resources placed first, and then sorted by utilization in ascending order under low-critical-level conditions. The remaining processors are then sorted by utilization in ascending order under low-critical-level conditions.

[0033] Tasks within the current task group are assigned sequentially, and tasks are assigned to the first schedulable processor in processor order, until task assignments for all low-critical-level task groups corresponding to all resources are completed.

[0034] Tasks within an independent task group are sorted in descending order of utilization at the lowest critical level. Before each independent task is assigned, processors are sorted in ascending order of utilization at the lowest critical level, and the processors are traversed and assigned to the first schedulable processor.

[0035] Optionally, the step of scheduling system mode switching using a task migration method based on the allocated high-criticality tasks and low-criticality tasks to complete task allocation includes:

[0036] Calculate the response time of each high-critical-level task during mode switching, and check whether the task's response time exceeds the deadline during mode switching;

[0037] When a task's response time exceeds the deadline, check the timeout reasons for each task in turn until the task can be scheduled.

[0038] Complete the scheduling of all high-critical tasks.

[0039] Optionally, the step of checking the timeout reasons of the task sequentially when the task's response time exceeds the deadline until the task can be scheduled includes:

[0040] When a high-critical task experiences arrival delays during mode switching that are greater than those experienced under the normal high-criticality level, acquire the resource causing the maximum arrival delay and execute the following steps:

[0041] If no high-critical task accesses the resource on the processor to which the current task belongs, and only low-critical tasks access the resource: sort the processors, placing the processors that can cause spin blocking for low-critical tasks first, and sort the remaining processors in descending order of relaxation time; according to the processor order, migrate all low-critical tasks accessing the resource on that processor to the first processor that can meet the conditions.

[0042] If a high-critical task is accessing the resource on the processor where the current task resides: all low-critical tasks accessing the resource on the processor that is causing the current task to block access will attempt to migrate to the processor where the current task resides.

[0043] If the current task is still unschedulable after performing the above steps, continue with the following steps:

[0044] If the resource access blocking time is greater than 0, then iterate by resource number and check by processor number in turn whether there is a low-critical task accessing the resource on each processor causing spin blocking of the task, and migrate the low-critical task accessing the resource on the processor to the core where the current task is located; if this migration will not cause any new task timeouts, then execute the migration.

[0045] Stop when the current task is schedulable or when all resources have been traversed.

[0046] Another aspect of this invention provides a resource-aware task allocation device for a hybrid critical partition real-time operating system, comprising:

[0047] The first module is used to group tasks according to resource access status;

[0048] The second module is used to allocate high-critical tasks based on the task grouping results, while ensuring that the allocation results are schedulable in the high-critical-level system mode.

[0049] The third module is used to allocate low-critical tasks based on the task grouping results, while ensuring that the allocation results are schedulable in the low-critical-level system mode.

[0050] The fourth module is used to schedule system mode switching based on the assigned high-criticality and low-criticality tasks, and to complete task allocation.

[0051] Another aspect of the present invention provides an electronic device, including a processor and a memory;

[0052] The memory is used to store programs;

[0053] The processor executes the program to implement the method described above.

[0054] Another aspect of this invention provides a computer-readable storage medium storing a program that is executed by a processor to implement the methods described above.

[0055] This invention also discloses a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium and execute the computer instructions, causing the computer device to perform the aforementioned method.

[0056] In embodiments of the present invention, tasks are grouped according to resource access status; based on the task grouping results, high-critical tasks are allocated while ensuring the allocation result is schedulable in a high-criticality system mode; based on the task grouping results, low-critical tasks are allocated while ensuring the allocation result is schedulable in a low-criticality system mode; based on the allocated high-critical and low-critical tasks, a task migration method is used to schedule system mode switching, completing task allocation. The present invention can improve the overall schedulability of the system. Attached Figure Description

[0057] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0058] Figure 1 The overall process flowchart provided for embodiments of the present invention. Detailed Implementation

[0059] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0060] The following is an explanation of the relevant technical terms that may appear in this invention:

[0061] Fixed-priority scheduling (FPS) is a scheduling method used in real-time systems. Task priorities are statically assigned before system execution and remain fixed throughout the task's lifecycle. During system operation, tasks with higher priorities are scheduled for execution first.

[0062] Semi-partitioned scheduling: A real-time scheduling scheme for multiprocessors. Before runtime, tasks are statically allocated to each processor, and scheduling is performed independently on each processor. However, unlike full partitioning, semi-partitioned scheduling allows some tasks to migrate to pre-specified processors under specific conditions.

[0063] Sporadic task model: A computational task with explicit time constraints. The arrival of the task does not have a fixed period, but there is a minimum arrival interval. In the worst case, it can be regarded as a periodic task.

[0064] Shared resources: Hardware or software resources that multiple tasks can request simultaneously but must exclusively access. To ensure data integrity, each resource is protected by a designated lock. A task is only allowed to access a resource if it acquires the lock corresponding to that resource; if a resource is occupied, the task requesting the resource will wait until the resource becomes available again.

[0065] Scheduleability refers to the ability of all tasks in the system to complete and run within the deadline.

[0066] Schedulerability testing refers to a set of mathematical tools that can calculate the worst-case response time (from release to completion) of a task on a target system. The worst-case response time typically includes several main components such as the worst-case time required for the task itself to execute (WCET), the interference time of local high-priority tasks, and the blocking time caused by the task accessing shared resources (explained in detail below).

[0067] Spin delay occurs in multiprocessor systems using spinlock-based resource sharing protocols when a task on a remote processor accesses a resource, causing the local task requesting the same resource to spin and wait. Direct spin delay occurs when the requesting task is directly affected by the remote task; indirect spin delay occurs when a low-priority task is transitively blocked by a high-priority task that is being interfered with by a remote task.

[0068] Arrival blocking: In systems based on non-preemptive or priority promotion techniques, high-priority tasks are blocked by local low-priority tasks when they arrive because they cannot be preempted.

[0069] To address the problems existing in the prior art, this invention proposes a task allocation method for shared resources, which significantly reduces the blocking time of tasks accessing shared resources and improves the schedulability of the system.

[0070] Specifically, one aspect of this invention provides a resource-aware task allocation method for a hybrid critical partition real-time operating system, including:

[0071] Group the tasks according to resource access information;

[0072] Based on the task grouping results, allocate high-critical-level tasks while ensuring that the allocation results are schedulable in the high-critical-level system mode.

[0073] Based on the task grouping results, low-critical tasks are allocated while ensuring that the allocation results are schedulable in the low-critical-level system mode.

[0074] Based on the assigned high-criticality and low-criticality tasks, the system mode switching is scheduled using the task migration method to complete the task allocation.

[0075] Optionally, grouping tasks based on resource access includes:

[0076] Sort the shared resources in descending order of the total number of times they have been accessed to obtain the resource sorting results;

[0077] Tasks are grouped according to the resource sorting results;

[0078] Based on the criticality level of the task, each resource task group and independent task group is further subdivided.

[0079] Optionally, the step of grouping tasks according to the resource sorting result includes:

[0080] Starting with the first resource, if a task needs to request that resource, it is added to the task group corresponding to that resource; if a task has already been added to a group, it is not added to any other task groups; tasks that do not request any resources are treated as a separate group.

[0081] The process of further subdividing each resource task group and independent task group based on the criticality level of the task includes:

[0082] Each resource task group and independent task group is further divided to obtain a high-criticality task group and a low-criticality task group corresponding to each resource, as well as an independent high-criticality task group and an independent low-criticality task group.

[0083] Optionally, the step of allocating high-critical tasks based on the task grouping results, while ensuring that the allocation results are schedulable in the high-criticality system mode, includes:

[0084] Based on the task grouping results, a high-criticality task group and an independent high-criticality group are obtained for each resource. The tasks in the task group corresponding to each resource are sorted in ascending order according to their utilization rate under the high-criticality level.

[0085] Start iterating from the task group corresponding to the resource with the highest total number of visits;

[0086] Sort the processors by utilization rate in the high-criticality category from smallest to largest;

[0087] Tasks within the current task group are assigned sequentially, and tasks are assigned to the first schedulable processor in processor order, until task assignments for all high-critical task groups corresponding to all resources are completed.

[0088] Tasks within an independent task group are sorted in descending order of utilization under high criticality. Before each independent task is assigned, processors are sorted in ascending order of utilization under high criticality and assigned to the first schedulable processor in that order.

[0089] Optionally, the step of allocating low-critical tasks based on the task grouping results, while ensuring that the allocation results are schedulable in the low-criticality system mode, includes:

[0090] Based on the task grouping results, each resource has a corresponding low-criticality task group and an independent low-criticality task group. The tasks in each resource's task group are sorted in ascending order of utilization rate under the low-criticality level.

[0091] Start iterating from the task group corresponding to the resource with the highest total number of visits;

[0092] The processors are sorted, with those having high-critical-level tasks accessing the current resources placed first, and then sorted by utilization in ascending order under low-critical-level conditions. The remaining processors are then sorted by utilization in ascending order under low-critical-level conditions.

[0093] Tasks within the current task group are assigned sequentially, and tasks are assigned to the first schedulable processor in processor order, until task assignments for all low-critical-level task groups corresponding to all resources are completed.

[0094] Tasks within an independent task group are sorted in descending order of utilization at the lowest critical level. Before each independent task is assigned, processors are sorted in ascending order of utilization at the lowest critical level, and the processors are traversed and assigned to the first schedulable processor.

[0095] Optionally, the step of scheduling system mode switching using a task migration method based on the allocated high-criticality tasks and low-criticality tasks to complete task allocation includes:

[0096] Calculate the response time of each high-critical-level task during mode switching, and check whether the task's response time exceeds the deadline during mode switching;

[0097] When a task's response time exceeds the deadline, check the timeout reasons for each task in turn until the task can be scheduled.

[0098] Complete the scheduling of all high-critical tasks.

[0099] Optionally, the step of checking the timeout reasons of the task sequentially when the task's response time exceeds the deadline until the task can be scheduled includes:

[0100] When a high-critical task experiences arrival delays during mode switching that are greater than those experienced under the normal high-criticality level, acquire the resource causing the maximum arrival delay and execute the following steps:

[0101] If no high-critical task accesses the resource on the processor to which the current task belongs, and only low-critical tasks access the resource: sort the processors, placing the processors that can cause spin blocking for low-critical tasks first, and sort the remaining processors in descending order of relaxation time; according to the processor order, migrate all low-critical tasks accessing the resource on that processor to the first processor that can meet the conditions.

[0102] If a high-critical task is accessing the resource on the processor where the current task resides: all low-critical tasks accessing the resource on the processor that is causing the current task to block access will attempt to migrate to the processor where the current task resides.

[0103] If the current task is still unschedulable after performing the above steps, continue with the following steps:

[0104] If the resource access blocking time is greater than 0, then iterate by resource number and check by processor number in turn whether there is a low-critical task accessing the resource on each processor causing spin blocking of the task, and migrate the low-critical task accessing the resource on the processor to the core where the current task is located; if this migration will not cause any new task timeouts, then execute the migration.

[0105] Stop when the current task is schedulable or when all resources have been traversed.

[0106] Another aspect of this invention provides a resource-aware task allocation device for a hybrid critical partition real-time operating system, comprising:

[0107] The first module is used to group tasks according to resource access status;

[0108] The second module is used to allocate high-critical tasks based on the task grouping results, while ensuring that the allocation results are schedulable in the high-critical-level system mode.

[0109] The third module is used to allocate low-critical tasks based on the task grouping results, while ensuring that the allocation results are schedulable in the low-critical-level system mode.

[0110] The fourth module is used to schedule system mode switching based on the assigned high-criticality and low-criticality tasks, and to complete task allocation.

[0111] Another aspect of the present invention provides an electronic device, including a processor and a memory;

[0112] The memory is used to store programs;

[0113] The processor executes the program to implement the method described above.

[0114] Another aspect of this invention provides a computer-readable storage medium storing a program that is executed by a processor to implement the methods described above.

[0115] This invention also discloses a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium and execute the computer instructions, causing the computer device to perform the aforementioned method.

[0116] The specific implementation process of the present invention will now be described in detail with reference to the accompanying drawings:

[0117] This invention is based on a mixed-criticality system comprising two system execution modes (L∈{HI,LO}): a high-criticality system and a low-criticality system. The system includes a set of identical symmetric multiprocessors Φ and a set of sporadic tasks Γ. The system employs a semi-partitioned fixed-priority scheduling scheme.

[0118] In the system, each task (t) i The representation is defined by the period, deadline, worst-case execution time estimate, priority, criticality level, allocation scheme, and migration scheme. Unlike ordinary periodic tasks, the worst-case execution estimate for hybrid mission-critical tasks exhibits a vector characteristic, meaning that different system execution modes have different worst-case time estimates. Higher-level system modes will use a more conservative approach to estimate the task execution time (C). i (HI)>C i (LO)). The worst-case response time of a task in mode L is denoted as R. i (L), the utilization rate of the task in mode L is expressed as processor The utilization rate under mode L is expressed as:

[0119] Additionally, the system contains a set of shared resources (resource set denoted by R) protected by spinlocks. For a resource in the system (denoted by r) k (indicated), c k (L) indicates that r is executed at the critical level L. k Worst execution time estimate, also assuming c k (HI)>c k (LO). Represents task τ i Accessing resource r during a single run k The number of times; the function F(·) represents the set of resources accessed by a given task, and the function G(·) represents the set of tasks accessing a given resource. Indicates resource r k Corresponding task groups, This indicates a task group that does not request resources.

[0120] The hybrid criticality model assumes that the system starts at a low criticality level, and all tasks are scheduled using the budget for that low criticality level. In actual operation, if a task's execution time exceeds the budget for that mode, the system will switch to a high criticality level and suspend all low criticality tasks.

[0121] like Figure 1 As shown, the present invention includes four core steps: first, tasks are grouped based on resource access; then, high-criticality tasks are prioritized and allocated according to the task grouping results, ensuring that the allocation results are schedulable in the high-criticality system mode; next, low-criticality tasks are allocated and the allocation results are ensured to be schedulable in the low-criticality system mode; and finally, a task migration method is used to ensure schedulability when switching system modes.

[0122] The specific steps of this invention are as follows:

[0123] Step 1: Task Grouping:

[0124] Step 1.1: Sort the shared resources in descending order of total access frequency, i.e.

[0125] Step 2.1: Group the tasks according to the resource sorting in Step 1.1. Starting with the first resource, if a task needs to request resource r... k Then add the resource r k Corresponding task groups If a task has already been added to a group, it will not be added to any other task groups. Tasks that do not request task resources are all grouped as independent tasks.

[0126] Step 3.1: Further divide each resource task group and independent task group according to the criticality level to obtain each resource r k Corresponding high-criticality task group and low-criticality task groups And a separate high-critical mission group and an independent low-criticality task group

[0127] Step 2: Assignment of high-criticality tasks:

[0128] Step 2.1: Based on task grouping (Algorithm 1), obtain the high-criticality task group corresponding to each resource. And an independent high-criticality group Tasks within each resource's task group are ranked according to their utilization rate under the high-criticality level. i (HI) Sort in ascending order.

[0129] Step 2.2: From the total number of visits N kThe task group corresponding to the largest resource is then traversed.

[0130] Step 2.3: Configure the processor for high criticality. Sort by size from smallest to largest (processors with smaller workloads can be assigned more tasks from the same task group);

[0131] Step 2.4: Assign tasks within the current task group sequentially, assigning tasks to the first schedulable processor in processor order, until all tasks in the high-criticality task groups corresponding to all resources are assigned. The schedulability test uses schedulability analysis in the high-criticality mode.

[0132] Repeat steps 2.3 and 2.4 until the task assignment for all high-critical task groups corresponding to all resources is completed.

[0133] Step 2.5: Within an independent task group, tasks are ranked according to their utilization rate (u) under the highest criticality level. i (HI) Descending sorting: Before each independent task is assigned, the processors are sorted from smallest to largest according to their utilization under high criticality, and assigned to the first schedulable processor in order. The schedulability test uses schedulability analysis under high criticality mode.

[0134] Step 3: Assignment of low-criticality tasks:

[0135] Step 3.1: Based on task grouping (Algorithm 1), obtain the low-criticality task group corresponding to each resource. And a separate low-criticality task group The tasks within each resource's task group are allocated based on their utilization rate at the low criticality level. i (LO) sorts in ascending order.

[0136] Step 3.2: From the total number of visits N k The task group corresponding to the largest resource is then traversed.

[0137] Step 3.3: Sort the processors. Processors with high-criticality tasks accessing the resource are ranked first, followed by processors with low-criticality utilization. Sort by size from smallest to largest, and then allocate the remaining processors according to their utilization rate under low criticality. Sort by size from smallest to largest.

[0138] Step 3.4: Assign tasks within the current task group sequentially, assigning tasks to the first schedulable processor in processor order. The schedulability test uses schedulability analysis in low-criticality mode.

[0139] Repeat steps 3.3 and 3.4 until task assignments for all low-critical task groups corresponding to all resources are completed.

[0140] Step 3.5: Within an independent task group, tasks are categorized by their utilization rate (u) at the lowest criticality level. i (LO) sorting in descending order: before allocating each independent task, the processors are sorted in ascending order of utilization under low criticality. The processors are traversed and the task is allocated to the first schedulable processor. The schedulability test uses the schedulability analysis under low criticality mode.

[0141] Step 4: Task migration method during mode switching:

[0142] In a mixed-critical system, if a task's execution time exceeds the worst-case time estimate, the system mode will be upgraded (i.e., mode switch). After the upgrade, low-critical tasks will be suspended, while high-critical tasks will run with a more pessimistic worst-case time. Due to the existence of shared resources, to ensure the integrity of shared resources, if a low-critical task holds a shared resource during system mode switch, that task will be suspended after the current resource is completed; otherwise, the task will be suspended directly.

[0143] In analyzing the worst response time (R) of the task i When we consider a low-criticality task τ, we use a more pessimistic assumption to provide a safe worst-case response time boundary. Specifically, during mode switching, the low-criticality task will run with the lowest priority and suspend after accessing all the resources it needs once. That is, for a low-criticality task τ... j If r k ∈F(τ j ),

[0144] Based on the high-criticality task allocation steps, we ensure the schedulability of high-criticality tasks under the high-criticality mode while allocating them, i.e., R i (HI) <D i During mode switching, access to resources by low-critical tasks can block the execution of high-critical tasks, causing some high-critical tasks to become unschedulable. We consider migrating low-critical tasks during mode switching to mitigate this impact on high-critical tasks, thereby ensuring the schedulability of high-critical tasks during mode switching.

[0145] First, determine whether a high-criticality task will time out after being interfered with by a low-criticality task during mode switching.

[0146] R i =R i (HI)+I i +B i

[0147] Among them, I i For low-critical tasks on remote processors to τ iThe resulting spin blocking time, B i For τ i The increased arrival blocking time. Using existing blocking time analysis methods, the resource access blocking time I can be calculated. i and B i .

[0148]

[0149] For processor Accessing resources above k Low-criticality tasks to task τ i The resulting blockage, where F A (τ i ) for possible tasks τ i The set of resources that cause the blockage, B i (HI) represents task τ i Arrival blocking time in high-criticality mode.

[0150]

[0151] The transfer algorithm steps are as follows:

[0152] Step 4.1: Using R i =R i (HI)+I i +B i Calculate the response time R for each high-criticality task during mode switching. i Determine whether the deadline D has been exceeded. i Based on the updated R i The core's slack time is defined as...

[0153] Step 4.2: If there is a task τ i If a timeout occurs, check the reasons for the timeout in sequence.

[0154] Step 4.2.1: If B i >0, obtain the maximum arrival blockage B. i resources r k There are two scenarios to consider:

[0155] 1) If in task τ i On the processor in question, no high-critical tasks access the resource; only low-critical tasks do. Sort the processors, prioritizing those capable of causing spin blocking for these low-critical tasks, and then sort the remaining processors by their relaxation time from largest to smallest. Then, in processor order, process all tasks on that processor that access the resource r...k Low-critical tasks can be migrated to the first processor that meets the requirements. The requirement for migration is that there are no new timeout tasks.

[0156] 2) If in task τ i On the processor in question, if a high-critical task is accessing this resource: all low-critical tasks on the processor that are causing a blockage to this task will attempt to migrate to task τ. i The processor in which the task is located. Migration is possible only if there are no new timeout tasks.

[0157] Repeat step 4.2.1 until B. i =0 or R i <D i If the above migration is unsuccessful, proceed to step 4.2.2.

[0158] Step 4.2.2: If I i If the value is greater than 0, then iterate through the resource ID k and check each processor in turn by processor ID m. Is there access to the resource r? k Low-criticality tasks to task τ i This causes spin blocking, i.e. if Then the processor Accessing resources above k Low-criticality mission migration to mission τ i Located in the core. If this migration will not cause any new task timeouts, then execute the migration. When task τ i Scheduling (R) i <D i Alternatively, stop when all resources have been traversed.

[0159] Step 4.3: If the task is schedulable after step 4.2 has finished executing, then continue executing step 4.2 until all high-criticality tasks are schedulable (R... i <D i ).

[0160] In summary, compared with the prior art, the present invention has the following characteristics:

[0161] 1. This solution takes into account the impact of shared resources, localizes highly competitive resources as much as possible, thereby reducing resource access conflicts between cores, reducing task blocking time, and improving the schedulability of the system.

[0162] 2. The scheme considers the worst-case running time of tasks at different critical levels under a hybrid critical system during the allocation process (i.e., tasks have different utilization rates at different critical levels, with higher critical levels having higher utilization rates); it proposes a task allocation and migration method during various modes and mode switching to ensure the schedulability of the system in all operating scenarios.

[0163] This invention reduces resource blocking time and improves system schedulability by allocating tasks to localized, highly competitive shared resources. It considers the critical-level characteristics of hybrid critical-level systems, ensuring schedulability under each critical-level mode during allocation; it uses task migration to guarantee schedulability during mode switching, rationally utilizing system capacity and improving overall system schedulability.

[0164] In some alternative embodiments, the functions / operations mentioned in the block diagrams may not occur in the order shown in the operation diagrams. For example, depending on the functions / operations involved, two consecutively shown blocks may actually be executed substantially simultaneously, or the blocks may sometimes be executed in reverse order. Furthermore, the embodiments presented and described in the flowcharts of this invention are provided by way of example to provide a more comprehensive understanding of the technology. The disclosed methods are not limited to the operations and logic flows presented herein. Alternative embodiments are contemplated in which the order of various operations is altered and sub-operations described as part of a larger operation are executed independently.

[0165] Furthermore, although the invention has been described in the context of functional modules, it should be understood that, unless otherwise stated, one or more of the described functions and / or features may be integrated into a single physical device and / or software module, or one or more functions and / or features may be implemented in a separate physical device or software module. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding the invention. Rather, given the properties, functions, and internal relationships of the various functional modules in the apparatus disclosed herein, the actual implementation of the module will be understood within the scope of conventional skill of an engineer. Therefore, those skilled in the art can implement the invention as set forth in the claims using ordinary techniques without excessive experimentation. It is also understood that the specific concepts disclosed are merely illustrative and not intended to limit the scope of the invention, which is determined by the full scope of the appended claims and their equivalents.

[0166] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0167] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.

[0168] More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.

[0169] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0170] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0171] Although embodiments of the invention have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.

[0172] The above is a detailed description of the preferred embodiments of the present invention, but the present invention is not limited to the embodiments described. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the present invention, and these equivalent modifications or substitutions are all included within the scope defined by the claims of this application.

Claims

1. A resource-aware task allocation method for a mixed-critical partitioned real-time operating system, characterized in that, The method comprises the following steps: grouping tasks according to resource access conditions; allocating high criticality level tasks according to the grouping results of the tasks, under the condition that the allocation results are schedulable in a high criticality level system mode; allocating low criticality level tasks according to the grouping results of the tasks, under the condition that the allocation results are schedulable in a low criticality level system mode; performing scheduling for system mode switching by using a task migration method according to the allocated high criticality level tasks and low criticality level tasks, and completing task allocation; the grouping of the tasks according to resource access conditions comprises the following steps: sorting shared resources according to the total number of accesses from large to small to obtain a resource sorting result; grouping tasks according to the resource sorting result; further dividing each resource task group and independent task group obtained by the division according to the criticality level of the tasks; the grouping of the tasks according to the resource sorting result comprises the following steps: starting from the first resource, if a task needs to request the resource, the task is added to the task group corresponding to the resource; if the task has been added to a group, the task is not added to other groups; tasks that do not request any resource are all regarded as an independent group; the further division of each resource task group and independent task group according to the criticality level of the tasks comprises the following steps: further dividing each resource task group and independent task group to obtain a high criticality level task group and a low criticality level task group corresponding to each resource, and to obtain an independent high criticality level task group and an independent low criticality level task group; the allocation of high criticality level tasks according to the grouping results of the tasks, under the condition that the allocation results are schedulable in a high criticality level system mode, comprises the following steps: obtaining a high criticality level task group corresponding to each resource and an independent high criticality level group according to the grouping results of the tasks, and sorting the tasks in each task group corresponding to each resource in ascending order according to the utilization rate under the high criticality level; starting from the task group corresponding to the resource with the largest total number of accesses; sorting processors in descending order according to the utilization rate under the high criticality level; sequentially allocating the tasks in the current task group, and allocating the tasks to the first schedulable processor in processor order until the task allocation of the high criticality level task groups corresponding to all resources is completed; sorting the tasks in the independent task group in descending order according to the utilization rate under the high criticality level, sorting the processors in ascending order according to the utilization rate under the high criticality level before allocating the independent tasks each time, and allocating the tasks to the first schedulable processor in processor order.

2. The resource-aware task allocation method of a mixed-critical partitioned real-time operating system according to claim 1, characterized in that, the allocation of low criticality level tasks according to the grouping results of the tasks, under the condition that the allocation results are schedulable in a low criticality level system mode, comprises the following steps: obtaining a low criticality level task group corresponding to each resource and an independent low criticality level task group according to the grouping results of the tasks, and sorting the tasks in each task group corresponding to each resource in ascending order according to the utilization rate under the low criticality level; starting from the task group corresponding to the resource with the largest total number of accesses; sorting processors, arranging processors with high criticality level tasks accessing the current resource in front, and sorting the remaining processors in ascending order according to the utilization rate under the low criticality level. sequentially allocating tasks in the current task group, and allocating the tasks to the first schedulable processor in processor order until all the tasks in the task group corresponding to the low criticality level of the corresponding resource are allocated; the tasks in the independent task group are sorted in descending order of the utilization under the low criticality level, and each time before allocating an independent task, the processors are sorted in ascending order of the utilization under the low criticality level, and the processors are traversed to allocate the task to the first schedulable processor.

3. The resource-aware task allocation method of a mixed-critical partitioned real-time operating system according to claim 1, characterized in that, the scheduling of the system mode switching using the task migration method according to the allocated high criticality level tasks and low criticality level tasks, and the completion of the task allocation, comprising: calculating the response time of each high criticality level task during the mode switching, and checking whether the response time of the task exceeds the deadline during the mode switching; when the response time of the task exceeds the deadline, sequentially checking the timeout reason of the task until the task is schedulable; completing the scheduling of all the high criticality level tasks.

4. The resource-aware task allocation method of a mixed-critical partitioned real-time operating system according to claim 3, characterized in that, the scheduling of the system mode switching using the task migration method according to the allocated high criticality level tasks and low criticality level tasks, and the completion of the task allocation, comprising: when the arrival blocking time of the high criticality task during the mode switching is greater than the arrival blocking time under the high criticality level, obtaining the resource causing the maximum arrival blocking, and performing the following steps: if there is no high criticality task accessing the resource on the processor to which the current task belongs, and only low criticality level tasks access the resource: sorting the processors, arranging the processors that can cause spin blocking to the low criticality tasks in the front, and sorting the remaining processors in descending order of the relaxation time; in processor order, migrating all the low criticality tasks accessing the resource on the processor to the first processor that can meet the condition; if there is a high criticality task accessing the resource on the processor to which the current task belongs: attempting to migrate all the low criticality level tasks accessing the resource on the processor causing the arrival blocking to the current task to the processor to which the current task belongs; when the above steps are performed, and the current task is still not schedulable, the following steps are continuously performed: if the resource access blocking time is greater than 0, traversing according to the resource number, checking whether there is a low criticality level task accessing the resource on each processor to cause spin blocking to the task in the order of the processor number, and migrating the low criticality task accessing the resource on the processor to the core to which the current task belongs; if the migration does not newly add a task timeout, the migration is performed; stopping when the current task is schedulable or all the resources are traversed.

5. An apparatus for implementing the resource-aware task allocation method of the hybrid-critical partitioned real-time operating system of any one of claims 1-4, characterized in that, comprising: a first module configured to group the tasks according to the resource access; a second module configured to allocate the high criticality level tasks according to the task grouping result, under the condition that the allocation result is schedulable under the high criticality level system mode; a third module configured to allocate the low criticality level tasks according to the task grouping result, under the condition that the allocation result is schedulable under the low criticality level system mode; a fourth module configured to complete the task allocation by scheduling the system mode switching using the task migration method according to the allocated high criticality level tasks and low criticality level tasks.

6. An electronic device, comprising: comprising a processor and a memory; the memory is configured to store a program; the processor is configured to execute the program to implement the method according to any one of claims 1 to 4.

7. A computer readable storage medium characterized in that, The storage medium stores a program, and the program is executed by the processor to implement the method in any one of claims 1 to 4.