Time protection method and device of real-time operation system, vehicle and medium

By monitoring the duration of factors affecting response time, identifying and controlling exception handling of real-time operating systems, problems such as task and ISR execution timeouts in real-time operating systems are solved, interrupt management and resource allocation are optimized, and the real-time and stability of the system are improved. .

CN119292865APending Publication Date: 2025-01-10BEIJING AUTOMOBILE RES GENERAL INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411301291.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-18
Publication Date
2025-01-10

AI Technical Summary

Technical Problem

The lack of time protection standards in real-time operating systems leads to problems such as task and ISR execution timeouts, response delays, system deadlocks, and resource exhaustion.

Method used

By monitoring the duration of response time-influence factors, identifying and controlling abnormal handling of real-time operating system entry time protection, including task and ISR execution time, interrupt disabling time, resource holding time and task activation frequency, using comparators and timers Mechanism optimizes interrupt management and resource allocation.

Benefits of technology

Accurately identify the root cause of response delay, avoid too long system response time, improve real-time and stability, and enhance system security and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119292865A_ABST
    Figure CN119292865A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of automobile function safety, in particular to a time protection method and device for a real-time operation system, a vehicle and a medium, and the method comprises the steps: obtaining response time influence factors of the real-time operation system; monitoring the duration of the response time influence factor; and controlling the real-time operating system to enter the exception handling of time protection according to the duration. Therefore, the problems that in the prior art, extreme conditions of tasks, interruption and resource management in a real-time operating system are difficult to control, and system performance and stability are affected are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of vehicle functional safety technology, and in particular to a time protection method, device, vehicle and medium for a real-time operating system. Background Art

[0002] In the field of automotive functional safety, in response to the strict requirements of safety standards on time protection, the AUTOSAR (Automotive Open System Architecture) operating system has introduced multiple mechanisms such as execution time protection, lock time protection and interval time protection, and has achieved standardization and customization of time protection mechanisms through highly flexible configuration tools.

[0003] However, the current real-time operating system field is facing the dilemma of lack of time protection standards. This situation directly leads to the frequent occurrence of various problems: task and ISR (Interrupt Service Routine) execution timeout, affecting real-time response; interrupt disable time is too long, resulting in response delay; resources are locked for a long time, causing system deadlock or performance degradation; task activation interval is too short, increasing system overhead; ISR is frequently triggered, exhausting system resources. Summary of the invention

[0004] The present application provides a time protection method, device, vehicle and medium for a real-time operating system to solve the problems in the prior art that extreme situations of tasks, interrupts and resource management in real-time operating systems are difficult to control, affecting system performance and stability.

[0005] The first aspect of the present application provides a time protection method for a real-time operating system, comprising the following steps: obtaining response time influencing factors of the real-time operating system; monitoring the duration of the response time influencing factors; and controlling the real-time operating system to enter time protection exception processing according to the duration.

[0006] Optionally, the response time influencing factors include at least one of the execution time of the task and the ISR, the interruption disabled time, the resource holding time, the task activation and the ISR occurrence.

[0007] Optionally, if the response time influencing factor is the execution duration of the task and the ISR, the real-time operating system is controlled to enter the time protection exception processing according to the duration, including: identifying the current task executed by each core of the CPU; if the current task enters the running state or the current ISR is triggered, setting the remaining execution budget duration of the current task or the current ISR in the comparator, if the current task is preempted and proceeds to the ready state or the SR is preempted, updating it to the remaining execution budget duration of the new task or the new ISR in the comparator, retaining the remaining execution budget duration of the old task or the old ISR in the stack of the preempted task or the preempted ISR, and when the old task enters the running state again or the old ISR is triggered, the remaining execution budget duration of the old task is put back into the comparator; if the running time of the current task or the current ISR is greater than the first preset duration, when the value of the timer and the comparator are equal, controlling the real-time operating system to enter the time protection exception processing.

