TBOX reservation task scheduling method and system based on dynamic priority timer
By combining a dynamic priority timer and a multi-level time wheel with a dynamic linked list task pool, the problems of resource waste and high-priority task blocking in TBOX scheduled task scheduling are solved, achieving efficient and reliable task scheduling and periodic task management.
Patent Information
- Application Number
- CN202511692848.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-18
- Publication Date
- 2026-02-17
AI Technical Summary
The existing TBOX scheduled task scheduling scheme has problems such as resource waste, inability to meet the needs of periodic task scheduling, lack of priority management mechanism, which may cause high-priority tasks to be blocked by low-priority tasks, resulting in insufficient scheduling efficiency and reliability.
A scheduling method based on dynamic priority timers is adopted, using multi-level time wheels and dynamic linked list task pools to support hierarchical management and priority adjustment of tasks. Combined with a preemptive scheduling mechanism, it ensures the real-time execution of high-priority tasks and sets task timeout thresholds to handle timeout tasks.
It significantly improves the efficiency and reliability of task scheduling, ensures timely response to high-priority tasks, reduces system resource consumption, and supports flexible expansion of task types and automatic scheduling of periodic tasks.
Smart Images

Figure CN121542001A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of vehicle-mounted remote communication, in particular to a TBOX pre-booking task scheduling method and system based on a dynamic priority timer. BACKGROUND
[0002] With the rapid development of automobile intelligence and networking, TBOX (Telematics Box, remote communication module in vehicle information entertainment system) as the core component of vehicle and cloud data interaction needs to handle a large number of pre-booking tasks, such as pre-booking air conditioning start, high temperature bacteriostasis, parking fresh air, OTA (Over-the-Air) upgrade, etc. These pre-booking tasks have the characteristics of periodicity or single execution, and some tasks (such as OTA upgrade, emergency fault diagnosis) have very high real-time requirements and need to be executed first. However, the existing TBOX pre-booking task scheduling scheme has many defects and cannot meet the efficient and reliable scheduling requirements.
[0003] The first prior art is a timer scheduling scheme based on a fixed array. This scheme stores pre-booking tasks in a preset fixed-size array, each task is assigned an independent timestamp, and the timer polls the array to trigger task execution. However, this scheme has obvious shortcomings: first, resource waste is serious. When the number of tasks is small, a large amount of storage space in the array is idle, and when the number of tasks exceeds the array capacity, tasks will be lost; second, it only supports single execution tasks and cannot meet the scheduling needs of periodic tasks. If periodic tasks need to be executed, manual repeated configuration is required, which is tedious to operate; third, there is no priority management mechanism, all tasks are executed in time sequence, and high-priority tasks may be blocked by low-priority tasks, resulting in critical tasks not being responded to in time.
[0004] The second prior art is a scheduling scheme based on a single priority queue. This scheme uses a priority queue to manage tasks, and high-priority tasks are executed first, but it does not combine a time wheel mechanism. Its main defects are: first, it lacks dynamicity. The insertion and deletion operations of tasks need to traverse the entire queue, and the time complexity and space complexity are large. When the number of tasks is large, the scheduling efficiency is greatly reduced; second, periodic task processing is inefficient. Additional complex algorithms are needed to calculate the next execution time of the task, which increases the CPU load and affects the overall performance of the system.
[0005] Therefore, a TBOX pre-booking task scheduling scheme that can dynamically manage multiple tasks, support periodic tasks and pre-emptive scheduling, reduce scheduling delay and system resource occupancy, has become a technical problem that needs to be solved. SUMMARY
[0006] The application aims to solve at least one of the technical problems in the prior art, and provides a TBOX reserved task scheduling method and system based on a dynamic priority timer.
[0007] In a first aspect, an embodiment of the application provides a TBOX reserved task scheduling method based on a dynamic priority timer, comprising:
[0008] A reserved task is issued to a TBOX, a corresponding task node is generated according to the reserved task, the task node is added to a dynamic linked list task pool, and the task node is distributed to a corresponding level of a multi-level time wheel of a dynamic priority timer according to a task period;
[0009] When a timer for executing a task is triggered, a task linked list at a current level of the multi-level time wheel is traversed, an expired task is identified, and the task is executed;
[0010] When the preset task is executed, a next execution time stamp of the task is recalculated, an execution time stamp attribute of the task node is updated, and the task node is inserted into a head of the dynamic linked list task pool, and the task node is distributed to a corresponding level of the multi-level time wheel according to the new execution time stamp.
[0011] Further, the TBOX reserved task scheduling method based on the dynamic priority timer further comprises: when a high-priority task triggers execution, if there is a low-priority task being executed at present, an execution state of the low-priority task is saved, the low-priority task node is moved to a tail of the dynamic linked list task pool, system resources are released for execution of the high-priority task, and after the system resources are idle, the execution of the low-priority task is resumed.
[0012] Further, the TBOX reserved task scheduling method based on the dynamic priority timer further comprises: a task timeout threshold is set, when a task execution time exceeds the timeout threshold, a task timeout fuse mechanism is triggered, the timeout task is automatically degraded to a lowest priority or terminated and released, a task timeout log is recorded, an abnormal notification is sent to a cloud to trigger a remote diagnosis instruction, before the TBOX is put to sleep, unexecuted tasks in the dynamic linked list task pool are persisted to a Flash storage, after the TBOX is woken up, state information of the unexecuted tasks is read from the Flash, and a structure of the dynamic linked list task pool and attributes of the task nodes are restored.
[0013] Further, the task node comprises an execution time stamp, a period type, a priority, and a callback function pointer attribute parameter.
[0014] Further, the levels of the multi-level time wheel include a second-level time wheel, a minute-level time wheel and an hour-level time wheel; and the division rule is that the second-level time wheel is used for managing tasks with a period less than 60 seconds, and the time granularity is 1 second; the minute-level time wheel is used for managing tasks with a period less than 3600 seconds, and the time granularity is 1 minute; the hour-level time wheel is used for managing tasks with a period less than 86400 seconds, and the time granularity is 1 hour; when the task period exceeds 24 hours, the task is split to the hour-level time wheel according to the day-level period.
[0015] Further, the dynamic linked list task pool adopts a double linked list structure to store task nodes, and the specific node state saving method includes:
[0016] When a high-priority task preoccupies a low-priority task for execution, the current execution progress of the low-priority task is written into the corresponding task node attribute in real time;
[0017] Before the TBOX triggers the sleep instruction, all node attributes of unexecuted tasks are stored into the Flash by traversing the dynamic linked list task pool, and the node attributes at least include an execution timestamp, a period type, a priority, a callback function pointer and an execution progress;
[0018] After the TBOX is woken up, the unexecuted task node attributes stored in the Flash are read, and the dynamic linked list task pool is reconstructed according to the task priority and the execution timestamp.
[0019] Further, the fuse mechanism in the preoccupation scheduling specifically includes:
[0020] Corresponding timeout thresholds are set for different types of reservation tasks, when the task execution time reaches the corresponding timeout threshold, a preset callback function is triggered, the callback function automatically records the detailed information of the task timeout to a local log file, and the detailed information of the task timeout at least includes a task identifier, a triggering time, a timeout duration and a current system resource occupation situation;
[0021] If the timeout task is a non-critical task, it is automatically degraded to the lowest priority, and is re-executed when the system resource is sufficient; if the timeout task is a critical task, the task execution is terminated, the occupied system resource is released, and an exception report is generated and sent to the cloud platform, after the cloud platform receives the exception report, a remote diagnosis instruction is sent to the TBOX to investigate the cause of the task timeout.
[0022] In the second aspect, the application further discloses a TBOX reservation task scheduling system based on a dynamic priority timer, which includes a reservation task issuing processing unit, a reservation task execution unit and a reservation task periodic processing unit; wherein:
[0023] The pre-appointment task issuing processing unit is configured to issue a pre-appointment task to a TBOX, generate a corresponding task node according to the pre-appointment task, add the task node to a dynamic linked list task pool, and distribute the task node to a corresponding level of a multi-level time wheel in a dynamic priority timer according to a task period;
[0024] The pre-appointment task executing unit is configured to traverse a task linked list of a current level of the multi-level time wheel when a timer for executing a task is triggered, identify an expired task, and execute the expired task.
[0025] The pre-appointment task periodic processing unit is configured to recalculate a next execution timestamp of the task when the pre-appointment task is executed, update an execution timestamp attribute of the task node, insert the task node into a head of the dynamic linked list task pool, and distribute the task node to a corresponding level of the multi-level time wheel according to the new execution timestamp.
[0026] In a third aspect, the present application further discloses an electronic device, characterized by comprising:
[0027] one or more processors;
[0028] a memory configured to store one or more programs;
[0029] When the one or more programs are executed by the one or more processors, the one or more processors implement the pre-appointment task scheduling method.
[0030] In a fourth aspect, the present application further discloses a computer readable medium, wherein the computer readable medium stores a computer program, and the computer program is executed by a processor to implement steps in the pre-appointment task scheduling method.
[0031] Compared with the prior art, the present application has the following remarkable beneficial effects:
[0032] 1. The scheduling efficiency is greatly improved. The dynamic linked list task pool adopts a double linked list structure, and the insertion and deletion operations of the task only need to modify the pointer of the linked list node, so that the time complexity is reduced to O(1). Compared with the fixed array in the prior art and the single priority queue in the prior art, the scheduling efficiency is significantly improved. Meanwhile, the multi-level time wheel realizes the hierarchical management of the task, avoids the indiscriminate scanning of all tasks, and reduces the invalid scheduling operation.
[0033] 2. The task execution reliability is enhanced. The preemptive scheduling engine guarantees the real-time performance of the high-priority task. When the high-priority task is triggered, the execution of the low-priority task can be immediately interrupted, so that the high-priority task can be timely responded, and the problem that the high-priority task is blocked in the prior art is avoided.
[0034] 3. System Scalability Optimization: The hierarchical division rules of the multi-level time wheel are flexible and adjustable. The number of time wheel levels or the time granularity of each level can be adjusted according to the task scheduling needs of different vehicle models, without requiring large-scale modifications to the core system architecture. Simultaneously, the dynamic linked list task pool supports flexible expansion of task types. Newly added reservation tasks only need to define the corresponding task node attributes and callback functions to be integrated into the existing scheduling system, adapting to task scheduling needs in different scenarios. Attached Figure Description
[0035] Figure 1 This is a first flowchart illustrating a TBOX reservation task scheduling method based on a dynamic priority timer, provided in an embodiment of the present invention.
[0036] Figure 2 This is a second flowchart illustrating the TBOX reservation task scheduling method based on a dynamic priority timer provided in an embodiment of the present invention.
[0037] Figure 3 This invention provides a structural block diagram of a TBOX reservation task scheduling system based on a dynamic priority timer, as provided in an embodiment of the invention.
[0038] Figure 4 This is a structural block diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0039] To enable those skilled in the art to better understand the technical solutions of the present invention, exemplary embodiments of the present invention are described below in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to aid understanding. These should be considered merely exemplary. Therefore, those skilled in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0040] Where there is no conflict, the various embodiments of the present invention and the features thereof may be combined with each other.
[0041] As used herein, the term “and / or” includes any and all combinations of one or more related enumerated entries.
[0042] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used herein, the singular forms “a” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that when the terms “comprising” and / or “made of” are used in this specification, the presence of the stated feature, integral, step, operation, element, and / or component is specified, but the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or groups thereof is not excluded. Terms such as “connected” or “linked” are not limited to physical or mechanical connections but can include electrical connections, whether direct or indirect.
[0043] Unless otherwise specified, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having the meaning consistent with their meaning in the context of the relevant art and the invention, and will not be interpreted as having an idealized or overly formal meaning unless expressly so defined herein.
[0044] In the technical solution of this invention, the collection, storage, use, processing, transmission, provision, and disclosure of user personal information all comply with relevant laws and regulations and do not violate public order and good morals. The use of user data in this technical solution follows relevant national laws and regulations (e.g., the "Information Security Technology - Personal Information Security Specification"). For example: appropriate measures are taken for personal information access control; restrictions are imposed on the display of personal information; the purpose of using personal information does not exceed the scope of direct or reasonable association; and explicit identity targeting is eliminated when using personal information to avoid precisely locating a specific individual.
[0045] To address at least one of the technical problems existing in the aforementioned related technologies, this embodiment provides a TBOX reservation task scheduling method and system based on a dynamic priority timer.
[0046] This embodiment discloses 1. a TBOX reservation task scheduling method based on a dynamic priority timer, such as Figure 1 ,include:
[0047] S100. Issue a reservation task to TBOX, generate a corresponding task node based on the reservation task, add the task node to the dynamic linked list task pool, and allocate it to the corresponding level of the multi-level time wheel in the dynamic priority timer according to the task cycle; wherein, the task node includes execution timestamp, cycle type, priority, and callback function pointer attribute parameters.
[0048] In this embodiment, the multi-level time wheel includes a second-level time wheel, a minute-level time wheel, and an hour-level time wheel. The division rules are as follows: the second-level time wheel is used to manage tasks with a cycle of less than 60 seconds, with a time granularity of 1 second; the minute-level time wheel is used to manage tasks with a cycle of less than 3600 seconds, with a time granularity of 1 minute; the hour-level time wheel is used to manage tasks with a cycle of less than 86400 seconds, with a time granularity of 1 hour; when the task cycle exceeds 24 hours, it is split into hour-level time wheels according to the daily cycle.
[0049] In this embodiment, the multi-level time wheel includes a second-level time wheel, a minute-level time wheel, and an hour-level time wheel. The division rules are as follows: the second-level time wheel is used to manage tasks with a cycle of less than 60 seconds, with a time granularity of 1 second; the minute-level time wheel is used to manage tasks with a cycle of less than 3600 seconds, with a time granularity of 1 minute; the hour-level time wheel is used to manage tasks with a cycle of less than 86400 seconds, with a time granularity of 1 hour; when the task cycle exceeds 24 hours, it is split into hour-level time wheels according to the daily cycle.
[0050] For example, a user submits a reservation task via the in-vehicle app to "start the air conditioner at 23:00 every day for 30 minutes." The task registration module parses this instruction and generates a task node with an execution timestamp of "November 1, 2025, 23:00," a period type of "periodic (daily)," a priority of "medium-low priority," and a callback function pointer pointing to the air conditioner start control logic. Based on the task period (86400 seconds, 24 hours), the task registration module determines that the task should be assigned to the hourly time wheel and sends the task node to the dynamic linked list task pool module. The dynamic linked list task pool module then inserts it into the medium-low priority area of the doubly linked list.
[0051] S200. When the timer for executing a task is triggered, the task list at the current level of the multi-level time wheel is traversed to identify and execute expired tasks. Specifically, a high-precision timer (such as Linuxtimerfd) is used as the driver source. This timer features high precision and stability, and can meet the triggering requirements of different time wheel levels (second-level triggering, minute-level triggering, hour-level triggering). The timer driver module triggers at intervals consistent with the time granularity of the time wheel level. Each time it is triggered, the task list at the current level in the dynamic priority timer module is traversed, the execution timestamp of the task node is compared with the current system time, expired tasks are selected, and the node information of the expired tasks is sent to the preemptive scheduling engine module to trigger the task execution process.
[0052] For example, the timer of the hourly time wheel is triggered at 1-hour intervals. When the trigger time reaches 23:00 on November 1, 2025, the timer driver module traverses the task chain of the hourly time wheel, identifies that the air conditioning reservation task has expired, and sends the task node to the preemptive scheduling engine.
[0053] S300. After the preset task is completed, the next execution timestamp of the task is recalculated, the execution timestamp attribute of the task node is updated, and the task node is inserted into the head of the dynamic linked list task pool. At the same time, it is allocated to the corresponding level of the multi-level time wheel according to the new execution timestamp.
[0054] Specifically, based on the task node's period type (e.g., daily, weekly, monthly) and period duration, combined with the current system time, the module automatically calculates the next execution timestamp for the task. For example, for a task with a period of 1 day (86400 seconds) and an initial execution time of 23:00 on November 1, 2025, the next execution timestamp is calculated to be 23:00 on November 2, 2025. After calculation, the module updates the task node's execution timestamp attribute and sends the updated task node to the dynamic linked list task pool module, which inserts it into the head of the doubly linked list. Simultaneously, the module notifies the dynamic priority timer module to determine the target time wheel level of the task node based on the new execution timestamp, achieving automatic cyclic scheduling of periodic tasks without manual intervention.
[0055] For example, if the air conditioning task is completed after 30 minutes, the periodic task processing module calculates the next execution timestamp as "November 2, 2025, 23:00", updates the execution timestamp attribute of the task node, sends it to the dynamic linked list task pool module, inserts it at the head of the doubly linked list, and notifies the dynamic priority timer module to continue to allocate it to the hourly time wheel.
[0056] In some preferred embodiments, a TBOX reservation task scheduling method based on a dynamic priority timer, such as... Figure 2 It also includes S400. When a high-priority task is triggered for execution, if there is a low-priority task currently being executed, the execution status of the low-priority task is saved, the low-priority task node is moved to the end of the dynamic linked list task pool, system resources are released for the high-priority task to execute, and the execution of the low-priority task is resumed after the system resources are idle.
[0057] Specifically, when an expired task is identified and executed, the current system task execution status is first checked. If the system is idle (no tasks are currently executing), the callback function of the task node is directly called to execute the expired task. If the system is executing a low-priority task, the execution status (execution progress, remaining time, current operation context) of the low-priority task is immediately saved to the attribute fields of the task node. The low-priority task node is then moved to the tail of the doubly linked list in the dynamic linked list task pool module, releasing the CPU, memory, and other system resources occupied by the low-priority task. Afterward, the callback function of the expired high-priority task is called to execute the high-priority task. Once the high-priority task has completed execution, the module reads the low-priority task node from the tail of the doubly linked list in the dynamic linked list task pool module, restores its previously saved execution status, and continues to execute the low-priority task, achieving seamless task switching and preemption.
[0058] For example, if there are no tasks currently being executed in the system, the preemptive scheduling engine module directly calls the callback function of the task node to start the air conditioning control logic and execute the scheduled air conditioning task; if the system is currently executing a low-priority parking fresh air task, the preemptive scheduling engine module saves the execution progress of the parking fresh air task (e.g., it has been running for 10 minutes and has 20 minutes remaining), moves its task node to the end of the dynamic linked list task pool, releases CPU resources, and then starts the air conditioning task.
[0059] In some preferred embodiments, a TBOX scheduled task method based on a dynamic priority timer further includes S500: setting a task timeout threshold; when the task execution time exceeds the timeout threshold, triggering a task timeout circuit breaker mechanism to automatically downgrade the timed-out task to the lowest priority or terminate its execution and release resources; recording a task timeout log; and simultaneously sending an exception notification to the cloud to trigger a remote diagnostic command; before the TBOX goes to sleep, persisting unexecuted tasks in the dynamic linked list task pool to Flash storage; after the TBOX wakes up, reading the status information of unexecuted tasks from Flash and restoring the structure of the dynamic linked list task pool and the attributes of the task nodes.
[0060] Specifically, the S500 in this implementation handles task timeout processing and system hibernation / wake-up recovery functions, including:
[0061] Task Timeout Handling: Different timeout thresholds are configured for different types of scheduled tasks (OTA upgrades, air conditioning reservations, high-temperature sterilization, etc.), and the execution duration of tasks is monitored in real time through timers. When the task execution duration reaches the timeout threshold, a circuit breaker mechanism is triggered: a callback function is called to record the task timeout log (including task ID, trigger time, timeout duration, system resource utilization, etc.); based on task importance, non-critical tasks are downgraded to the lowest priority, and critical tasks are terminated directly and resources are released; an exception notification is sent to the cloud platform, and remote diagnostic instructions are received from the cloud to investigate the cause of the task timeout (such as checking CPU load, memory usage, network connection status, etc.).
[0062] System Hibernation / Wake-up Recovery: Monitors system hibernation and wake-up events. Upon receiving a system hibernation command, it traverses the doubly linked list of the dynamic linked list task pool module, collecting the node attributes (execution timestamp, period type, priority, callback function pointer, execution progress) of all unexecuted tasks. The data is then verified using a CRC32 data checksum algorithm to ensure data integrity, and subsequently persisted to a designated partition in Flash storage. Upon receiving a system wake-up command, it reads the unexecuted task data from Flash and performs another CRC32 check. If the check passes, it reconstructs the doubly linked list of the dynamic linked list task pool module based on the task node's priority and execution timestamp, and notifies the dynamic priority timer module to adjust the hierarchical allocation of task nodes, restoring the task scheduling process. If the check fails, it generates a data corruption report and sends it to the cloud platform, requesting the re-issuance of the relevant tasks.
[0063] For example, if the air conditioning task times out due to low vehicle battery power (timeout threshold set to 60 seconds) during execution, the exception handling module triggers the circuit breaker mechanism: it records a timeout log (task ID: AC_001, trigger time: November 1, 2025, 23:01, timeout duration: 1 second), downgrades the air conditioning task to the lowest priority, waits for the battery to charge before re-executing, and sends an exception notification of "air conditioning task timeout (low battery power)" to the cloud. After receiving the notification, the cloud sends a battery status diagnosis command to TBOX to investigate battery problems.
[0064] This embodiment discloses a TBOX reservation task scheduling method based on a dynamic priority timer. This method, through the collaborative work of a dynamic priority timer, a dynamic linked list task pool, and a preemptive scheduling engine, solves the problems of resource waste, inefficient handling of periodic tasks, and poor real-time performance of high-priority tasks in existing TBOX reservation task scheduling. Specifically, the dynamic priority timer includes a multi-level time wheel and a priority queue, enabling hierarchical management and priority triggering of tasks; the dynamic linked list task pool supports dynamic addition, deletion, and priority adjustment of tasks; and the preemptive scheduling engine ensures the priority execution of high-priority tasks and handles task timeout exceptions. This invention reduces task time complexity, supports concurrent management of multiple tasks, reduces task trigger latency, and significantly improves the efficiency, reliability, and scalability of TBOX reservation task scheduling.
[0065] Based on the same inventive concept, embodiments of the present invention also provide a TBOX reservation task scheduling system based on a dynamic priority timer, such as... Figure 3 It includes: a reservation task issuance and processing unit, a reservation task execution unit, and a reservation task periodic processing unit; wherein:
[0066] The reservation task issuance and processing unit is used to issue reservation tasks to TBOX, generate corresponding task nodes according to the reservation tasks, add the task nodes to the dynamic linked list task pool, and allocate them to the corresponding level of the multi-level time wheel in the dynamic priority timer according to the task cycle.
[0067] The scheduled task execution unit is used to traverse the task list of the current level of the multi-level time wheel, identify the due tasks, and execute them when the timer for executing a task is triggered.
[0068] The scheduled task periodic processing unit is used to recalculate the next execution timestamp of the task after the preset task is completed, update the execution timestamp attribute of the task node, insert the task node into the head of the dynamic linked list task pool, and allocate it to the corresponding level of the multi-level time wheel according to the new execution timestamp.
[0069] The specific working methods of the reservation task issuance and processing unit, the reservation task execution unit, and the reservation task periodic processing unit have been described in detail in the above-mentioned TBOX reservation task scheduling method based on dynamic priority timer, and will not be repeated here in this embodiment.
[0070] In some preferred embodiments, the system further includes a preemptive scheduling engine module, which is a key module for ensuring the real-time performance of high-priority tasks and is responsible for receiving expired task nodes sent by the timer driver module. This module first checks the current task execution status of the system. If the system is idle (no tasks are currently executing), it directly calls the callback function of the task node to execute the expired task. If the system is executing a low-priority task, it immediately saves the execution status (execution progress, remaining time, current operation context) of the low-priority task to the attribute fields of the task node, moves the low-priority task node to the tail of the doubly linked list of the dynamic linked list task pool module, and releases the CPU, memory, and other system resources occupied by the low-priority task. Then, it calls the callback function of the expired high-priority task to execute the high-priority task. After the high-priority task is completed, the module reads the low-priority task node from the tail of the doubly linked list of the dynamic linked list task pool module, restores its previously saved execution status, and continues to execute the low-priority task, achieving seamless task switching and preemption.
[0071] In some preferred embodiments, the system further includes an exception handling module, which is responsible for handling task timeouts and system hibernation / wake-up recovery, specifically including:
[0072] Task Timeout Handling: Different timeout thresholds are configured for different types of scheduled tasks (OTA upgrades, air conditioning reservations, high-temperature sterilization, etc.), and the execution duration of tasks is monitored in real time through timers. When the task execution duration reaches the timeout threshold, a circuit breaker mechanism is triggered: a callback function is called to record the task timeout log (including task ID, trigger time, timeout duration, system resource utilization, etc.); based on task importance, non-critical tasks are downgraded to the lowest priority, and critical tasks are terminated directly and resources are released; an exception notification is sent to the cloud platform, and remote diagnostic instructions are received from the cloud to investigate the cause of the task timeout (such as checking CPU load, memory usage, network connection status, etc.).
[0073] System Hibernation / Wake-up Recovery: Monitors system hibernation and wake-up events. Upon receiving a system hibernation command, it traverses the doubly linked list of the dynamic linked list task pool module, collecting the node attributes (execution timestamp, period type, priority, callback function pointer, execution progress) of all unexecuted tasks. The data is then verified using a CRC32 data checksum algorithm to ensure data integrity, and subsequently persisted to a designated partition in Flash storage. Upon receiving a system wake-up command, it reads the unexecuted task data from Flash and performs another CRC32 check. If the check passes, it reconstructs the doubly linked list of the dynamic linked list task pool module based on the task node's priority and execution timestamp, and notifies the dynamic priority timer module to adjust the hierarchical allocation of task nodes, restoring the task scheduling process. If the check fails, it generates a data corruption report and sends it to the cloud platform, requesting the re-issuance of the relevant tasks.
[0074] Based on the same inventive concept, embodiments of the present invention also provide an electronic device. Figure 4 This is a structural block diagram of an electronic device provided in an embodiment of the present invention. Figure 4 As shown, an embodiment of the present invention provides an electronic device including: one or more processors 101, a memory 102, and one or more I / O interfaces 103. The memory 102 stores one or more programs, which, when executed by the one or more processors, enable the one or more processors to implement any of the scheduled task methods described in the above embodiments; the one or more I / O interfaces 103 are connected between the processors and the memory, configured to enable information interaction between the processors and the memory.
[0075] The processor 101 is a device with data processing capabilities, including but not limited to a central processing unit (CPU); the memory 102 is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), and flash memory (FLASH); the I / O interface (read / write interface) 103 is connected between the processor 101 and the memory 102, and can realize information interaction between the processor 101 and the memory 102, including but not limited to a data bus (Bus).
[0076] In some embodiments, the processor 101, memory 102, and I / O interface 103 are interconnected via bus 104, and thus connected to other components of the computing device.
[0077] In some embodiments, the one or more processors 101 include a field-programmable gate array.
[0078] This invention also provides a computer-readable medium. The computer-readable medium stores a computer program, which, when executed by a processor, implements the steps of any of the scheduled task methods described in the above embodiments. The computer-readable storage medium may be volatile or non-volatile.
[0079] This invention also provides a computer program product, including computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code. When the computer-readable code is run in the processor of an electronic device, the processor in the electronic device executes the above-described scheduled task method.
[0080] Those skilled in the art will understand that all or some of the steps, systems, and apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software can be distributed on a computer-readable storage medium, which may include computer storage media (or non-transitory media) and communication media (or transient media).
[0081] As is known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information, such as computer-readable program instructions, data structures, program modules, or other data. Computer storage media includes, but is not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technologies, portable compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, it is known to those skilled in the art that communication media typically contain computer-readable program instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
[0082] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.
[0083] The computer program instructions used to perform the operations of this invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as the "C" language or similar programming languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing state information from the computer-readable program instructions. This electronic circuitry can execute the computer-readable program instructions to implement various aspects of the invention.
[0084] The computer program product described herein can be implemented specifically through hardware, software, or a combination thereof. In one alternative embodiment, the computer program product is specifically embodied in a computer storage medium; in another alternative embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.
[0085] Various aspects of the present invention are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.
[0086] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processor of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner; thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.
[0087] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.
[0088] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction, which contains one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0089] Example embodiments have been disclosed herein, and while specific terminology has been used, it is for illustrative purposes only and should be construed as such, and is not intended to be limiting. In some instances, it will be apparent to those skilled in the art that features, characteristics, and / or elements described in conjunction with particular embodiments may be used alone, or in combination with features, characteristics, and / or elements described in conjunction with other embodiments, unless otherwise expressly indicated. Therefore, those skilled in the art will understand that various changes in form and detail may be made without departing from the scope of the invention as set forth in the appended claims.
Claims
1. A TBOX pre-booking task scheduling method based on dynamic priority timer, characterized in that, The application relates to a task scheduling method and device based on preemptive scheduling and dynamic priority time wheel. The application comprises the following steps: A preset task is executed according to a task node in a dynamic linked list task pool, wherein the task node is generated according to a task node issued by a TBOX, and the task node is added to the dynamic linked list task pool and distributed to a corresponding level of a multi-level time wheel according to a task period. When a timer for executing a task is triggered, a task linked list in a current level of the multi-level time wheel is traversed, an expired task is identified, and the expired task is executed.
2. The method of claim 1, wherein, When the preset task is executed, a next execution time stamp of the task is recalculated, an execution time stamp attribute of the task node is updated, the task node is inserted into a head of the dynamic linked list task pool, and the task node is distributed to a corresponding level of the multi-level time wheel according to the new execution time stamp. The application further comprises the following steps:
3. The method of claim 1, wherein, When a high-priority task is triggered to be executed, if a low-priority task is being executed, an execution state of the low-priority task is saved, the low-priority task node is moved to a tail of the dynamic linked list task pool, system resources are released for the high-priority task to be executed, and the execution of the low-priority task is resumed when the system resources are idle. The application further comprises the following steps:
4. The method of claim 1, wherein, A task timeout threshold is set, when a task execution time exceeds the timeout threshold, a task timeout fuse mechanism is triggered, the timeout task is automatically degraded to a lowest priority or terminated and released, a task timeout log is recorded, an abnormality notification is sent to a cloud end to trigger a remote diagnosis instruction, before the TBOX is put to sleep, unexecuted tasks in the dynamic linked list task pool are persisted to a flash memory, and after the TBOX is woken up, state information of the unexecuted tasks is read from the flash memory, a structure of the dynamic linked list task pool and attributes of the task nodes are restored.
5. The method of claim 1, wherein, The task node comprises execution time stamp, period type, priority, callback function pointer attribute parameters.
6. The method of claim 1, wherein, The levels of the multi-level time wheel comprise a second-level time wheel, a minute-level time wheel and an hour-level time wheel, and the division rules are as follows: the second-level time wheel is used for managing tasks with a period less than 60 seconds, and the time granularity is 1 second; the minute-level time wheel is used for managing tasks with a period less than 3600 seconds, and the time granularity is 1 minute; the hour-level time wheel is used for managing tasks with a period less than 86400 seconds, and the time granularity is 1 hour; when a task period exceeds 24 hours, the task is split to the hour-level time wheel according to a day-level period. The dynamic linked list task pool stores the task nodes in a double-linked list structure, and the specific node state saving method comprises the following steps: When a high-priority task preoccupies a low-priority task, a current execution progress of the low-priority task is written into a corresponding task node attribute in real time; Before a sleep instruction of the TBOX is triggered, node attributes of all unexecuted tasks in the dynamic linked list task pool are stored into a flash memory, and the node attributes at least comprise execution time stamp, period type, priority, callback function pointer and execution progress; 7. The method of claim 3, wherein, After the TBOX is woken up, the node attributes of the unexecuted tasks stored in the flash memory are read, and the dynamic linked list task pool is reconstructed according to the task priority and the execution time stamp. The fuse mechanism in the preemptive scheduling comprises the following steps: A corresponding timeout threshold is set for different types of reservation tasks, and when the task execution time reaches the corresponding timeout threshold, a preset callback function is triggered, and the callback function automatically records the detailed information of the task timeout to a local log file, wherein the detailed information of the task timeout at least includes task identification, triggering time, timeout duration, and current system resource occupation situation; If the timeout task is a non-critical task, it is automatically degraded to the lowest priority, and is re-executed when the system resources are sufficient; if the timeout task is a critical task, the task execution is terminated, the occupied system resources are released, and an exception report is generated and sent to the cloud platform, and after receiving the exception report, the cloud platform sends a remote diagnosis instruction to the TBOX to investigate the cause of the task timeout.
8. A TBOX pre-emptive task scheduling system based on dynamic priority timer, adopting the pre-emptive task scheduling method of any one of claims 1-7, characterized in that, The method comprises the following steps: a reservation task issuing processing unit, a reservation task execution unit, and a reservation task periodic processing unit; wherein: the reservation task issuing processing unit is configured to issue a reservation task to the TBOX, generate a corresponding task node according to the reservation task, add the task node to a dynamic linked list task pool, and distribute the task node to a corresponding level of a multi-level time wheel in a dynamic priority timer according to a task period; the reservation task execution unit is configured to, when a timer for executing a task is triggered, traverse a task linked list at a current level of the multi-level time wheel, identify an expired task, and execute the task; the reservation task periodic processing unit is configured to, after the preset task execution is completed, recalculate a next execution timestamp of the task, update an execution timestamp attribute of the task node, insert the task node into a head of the dynamic linked list task pool, and distribute the task node to a corresponding level of the multi-level time wheel according to the new execution timestamp.
9. An electronic device, comprising: The method comprises the following steps: one or more processors; a memory for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors implement the reservation task scheduling method according to any one of claims 1 to 7.
10. A computer readable medium having stored thereon a computer program, characterized in that The computer program is executed by the processor to implement the steps in the reservation task scheduling method according to any one of claims 1 to 7.