Delay method, device and equipment based on AutoSar operating system, medium and vehicle
Set delay time and timeout interrupts in the AutoSar operating system through hardware timers to convert service task status, solving the problem of insufficient delay mechanism of the AutoSar operating system in the functional fusion scenario, achieving efficient and reliable delay service, and improving CPU utilization and application usage time range.
Patent Information
- Application Number
- CN202411255850.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2025-01-07
AI Technical Summary
In the scenario of in-vehicle controller functions fusion, the existing AutoSar operating system has insufficient delay mechanism, resulting in wasted CPU time and limited application usage time range, and control delay is inefficient.
Set the delay time through the hardware timer, generate timeout interrupts, convert the service task state, switch from the waiting state to the ready state, and schedule the ready task when the delay time is not reached. The task with the highest priority obtains CPU resources, and achieves efficient and reliable delays Serve.
Improves the run time range of ready tasks, avoids loop waiting time limits, improves CPU utilization and application usage time range, and provides efficient and reliable latency services.
Smart Images

Figure CN119271367A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of automobile control technology, and in particular to a delay method, device, equipment, medium and vehicle based on the AutoSar operating system. Background Art
[0002] AutoSar, the full name of which is Automotive Open System Architecture, is a collaborative development framework for automotive electronic systems jointly developed by global automakers, parts suppliers, and various research and service institutions. Its corresponding AutoSar operating system (OS) is a streamlined real-time operating system.
[0003] The existing on-board controller controls external devices such as switches, batteries, air conditioners or motors through a microcontroller unit (MCU) running the AutoSar operating system. In traditional cars, a microcontroller unit only controls one external device to be run at a time, and other external devices need to wait in a loop, which makes a microcontroller unit single-function. However, with the development of new energy vehicles, the functions of in-vehicle controllers are increasingly integrated. For example, the microcontroller unit needs to control the switch, the acoustic vehicle alert system (AVAS), the interior ambient light or the reversing radar at the same time. In this case, the MCU delays and then uses the delay method of waiting in place, which not only wastes CPU time, but also limits the application usage time range, resulting in inefficient control delay. Summary of the invention
[0004] The purpose of this application is to address the deficiencies of the above-mentioned existing related technologies and provide a delay method, device, equipment, medium and vehicle based on the AutoSar operating system, which can increase the usage time range of the application.
[0005] In a first aspect, the present application provides a delay method based on an AutoSar operating system, wherein the AutoSar operating system is provided in a microcontroller unit; the delay method comprises:
[0006] When the service task of the AutoSar operating system is in a running state, a delay requirement is triggered according to a preset condition, and a delay time is set based on a hardware timer;
[0007] After the delay time has elapsed, a timeout interrupt is generated by a hardware timer, and the service task is converted from the running state to the waiting state;
[0008] When the AutoSar operating system receives the timeout interrupt, the scheduler is triggered to convert the service task from the waiting state to the ready state.
[0009] The present application sets a delay time and implements a delay mechanism for scheduling service tasks in the AutoSar operating system according to the delay time, thereby being able to regularly convert service tasks in a waiting state to a ready state, thereby increasing the running time range of ready tasks and no longer being limited by the limitation of the cyclic waiting time, and when the AutoSar operating system receives the timeout interrupt, converts the service task from a waiting state to a ready state, thereby comprehensively providing efficient and reliable delayed services; in addition, the present application can implement the timing delay mechanism of the AutoSar operating system through a hardware timer outside the AutoSar operating system, without increasing the complexity of the AutoSar operating system itself, and regularly delays the conversion of the state of the service task through the timeout interrupt sent by the hardware timer, which has low implementation difficulty and high applicability.
[0010] Further, when the AutoSar operating system receives the timeout interrupt, the scheduler is triggered to switch the service task from the waiting state to the ready state, including: when the AutoSar operating system receives the timeout interrupt, a trigger event is generated, and according to the trigger event, the scheduler is triggered to switch the service task from the waiting state to the ready state.
[0011] Furthermore, the delay method also includes: when the delay time is not reached, based on the AutoSar operating system, scheduling the ready task in the ready state through idle CPU resources; the CPU resources are released when the service task is converted to the waiting state.
[0012] Furthermore, the delay method also includes: when the AutoSar operating system does not receive the timeout interrupt, selecting the ready task with the highest priority from the ready state queue and allocating idle CPU resources for scheduling and running; wherein the priority is pre-set according to business requirements.
[0013] This application uses the timeout interrupt sent by the hardware timer to select the ready task with the highest priority from the ready state and allocate CPU resources for scheduling and running, which can meet the execution of high-priority ready tasks required by business needs, thereby providing efficient and reliable delay services.
[0014] Furthermore, the ready task includes: a real-time micro-control unit task and the service task; the delay method also includes: according to business needs, setting the priority of the service task to be lower than the priority of the micro-control unit task, and allocating the CPU resources to the service task or the micro-control unit task for scheduling and running according to the priority from high to low.
[0015] The present application places service tasks at a lower priority and real-time microcontroller unit tasks at a higher priority, and schedules and runs tasks in the ready queue in the order of real-time business needs first and CPU utilization second. This can prioritize the real-time performance of high-priority tasks and then save CPU resources, thereby providing efficient and reliable delayed services with the technical concept of real-time first and CPU resources second.
[0016] Further, the converting the service task from the running state to the waiting state includes: triggering the scheduler, and converting the service task from the running state to the waiting state through the scheduler.
[0017] In a second aspect, the present application further provides a delay device based on an AutoSar operating system, wherein the AutoSar operating system is disposed in a microcontroller unit; the delay device comprises: a first setting unit, a first state conversion unit, and a second state conversion unit; wherein,
[0018] The first setting unit is used to trigger a delay requirement according to a preset condition and set a delay time based on a hardware timer when the service task of the AutoSar operating system is in a running state;
[0019] The first state conversion unit is used to generate a timeout interrupt through a hardware timer after the delay time has passed, and convert the service task from the running state to the waiting state;
[0020] The second state conversion unit is used to trigger the scheduler to convert the service task from the waiting state to the ready state when the AutoSar operating system receives the timeout interrupt.
[0021] The present application sets a delay time and implements a delay mechanism for scheduling service tasks in the AutoSar operating system according to the delay time, thereby being able to regularly convert service tasks in a waiting state to a ready state, thereby increasing the running time range of ready tasks and no longer being limited by the limitation of the cyclic waiting time, and when the AutoSar operating system receives the timeout interrupt, converts the service task from a waiting state to a ready state, thereby comprehensively providing efficient and reliable delayed services; in addition, the present application can implement the timing delay mechanism of the AutoSar operating system through a hardware timer outside the AutoSar operating system, without increasing the complexity of the AutoSar operating system itself, and regularly delays the conversion of the state of the service task through the timeout interrupt sent by the hardware timer, which has low implementation difficulty and high applicability.
[0022] In a third aspect, the present application provides an electronic device, the device comprising: a processor and a memory storing computer program instructions;
[0023] When the processor executes the computer program instructions, the delay method based on the AutoSar operating system as described in the first aspect or further described in the first aspect is implemented.
[0024] The present application runs the delay method based on the AutoSar operating system described in the first aspect or further described in the first aspect in the form of a program in an electronic device, which can be run in different types of applications to perform efficient and reliable service task delays in different scenarios, and has greater practicality, applicability and scalability.
[0025] In a fourth aspect, the present application provides a computer-readable storage medium having computer program instructions stored thereon, and when the computer program instructions are executed by a processor, the delay method based on the AutoSar operating system as further described in the first aspect or the first aspect is implemented.
[0026] When the present application stores the delay method based on the AutoSar operating system described in the first aspect or the first aspect further in the form of a program in a storage medium, by running or reading an executable program in any programming language in the storage medium, it can instantly perform operations such as delaying the service task or converting the running state to the waiting state or the timed delay conversion of the waiting state to the ready state. It can be applicable to more programming language environments and application scenarios, and provide efficient and reliable service task delays in different scenarios, with greater compatibility, reusability, scalability and applicability.
[0027] In a fifth aspect, the present application provides a vehicle, comprising: a delay device based on the AutoSar operating system as described in the second aspect or an electronic device as described in the third aspect.
[0028] The present application assembles the delay device based on the AutoSar operating system as described in the second aspect or the electronic device as described in the third aspect into a vehicle, which can be used in different vehicle types and different vehicle applications to perform efficient and reliable service task delays in different scenarios, and has greater practicality, applicability and scalability. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is a schematic diagram of the AutoSar architecture provided by this application;
[0030] Figure 2 It is a schematic diagram of the structure of the service layer provided by this application;
[0031] Figure 3 It is a flowchart of the delay method based on the AutoSar operating system provided by the present application;
[0032] Figure 4 This is a service task state transition diagram I with a delay mechanism provided by the present application;
[0033] Figure 5 This is a service task state transition diagram II with a delay mechanism provided by this application;
[0034] Figure 6 It is a structural schematic diagram of a delay device based on the AutoSar operating system provided by the present application;
[0035] Figure 7 It is a structural schematic diagram of an electronic device provided by this application. DETAILED DESCRIPTION
[0036] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0037] It is worth mentioning that AutoSar allows application software developers to focus on the development of specific application functions without having to consider the underlying operation process of the controller through the standardized interface between the application software (Application layer) and the underlying microcontroller abstraction layer (Microcontroller abstraction layer). In this way, even if the processor hardware is replaced, the application software can be ported without much modification. Figure 1, is a schematic diagram of the AutoSar architecture provided by the present application. The AutoSar architecture 11 includes: an application software layer 12, a runtime environment 13, a complex driver layer 14, a service layer 15, an ECU abstraction layer 16, a microcontroller abstraction layer 17 and a microcontroller 18.
[0038] The AutoSar operating system is in the service layer 15 and is a successor to the OSEK (Offene Systeme and derenSchnittstellen fur die Elektronik im Kraftfahr-zeug, automotive electronics open system and its interface) operating system, but has more extended capabilities, including: scalable functions, including: scheduling tables, operating system applications (OS applications), memory protection and timing protection, etc. Figure 2 , is a structural diagram of the service layer provided in the present application, and the service layer 15 includes: a basic software mode manager (BswM) 150, a communication management module (ComM) 151, a watchdog manager (WdgM) 152, a time service (Tm) 153, a synchronized time base manager (StbM) 154, a default error tracer (Det) 155, a function inhibition manager (FiM) 156, a diagnostic event manager (Dem) 157, an ECU state manager (EcuM) 158 and an AutoSar operating system (AutoSar OS) 159.
[0039] Although based on Figure 1 The complete AutoSar architecture and Figure 2The AutoSar operating system has a complete service layer functional structure, but due to the particularity of its application only in the automotive control industry, it does not provide users with an efficient and reliable delay implementation method to enable the integration of in-vehicle controller functions (i.e., to achieve efficient concurrency). It is worth noting that the AutoSar operating system is a real-time system in which each concurrent activity is represented by a task, and most application code exists in the task. If there are many tasks that must be executed simultaneously, a method that allows concurrency will need to be provided. A separate processor can be set up for each task and then scheduled through a parallel computer, but this method is too expensive to handle multiple applications. In comparison, another more cost-effective method is more worth trying: run one task at a time on a single processor, and then switch between tasks so that they appear to be executed simultaneously. Unlike Windows, Linux or Unix operating systems, the AutoSar operating system does not provide a ready-made delay mechanism. In order to achieve task switching, the existing related technologies delay the current task for a fixed period of time and switch some applications in a circular waiting manner.
[0040] For example, the delay process of the existing related technology is as follows: If the micro control unit allows the switch to execute an instruction, the process is generally as follows:
[0041] (1) The microcontroller unit sends a command to the switch, and then waits for a period of time (e.g., 10 ms) to obtain the execution result of the switch;
[0042] (2) The switch starts executing after receiving the command, and the execution process takes 10ms;
[0043] (3) After the 10ms wait time of the switch is up, the execution result is obtained from the switch;
[0044] (4) Follow the (1)-(3) loop and the microcontroller unit continues to let the switch execute the next instruction.
[0045] However, if the switch, AVAS, interior ambient light or reversing radar are controlled by the microcontroller unit at the same time, it is not cost-effective for the microcontroller unit to delay and wait in situ. A more optimized delay method is urgently needed to release the computing resources of the microcontroller unit while waiting, so as to achieve more functions with fewer microcontroller units, thereby improving CPU utilization and the usage time range of the application.
[0046] In summary, in order to achieve task concurrency in the AutoSar operating system, the existing related technologies use a circular waiting method to perform task switching. However, this method not only wastes CPU time, but also limits the usage time range of the application, resulting in low task delay reliability and efficiency of the AutoSar operating system.
[0047] Based on this, the present application provides a delay method, device, equipment, medium and vehicle based on the AutoSar operating system, which realizes the automatic timing delay and automatic recovery of the ready state of the service tasks of the AutoSar operating system through a hardware timer for scheduling and operation, which can not only improve the CPU utilization, but also increase the usage time range of the application, thereby improving resource efficiency, processing efficiency and reliability.
[0048] In order to more clearly illustrate the delay method, device, equipment, medium and vehicle based on the AutoSar operating system provided by the present application, a detailed description will be given through the following real-time example.
[0049] Example 1
[0050] See also Figure 3 , is a flow chart of a delay method based on the AutoSar operating system provided by the present application, wherein the AutoSar operating system is provided in a microcontroller unit, and the delay method comprises steps S11 to S13, specifically:
[0051] Step S11: When the service task of the AutoSar operating system is in a running state, a delay requirement is triggered according to a preset condition, and a delay time is set based on a hardware timer.
[0052] In some embodiments, the service task can be an extended task. The present application implements the timing delay mechanism of the AutoSar operating system by using a hardware timer outside the AutoSar operating system, without increasing the complexity of the AutoSar operating system itself, and uses the timeout interrupt sent by the hardware timer to time the delay conversion of the state of the service task, which is easy to implement and has high applicability.
[0053] In some embodiments, a hardware timer (General purpose timer(s), GPT) may be a hardware unit in a microcontroller unit.
[0054] This application uses the event mechanism of the AutoSar operating system to implement an efficient delay method with the support of a hardware timer. Through the hardware timer channel of the hardware timer, a timing function can be provided for the AutoSar operating system or other modules that require a timer function, thereby achieving efficient and reliable delay scheduling.
[0055] In some embodiments, the functions of the hardware timer include: starting and stopping the hardware timer; obtaining the elapsed and remaining timer values; controlling the timing value of the timer; and controlling time-triggered interrupts.
[0056] Step S12: after the delay time has elapsed, a timeout interrupt is generated by a hardware timer, and the service task is switched from the running state to the waiting state.
[0057] In some embodiments, the converting the service task from the running state to the waiting state includes: triggering a scheduler based on the service task, and converting the service task from the running state to the waiting state through the scheduler.
[0058] It is worth noting that the AutoSar operating system-based delay method provided in the present application is based on a service task (ECC task) running in a separate AutoSar operating system, and is based on the support of hardware timers and AutoSar operating system mechanisms.
[0059] In some embodiments, if a service task is in a running state, it is necessary to set a corresponding delay time for the service task. Specifically, the hardware timer of the microcontroller unit can be set to the corresponding delay time, and the service task can trigger the scheduler of the AutoSar operating system to convert the service task from a running state to a waiting state.
[0060] In some embodiments, when the AutoSar operating system receives the timeout interrupt, the scheduler is triggered to switch the service task from the waiting state to the ready state, including: when the AutoSar operating system receives the timeout interrupt, a trigger event is generated, and according to the trigger event, the scheduler is triggered to switch the service task from the waiting state to the ready state.
[0061] Correspondingly, in some embodiments, the delay method also includes: when the delay time is not reached, based on the AutoSar operating system, scheduling the ready task in the ready state through idle CPU resources; the CPU resources are released when the service task is switched to the waiting state.
[0062] In this way, these embodiments can allocate idle CPU resources to other ready tasks, which can prevent other ready tasks from falling into a loop waiting in place, thereby improving CPU resource utilization.
[0063] Step S13: When the AutoSar operating system receives the timeout interrupt, the scheduler is triggered to convert the service task from the waiting state to the ready state, so that the AutoSar operating system can subsequently schedule the scheduled task.
[0064] In some embodiments, the delay method also includes an implementation method in which the AutoSar operating system does not receive a timeout interrupt: when the AutoSar operating system does not receive the timeout interrupt, the ready task with the highest priority is selected from the queue in the ready state, and idle CPU resources are allocated for scheduling and running; wherein the priority is pre-set according to business requirements.
[0065] This application uses the timeout interrupt sent by the hardware timer to select the ready task with the highest priority from the ready state and allocate CPU resources for scheduling and running, which can meet the execution of high-priority ready tasks required by business needs, thereby providing efficient and reliable delay services.
[0066] In some embodiments, the above-mentioned ready tasks include: real-time micro control unit tasks and service tasks; the delay method also includes: according to business needs, setting the priority of the service task to be lower than the priority of the micro control unit task, and allocating CPU resources to the service task or micro control unit task for scheduling and running according to the priority from high to low.
[0067] In some embodiments, when a service task is transferred from a waiting state to a ready state, it needs to enter a ready queue for queueing. At this time, according to business needs, the service task is given a priority lower than the real-time microcontroller task and queued, so that each time the highest priority ready task is selected from the ready queue for scheduling and operation.
[0068] The present application places service tasks at a lower priority and real-time microcontroller unit tasks at a higher priority, and schedules and runs tasks in the ready queue in the order of real-time business needs first and CPU utilization second. This can prioritize the real-time performance of high-priority tasks and then save CPU resources, thereby providing efficient and reliable delayed services with the technical concept of real-time first and CPU resources second.
[0069] In some embodiments, see Figure 4 , is a schematic diagram of the service task state transition with a delay mechanism provided by this application I. Figure 4In the process of hardware timer timing, when the service task of the AutoSar operating system is in the running state 101, the delay time can be set on the hardware timer of the external microcontroller unit and wait for the delay time to be reached. When the delay time is reached, the service task is converted from the running state 101 to the waiting state 103 through the scheduler. At this time, the service task releases the CPU resources; during the timing of the hardware timer, the AutoSar operating system allocates the idle CPU resources to other ready tasks with the highest priority in the ready queue; if the hardware timer timing reaches the delay time, a timeout interrupt is generated and the timeout interrupt is sent to the AutoSar operating system; after receiving the timeout interrupt, the AutoSar operating system generates a trigger event, triggering the scheduler to convert the service task from the waiting state 103 to the ready state 102; after the service task is converted to the ready state 102, the corresponding priority is set, and a task is selected from high to low priority to start (Start) scheduling and running, and the task selected for scheduling and running is converted from the ready state to the running state.
[0070] In some embodiments of the present application, a delay time can be set by a microcontroller unit, and a delay mechanism for scheduling service tasks in the AutoSar operating system can be implemented according to the delay time, so that a service task in a waiting state can be periodically converted to a ready state. During this period, idle CPU resources can be allocated to other ready tasks, which can prevent other ready tasks from being stuck in a loop waiting in situ, thereby improving CPU resource utilization and improving the running time range of the ready task, which is no longer limited by the limitation of the loop waiting time. When the AutoSar operating system receives the timeout interrupt, the service task converted to the ready state will be scheduled for operation. At this time, the task selected for scheduling and operation is converted from the ready state to the running state, thereby providing comprehensive, efficient and reliable delay services.
[0071] In some embodiments, see Figure 5 , is a schematic diagram of the service task state transition with a delay mechanism provided by this application II, compared to Figure 4 , Figure 5The entire state transition process of the service task is given. The service task in the running state 101 can also be terminated (Terminate) and enter the suspended (Suspend) state 104. At this time, the developer generally performs program inspection. After the inspection is completed, the service task in the suspended state 104 is activated (Activate) and enters the ready state 102 again. At this time, the corresponding priority is set, and the scheduling operation is carried out from high to low priority. The resources of the service task in the running state 101 can also be preempted (Preempt), so that the service task in the running state 101 enters the ready state 102 again. At this time, the corresponding priority still needs to be set, and the scheduling operation is carried out from high to low priority. At this time, the task selected for scheduling is converted from the ready state to the running state.
[0072] Compared with the circular waiting method commonly used by the AutoSar operating system to achieve delay, the present application uses a hardware timer to time the service task to perform state transitions during the delay period, so that other tasks can be run after the CPU resources are released, thereby efficiently utilizing the CPU computing resources, and after the delay time is reached, the state is automatically converted again to enter the ready state for scheduling and operation.
[0073] Example 2
[0074] See also Figure 6 , is a structural diagram of a delay device based on the AutoSar operating system provided in the present application, wherein the AutoSar operating system is arranged in a microcontroller unit; the delay device comprises: a first setting unit 21, a first state conversion unit 22 and a second state conversion unit 23.
[0075] The first setting unit 21 is used to trigger a delay requirement according to a preset condition and set a delay time based on a hardware timer when the service task of the AutoSar operating system is in a running state.
[0076] The first state conversion unit 22 generates a timeout interrupt through a hardware timer after the delay time has elapsed, and converts the service task from the running state to the waiting state.
[0077] In some embodiments, when the AutoSar operating system receives the timeout interrupt, the scheduler is triggered to switch the service task from the waiting state to the ready state, including: when the AutoSar operating system receives the timeout interrupt, a trigger event is generated, and according to the trigger event, the scheduler is triggered to switch the service task from the waiting state to the ready state.
[0078] In some embodiments, the delay method further comprises: when the delay time is not reached, based on the AutoSar operating system, scheduling a ready task in a ready state through idle CPU resources; the CPU resources are released when the service task is switched to a waiting state. In some embodiments, switching the service task from the running state to the waiting state comprises: triggering the scheduler, and switching the service task from the running state to the waiting state through the scheduler.
[0079] The second state conversion unit 23 is used to trigger the scheduler to convert the service task from the waiting state to the ready state when the AutoSar operating system receives the timeout interrupt.
[0080] In some embodiments, the delay method also includes: when the AutoSar operating system does not receive the timeout interrupt, selecting the ready task with the highest priority from the ready state queue, and allocating idle CPU resources for scheduling and running; wherein, the priority is pre-set according to business needs.
[0081] In some embodiments, the ready task includes: a real-time micro control unit task and the service task; the delay method also includes: according to business needs, setting the priority of the service task to be lower than the priority of the micro control unit task, and allocating the CPU resources to the service task or the micro control unit task for scheduling and running according to the priority from high to low.
[0082] The present application sets a delay time and implements a delay mechanism for scheduling service tasks in the AutoSar operating system according to the delay time, thereby being able to regularly convert service tasks in a waiting state to a ready state, thereby increasing the running time range of ready tasks and no longer being limited by the limitation of the cyclic waiting time, and when the AutoSar operating system receives the timeout interrupt, converts the service task from a waiting state to a ready state, thereby comprehensively providing efficient and reliable delayed services; in addition, the present application can implement the timing delay mechanism of the AutoSar operating system through a hardware timer outside the AutoSar operating system, without increasing the complexity of the AutoSar operating system itself, and regularly delays the conversion of the state of the service task through the timeout interrupt sent by the hardware timer, which has low implementation difficulty and high applicability.
[0083] Example 3
[0084] See also Figure 7, is a structural diagram of an electronic device provided in the present application, the device comprising: a processor 32 and a memory 31 storing computer program instructions; when the processor 32 executes the computer program instructions, it implements the delay method based on the AutoSar operating system as further described in the first aspect or the first aspect.
[0085] In some embodiments, the electronic device further includes: a communication interface 33 and a communication bus 34 ; wherein the processor 32 , the communication interface 33 and the memory 31 communicate with each other via the communication bus 34 .
[0086] The present application runs the delay method based on the AutoSar operating system described in the first aspect or further described in the first aspect in the form of a program in an electronic device, which can be run in different types of applications to perform efficient and reliable service task delays in different scenarios, and has greater practicality, applicability and scalability.
[0087] Example 4
[0088] It is a computer-readable storage medium provided by the present application, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the delay method based on the AutoSar operating system as described in Example 1 is implemented.
[0089] In some embodiments, the instructions may include programming languages such as C language, C++ language, Python language, MATLAB language, Java language, assembly language, or pseudocode.
[0090] When the present application stores the delay method based on the AutoSar operating system described in the first aspect or the first aspect further in the form of a program in a storage medium, by running or reading an executable program in any programming language in the storage medium, it can instantly perform operations such as delaying the service task or converting the running state to the waiting state or the timed delay conversion of the waiting state to the ready state. It can be applicable to more programming language environments and application scenarios, and provide efficient and reliable service task delays in different scenarios, with greater compatibility, reusability, scalability and applicability.
[0091] Example 5
[0092] A vehicle is provided in the present application, and the vehicle includes: a delay device based on the AutoSar operating system as described in Example 2 or an electronic device as described in Example 3.
[0093] The present application assembles the delay device based on the AutoSar operating system described in Example 2 or the electronic device described in Example 3 into a vehicle, which can run in different vehicle types and different vehicle applications to perform efficient and reliable service task delays in different scenarios, and has greater practicality, applicability and scalability.
[0094] Those skilled in the art will appreciate that the embodiments of the present application may also provide computer program products. Therefore, the present application may adopt the form of complete hardware embodiments, complete software embodiments, or embodiments in combination with software and hardware. Moreover, the present application may adopt the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program codes.
[0095] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0096] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0097] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0098] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A delay method based on the AutoSar operating system, characterized in that: The AutoSar operating system is arranged in the micro control unit; The delay method includes: When the service task of the AutoSar operating system is in a running state, a delay requirement is triggered according to a preset condition, and a delay time is set based on a hardware timer; After the delay time has elapsed, a timeout interrupt is generated by a hardware timer, and the service task is converted from the running state to the waiting state; When the AutoSar operating system receives the timeout interrupt, the scheduler is triggered to convert the service task from the waiting state to the ready state.
2. The delay method based on the AutoSar operating system as claimed in claim 1, characterized in that: When the AutoSar operating system receives the timeout interrupt, triggering the scheduler to convert the service task from the waiting state to the ready state includes: When the AutoSar operating system receives the timeout interrupt, a trigger event is generated, and according to the trigger event, the scheduler is triggered to switch the service task from the waiting state to the ready state.
3. The delay method based on the AutoSar operating system as claimed in claim 1, characterized in that: The delay method further comprises: When the delay time is not reached, based on the AutoSar operating system, the ready task in the ready state is scheduled to run through the idle CPU resources; the CPU resources are released when the service task is converted to the waiting state.
4. The delay method based on the AutoSar operating system as claimed in claim 3, characterized in that: The delay method further comprises: When the AutoSar operating system does not receive the timeout interrupt, the ready task with the highest priority is selected from the queue in the ready state, and idle CPU resources are allocated for scheduling and running; wherein the priority is preset according to business requirements.
5. The delay method based on the AutoSar operating system as claimed in claim 4, characterized in that: The ready task includes: a real-time micro control unit task and the service task; the delay method also includes: According to business requirements, the priority of the service task is set to be lower than the priority of the micro control unit task, and the CPU resources are allocated to the service task or the micro control unit task for scheduling and running according to the priority from high to low.
6. The delay method based on the AutoSar operating system as claimed in claim 1, characterized in that: The step of converting the service task from the running state to the waiting state comprises: The scheduler is triggered, and the service task is converted from the running state to the waiting state through the scheduler.
7. A delay device based on the AutoSar operating system, characterized in that: The AutoSar operating system is arranged in the micro control unit; the delay device comprises: a first setting unit, a first state conversion unit and a second state conversion unit; wherein, The first setting unit is used to trigger a delay requirement according to a preset condition and set a delay time based on a hardware timer when the service task of the AutoSar operating system is in a running state; The first state conversion unit is used to generate a timeout interrupt through a hardware timer after the delay time has passed, and convert the service task from the running state to the waiting state; The second state conversion unit is used to trigger the scheduler to convert the service task from the waiting state to the ready state when the AutoSar operating system receives the timeout interrupt.
8. An electronic device, characterized in that: The device comprises: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the delay method based on the AutoSar operating system as described in any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by the processor, the delay method based on the AutoSar operating system as described in any one of claims 1 to 6 is implemented.
10. A vehicle, characterized in that: The vehicle comprises: a delay device based on the AutoSar operating system as claimed in claim 7 or an electronic device as claimed in claim 8.
Citation Information
Cited By
Design method and system capable of nesting DSR priorities
CN119883574A