[0008] Optionally, if the factor affecting the response time is the duration for which the interrupt is disabled, the real-time operating system is controlled to enter the time protection exception processing according to the duration, including: when the interrupt is disabled, setting the value in the comparator to the interrupt disable budget duration; when the task turns on the interrupt, if the timer has not accumulated to the value in the comparator, turning off the timer; if the timer and the comparator values ​​are equal, controlling the real-time operating system to enter the time protection exception processing.

[0009] Optionally, if the response time influencing factor is the resource holding time, the real-time operating system is controlled to enter the time protection exception processing according to the duration, including: identifying all resources held by each task; using a linked list of a comparator to manage the holding time of all resources of each task, wherein the value in the linked list header is the interval between the budget duration of the first holding time expected to arrive and the counter; if new resources are added, the difference between the budget duration of the new resource holding time and the timing duration of the current timer is calculated, and the resources are added to the linked list in order of the difference; if the resource is released within the budget duration of the holding time, the linked list node where the resource ID is released is released; if the resource is not released within the budget duration of the holding time, if the timer and the comparator are compared successfully, the real-time operating system is controlled to enter the time protection exception processing.

[0010] Optionally, if the response time influencing factor is task activation, the real-time operating system is controlled to enter the time protection exception processing according to the duration, including: each time the task enters the running state, the current counter value is recorded as the new value, and the counter value of the last time it entered the running state is recorded as the old value; after the task enters the running state, the difference between the new value and the old value is calculated, and if the difference is less than the first preset value, the real-time operating system is controlled to enter the time protection exception processing.

[0011] Optionally, if the response time influencing factor is the occurrence of ISR, the real-time operating system is controlled to enter the time protection exception processing according to the duration, including: recording the current counter value each time the ISR occurs as the new value, and recording the counter value each time the last ISR occurred as the old value; after entering the interrupt function, calculating the difference between the new value and the old value, if the difference is less than the second preset value, controlling the real-time operating system to enter the time protection exception processing.

[0012] The second aspect of the present application provides a time protection device for a real-time operating system, including: an acquisition module for acquiring response time influencing factors of the real-time operating system; a monitoring module for monitoring the duration of the response time influencing factors; and a control module for controlling the real-time operating system to enter time protection exception processing according to the duration.

[0013] The third aspect of the present application provides a vehicle, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement a time protection method for a real-time operating system as in the above-mentioned embodiment.

[0014] A fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, the program being executed by a processor to implement a time protection method for a real-time operating system as in the above-mentioned embodiment.

[0015] Therefore, this application includes the following beneficial effects:

[0016] By monitoring the factors affecting the response time, the embodiment of the present application can accurately identify the root cause of the system response delay. Once it is found that the duration of the influencing factor exceeds the preset threshold, measures can be taken quickly to avoid excessive system response time and improve real-time performance and stability. By optimizing interrupt management, resource allocation and system scheduling, system security and user experience are enhanced. Thus, the technical problems that the extreme situations of tasks, interrupts and resource management in real-time operating systems in the prior art are difficult to control and affect system performance and stability are solved.

[0017] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0019] Figure 1 A flowchart of a time protection method for a real-time operating system provided according to an embodiment of the present application;

[0020] Figure 2 This is an example diagram of a task structure provided according to an embodiment of the present application;

[0021] Figure 3 A flowchart of resource application provided according to an embodiment of the present application;

[0022] Figure 4 A flowchart of resource release provided according to an embodiment of the present application;

[0023] Figure 5 A flowchart of resource holding timeout provided according to an embodiment of the present application;

[0024] Figure 6 This is an example diagram of a time protection device of a real-time operating system according to an embodiment of the present application;

[0025] Figure 7 It is a schematic diagram of the structure of a vehicle according to an embodiment of the present application. DETAILED DESCRIPTION

[0026] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.

