Interrupt management method and system based on vehicle operating system and storage medium
The interrupt management method addresses the inefficiencies in existing vehicle operating systems by classifying and prioritizing interrupt tasks, ensuring timely and efficient handling of hardware and software interrupts to enhance real-time responsiveness.
Patent Information
- Application Number
- CN202310623469.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-30
- Publication Date
- 2024-12-03
AI Technical Summary
Existing interrupt processing technologies in vehicle operating systems suffer from high cost, unclear classification, low real-time requirements, and high power consumption, making it difficult to meet strict time constraints and improve overall system efficiency.
An interrupt management method that classifies interrupt processing priorities based on a pre-designed standard, prioritizing tasks with the highest interrupt processing priority for immediate handling, and adjusting task lists based on vehicle operating states to ensure real-time responsiveness.
The method ensures timely and efficient handling of high-real-time interrupt events by establishing a priority mechanism for hardware and software interrupts, enhancing the vehicle operating system's real-time responsiveness to interrupt requests.
Smart Images

Figure CN119065797A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of vehicle operating system kernel interrupt management, and in particular to an interrupt management method, system and storage medium based on a vehicle operating system. Background Art
[0002] The operating system was first used in computers. With the development of embedded chips and related hardware, embedded operating systems also came into being. As the application field of vehicles becomes wider and wider, the demand for hardware peripherals, data processing and the Internet of Everything in related fields gradually emerges. In order to realize the Internet of Everything inside and outside the vehicle, an operating system for the vehicle controller is developed. The operating system suitable for the vehicle controller has strict requirements on real-time performance, requiring it to execute its functions within a certain time and respond to external asynchronous time in a timely manner. The correctness of the operation of the operating system of the vehicle controller depends not only on the correctness of the logic design, but also on the time of these operations. Therefore, the primary task of the operating system is to schedule all available resources to complete real-time control tasks. Therefore, compared with general operating systems, the important feature of the operating system of the vehicle controller is to meet the time constraints and requirements and focus on improving the overall system efficiency.
[0003] The existing technologies mostly use the common interrupt processing process: when the peripheral sends an interrupt request signal to the operating system, if the interruption conditions are met, the execution of the currently executing main program is suspended, and the corresponding subroutine that can perform the operation is executed. After the operation is completed, the execution of the original interrupted main program is returned. However, the existing common interrupt processing technology has the problems of high cost, unclear classification, low real-time requirements, large code and high power consumption.
[0004] Therefore, how to provide an interrupt management for a vehicle operating system that can achieve better real-time performance is an urgent problem to be solved. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method to eliminate or improve one or more defects in the prior art.
[0006] One aspect of the present invention provides an interrupt management method, system and storage medium based on a vehicle operating system, the method comprising the following steps:
[0007] Receive a hardware interrupt request generated by external hardware associated with the vehicle operating system, jump to a hardware interrupt vector table based on a hardware interrupt vector contained in the hardware interrupt request, query the hardware interrupt vector in the hardware interrupt vector table to determine the hardware interrupt type and generate a hardware interrupt task corresponding to the hardware interrupt type, determine the interrupt processing priority of the hardware interrupt task according to a preset interrupt processing classification standard, and save the current register content by the vehicle operating system; or receive a software interrupt request generated by internal software associated with the vehicle operating system, determine the interrupt processing priority of the software interrupt task based on the number of instructions contained in the software interrupt task corresponding to the software interrupt request and the preset interrupt processing classification standard; wherein the interrupt processing priority is divided into the highest interrupt priority and a preset number of interrupt sub-priorities from high to low, and each interrupt sub-priority corresponds to an interrupt task linked list;
[0008] Handing over the hardware interrupt task or software interrupt task with the highest interrupt processing priority to the interrupt service routine in the vehicle operating system for immediate processing;
[0009] Send the hardware interrupt task or software interrupt task whose interrupt processing priority is the interrupt subpriority to the corresponding interrupt task list;
[0010] When the hardware interrupt task and software interrupt task with the highest interrupt processing priority are executed, the hardware interrupt task or software interrupt task with the second highest interrupt processing priority in the interrupt task chain list is processed by the vehicle operating system in order from high to low;
[0011] After the interrupt task is processed, the interrupt is jumped out, and the vehicle operating system restores the register content before the hardware interrupt, and the vehicle operating system returns to the task before the interrupt.
[0012] In some embodiments of the present invention, the working state of the interrupt service program is set to an interrupt-off state; the method also includes: before handing over the hardware interrupt task or software interrupt task with the highest interrupt priority to the interrupt service program for processing, modifying the working state of the interrupt service program to an interrupt-on state; after handing over the hardware interrupt task or software interrupt task with the highest interrupt priority to the interrupt service program for processing, modifying the working state of the interrupt service program to an interrupt-off state.
[0013] In some embodiments of the present invention, the method also includes: after querying the hardware interrupt vector in the hardware interrupt vector table to determine the hardware interrupt type and generating a hardware interrupt task corresponding to the hardware interrupt type, determining the task execution time of the hardware interrupt based on the hardware interrupt type, and determining the task execution time of the software interrupt based on the number of instructions contained in the software interrupt task corresponding to the software interrupt request; for interrupt tasks that stay in the interrupt task linked list, counting the interrupt task residence time; for interrupt tasks in the interrupt task linked list corresponding to interrupt sub-priorities other than the highest and lowest interrupt sub-priorities, when the interrupt task residence time reaches a preset multiple of the task execution time, adjusting the interrupt task to the interrupt task linked list corresponding to the interrupt sub-priority level of the upper level.
[0014] In some embodiments of the present invention, the method further includes: adjusting the number of a preset number of interrupt sub-priorities from high to low and a preset number of interrupt task lists corresponding to the preset number of interrupt sub-priorities based on the vehicle operating status obtained from the operating system, wherein the vehicle operating status includes a shutdown state, a power-on state, and a driving state.
[0015] In some embodiments of the present invention, for a preset number of interrupt sub-priorities from high to low and a preset number of interrupt task lists corresponding to the preset number of interrupt sub-priorities, a number adjustment step is performed based on the vehicle operating state obtained from the operating system, including: when the vehicle operating state is a shutdown state, adjusting the interrupt task list to 0; when the vehicle operating state is a power-on state, retaining at least one interrupt task list; when the vehicle operating state is a driving state, retaining at least one highest interrupt task list and one lowest interrupt task list.
[0016] In some embodiments of the present invention, the method also includes: uniformly assigning interrupt number IDs to all hardware interrupt tasks and software interrupt tasks, and in a multi-core vehicle operating system, determining the kernel positions corresponding to the hardware interrupt tasks and software interrupt tasks based on the interrupt number IDs.
[0017] In some embodiments of the present invention, during the initialization phase of the vehicle operating system, a hardware interrupt vector table and an interrupt processing classification standard for hardware interrupts are registered in the operating system.
[0018] In some embodiments of the present invention, the internal software associated with the vehicle operating system includes multiple types of a braking software system, a tire pressure abnormality monitoring software system, and a radar software system.
[0019] Another aspect of the present invention provides an interrupt management system based on a vehicle operating system, including a processor and a memory, wherein computer instructions are stored in the memory, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the system implements the steps of the method described in any one of the above embodiments.
[0020] Another aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in any one of the above embodiments.
[0021] The interrupt management method, system and storage medium based on the vehicle operating system proposed in the present invention can respond to high-real-time interrupt events in a timely manner based on a pre-established priority mechanism for hardware interrupts and software interrupts, thereby ensuring the real-time response of the vehicle operating system to the interrupt request of the software program.
[0022] Additional advantages, purposes, and features of the present invention will be described in part in the following description, and will become apparent to those skilled in the art after studying the following, or may be learned from the practice of the present invention. The purposes and other advantages of the present invention may be achieved and obtained by the structures specifically indicated in the specification and the accompanying drawings.
[0023] Those skilled in the art will appreciate that the objectives and advantages that can be achieved with the present invention are not limited to the above specific description, and the above and other objectives that can be achieved by the present invention will be more clearly understood from the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention. The components in the drawings are not drawn to scale, but are only for illustrating the principles of the present invention. In order to facilitate the illustration and description of some parts of the present invention, the corresponding parts in the drawings may be enlarged, that is, they may become larger relative to other components in the exemplary device actually manufactured according to the present invention. In the drawings:
[0025] Figure 1 The figure is a flow chart of an interrupt management method based on a vehicle operating system in one embodiment of the present invention.
[0026] Figure 2 This is a Gantt chart of an interruption management method based on a vehicle operating system in one embodiment of the present invention.
[0027] Figure 3 The figure shows a schematic diagram of interrupting a task chain in one embodiment of the present invention.
[0028] Figure 4 Schematic diagram of interrupt management and multi-linked list process management in one embodiment of the present invention. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments and the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0030] It should also be noted that, in order to avoid obscuring the present invention due to unnecessary details, only structures and / or processing steps closely related to the solutions according to the present invention are shown in the accompanying drawings, while other details that are not closely related to the present invention are omitted.
[0031] It should be emphasized that the term “include / comprises” when used herein refers to the presence of features, elements, steps or components, but does not exclude the presence or addition of one or more other features, elements, steps or components.
[0032] It should also be noted that, unless otherwise specified, the term “connection” herein may refer not only to a direct connection but also to an indirect connection involving an intermediate.
[0033] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the accompanying drawings, the same reference numerals represent the same or similar components, or the same or similar steps.
[0034] In order to improve the real-time performance of a vehicle's operating system for hardware interrupts and software interrupts of the vehicle, the present invention provides an interrupt management method, system and storage medium based on a vehicle operating system. The method divides interrupt processing priorities based on a pre-designed interrupt processing classification standard so that the kernel can process time-critical tasks in a more real-time manner.
[0035] Figure 1 This is a flow chart of an interrupt management method based on a vehicle operating system in an embodiment of the present invention, the method comprising the following steps:
[0036] Step S110: receiving a hardware interrupt request generated by external hardware associated with the vehicle operating system, jumping to a hardware interrupt vector table based on a hardware interrupt vector contained in the hardware interrupt request, querying the hardware interrupt vector in the hardware interrupt vector table to determine the hardware interrupt type and generating a hardware interrupt task corresponding to the hardware interrupt type, determining the interrupt processing priority of the hardware interrupt task according to a preset interrupt processing classification standard, and having the vehicle operating system save the current register content; or, receiving a software interrupt request generated by internal software associated with the vehicle operating system, determining the interrupt processing priority of the software interrupt task based on the number of instructions contained in the software interrupt task corresponding to the software interrupt request and a preset interrupt processing classification standard; wherein the interrupt processing priority is divided into a highest interrupt priority and a preset number of interrupt sub-priorities from high to low, and each interrupt sub-priority corresponds to an interrupt task linked list.
[0037] Among them, the interrupt type is associated with the specific operation of each interrupt task. The specific operation that each interrupt task needs to perform is pre-written in the operating system by the software application or hardware interrupt. That is, when the operating system knows the interrupt type, it can know what interrupt task the interrupt request requests to execute. In addition, the hardware interrupt is transmitted asynchronously, and the interrupt processing priority of the hardware interrupt needs to be queried with the help of the hardware interrupt vector table. The software interrupt task generated based on the software interrupt request contains multiple instructions corresponding to the task. The more instructions, the longer the execution time. The definition of hardware interrupt and software interrupt in the present invention is different from the popular hard interrupt and soft interrupt, which should be distinguished. The function of the interrupt vector table is to store the corresponding interrupt vector in the order of the interrupt type number from small to large, and to store all the interrupt vectors in a centralized manner, wherein the interrupt vector is the interrupt entry address generated by the hardware in the operating system or the first address of the interrupt service program. In layman's terms, the interrupt vector can jump to the interrupt service program.
[0038] Step S120: Hand over the hardware interrupt task or software interrupt task with the highest interrupt processing priority to the interrupt service program in the vehicle operating system for immediate processing.
[0039] Among them, the Interrupt Service Routines (ISR) is a program that is pre-programmed to handle "emergency events". When the central processing unit is processing internal data, an emergency occurs in the outside world, requiring the CPU to suspend the current work and handle this emergency. After processing, it returns to the original address that was interrupted and continues the original work. This process is called an interrupt. The component that implements this function is called an interrupt system, and the request source for applying for CPU interrupt is called an interrupt source. The interrupt system of the microcontroller generally allows multiple interrupt sources. When multiple interrupt sources request interrupts to the CPU at the same time, there is an interrupt priority issue. Usually, according to the priority level of the interrupt source, the interrupt request source of the most urgent event is processed first, that is, the interrupt request with the highest level is responded to first.
[0040] Wherein, the working state of the interrupt service program is set to the interrupt-disabled state.
[0041] Step S130: Send the hardware interrupt task or software interrupt task whose interrupt processing priority is the interrupt secondary priority to the corresponding interrupt task linked list.
[0042] Step S140: When the hardware interrupt task and software interrupt task with the highest interrupt processing priority are executed, the hardware interrupt task or software interrupt task with the second highest interrupt processing priority in the interrupt task list is processed by the vehicle operating system in order from high to low.
[0043] Step S150: After the interrupt task processing is completed, the interrupt is jumped out, and the vehicle operating system restores the register content before the hardware interrupt, and the vehicle operating system returns to the task before the interrupt. That is, when the interrupt handler has no unprocessed hardware interrupt task or software interrupt task, it will jump out of the interrupt and return to the normal working state.
[0044] Before step S110 of the present invention, in the initialization stage of the vehicle operating system, the method further includes: registering a hardware interrupt vector table for hardware interrupts and the interrupt processing classification standard in the operating system. The internal software associated with the vehicle operating system includes multiple of a braking software system, a tire pressure abnormality monitoring software system, and a radar software system.
[0045] The preset interrupt processing classification standard in step S110 of the present invention is, in principle, to classify hardware interrupt tasks and software interrupt tasks. The task with the highest processing priority is a fast interrupt, which requires the kernel to respond to the interrupt request in time and process it immediately, but only performs simple and fast work with strict time limits, and prohibits some or all interrupts according to the priority during execution. For other operations that are not strictly time-limited or relatively time-consuming, i.e., ordinary interrupts, all ordinary interrupts are divided into a hierarchical interrupt linked list for storage according to the strictness of the time limit and the time-consuming degree, and are read and processed one by one.
[0046] After the step S110 of the present invention of querying the hardware interrupt vector in the hardware interrupt vector table to determine the hardware interrupt type and generating a hardware interrupt task corresponding to the hardware interrupt type, the method further includes:
[0047] (1) Determine the task execution time of the hardware interrupt based on the hardware interrupt type, and determine the task execution time of the software interrupt based on the number of instructions contained in the software interrupt task corresponding to the software interrupt request; wherein, for the hardware interrupt, the task execution time can be determined by its type, and for the software interrupt, the task execution time can be directly determined by the length of the executed instruction set. The longer the instruction set, the longer the task execution time;
[0048] (2) For the interrupt tasks that stay in the interrupt task list, the interrupt task stay time is counted;
[0049] (3) For interrupt tasks in the interrupt task chain list corresponding to interrupt sub-priorities other than the highest and lowest interrupt sub-priorities, when the interrupt task stay time reaches a preset multiple of the task execution time, the interrupt task is adjusted to the interrupt task chain list corresponding to the interrupt sub-priority of the next level. For example, the preset multiple can be 2-10 times, preferably 3 times. In another embodiment of the present invention, the method for dynamically adjusting the interrupt priority of the interrupt task includes: in order to prevent the continuous backlog of low-priority processes, each interrupt task with a priority between 2-6 is set with an execution time, and each time the execution time exceeds 2 times, the priority of the interrupt task is increased by one level, and priority 0 and 7 are reserved. Priority 0 is the highest priority, and the resource operating system is reserved. No interrupt task can be automatically upgraded to priority 0 due to a long time; priority 7 is the lowest priority, and it is an interrupt task that takes a long time and is not sensitive to the execution time, so it is reserved for a long time and processed when the operating system is idle, and it cannot be automatically upgraded due to a long time. The preset multiple is only an example, and the present invention is not limited to this.
[0050] In some embodiments of the present invention, the running state of the vehicle includes a shutdown state, a startup state and a driving state, and the method further includes: adjusting the number of interrupt task chain lists corresponding to a preset number of interrupt sub-priorities from high to low and a preset number of interrupt sub-priorities based on the vehicle running state obtained from the operating system. For example, the number of interrupt task chain lists in the vehicle in the daily driving state is 8, and the number of interrupt task chain lists can be reduced to 3 when the vehicle is stationary and only in the startup state, and the number of interrupt task chain lists in the operating system when the vehicle is in the shutdown state is at least 1. In another embodiment of the present invention, the operating system generates at least one task chain list when it is initialized. If there is no task chain list, it means that there is no task process to be executed, and the operating system enters the shutdown state after judgment. In each task chain list, it is composed of task process structures connected. The chain list no longer distinguishes between interrupt task chain lists and other task chain lists. The task chain list is uniformly distinguished according to the task priority, and processes with the same priority are in the same task chain list. Different modes can be divided in the operating system according to different division conditions (for example: shutdown state, startup state, driving state). It should be noted that: in principle, the operating system only provides multi-link list management, so the division of each link list status can be adjusted according to product requirements, the driving status of the vehicle operating system can be obtained, and then different settings can be made.
[0051] Specifically, in another embodiment of the present invention, the preset number of interrupt sub-priorities from high to low and the preset number of interrupt task lists corresponding to the preset number of interrupt sub-priorities are adjusted based on the vehicle operating state obtained from the operating system, including: when the vehicle operating state is the shutdown state, adjusting the interrupt task list to 0; when the vehicle operating state is the power-on state, retaining at least one interrupt task list; when the vehicle operating state is the driving state, retaining at least one highest interrupt task list and one lowest interrupt task list.
[0052] In step S120 of the present invention, the method further includes: before handing over the hardware interrupt task or software interrupt task with the highest interrupt priority to the interrupt service program for processing, modifying the working state of the interrupt service program to the interrupt-on state, and after handing over the hardware interrupt task or software interrupt task with the highest interrupt priority to the interrupt service program for processing, modifying the working state of the interrupt service program to the interrupt-off state. That is, the working state of the interrupt service program is allowed to be set to interrupt nesting (or non-maskable interrupt), and the meaning of interrupt nesting is that when the interrupt system is executing an interrupt service, another interrupt with a higher priority makes an interrupt request, and at this time, the service program of the currently executing interrupt source with a lower level will be temporarily terminated to process the interrupt source with a higher level, and after the processing is completed, it will return to the interrupted interrupt service program to continue the execution process.
[0053] In one embodiment of the present invention, the method further includes: uniformly allocating an interrupt number ID to all hardware interrupt tasks and software interrupt tasks, and determining the core position corresponding to the hardware interrupt task and the software interrupt task based on the interrupt number ID in a multi-core vehicle operating system. When each hardware interrupt task and software interrupt task in step S110 is generated, an interrupt number ID is uniformly allocated to it.
[0054] Among them, the objects of interrupt management are divided into two types: one is the 32 non-core interrupts based on the KE06 platform, which are mainly based on the hardware to set the priority and can be nested, called hardware interrupts; the other is based on the combination of the operating system and the product, and is caused by the application status / scenario changes, which need to be processed. The events are called software interrupts. For all interrupts, on the KE06 platform, a unified interrupt ID number is established. Since the interrupt ID number is uniquely corresponding to the interrupt task, it can be directly introduced in the multi-core vehicle operating system.
[0055] In one embodiment of the present invention, the method further designs a multi-time base nesting mode: a fixed main time base + multiple task time bases. First, a main time base is established, and the minimum period of the main time base cannot be adjusted. In the program, the main time base is timed according to a fixed period. Under different states, based on the main time base, the minimum common divisor of each process in the linked list is used as the minimum period number, and the task time base is established based on this as a benchmark to execute the process of the corresponding task linked list. Different task time bases are established according to different states / scenarios. The task time base can also be destroyed by setting conditions. Specifically: when the operating system is started, the main time base is established, and the main time base is timed with a minimum period of 10ms. Under different vehicle states (vehicle shutdown state, startup state, driving state), the operating system executes the corresponding process according to different task linked lists in process management, and establishes the corresponding task time base according to the period of the required execution process. According to the change of the vehicle state, the operating system keeps the main time base period unchanged, establishes different task time bases, or destroys the invalid task time base, so that the main time base and the task time base are independent of each other, and the overall time base structure is clearer.
[0056] It should be noted that the classification standards of software interrupts and hardware interrupts in the present invention are different from those in the prior art, where soft interrupts are set as events that need to be processed due to changes in application status / scenario. In addition, a unified interrupt ID number is established to pave the way for a multi-core operating system, in which the corresponding kernel and interrupt can be found according to the unique corresponding interrupt ID number.
[0057] Figure 2 This is a Gantt chart of an interruption management method based on a vehicle operating system in one embodiment of the present invention, combined with Figure 2 The different stages shown in the figure illustrate the interrupt management process of the vehicle operating system:
[0058] Phase a, receiving a hardware interrupt request: receiving a hardware interrupt request generated by external hardware associated with the vehicle operating system, and the operating system detects the occurrence of an interrupt;
[0059] Phase b, jump to interrupt vector: jump to hardware interrupt vector table based on hardware interrupt vector included in hardware interrupt request, query the hardware interrupt vector in hardware interrupt vector table to determine hardware interrupt type and generate hardware interrupt task corresponding to hardware interrupt type, determine interrupt processing priority of hardware interrupt task according to preset interrupt processing classification standard; wherein, interrupt vector refers to interrupt identification code generated by hardware in early microcomputer system, i.e. identification mark of interrupt source, which can be used to form entry address of corresponding interrupt service program or first address of interrupt service program, and interrupt vector table records interrupt type; here, jump to interrupt vector first, then query hardware interrupt vector table, match generated interrupt with table, and clarify interrupt type;
[0060] Phase c, save the CPU register contents: after determining the interrupt type, save the current register contents and then enter the interrupt handler;
[0061] Phase d, Interrupt Service Processing ISR: The interrupt handler is preset in advance by the user of interrupt management. In the interrupt handler, two modes are supported: interrupt nesting and interrupt non-nesting. If interrupt nesting is allowed, the program needs to configure the interrupt. If interrupt nesting is not allowed, the interrupt is closed. The interrupt service program only processes simple, fast and time-limited tasks at this stage, that is, hardware interrupt tasks or software interrupt tasks with the highest interrupt priority. Simple and fast tasks with strict time limits are processed immediately. For time-consuming operations, the hardware interrupt task or software interrupt task is sent to the corresponding interrupt task list according to the priority order (that is, the interrupt secondary priority). In addition, the software interrupt task generated by the software interrupt request is also processed immediately or arranged in the interrupt task list at the interrupt service processing ISR stage. Its division principle is similar to that of the hardware interrupt task. The number of instruction sets can be used to directly judge whether the task is time-consuming.
[0062] Phase e, restore the CPU register contents: that is, after the interrupt task with a strict time limit is processed, the interrupt is exited and the register contents are restored;
[0063] Phase f: Interrupt return: The interrupt has been exited and the contents of the CPU registers have been restored, that is, the normal task progress before the interrupt has been returned;
[0064] Phase g: Continue to process other tasks before the interruption;
[0065] In stage h, tasks without strict time limits or time-consuming tasks are placed in the interrupt task list: tasks without strict time limits or time-consuming tasks of hardware interrupts and software interrupts are not processed immediately in the interrupt service processing, but are arranged in the interrupt service list to wait for subsequent processing; it should be explained here that the hardware interrupt task or software interrupt task with the interrupt processing priority of the interrupt secondary priority is first sent to the interrupt service program, but the interrupt service program does not process them immediately but places them in the interrupt task list. The interrupt priority determination of the hardware interrupt task and the software interrupt task can also be determined in the interrupt service program ISR.
[0066] The present invention sets the interrupt service processing ISR to disable interrupt by default at position ①. In some embodiments, the position ① can be optionally set to enable interrupt and restored to disable interrupt at position ②.
[0067] Figure 3 This is a schematic diagram of interrupting a task chain in an embodiment of the present invention. Figure 3In this embodiment, it can be seen that the interrupt task list is divided into multiple links (for example, 8), which are divided into multiple priorities from high to low. Each interrupt task list corresponds to an interrupt priority level. In each interrupt task list, there are multiple process nodes representing unprocessed interrupt tasks arranged in chronological order.
[0068] Figure 4 This is a schematic diagram of interrupt management and multi-linked list process management in one embodiment of the present invention. Figure 4 The left side of the figure shows the interrupt management system, which is divided into three levels. The three levels provide a calling API interface with preset specifications. The three levels are:
[0069] (1) The interrupt driver layer is responsible for the generation of hardware interrupts and software interrupts, including receiving interrupt requests, determining interrupt types, and submitting interrupt events to generate interrupt tasks. The association between jumping to the interrupt vector and querying the hardware interrupt vector table is that you need to jump to the interrupt vector first before you can query the interrupt vector table. Only after entering the interrupt can you query the vector table, which is equivalent to an entry. Generally speaking, the interrupt vector is included in the interrupt request, although the hardware interrupt task is generated after the interrupt type is clarified and the interrupt handler is entered. However, the specific operations of various interrupt tasks will be written when the program is written, and the corresponding interrupt type is associated with the specific operation.
[0070] (2) Interrupt processing layer. The interrupt processing layer relies on the interrupt driver layer. According to the interrupt event submitted by the interrupt driver layer, the interrupt processing layer processes the relevant hard interrupt / soft interrupt, wherein the hard interrupt includes interrupt nesting and interrupt. The interrupt processing layer only processes interrupts with strict time limits. Any interrupt processing that is time-consuming or has a low priority will generate a related interrupt task in the interrupt processing layer and submit it to the interrupt task layer. In some embodiments of the present invention, the interrupt processing layer also provides a method for dynamically adjusting the priority of the interrupt task.
[0071] (3) The interrupt task layer is independent of any interrupt hardware and is related to the operating system layer. Priority is determined based on the various interrupt tasks submitted by the interrupt processing layer. The interrupt task list is based on Figure 4 There are 8 sub-linked lists for each of the 8 priorities shown in the figure. Tasks with the same priority are in the same linked list to facilitate dynamic adjustment of priorities and tasks. Each interrupt task processing has its own priority. In the same priority, related operations are executed sequentially. Finally, an interrupt management task linked list is formed, and the task linked list is submitted to the process management for execution. The interrupt task linked list is independent of other linked lists, but is also under unified process management. The number of task linked lists is only an example, and the present invention is not limited thereto.
[0072] In a specific embodiment of the present invention, taking the vehicle driving process as an example, during the vehicle driving process, when a hard interrupt such as externally transmitted data is received, it first jumps to the interrupt vector, saves the current CPU register content, enters the interrupt processing program, and first executes strict time limit operations such as receiving complete data, and hangs time-consuming operations such as data parsing and processing into the interrupt task list according to priority; in this process, if the vehicle status changes and generates software interrupt operations such as vehicle warning setting, strict time limit operations such as vehicle warning flag will be completed first, and time-consuming operations such as vehicle warning monitoring and warning uploading will be hung into the interrupt task list according to priority. The interrupt task list executes different time-consuming operations in order of priority.
[0073] In summary, the interrupt management method based on the vehicle operating system proposed in the present invention can respond to high-real-time interrupt events in a timely manner based on a pre-established priority mechanism for hardware interrupts and software interrupts, thereby ensuring the real-time response of the vehicle operating system to the interrupt request of the software program. The interrupt management method provided by the present invention is based on external asynchronous event hardware interrupts and internal software-generated software interrupts to establish two layers of interrupt management. The first layer is a fast interrupt, which responds to interrupt requests in a timely manner and processes them immediately. The second layer is a normal interrupt. After the interrupt occurs, the interrupt task is added to the interrupt task management list. By using the preset adjustment mechanism to adjust the order of the interrupt task in the interrupt list, the appropriate time to execute the corresponding processing program can be flexibly controlled.
[0074] Corresponding to the above method, the present invention also provides an interrupt management system based on a vehicle operating system, the system comprising a computer device, the computer device comprising a processor and a memory, the memory storing computer instructions, the processor being used to execute the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the system implements the steps of the method described above.
[0075] The embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method described above are implemented. The computer-readable storage medium can be a tangible storage medium, such as a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a floppy disk, a hard disk, a removable storage disk, a CD-ROM, or any other form of storage medium known in the technical field.
[0076] It should be understood by those skilled in the art that the exemplary components, systems and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software or a combination of the two. Whether it is performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link via a data signal carried in a carrier.
[0077] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.
[0078] In the present invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with features of other embodiments or replace features of other embodiments.
[0079] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. An interruption management method based on a vehicle operating system, characterized in that: The method comprises the following steps: Receive a hardware interrupt request generated by external hardware associated with the vehicle operating system, jump to a hardware interrupt vector table based on a hardware interrupt vector included in the hardware interrupt request, query the hardware interrupt vector in the hardware interrupt vector table to determine the hardware interrupt type and generate a hardware interrupt task corresponding to the hardware interrupt type, determine the interrupt processing priority of the hardware interrupt task according to a preset interrupt processing classification standard, and save the current register content by the vehicle operating system; or receive a software interrupt request generated by internal software associated with the vehicle operating system, determine the interrupt processing priority of the software interrupt task based on the number of instructions included in the software interrupt task corresponding to the software interrupt request and a preset interrupt processing classification standard; wherein the interrupt processing priority is divided into a highest interrupt priority and a preset number of interrupt sub-priorities from high to low, and each interrupt sub-priority corresponds to an interrupt task linked list; Handing over the hardware interrupt task or software interrupt task with the highest interrupt processing priority to the interrupt service routine in the vehicle operating system for immediate processing; Sending a hardware interrupt task or a software interrupt task whose interrupt processing priority is an interrupt secondary priority to a corresponding interrupt task linked list; When the hardware interrupt task and the software interrupt task with the highest interrupt processing priority are executed, the hardware interrupt task or the software interrupt task with the second highest interrupt processing priority in the interrupt task chain list is processed by the vehicle operating system in order from high to low; After the interrupt task is processed, the interrupt is jumped out, and the vehicle operating system restores the register content before the hardware interrupt, and the vehicle operating system returns to the task before the interrupt.
2. The interruption management method based on the vehicle operating system according to claim 1, characterized in that: The working state of the interrupt service program is set to the interrupt-off state; The method further includes: Before handing over the hardware interrupt task or software interrupt task whose interrupt processing priority is the highest interrupt priority to the interrupt service program for processing, the working state of the interrupt service program is modified to the interrupt-on state; after handing over the hardware interrupt task or software interrupt task whose interrupt processing priority is the highest interrupt priority to the interrupt service program for processing, the working state of the interrupt service program is modified to the interrupt-off state.
3. The interruption management method based on the vehicle operating system according to claim 1, characterized in that: The method further includes: After the step of searching the hardware interrupt vector in the hardware interrupt vector table to determine the hardware interrupt type and generating a hardware interrupt task corresponding to the hardware interrupt type, determining the task execution time of the hardware interrupt based on the hardware interrupt type, and determining the task execution time of the software interrupt based on the number of instructions included in the software interrupt task corresponding to the software interrupt request; For the interrupt tasks staying in the interrupt task chain list, the interrupt task stay time is counted; For interrupt tasks in the interrupt task linked list corresponding to interrupt subpriorities other than the highest and lowest interrupt subpriorities, when the interrupt task residence time reaches a preset multiple of the task execution time, the interrupt task is adjusted to the interrupt task linked list corresponding to the interrupt subpriority of the next higher level.
4. The interrupt management method based on the vehicle operating system according to claim 1, characterized in that: The method also includes: adjusting the number of a preset number of interrupt sub-priorities from high to low and a preset number of interrupt task linked lists corresponding to the preset number of interrupt sub-priorities based on the vehicle operating status obtained from the operating system, wherein the vehicle operating status includes a shutdown state, a startup state, and a driving state.
5. The interruption management method based on the vehicle operating system according to claim 4, characterized in that: The step of adjusting the number of the preset number of interrupt sub-priorities from high to low and the preset number of interrupt task chain lists corresponding to the preset number of interrupt sub-priorities based on the vehicle running state obtained from the operating system includes: When the vehicle is in shutdown state, adjust the interrupt task list to 0; When the vehicle is in the power-on state, at least one interrupt task list is retained; When the vehicle is in the driving state, at least one highest interrupt task linked list and one lowest interrupt task linked list are retained.
6. The interruption management method based on the vehicle operating system according to claim 1, characterized in that: The method also includes: uniformly allocating interrupt number IDs to all hardware interrupt tasks and software interrupt tasks, and in a multi-core vehicle operating system, determining the kernel positions corresponding to the hardware interrupt tasks and software interrupt tasks based on the interrupt number IDs.
7. The interruption management method based on the vehicle operating system according to claim 1, characterized in that: During the initialization phase of the vehicle operating system, a hardware interrupt vector table for hardware interrupts and the interrupt processing classification standard are registered in the operating system.
8. The interruption management method based on the vehicle operating system according to claim 1, characterized in that: The internal software associated with the vehicle operating system includes multiple types of braking software systems, tire pressure abnormality monitoring software systems and radar software systems.
9. An interrupt management system based on a vehicle operating system, comprising a processor and a memory, characterized in that: The memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the system implements the steps of the method as claimed in any one of claims 1 to 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
