Timer implementation method, device, vehicle and computer program product
By selecting the appropriate queue insertion position in the timer according to the task type, the problem of inefficiency of the existing timer is solved, and efficient and precise task processing is achieved, suitable for autonomous driving systems.
Patent Information
- Application Number
- CN202411428471.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2044-10-12
AI Technical Summary
Existing timers are inefficient in autonomous driving and vehicle internal control systems, with limited accuracy, low CPU idling and low efficiency, especially in high-frequency tasks.
Optimize the task insertion position for efficiency by receiving the type of task to be added, determining it as a high-frequency or low-frequency task, and adding it to the corresponding fixed-time queue or hybrid queue. High-frequency tasks are directly inserted into the tail of the fixed-time queue, and low-frequency tasks are inserted into the mixed queue according to the waiting time.
It improves the efficiency of task insertion and execution, reduces time complexity, and achieves efficient and accurate timer operation, which is suitable for low resource occupation and high sensitivity requirements in the field of autonomous driving.
Smart Images

Figure CN118939437B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a timer implementation method, device, vehicle and computer program product. Background Art
[0002] As vehicles become more and more popular, people's requirements for vehicles continue to increase. Timers play an important role in vehicles, especially in autonomous driving, advanced driver assistance systems, and vehicle internal control systems. Timers are used to accurately schedule and synchronize various operations and tasks to ensure efficient and safe operation of the system. Therefore, how to better implement timers is a technical problem that needs to be solved urgently. Summary of the invention
[0003] To overcome the problems existing in the related art, the present disclosure provides a timer implementation method, device, vehicle and computer program product.
[0004] According to a first aspect of an embodiment of the present disclosure, a timer implementation method is provided, including:
[0005] Receive a task to be added, and obtain a task type of the task to be added, where the task type includes a high-frequency task and a low-frequency task;
[0006] Determine a target queue corresponding to the task type, the target queue comprising a fixed time queue and a mixed queue;
[0007] Add the task to be added to the target queue.
[0008] Optionally, determining the target queue corresponding to the task type includes:
[0009] When it is determined that the task to be added is the high-frequency task, the waiting time of the task to be added is obtained, where the waiting time is how long it will take for the task to be added to be executed;
[0010] The target queue is determined from at least one of the fixed time queues according to the waiting time.
[0011] Optionally, determining the target queue from at least one of the fixed time queues according to the waiting time includes:
[0012] Obtaining a hash value corresponding to the waiting time, and determining the target queue from at least one of the fixed time queues based on the hash value;
[0013] The adding the to-be-added task to the target queue includes:
[0014] Add the task to be added to the tail of the target queue.
[0015] Optionally, the determining the target queue corresponding to the task type further includes:
[0016] When it is determined that the task to be added is the low-frequency task, the mixed queue is used as the target queue.
[0017] Optionally, adding the to-be-added task to the target queue includes:
[0018] Obtaining the waiting time of the task to be added;
[0019] The mixed queue is traversed according to the waiting time, an insertion position of the task to be added is determined, and the task to be added is added to the insertion position.
[0020] Optionally, the method further comprises:
[0021] It is determined that there is a task to be executed in the timer, and when the task to be executed reaches the execution time, the task to be executed is executed.
[0022] Optionally, the timer includes the fixed time queue and the mixed queue;
[0023] The determining that there is a task to be executed in the timer, and executing the task to be executed when the task to be executed reaches the execution time, includes:
[0024] When it is determined that there are tasks to be executed in the timer, and there are at least two tasks to be executed, obtaining a first waiting time of the task indicated by the head pointer of the fixed time queue, and obtaining a second waiting time of the task indicated by the head pointer of the mixed queue;
[0025] Compare the first waiting time with the second waiting time, and take the task corresponding to the minimum value as the target task;
[0026] When it is determined that the target task reaches the execution time, the target task is executed.
[0027] According to a second aspect of an embodiment of the present disclosure, a timer implementation device is provided, including:
[0028] An acquisition module is configured to receive a task to be added and acquire a task type of the task to be added, wherein the task type includes a high-frequency task and a low-frequency task;
[0029] A determination module is configured to determine a target queue corresponding to the task type, wherein the target queue includes a fixed time queue and a mixed queue;
[0030] The adding module is configured to add the task to be added to the target queue.
[0031] According to a third aspect of an embodiment of the present disclosure, a vehicle is provided, the vehicle comprising:
[0032] processor;
[0033] a memory for storing processor-executable instructions;
[0034] Wherein, the processor is configured to:
[0035] Receive a task to be added, and obtain a task type of the task to be added, where the task type includes a high-frequency task and a low-frequency task;
[0036] Determine a target queue corresponding to the task type, the target queue comprising a fixed time queue and a mixed queue;
[0037] Add the task to be added to the target queue.
[0038] According to a fourth aspect of an embodiment of the present disclosure, a computer program product is provided, including a computer program, which, when executed by a processor, implements the steps of the timer implementation method provided in the first aspect.
[0039] The present disclosure can improve the efficiency of task insertion by selecting the insertion queue corresponding to the type of task to be added. Specifically, the task to be added is received, and the task type of the task to be added is obtained, wherein the task type includes high-frequency tasks and low-frequency tasks. On this basis, the target queue corresponding to the task type is determined, and the task to be added is accurately added to the determined target queue.
[0040] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0042] Figure 1 This is an example diagram of inserting tasks directly into a queue.
[0043] Figure 2 This is an example diagram of inserting a task into the time wheel timer.
[0044] Figure 3 The figure is a flow chart showing a method for implementing a timer according to an exemplary embodiment.
[0045] Figure 4 The figure is an example diagram showing a situation of adding historical tasks in a timer implementation method according to an exemplary embodiment.
[0046] Figure 5 The figure is a flow chart showing another timer implementation method according to an exemplary embodiment.
[0047] Figure 6 The figure is an example diagram of inserting different task types in another timer implementation method according to an exemplary embodiment.
[0048] Figure 7 The present invention is a flowchart of adding a timer task in another timer implementation method according to an exemplary embodiment.
[0049] Figure 8 The present invention is a flowchart of executing a timing task in another timer implementation method according to an exemplary embodiment.
[0050] Fig. 9 The invention is a block diagram showing a device for implementing a timer according to an exemplary embodiment.
[0051] Fig.10 is a block diagram of a vehicle according to an exemplary embodiment.
[0052] Fig.11 is a block diagram of a chip system according to an exemplary embodiment. DETAILED DESCRIPTION
[0053] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0054] In the description of the present disclosure, the terms used, such as "first", "second", etc., are used to distinguish similar objects and do not have to be understood as a specific order or sequence. In addition, in the description with reference to the accompanying drawings, the same symbols in different drawings represent the same elements unless otherwise stated.
[0055] Although operations or steps are described in a specific order in the drawings in the embodiments of the present disclosure, it should not be understood that it is required to perform these operations or steps in the specific order shown or in a serial order, or to perform all the operations or steps shown to obtain the desired results. In the embodiments of the present disclosure, these operations or steps can be performed in series; these operations or steps can also be performed in parallel; or some of these operations or steps can be performed.
[0056] The autonomous driving communication middleware is a vital component of autonomous driving technology, and it plays the role of a bridge between the underlying hardware and the upper-level application software. Specifically, the autonomous driving communication middleware may include timers, message transmission layers, data serial numbers / deserialization, communication protocol management, service discovery and routing, message queues, synchronization and time management, security and encryption, etc. It can be seen that the autonomous driving communication middleware is a type of software between the application system and the system software. It can use the basic services provided by the system software to connect the various parts of the application system or different applications on the network to achieve the purpose of resource sharing and function sharing.
[0057] In an autonomous driving system, autonomous driving communication middleware can be used to be responsible for the communication between various application software modules and the scheduling of system resources, ensuring that data can be transmitted securely and in real time and that resources are reasonably allocated and scheduled. In other words, the core functions of the communication middleware are high efficiency and low latency, and the timer is an indispensable module in the autonomous driving communication middleware.
[0058] In the related art, the implementation of the timer may involve task addition and task execution. In the process of adding tasks, the tasks may be inserted into the queue in ascending order of time, as described in detail. Figure 1 shown. Figure 1 Any_Task_After_Ams in the above example can be a task to be added. The task to be added needs to be executed after A milliseconds. It can be inserted into the queue Task_A_list, which can include tasks Task_A_1, Task_A_2, Task_A_3, Task_A_x, and Task_A_n. These tasks can be added in ascending order according to the waiting time of the tasks, and the corresponding time complexity is O(1 / 2N). It can be seen that this method is inefficient in the process of inserting tasks.
[0059] In addition, the autonomous driving communication middleware can be based on Figure 2 The time wheel timer shown divides time into a series of fixed time intervals, which can be called "slots" or "buckets". Each slot can represent a time period, and these slots can be arranged in time order to form a circular array structure, which is similar to the face plate of a clock. Figure 2 As shown, there may be a pointer on the time wheel timer, which is used to indicate the current time position. As time goes by, the pointer will continue to move forward, triggering and executing the due timed task.
[0060] However, the timing wheel timer has problems such as limited accuracy, CPU idling, large processing time span, and low time efficiency. In the field of autonomous driving, a timer with low resource usage, high efficiency and high sensitivity is required, which makes the timing wheel timer not applicable.
[0061] In order to solve the above problems, the embodiments of the present invention illustrate a timer implementation method, device, vehicle and computer program product. After receiving a task to be added, the method determines the task addition queue by using the task type of the task to be added, and inserts the task to be added into the determined target queue, thereby improving the efficiency of task adding.
[0062] Figure 3 is a flow chart of a timer implementation method according to an exemplary embodiment. Figure 3 As shown, the method may include the following steps.
[0063] In step S110 , a task to be added is received, and the task type of the task to be added is acquired.
[0064] In some embodiments, the task to be added may include what the task is used for and when the task is executed. The task type of the task to be added may include high-frequency tasks and low-frequency tasks, wherein high-frequency tasks may be tasks that need to be executed frequently. Exemplarily, high-frequency tasks may be related to vehicle safety, real-time control, and dynamic environment perception. For example, the task to be detected may be sensor data acquisition and processing, control system response, real-time perception and decision-making, etc.
[0065] In addition, low-frequency tasks may be tasks that do not need to be performed frequently. For example, low-frequency tasks may be tasks related to system status update, maintenance, navigation, etc. For example, the tasks to be added may be map update and navigation planning, system self-check and maintenance, in-vehicle entertainment and auxiliary functions, etc.
[0066] In some embodiments, a high-frequency task may be a timed task, that is, the task may be triggered fixedly, and a high-frequency task may be referred to as a task with a fixed time. For example, if a sensor collects data every 1 ms, when a collection task about the sensor is received, it can be determined that the task is a high-frequency task. It can be seen that a high-frequency task is an automatically triggered task.
[0067] Optionally, a low-frequency task can be an irregular task, that is, the time of triggering the task is not fixed. A low-frequency task can also be called a task with irregular timing. For example, a map update task is a task triggered when a new version of the map appears, which is not a scheduled task. It can be seen that a low-frequency task can be a passively triggered task.
[0068] As an optional method, the task to be added may carry a category identifier. After receiving the task to be added, the embodiment of the present disclosure may first obtain the category identifier in the task to be added, and then obtain the task type of the task to be added according to the category identifier.
[0069] As an example, when the type identifier is 01, it indicates that the task to be added is a high-frequency task; and when the type identifier is 02, it indicates that the task to be added is a low-frequency task.
[0070] As another optional manner, when receiving a task to be added, the embodiment of the present disclosure may also obtain the task adding status within a specified time period before the current moment, and on this basis, determine the task type of the task to be added according to the task adding status.
[0071] Specifically, after receiving the task to be added, the embodiment of the present disclosure can determine the waiting time of the task to be added, and on this basis, determine the number of additions corresponding to the waiting time based on the task addition situation in the specified time period, and determine whether the number of additions exceeds the preset threshold. If it is determined that the number of additions exceeds the preset threshold, it means that the task to be added is a high-frequency task. Otherwise, it is determined that the task to be added is a low-frequency task.
[0072] Here, the waiting time can be how long it will take for the task to be added to be executed from the current moment. For example, if a task A to be added is received, the task A to be added includes the execution time of the task. Based on the current moment and the execution time, the waiting time of the task A to be added can be determined, which can be the difference between the execution time and the current moment.
[0073] As an example, Figure 4 The current time is 9:06, and the execution time of the task A to be added is 10:06. The waiting time of the task A to be added can be 1 hour, that is, the task A to be added will be executed after 1 hour. At this time, in order to accurately determine the task type of the task A to be added, the embodiment of the present disclosure can obtain prior data, that is, obtain the number of times a task with a waiting time of 1 hour is added within a specified time period (within 5 minutes before the current time). Figure 4 We know that the number of 1h tasks added within 5 minutes before 9:06 is 5, that is, a task to be executed one hour later was added at 9:01; a task to be executed one hour later was added at 9:02; a task to be executed one hour later was added at 9:03; a task to be executed one hour later was added at 9:04; and a task to be executed one hour later was added at 9:05.
[0074] That is, within 5 minutes before the current time 9:06, a total of five tasks were added, and the waiting time of these five tasks is the same as the waiting time of the currently received task to be added. Since the number of tasks added at this time is greater than the preset threshold 3, it is determined that the task to be added is a high-frequency task. It can be seen that the embodiment of the present disclosure can determine whether the task to be added received at the current moment is a high-frequency task or a low-frequency task based on historical tasks.
[0075] As another optional method, after receiving the task to be added, the embodiment of the present disclosure may also obtain the trigger frequency of the task to be added, and on this basis, determine the type of the task to be added according to the trigger frequency. Specifically, determine whether the trigger frequency is greater than the preset frequency. If it is determined that the trigger frequency is greater than the preset frequency, then determine that the task to be added is a high-frequency task. On the contrary, if it is determined that the trigger frequency is less than the preset frequency, then determine that the task to be added is a low-frequency task.
[0076] The above-mentioned multiple methods for obtaining task types can be used separately or in combination. For example, the task type of the task to be added is determined to be a low-frequency task through the type identification of the task to be added, but the task type of the task to be added is determined to be a high-frequency task through obtaining historical tasks, and the task type can be updated to a high-frequency task. In other words, if the task types determined by different methods are the same, the embodiment of the present disclosure can use the task type as the task type of the task to be added.
[0077] On the contrary, if the task types determined by different methods are different, the embodiment of the present disclosure can obtain the task type by a third method, and use the task type obtained by the third method as the target type. For example, the task type of the task to be added is determined to be high frequency through type identification; the task type of the task to be added is determined to be low frequency through historical tasks; the task type is determined to be low frequency using the trigger frequency, and in this case, the task type of the task to be added can be determined to be low frequency.
[0078] It should be noted that, in the process of obtaining the task type of the task to be added, if the task types obtained by different methods are different, the embodiment of the present disclosure can determine the corresponding task type according to the priority of the different methods. For example, the method of obtaining the task type according to the historical task has the highest priority, so when it is determined that it is different from the task type obtained by other methods, the task type obtained by this method can be used as the target type.
[0079] In step S120, a target queue corresponding to the task type is determined.
[0080] As an optional manner, after obtaining the task type of the task to be added, the embodiment of the present disclosure may determine the target queue corresponding to the task type. If the task types are different, the corresponding target queues may also be different.
[0081] Specifically, when the task to be added is a high-frequency task, the embodiment of the present disclosure may add it to a first type of queue, where the first type of queue may be a fixed time queue; when the task to be added is a low-frequency task, the embodiment of the present disclosure may add it to a second type of queue, where the second type of queue may be an unfixed time queue. That is, the target queue may include a fixed time queue and a mixed queue.
[0082] In the disclosed embodiment, the timer may include at least one first type queue and one second type queue, wherein the task waiting time of each first type queue is different. For example, the waiting time of the first type queue A is 10ms, that is, after the task is inserted into the first type queue A, it can be executed after 10ms. For another example, the waiting time of the first type queue B is 20ms, that is, after the task is inserted into the first type queue B, it can be executed after 20ms.
[0083] In addition, when the received task is a high-frequency task, the embodiment of the present disclosure can directly add it to the tail of the first type of queue, that is, the task inserted into the queue later can be executed after the task inserted earlier.
[0084] In step S130 , the task to be added is added to the target queue.
[0085] As an optional method, after determining the target queue corresponding to the task to be added, the embodiment of the present disclosure can add the task to be added to the target queue. Specifically, the embodiment of the present disclosure can determine the position of the task to be added in the target queue according to the waiting time of the task to be added, and insert the task to be added into the position.
[0086] As can be seen from the above introduction, if the task types of the tasks to be added are different, the corresponding target queues are also different. At this time, the methods of adding the tasks to be added to the target queue are also different. Specifically, when it is determined that the tasks to be added can be inserted into the queue of the first type, the disclosed embodiment can directly insert the tasks to be added into the tail of the queue of the first type.
[0087] Optionally, when it is determined that the task to be added can be inserted into the queue of the second type, the embodiment of the present disclosure may first obtain the insertion position of the task to be added in the queue of the second type, and store it at the insertion position.
[0088] The disclosed embodiment can improve the efficiency of task insertion by selecting the insertion queue corresponding to the type of task to be added. Specifically, the task to be added is received, and the task type of the task to be added is obtained, where the task type includes high-frequency tasks and low-frequency tasks. On this basis, the target queue corresponding to the task type is determined, and the task to be added is accurately added to the determined target queue.
[0089] Figure 5 is a flow chart showing another timer implementation method according to an exemplary embodiment. Figure 5 As shown, the timer implementation method may include the following steps.
[0090] In step S210, a task to be added is received, and the task type of the task to be added is obtained.
[0091] The specific implementation of step S210 has been described in detail in the above embodiment, and will not be repeated here.
[0092] In step S220 , when it is determined that the task to be added is a high-frequency task, the waiting time of the task to be added is obtained.
[0093] Through the above introduction, we know that the task type can include high-frequency tasks and low-frequency tasks. When it is determined that the task type of the received task to be added is a high-frequency task, the embodiment of the present disclosure can obtain the waiting time of the task to be added. Here, the starting time of the waiting time of the task to be added can be the current moment, and the ending time can be the execution moment of the task to be added, that is, the waiting time can be how long it will take for the task to be added to be executed. For example, based on the current moment, if the waiting time of the task to be added is 1h, it means that the task to be added can be executed after 1 hour.
[0094] In step S230, a target queue is determined from at least one fixed time queue according to the waiting time.
[0095] In the disclosed embodiment, the timer may include at least one fixed time queue, and the waiting durations (waiting times) corresponding to these fixed time queues are different, that is, there may be a corresponding relationship between the waiting duration and the fixed time queue, and one waiting duration may correspond to one fixed time queue. For example, when the waiting duration is 5ms, the corresponding fixed time queue is queue A. For another example, when the waiting duration is 10ms, the corresponding fixed time queue is queue B.
[0096] As an optional method, after obtaining the waiting time of the task to be added, the embodiment of the present disclosure can determine the target queue from at least one fixed time queue according to the waiting time. Specifically, the embodiment of the present disclosure can search for a queue corresponding to the waiting time in at least one fixed time queue and use it as the target queue. Here, there can be a certain corresponding relationship between the fixed time queue and the waiting time.
[0097] Optionally, when determining that the task to be added is a high-frequency task, the embodiment of the present disclosure may also obtain the execution time of the task to be added, and on this basis, determine the queue corresponding to the execution time from at least one fixed time queue, and use it as the target queue. Here, there may be a certain correspondence between the fixed time queue and the execution time.
[0098] As another optional method, after obtaining the waiting time, the embodiment of the present disclosure may also first obtain a hash value corresponding to the waiting time, and determine a target queue from at least one fixed time queue based on the hash value. In other words, at least one fixed time queue may be a queue specified after hashing. Specifically, the waiting time is mapped based on a hash function, and a target queue is determined from at least one fixed time queue based on the mapping result.
[0099] Optionally, after obtaining the execution time of the task to be added, the embodiment of the present disclosure may also first obtain a hash value corresponding to the execution time, and determine a target queue from at least one fixed time queue based on the hash value. In other words, at least one fixed time queue may be a queue specified after hashing. Specifically, the execution time is mapped based on a hash function, and a target queue is determined from at least one fixed time queue based on the mapping result.
[0100] In step S240 , the task to be added is added to the tail of the determined fixed time queue.
[0101] In some embodiments, when it is determined that the task to be added is a high-frequency task, the embodiment of the present disclosure can determine the corresponding fixed time queue according to the waiting time and / or execution time of the high-frequency task. On this basis, the task to be added is inserted into the tail of the determined fixed time queue.
[0102] See also Figure 6 After receiving the task to be added, the embodiment of the present disclosure can map the waiting time of the task to be added through a hash function (hashFunction), and determine the corresponding fixed time queue based on the mapping result, and on this basis, insert the task to be added into the determined fixed time queue.
[0103] A hash function is a method of converting an input of any length (such as a string, file, data, etc.) into an output of a fixed length (which can be a number or a string) through a specific algorithm to convert the waiting time and / or execution time of the task to be added.
[0104] As an example, Figure 6As shown, when the received task is Many_Task_After_10ms (executed after 10ms), it is determined to be a high-frequency task by the task type, and the task can be added to the fixed time queue. Since the timer can include at least one fixed time queue, the embodiment of the present disclosure can add the task to the tail of the fixed time queue Task_A_list mapped out (after hashing) by 10ms.
[0105] As another example, Figure 6 As shown, when the received task is Many_Task_After_50ms (executed after 50ms), it is determined to be a high-frequency task by the task type, and the task can be added to the fixed time queue. Since the timer can include at least one fixed time queue, the embodiment of the present disclosure can add the task to the tail of the fixed time queue Task_N_list mapped out (after hashing) by 50ms.
[0106] In summary, when it is determined that the task to be added is a high-frequency task and the execution time is consistent, the embodiment of the present disclosure can store it in the queue specified after hashing. Among them, the queue specified after hashing can be a hash value of the task or data calculated by a hash function, and the hash value is used as an index to select a fixed time queue for task addition. As an example, when the added task is a data task such as wheel speed / lidar / camera, the task can be added in the above manner, which can be a task insertion method for the task queue.
[0107] It should be noted that, in the task queue task insertion method, due to the same timing, the task inserted later can be executed after the task inserted earlier, so there is no need to traverse to find the storage location of the task, that is, the newly added task can be inserted into the end of the queue, and its corresponding time complexity is O(1). It can be seen that the task insertion method proposed in the embodiment of the present disclosure can greatly reduce the number of queue traversals, thereby improving the efficiency of task addition.
[0108] In step S250, when it is determined that the task to be added is a low-frequency task, the mixed queue is used as the target queue.
[0109] As an optional method, when it is determined that the task to be added is a low-frequency task, the embodiment of the present disclosure can use a hybrid queue as the target queue. Here, the hybrid queue is used to store low-frequency tasks with inconsistent task execution times, and the hybrid queue can also be called a hybrid linked list. For example, the hybrid queue can be used to store OTA (Over-the-Air Technology) upgrade tasks, accelerator-stepping and other trigger-type tasks.
[0110] Since the timing of low-frequency tasks is very likely not fixed, there is a situation where a task inserted later is executed before a task inserted earlier. Therefore, when it is determined that the task to be added is a low-frequency task, the embodiment of the present disclosure can search for the storage location of the task by traversing, and the corresponding time complexity can be O(1 / 2n).
[0111] In step S260, the task to be added is added to the mixed queue.
[0112] Through the above introduction, it is known that when it is determined that the task to be added is a low-frequency task, the mixed queue can be used as the target queue, and the task to be added can be added to the mixed queue. Specifically, the embodiment of the present disclosure can obtain the waiting time of the task to be added. On this basis, the mixed queue is traversed according to the waiting time to determine the insertion position of the task to be added, and the task to be added is added to the insertion position.
[0113] Optionally, the embodiment of the present disclosure can obtain the execution time of the task to be added. On this basis, the mixed queue is traversed according to the execution time to determine the insertion position of the task to be added, and the task to be added is added to the insertion position.
[0114] It should be noted that in the process of traversing the mixed queue using the waiting time and / or execution time, the embodiment of the present disclosure can also use a hash function to map the waiting time and / or execution time, and use the mapping result to find the insertion position of the task in the mixed queue.
[0115] As an example, Figure 6 As shown, when the received task is Little_Task_After_1.1ms (executed after 1.1ms), it is determined to be a low-frequency task by the task type, and the task can be added to the mixed queue. Since the mixed queue can store tasks with non-fixed timing, the task Little_Task_After_1.1ms can be inserted into the corresponding position of Task_Mix_list. Here, the position can be obtained based on the hash mapping of the waiting time of Little_Task_After_1.1ms. For example, by determining that it is most appropriate to insert the Little_Task_After_1.1ms task between Task_Mix_2 and Task_Mix_3, it can be added between Task_Mix_2 and Task_Mix_3.
[0116] As another example, Figure 6As shown, when the received task is Little_Task_After_2.3ms (executed after 2.3ms), it is determined to be a low-frequency task by the task type, and the task can be added to the mixed queue. Since the mixed queue can store tasks with non-fixed timing, the task Little_Task_After_2.3ms can be inserted into the corresponding position of Task_Mix_list. Here, the position can be obtained based on the hash mapping of the waiting time of Little_Task_After_2.3ms. For example, by determining that it is most appropriate to insert the Little_Task_After_2.3ms task after Task_Mix_n, it can be added after Task_Mix_n.
[0117] In order to better illustrate the process of adding tasks, the present disclosure embodiment provides the following Figure 7 The example diagram shown is based on Figure 7 It is known that after receiving the task adding instruction (AddTask (after X ms), the embodiment of the present disclosure may first obtain the task type of the task, that is, determine whether the task to be added is a low-frequency task or a high-frequency task. If it is determined that the task to be added is a high-frequency task, the embodiment of the present disclosure may calculate the hash using the time (X ms) and confirm the target queue by the hash value. Here, the time may be the waiting time of the task, that is, the task is executed after X ms. On this basis, the task to be added is placed at the tail of the specified queue (target queue).
[0118] Optionally, if it is determined that the task to be added is a low-frequency task, the embodiment of the present disclosure can traverse the mixed linked list (mixed queue) and find the position to insert into the mixed linked list according to the task execution time (waiting time and / or execution time). Exemplarily, the embodiment of the present disclosure can determine the insertion position according to the execution time of the task, such as determining the task insertion position in ascending order. On this basis, the task to be added is inserted into the specific position of the mixed linked list.
[0119] In some embodiments, before adding the task to be added to the target queue, the embodiment of the present disclosure can determine whether the queue in the timer is empty. If it is empty, the task to be added can be inserted into the target queue, and notification information can be output at the same time, which is used to inform when the added task will be executed.
[0120] On this basis, the embodiment of the present disclosure can determine whether there is a task to be executed in the timer. If there is a task to be executed in the timer, the task to be executed is executed when the execution time of the task to be executed is reached.
[0121] From the above introduction, it can be known that the timer may include a fixed time queue and a mixed queue. In the process of executing a task, the embodiment of the present disclosure can determine whether there are tasks to be executed in the timer. If there are tasks to be executed, it is determined whether there are at least two tasks to be executed, that is, whether there are multiple tasks to be executed.
[0122] At this time, if there are at least two tasks to be executed in the timer, and these tasks to be executed belong to different types of queues, the embodiment of the present disclosure can obtain the first head pointer of the fixed time queue, and obtain the second head pointer of the mixed queue. On this basis, the first waiting time of the task indicated by the first head pointer is obtained, and the second waiting time of the task indicated by the second head pointer is obtained, the first waiting time and the second waiting time are compared, and the task corresponding to the minimum value is used as the target task. If it is determined that the target task has reached the execution time, the target task is executed.
[0123] It should be noted that the timer may include at least one fixed-time queue. In the process of comparing the waiting time, the embodiment of the present disclosure may compare the waiting time of the task indicated by the head pointer in each fixed-time queue to select the minimum value. On this basis, the minimum value is compared with the waiting time of the queue indicated by the head pointer of the mixed queue to determine the target task.
[0124] Optionally, the embodiment of the present disclosure may also sort the waiting time of the task indicated by the head pointer in each fixed time queue and the waiting time of the queue indicated by the head pointer of the mixed queue from small to large, and use the queue corresponding to the minimum value as the target queue.
[0125] In order to better illustrate the process of task execution, the present disclosure embodiment provides the following Figure 8 The example diagram shown is based on Figure 8 After the trigger task starts executing, the disclosed embodiment can check whether there is a task to be executed in the timer. If there is a task to be executed, the disclosed embodiment can find the minimum execution time of the head of the Task list (fixed time queue) and the mixed Task queue (mixed queue). On this basis, it is determined whether the current moment has reached the minimum execution time. If it has reached, the task indicated by the head pointer is executed. On the contrary, if the minimum execution time is not reached, the waiting state is entered until the execution time is reached and the task is executed.
[0126] Optionally, if it is determined that there is no task to be executed in the timer, the waiting state is entered until a new task is inserted and a notification message is received, triggering the following Figure 8 The task execution flow shown.
[0127] As an example, after receiving a notification message, it is determined that there are two fixed-time queues and one mixed queue in the timer, and both the fixed-time queues and the mixed queue are not empty. At this time, the waiting time of the task indicated by the head pointer of the first fixed-time queue is t1, the waiting time of the task indicated by the head pointer of the second fixed-time queue is t2, and the waiting time of the task indicated by the head pointer of the mixed queue is t3. By comparison, it is determined that t2 < t1 < t3. On this basis, if it is determined that the current time reaches the task indicated by the head pointer of the second fixed-time queue, the task is executed, and so on.
[0128] In the embodiments of the present disclosure, the length of the fixed-time queue can be N, the number of fixed-time queues can be M (M is much smaller than N), tasks can be evenly distributed among M fixed-time queues and one mixed queue. At this time, the time complexity of task addition can be O(1 / 2·N / (M + 1)), and the task execution time complexity is O(M + 1). It can be seen that the timer implementation method proposed in the embodiments of the present disclosure has low time complexity, no delay, no sorting, high efficiency, and high accuracy.
[0129] By combining the fixed-time queue and the mixed queue, the embodiments of the present disclosure can not only efficiently implement task addition, but also, since tasks are inserted into different queues according to low frequency and high frequency, to a certain extent, it can ensure the accuracy of task addition and task execution.
[0130] The embodiments of the present disclosure can be executed by an SOC (System on Chip). Combining the characteristics of the autonomous driving service, the SOC has characteristics such as low computing power, high algorithm efficiency, and high task real-time performance. Moreover, lidar, cameras, wheel speeds, etc. are generally periodic trigger tasks (fixed time). Based on the timer implementation method proposed in the present disclosure, tasks can be efficiently inserted without sorting, and the task execution time is accurate and without delay.
[0131] Fig. 9 It is a block diagram of a timer implementation device shown according to an exemplary embodiment. Referring to Fig. 9 , the timer implementation device 300 includes an acquisition module 310, a determination module 320, and an addition module 330.
[0132] The acquisition module 310 is configured to receive a task to be added and acquire the task type of the task to be added, where the task type includes high-frequency tasks and low-frequency tasks;
[0133] The determination module 320 is configured to determine a target queue corresponding to the task type, where the target queue includes the fixed-time queue and the mixed queue;
[0134] The addition module 330 is configured to add the task to be added to the target queue.
[0135] In some implementations, the determination module 320 may include:
[0136] A waiting time acquisition submodule is configured to acquire the waiting time of the task to be added when it is determined that the task to be added is the high-frequency task, wherein the waiting time is how long it will take for the task to be added to be executed;
[0137] The first determining submodule is configured to determine the target queue from at least one of the fixed time queues according to the waiting time.
[0138] In some implementations, the first determining submodule is further configured to obtain a hash value corresponding to the waiting time, and determine the target queue from at least one of the fixed time queues based on the hash value;
[0139] The adding module 330 is further configured to add the task to be added to the tail of the target queue.
[0140] In some implementations, the determination module 320 may further include:
[0141] The second determining submodule is configured to use the mixed queue as the target queue when it is determined that the task to be added is the low-frequency task.
[0142] In some embodiments, the adding module 330 is further configured to obtain the waiting time of the task to be added; traverse the mixed queue according to the waiting time, determine the insertion position of the task to be added, and add the task to be added to the insertion position.
[0143] In some implementations, the timer implementation device 300 may further include:
[0144] The execution module is configured to determine whether there is a task to be executed in the timer, and execute the task to be executed when the task to be executed reaches the execution time.
[0145] In some embodiments, the timer includes a fixed time queue and a mixed queue;
[0146] The execution module is also configured to determine that there are tasks to be executed in the timer, and when there are at least two tasks to be executed, obtain the first waiting time of the task indicated by the head pointer of the fixed time queue, and obtain the second waiting time of the task indicated by the head pointer of the mixed queue; compare the first waiting time with the second waiting time, and take the task corresponding to the minimum value as the target task; and execute the target task when it is determined that the target task has reached the execution time.
[0147] The disclosed embodiment can improve the efficiency of task insertion by selecting the insertion queue corresponding to the type of task to be added. Specifically, the task to be added is received, and the task type of the task to be added is obtained, where the task type includes high-frequency tasks and low-frequency tasks. On this basis, the target queue corresponding to the task type is determined, and the task to be added is accurately added to the determined target queue.
[0148] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0149] The present disclosure also provides a computer-readable storage medium having computer program instructions stored thereon, and when the program instructions are executed by a processor, the steps of the timer implementation method provided by the present disclosure are implemented.
[0150] Fig.10 6 is a block diagram of a vehicle 600 according to an exemplary embodiment. For example, the vehicle 600 may be a hybrid vehicle, a non-hybrid vehicle, an electric vehicle, a fuel cell vehicle, or other types of vehicles. The vehicle 600 may be an autonomous vehicle, a semi-autonomous vehicle, or a non-autonomous vehicle.
[0151] Reference Fig.10 , the vehicle 600 may include various subsystems, for example, an infotainment system 610, a perception system 620, a decision control system 630, a drive system 640, and a computing platform 650. The vehicle 600 may also include more or fewer subsystems, and each subsystem may include multiple components. In addition, each subsystem and each component of the vehicle 600 may be interconnected by wire or wireless means.
[0152] In some embodiments, the infotainment system 610 may include a communication system, an entertainment system, and a navigation system, among others.
[0153] The perception system 620 may include several sensors for sensing information about the environment around the vehicle 600. For example, the perception system 620 may include a global positioning system (the global positioning system may be a GPS system, or a Beidou system or other positioning systems), an inertial measurement unit (IMU), a laser radar, a millimeter wave radar, an ultrasonic radar, and a camera.
[0154] The decision control system 630 may include a computing system, a vehicle controller, a steering system, a throttle, and a braking system.
[0155] The drive system 640 may include components that provide powered motion for the vehicle 600. In one embodiment, the drive system 640 may include an engine, an energy source, a transmission system, and wheels. The engine may be one or a combination of an internal combustion engine, an electric motor, and an air compression engine. The engine is capable of converting energy provided by the energy source into mechanical energy.
[0156] Some or all functions of the vehicle 600 are controlled by a computing platform 650. The computing platform 650 may include at least one first processor 651 and a memory 652, and the first processor 651 may execute instructions 653 stored in the memory 652.
[0157] The first processor 651 may be any conventional processor, such as a commercially available CPU. The processor may also include a graphics processor (Graphic Process Unit, GPU), a field programmable gate array (Field Programmable Gate Array, FPGA), a system on chip (System on Chip, SOC), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC) or a combination thereof.
[0158] The memory 652 may be implemented by any type of volatile or nonvolatile memory device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0159] In addition to the instructions 653 , the memory 652 may also store data, such as road maps, route information, and data such as the location, direction, and speed of the vehicle. The data stored in the memory 652 may be used by the computing platform 650 .
[0160] In the embodiment of the present disclosure, the first processor 651 may execute instruction 653 to complete all or part of the steps of the above-mentioned timer implementation method.
[0161] In another exemplary embodiment, a computer program product is further provided. The computer program product includes a computer program that can be executed by a programmable device. The computer program has a code portion for executing the above-mentioned timer implementation method when executed by the programmable device.
[0162] Some embodiments of the present disclosure also provide a chip system, such as Fig.11As shown, the chip system includes at least one second processor 1301 and at least one interface circuit 1302. The second processor 1301 and the interface circuit 1302 can be interconnected through lines. For example, the interface circuit 1302 can be used to receive signals from other devices (such as the memory of the electronic device). For another example, the interface circuit 1302 can be used to send signals to other devices (such as the second processor 1301). Exemplarily, the interface circuit 1302 can read the instructions stored in the memory and send the instructions to the second processor 1301. When the instructions are executed by the second processor 1301, the timer implementation device can perform the various steps in the above embodiments. Of course, the chip system can also include other discrete devices, and some embodiments of the present disclosure are not specifically limited to this.
[0163] In some embodiments of the present disclosure, the interface circuit 1302 can obtain data, program instructions and / or information from the internal storage area of the chip system; it can also obtain data, program instructions and / or information from outside the chip system.
[0164] Optionally, the chip system also includes a memory (not shown in the icon), which is used to store necessary computer programs and data.
[0165] Those skilled in the art may also understand that the various illustrative logical blocks and steps listed in the embodiments of the present application may be implemented by electronic hardware, computer software, or a combination of the two. Whether such functions are implemented by hardware or software depends on the specific application and the design requirements of the entire system. Those skilled in the art may use various methods to implement the functions described for each specific application, but such implementation should not be understood as exceeding the scope of protection of the embodiments of the present application.
[0166] In addition, the word "exemplary" is used herein to indicate serving as an example, instance, or diagram. Any aspect or design described as "exemplary" in this article is not necessarily understood to be advantageous compared to other aspects or designs. On the contrary, the use of the word exemplary is intended to present concepts in a specific way. As used herein, the term "or" is intended to represent an inclusive "or" rather than an exclusive "or". That is, unless otherwise specified or clear from the context, "X applies A or B" is intended to represent any one of the natural inclusive arrangements. That is, if X applies A; X applies B; or X applies both A and B, "X applies A or B" is satisfied under any of the aforementioned examples. In addition, unless otherwise specified or clearly pointed to a singular form from the context, the articles "one" and "an" as used in this application and the appended claims are generally understood to mean "one or more".
[0167] Likewise, although the present disclosure has been shown and described with respect to one or more implementations, equivalent variations and modifications will occur to those skilled in the art after reading and understanding the specification and drawings. The present disclosure includes all such modifications and variations and is limited only by the scope of the claims. In particular, with respect to the various functions performed by the components (e.g., elements, resources, etc.) described above, unless otherwise indicated, the terms used to describe such components are intended to correspond to any component (functionally equivalent) that performs the specific functions of the described components, even if the structure is not equivalent to the disclosed structure. In addition, although specific features of the present disclosure may have been disclosed with respect to only one of several implementations, such features may be combined with one or more other features of other implementations as may be desired and beneficial to any given or specific application. In addition, with respect to "including", "having", "having", "having", or variations thereof used in a specific embodiment or claim, such terms are intended to be inclusive in a manner similar to the term "comprising".
[0168] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.
[0169] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
[0170] It should be understood that, unless otherwise specifically noted, the features of some embodiments of the various present disclosures described herein may be combined with each other. As used herein, the term "and / or" includes any one of the related listed items and any combination of any two or more; similarly, "at least one of . . . " includes any one of the related listed items and any combination of any two or more.
[0171] Although terms such as "first", "second" and "third" can be used herein to describe various components, parts, regions, layers or sections, these components, parts, regions, layers or sections are not limited to these terms. On the contrary, these terms are only used to distinguish one component, component, region, layer or section from another component, component, region, layer or section. Therefore, without departing from the teachings of each example, the first component, component, region, layer or section mentioned in the examples described herein may also be referred to as the second component, component, region, layer or section. In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first" and "second" may expressly or implicitly include at least one of the features. In the description herein, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
Claims
1. A timer implementation method, characterized in that: include: Receive a task to be added, and obtain a task type of the task to be added, where the task type includes a high-frequency task and a low-frequency task; Determine a target queue corresponding to the task type, the target queue comprising a fixed time queue and a mixed queue; The determining the target queue corresponding to the task type includes: When it is determined that the task to be added is the high-frequency task, the waiting time of the task to be added is obtained, where the waiting time is how long it will take for the task to be added to be executed; Obtaining a hash value corresponding to the waiting time, and determining the target queue from at least one of the fixed time queues based on the hash value; Add the task to be added to the target queue; The adding the to-be-added task to the target queue includes: Add the task to be added to the tail of the target queue.
2. The timer implementation method according to claim 1, characterized in that: The determining of the target queue corresponding to the task type further includes: When it is determined that the task to be added is the low-frequency task, the mixed queue is used as the target queue.
3. The timer implementation method according to claim 2, characterized in that: The adding the to-be-added task to the target queue includes: Obtaining the waiting time of the task to be added; The mixed queue is traversed according to the waiting time, an insertion position of the task to be added is determined, and the task to be added is added to the insertion position.
4. The timer implementation method according to claim 1, characterized in that: The method further comprises: It is determined that there is a task to be executed in the timer, and when the task to be executed reaches the execution time, the task to be executed is executed.
5. The timer implementation method according to claim 4, characterized in that: The timer includes the fixed time queue and the mixed queue; The determining that there is a task to be executed in the timer, and executing the task to be executed when the task to be executed reaches the execution time, includes: When it is determined that there are tasks to be executed in the timer, and there are at least two tasks to be executed, obtaining a first waiting time of the task indicated by the head pointer of the fixed time queue, and obtaining a second waiting time of the task indicated by the head pointer of the mixed queue; Compare the first waiting time with the second waiting time, and take the task corresponding to the minimum value as the target task; When it is determined that the target task reaches the execution time, the target task is executed.
6. A timer implementation device, characterized in that: include: An acquisition module is configured to receive a task to be added and acquire a task type of the task to be added, wherein the task type includes a high-frequency task and a low-frequency task; A determination module is configured to determine a target queue corresponding to the task type, the target queue including a fixed time queue and a mixed queue, and when it is determined that the task to be added is the high-frequency task, obtain a waiting time of the task to be added, the waiting time being how long it will take for the task to be added to be executed; obtain a hash value corresponding to the waiting time, and determine the target queue from at least one of the fixed time queues based on the hash value; The adding module is configured to add the task to be added to the target queue, and add the task to be added to the tail of the target queue.
7. A vehicle, characterized in that: include: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to: Receive a task to be added, and obtain a task type of the task to be added, where the task type includes a high-frequency task and a low-frequency task; Determine a target queue corresponding to the task type, the target queue comprising a fixed time queue and a mixed queue; The determining the target queue corresponding to the task type includes: When it is determined that the task to be added is the high-frequency task, the waiting time of the task to be added is obtained, where the waiting time is how long it will take for the task to be added to be executed; Obtaining a hash value corresponding to the waiting time, and determining the target queue from at least one of the fixed time queues based on the hash value; Add the task to be added to the target queue; The adding the to-be-added task to the target queue includes: Add the task to be added to the tail of the target queue.
8. A computer program product, characterized in that The invention comprises a computer program, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Task processing method and device
CN107450971A
Test task scheduling method and apparatus, server and storage medium
CN108052443A
Multi-type task management method and device
CN115509700A