[0027] The following describes the time protection method, device, vehicle and medium of the real-time operating system of the embodiment of the present application with reference to the accompanying drawings. In view of the problem that the real-time operating system mentioned in the above background technology does not have standard time protection, the present application provides a time protection method for a real-time operating system. In this method, by monitoring the factors affecting the response time, the root cause of the system response delay can be accurately identified. Once it is found that the duration of the influencing factor exceeds the preset threshold, measures can be taken quickly to avoid the system response time being too long and improve the real-time performance and stability. By optimizing interrupt management, resource allocation and system scheduling, the system security and user experience are enhanced. As a result, the problems of extreme situations of tasks, interrupts and resource management in real-time operating systems in the prior art being difficult to control and affecting system performance and stability are solved.

[0028] Specifically, Figure 1 A flow chart of a time protection method for a real-time operating system provided in an embodiment of the present application.

[0029] like Figure 1 As shown, the time protection method of the real-time operating system includes the following steps:

[0030] In step S101, factors affecting the response time of the real-time operating system are obtained.

[0031] The response time influencing factors may include at least one of the execution time of the task and the ISR, the interruption disabled time, the resource holding time, the task activation and the ISR occurrence.

[0032] It can be understood that the embodiments of the present application can accurately identify which factors cause system response delays by obtaining factors affecting the response time of the real-time operating system, which helps to quickly locate the root cause of the problem and facilitate subsequent exception handling.

[0033] In step S102, the duration of the factors affecting the response time is monitored.

[0034] The duration may be the time period from the appearance or start to the end of an influencing factor.

[0035] It can be understood that the embodiments of the present application achieve real-time monitoring and evaluation of system performance by monitoring the duration of response time influencing factors in the real-time operating system, which helps to timely identify and resolve performance bottlenecks, optimize resource allocation and task scheduling, and thus ensure the real-time, stability and reliability of the system.

[0036] In step S103, the real-time operating system is controlled to enter into the exception processing of the time protection according to the duration.

[0037] It can be understood that the embodiments of the present application monitor the duration of factors affecting the response time. When a factor is found to last too long and may affect the real-time response of the system, the system can automatically trigger the time protection exception handling mechanism, which helps prevent the system from responding late due to long-term processing of a task or resource contention.

[0038] In an embodiment of the present application, if the response time influencing factor is the execution duration of the task and the ISR, the real-time operating system is controlled to enter the time protection exception processing according to the continuous duration, including: identifying the current task executed by each core of the CPU; if the current task enters the running state or the current ISR is triggered, the remaining execution budget duration of the current task or the current ISR is set in the comparator; if the current task is preempted and proceeds to the ready state or the SR is preempted, it is updated in the comparator to the remaining execution budget duration of the new task or the new ISR, and the remaining execution budget duration of the old task or the old ISR is retained in the stack of the preempted task or the preempted ISR; when the old task enters the running state again or the old ISR is triggered, the remaining execution budget duration of the old task is put back into the comparator; if the running time of the current task or the current ISR is greater than the first preset duration, when the value of the timer and the comparator are equal, the real-time operating system is controlled to enter the time protection exception processing.

[0039] Among them, ISR is a special piece of code used to respond to interrupt requests; the remaining execution budget duration is a time budget allocated to the task or ISR, indicating how long they can still be executed on the CPU; the ready state can be that the task is ready to execute but has not yet been selected for execution by the CPU; the stack is a data structure used to store local variables, parameters, return addresses and other information of function calls; the first preset duration can be a pre-set time used to determine whether the task or ISR takes too long to execute.

[0040] It is understandable that the embodiment of the present application monitors the task execution status of each CPU core, uses the remaining execution budget duration and the comparator to ensure that the execution time of tasks and ISRs will not be too long, and saves and restores the context information of tasks through the stack to support task preemption and recovery. When the execution time of a task or ISR is too long, the system will trigger the exception handling of time protection to maintain the stability and real-time performance of the system.

[0041] Specifically, in the AUTOSAR operating system, each task and ISR is assigned an execution budget to limit their execution time on the CPU. When a task enters the running state or an ISR is triggered, the system sets its remaining execution budget in the hardware comparator. If the task is preempted or the ISR is interrupted, the value in the comparator is updated to the remaining budget of the new task / ISR, and the remaining budget of the old task / ISR is saved in the stack. When the task runs again, its remaining budget is reloaded into the comparator. If the task / ISR execution time exceeds the budget, the exception handling mechanism will be triggered when the hardware timer matches the comparator to protect system stability and responsiveness.

[0042] It should be noted that considering the basic attributes of the task and the exception handling mechanism, a task control block needs to be designed, such as Figure 2 As shown, it contains basic task information and elements related to exception handling.

[0043] In an embodiment of the present application, if the factor affecting the response time is the duration for which the interrupt is disabled, the real-time operating system is controlled to enter the time protection exception processing according to the duration, including: when the interrupt is disabled, setting the value in the comparator to the budget duration for which the interrupt is disabled; when the task turns on the interrupt, if the timer has not accumulated to the value in the comparator, turning off the timer; if the value of the timer is equal to the value of the comparator, controlling the real-time operating system to enter the time protection exception processing.

[0044] The budgeted duration for interrupt disabling may be a time budget for setting the interrupt disabling state, which is used to limit the duration for which the interrupt is disabled.

[0045] It can be understood that the embodiments of the present application ensure that critical tasks or code segments will not cause system response delays due to long-term disabling of interrupts during execution by setting a budget duration for interrupt disabling and monitoring its execution in real time in the hardware comparator. When the budget is exceeded, exception handling is triggered, and the exception handling mechanism of time protection is automatically triggered, making the system behavior more predictable.

[0046] Specifically, when a task disables interrupts, the system sets a hardware comparator to monitor the interrupt disable time budget. When the task re-enables interrupts, the monitoring is turned off if it has not timed out, and exception handling is triggered if it has timed out. This monitoring mechanism uses the highest priority interrupt to ensure timely response and protect the system from potential impacts caused by long-term interrupt disabling.

[0047] In an embodiment of the present application, if the response time influencing factor is the resource holding time, the real-time operating system is controlled to enter the time protection exception processing according to the duration, including: identifying all resources held by each task; using a linked list of a comparator to manage the holding time of all resources of each task, wherein the value in the linked list header is the estimated budget duration of the first holding time to be reached and the interval duration of the counter; if a new resource is added, the difference between the budget duration of the new resource holding time and the timing duration of the current timer is calculated, and the linked list is added in order of the difference; if the resource is released within the budget duration of the holding time, the linked list node where the resource ID is released is released; if the resource is not released within the budget duration of the holding time, if the timer and the comparator are compared successfully, the real-time operating system is controlled to enter the time protection exception processing.

[0048] The resource holding time refers to the length of time a task holds a certain resource. The linked list is used to manage the holding time of all resources held by each task. The head of the linked list points to the node that is expected to reach the holding time budget first. The budgeted time can be the longest time the task is expected to hold the resource.

[0049] It can be understood that the embodiments of the present application achieve efficient management and optimization of system resources by identifying task resources, using linked lists to manage resource holding durations, and setting time protection exception handling, thereby improving real-time performance, stability, and resource utilization, while enhancing code quality and maintainability.

[0050] Specifically, each task may hold multiple resources at the same time. In order to accurately monitor the holding time of these resources and prevent potential resource locking problems, the system adopts a mechanism that combines hardware timing comparator and software linked list management.

[0051] At the hardware level, a timing comparator is set up to store key information of the head node of the linked list, that is, the remaining interval time between the first resource that is expected to reach its holding time budget and the current timer, so that the system can perceive and respond to the upcoming resource timeout risk in real time.

[0052] At the software level, a linked list is constructed to dynamically manage the holding time information of all resources. Each node in the linked list represents a resource and stores key data such as the resource's unique ID, holding time budget, and current holding time. The linked list is sorted in the order of the resource's expected timeout time, that is, the head of the linked list always points to the resource node that is expected to reach its holding time budget first.

[0053] When a new resource is held by a task, such as Figure 3 As shown, the system will first calculate the difference between the holding time budget of the resource and the current timer time, and then insert the new resource node into the appropriate position in the linked list according to the difference to keep the linked list in order, ensuring that the system can accurately predict and prepare to handle upcoming resource timeout events.

[0054] Under normal circumstances, if Figure 4 As shown in the figure, if a resource is actively released by a task within its holding time budget, the system will find and release its corresponding node in the linked list according to the resource ID, and update the status of the linked list and the hardware comparator to reflect the latest resource holding status.

[0055] In the worst case, if Figure 5 As shown in the figure, if a resource cannot be released within its holding time budget for some reason, such as task exception, deadlock, etc., when the timer matches the value in the hardware comparator, the system will trigger an exception interrupt processing process. This process will be responsible for taking necessary remedial measures, such as forcibly releasing resources, restarting tasks, or recording error logs, to ensure that the stability and availability of the system are not affected.

[0056] In an embodiment of the present application, if the response time influencing factor is task activation, the real-time operating system is controlled to enter the time protection exception processing according to the duration, including: each time the task enters the running state, the current counter value is recorded as the new value, and the counter value of the last time it entered the running state is recorded as the old value; after the task enters the running state, the difference between the new value and the old value is calculated, and if the difference is less than the first preset value, the real-time operating system is controlled to enter the time protection exception processing.

[0057] The running state may be a state in the life cycle of a task, indicating that the task is being executed by the CPU, and the first preset value may be a preset threshold value for comparison with the difference value.

[0058] It is understandable that the embodiment of the present application can timely discover and handle tasks that may be damaged in real time due to frequent switching by monitoring the frequency of tasks entering the running state. When the difference is less than the first preset value, it means that the task may frequently occupy CPU resources in a short period of time, thereby affecting the execution of other tasks. By entering the exception handling of time protection, the impact of the task on the real time of the system can be reduced.

[0059] Specifically, when each task re-enters the running state, the system will immediately capture the current counter value as the new value, and review and record the counter value when the task last entered the running state as the old value. Subsequently, the system will perform a comparison operation between the new and old values ​​to calculate the actual time difference between the two time points. If this time difference is lower than a pre-set specific threshold, the system considers that the task may have an abnormal execution mode, and then triggers and executes a specially designed exception handling function.

[0060] In an embodiment of the present application, if the response time influencing factor is the occurrence of ISR, the real-time operating system is controlled to enter the time protection exception processing according to the duration, including: recording the current counter value each time the ISR occurs as the new value, and recording the counter value each time the last ISR occurred as the old value; after entering the interrupt function, calculating the difference between the new value and the old value, if the difference is less than the second preset value, controlling the real-time operating system to enter the time protection exception processing.

[0061] The second preset value may be a preset threshold value for comparison with the time interval between ISRs.

[0062] It is understandable that the embodiment of the present application timely discovers and handles the problem of over-frequency interrupt processing by monitoring the time interval between ISRs, thereby reducing the impact on the real-time performance of the system and enhancing the stability of the system. At the same time, the interrupt processing efficiency is improved by evaluating the interrupt processing efficiency and optimizing the processing strategy.

[0063] Specifically, whenever a system interrupt signal arrives, the system immediately captures the current counter value as the new value, which accurately reflects the exact time when the interrupt occurred. At the same time, the system reviews and records the counter value when the last interrupt arrived as the old value for subsequent comparison. Subsequently, before entering the interrupt service routine function to handle the interrupt, the system calculates the difference between the new and old values, that is, evaluates the time interval between the two interrupts;

[0064] If the calculated time interval is lower than a certain threshold preset by the system, this indicates that the interrupt may occur too frequently, posing a threat to the real-time performance and stability of the system. In this case, the system will actively trigger and enter an exception handling function, which is specially designed to handle problems caused by excessive interrupts. Through this mechanism, the system can respond quickly and take appropriate measures, such as adjusting interrupt priority, optimizing interrupt handling logic, or performing other necessary recovery operations to ensure stable operation and efficient performance of the system.

[0065] According to the time protection method of the real-time operating system proposed in the embodiment of the present application, by monitoring the factors affecting the response time, the root cause of the system response delay can be accurately identified. Once it is found that the duration of the influencing factor exceeds the preset threshold, measures can be taken quickly to avoid the system response time being too long and improve the real-time performance and stability. By optimizing interrupt management, resource allocation and system scheduling, the system security and user experience are enhanced. Thus, the problem that the extreme situations of tasks, interrupts and resource management in the real-time operating system in the prior art are difficult to control and affect the system performance and stability is solved.

[0066] Next, the time protection device of the real-time operating system proposed in accordance with the embodiment of the present application will be described with reference to the accompanying drawings.

[0067] Figure 6 It is a block diagram of a time protection device of a real-time operating system according to an embodiment of the present application.

[0068] like Figure 6 As shown, the time protection device 10 of the real-time operating system includes: an acquisition module 100 , a monitoring module 200 and a control module 300 .

[0069] Among them, the acquisition module 100 is used to obtain the response time influencing factors of the real-time operating system; the monitoring module 200 is used to monitor the duration of the response time influencing factors; and the control module 300 is used to control the real-time operating system to enter the time protection exception processing according to the duration.

[0070] It should be noted that the above explanation of the embodiment of the time protection method of the real-time operating system is also applicable to the time protection device of the real-time operating system of this embodiment, and will not be repeated here.

[0071] According to the time protection device of the real-time operating system proposed in the embodiment of the present application, by monitoring the factors affecting the response time, the root cause of the system response delay can be accurately identified. Once it is found that the duration of the influencing factor exceeds the preset threshold, measures can be taken quickly to avoid excessive system response time and improve real-time performance and stability. By optimizing interrupt management, resource allocation and system scheduling, system security and user experience are enhanced. Thus, the problem that the extreme situations of tasks, interrupts and resource management in the real-time operating system in the prior art are difficult to control and affect system performance and stability is solved.

[0072] Figure 7 A schematic diagram of the structure of a vehicle provided in an embodiment of the present application. The vehicle may include:

[0073] A memory 701 , a processor 702 , and a computer program stored in the memory 701 and executable on the processor 702 .

[0074] When the processor 702 executes the program, the time protection method of the real-time operating system provided in the above embodiment is implemented.

[0075] Furthermore, the vehicle also includes:

[0076] The communication interface 703 is used for communication between the memory 701 and the processor 702 .

[0077] The memory 701 is used to store computer programs that can be executed on the processor 702 .

[0078] The memory 701 may include a high-speed RAM (Random Access Memory) memory, and may also include a non-volatile memory, such as at least one disk memory.

[0079] If the memory 701, the processor 702 and the communication interface 703 are implemented independently, the communication interface 703, the memory 701 and the processor 702 can be connected to each other through a bus and communicate with each other. The bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0080] Optionally, in a specific implementation, if the memory 701, the processor 702 and the communication interface 703 are integrated on a chip, the memory 701, the processor 702 and the communication interface 703 can communicate with each other through an internal interface.

[0081] The processor 702 may be a CPU (Central Processing Unit), or an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application.

[0082] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the time protection method of a real-time operating system as described above.

[0083] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" 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 application. In this specification, the schematic representations of the above terms are not necessarily directed to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0084] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0085] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or N executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.

[0086] It should be understood that the various parts of the present application can be implemented in hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, the steps or methods can be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array, a field programmable gate array, etc.

[0087] A person of ordinary skill in the art may understand that all or part of the steps carried by the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the above-mentioned program may be stored in a computer-readable storage medium, which, when executed, includes one of the steps of the method embodiment or a combination thereof.

[0088] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.

Claims

1. A time protection method for a real-time operating system, characterized in that: The following steps are involved: Obtain the factors affecting the response time of the real-time operating system; Monitoring the duration of the response time influencing factors; The real-time operating system is controlled to enter into an exception process of time protection according to the duration.

2. The time protection method of a real-time operating system according to claim 1, characterized in that: The response time influencing factors include at least one of the execution time of the task and the ISR, the interruption disabled time, the resource holding time, the task activation and the ISR occurrence.

3. The time protection method of a real-time operating system according to claim 2, characterized in that: If the response time influencing factor is the execution duration of the task and the ISR, then controlling the real-time operating system to enter the exception processing of time protection according to the duration includes: Identify the current task being executed by each CPU core; If the current task enters the running state or the current ISR is triggered, the remaining execution budget duration of the current task or the current ISR is set in the comparator; if the current task is preempted and proceeds to the ready state or the SR is preempted, the remaining execution budget duration of the new task or the new ISR is updated in the comparator, and the remaining execution budget duration of the old task or the old ISR is retained in the stack of the preempted task or the preempted ISR; when the old task enters the running state again or the old ISR is triggered, the remaining execution budget duration of the old task is put back into the comparator; If the running time of the current task or the current ISR is greater than the first preset time, when the values ​​of the timer and the comparator are equal, the real-time operating system is controlled to enter the time protection exception processing.

4. The time protection method of a real-time operating system according to claim 2, characterized in that: If the response time influencing factor is the duration of the interrupt being disabled, then controlling the real-time operating system to enter time protection exception processing according to the duration includes: When the interrupt is disabled, the value in the comparator is set to the interrupt disabled budget duration; When the task turns on interrupts, if the timer does not accumulate to the value in the comparator, the timer is turned off; If the value of the timer is equal to the value of the comparator, the real-time operating system is controlled to enter into the exception processing of the time protection.

5. The time protection method of a real-time operating system according to claim 2, characterized in that: If the response time influencing factor is the resource holding duration, then controlling the real-time operating system to enter time protection exception processing according to the duration includes: Identify all resources held by each task; A linked list of comparators is used to manage the holding time of all resources of each task, wherein the value in the head of the linked list is the interval between the budgeted holding time expected to be reached and the counter; If a new resource is added, calculate the difference between the budget duration of the new resource and the timing duration of the current timer, and add it to the linked list in the order of the difference; If the resource is released within the budgeted holding time, the linked list node where the resource ID is located is released; if the resource is not released within the budgeted holding time, if the timer compares successfully with the comparator, the real-time operating system is controlled to enter the time protection exception processing.

6. The time protection method of a real-time operating system according to claim 2, characterized in that: If the response time influencing factor is the task activation, then controlling the real-time operating system to enter time protection exception processing according to the duration includes: If each time a task enters the running state, the current counter value is recorded as the new value, and the counter value that entered the running state last time is recorded as the old value; After the task enters the running state, the difference between the new value and the old value is calculated. If the difference is less than a first preset value, the real-time operating system is controlled to enter the exception processing of the time protection.

7. The time protection method of a real-time operating system according to claim 2, characterized in that: If the response time influencing factor is the occurrence of the ISR, then controlling the real-time operating system to enter the exception processing of time protection according to the duration includes: The current counter value when each ISR occurs is recorded as the new value, and the counter value when the last ISR occurred is recorded as the old value; After entering the interrupt function, the difference between the new value and the old value is calculated. If the difference is less than a second preset value, the real-time operating system is controlled to enter the exception processing of the time protection.

8. A time protection device for a real-time operating system, characterized in that: include: An acquisition module, used for acquiring factors affecting the response time of the real-time operating system; A monitoring module, used to monitor the duration of the factors affecting the response time; A control module is used to control the real-time operating system to enter the exception processing of time protection according to the duration.

9. A vehicle, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the time protection method for a real-time operating system as claimed in any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: When the computer program or instruction is executed, the time protection method of the real-time operating system described in any one of claims 1-7 is implemented.