Timer system
By using two linked list headers in the timer system to manage timers with different trigger times, and reassign timers before the system timer time enters the next poll, the problems of cross-platform compatibility and system resource consumption are solved, and efficient timing task processing and low time complexity are achieved.
Patent Information
- Application Number
- CN202411741508.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-25
AI Technical Summary
Existing timer systems have compatibility problems when running across platforms, and when applying for a large number of timers, they will consume more system resources, resulting in an increase in the number of file descriptors and affecting the normal operation of other applications.
Two linked list headers are used to store timers with different trigger times. The first linked list header is used to store timers within the preset timer, and the second linked list header is used to store timers with long timers, and before the system timer enters the next polling, the timers under the second linked list header are reassigned.
It realizes efficient processing of a large number of timing tasks, reduces time complexity, avoids time error problems caused by the increase in the number of timers, and has a simple system structure, easy to implement, and efficient performance.
Smart Images

Figure CN119690654A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of timing technology, and in particular to a timer system. Background Art
[0002] A timer is an electronic device or program used to measure time and send timing signals. It is used to control time intervals and automatically trigger an operation according to preset time intervals without human intervention.
[0003] Event polling (epoll) is an I / O multiplexing mechanism provided by the Linux kernel. It can efficiently manage a large number of file descriptors and monitor events on multiple file descriptors with just one system call, greatly improving the efficiency of I / O operations. In the implementation of timers, epoll can be used to monitor the triggering of timed events, thereby achieving precise control of timers.
[0004] However, since epoll is Linux-specific and cannot be used on other operating systems (such as Windows), if epoll is directly used to implement timers in applications that need to run across platforms, compatibility issues will occur, resulting in the inability of the application to run normally. Moreover, when applying for a large number of timers, the timer itself will consume relatively more system resources, especially when registering and canceling file descriptors. Each timer will occupy a system file descriptor. When there are a large number of timers in the system, the number of file descriptors occupied by these timers will increase rapidly, thereby compressing the number of file descriptors available in the system, and thus affecting the normal operation of other applications. Summary of the invention
[0005] In order to solve the above technical problems, the present invention provides a timer system.
[0006] The technical problem solved by the present invention can be achieved by adopting the following technical solutions:
[0007] A timer system, comprising:
[0008] A plurality of first link list headers, each of which corresponds to a fixed trigger duration and is used to store a first timer with the same fixed trigger duration, the fixed trigger duration increases from 1 second to a preset duration, and the system timing time is configured to perform a poll once every preset duration;
[0009] A second linked list header, wherein the second linked list header is used to store a second timer whose triggering duration exceeds the preset duration;
[0010] A reallocation module, used for reallocating and storing the second timer under the second link list head to the matching first link list head before the system timing time enters the next polling;
[0011] The timing trigger module is used to trigger the corresponding timer under the first chain list head according to the current system timing time.
[0012] Preferably, it also includes:
[0013] The allocation module is used to allocate the newly applied timer to the corresponding first chain list head or the second chain list head according to the timing duration of the newly applied timer.
[0014] Preferably, the allocation module comprises:
[0015] A first judging unit, configured to judge whether the timing duration applied by the timer exceeds the preset duration, and obtain a first judging result;
[0016] A first allocation unit, connected to the first judgment unit, configured to allocate the timer to the corresponding first chain list head when the first judgment result indicates that the timing duration applied by the timer does not exceed the preset duration;
[0017] The second allocation unit is connected to the first judgment unit, and is used to allocate the timer to the second linked list head when the first judgment result indicates that the timing duration applied by the timer exceeds the preset duration.
[0018] Preferably, the first allocation unit is used to allocate the timer to the nth first linked list head, where n satisfies the following conditions:
[0019]
[0020] Wherein, T1 represents the timing duration of the timer application;
[0021] S1 represents the system timing time corresponding to the timer application;
[0022] P represents the preset duration.
[0023] Preferably, the timing trigger module includes:
[0024] The first thread is used to send a message to the second thread every 1 second;
[0025] The second thread is used to, after receiving the message, add one to the system timing time, use the accumulated system timing time as the current system timing time, and trigger the corresponding timer under the first linked list head according to the current system timing time.
[0026] Preferably, the second thread is further used to clear the system timing time when the system timing time reaches the preset duration, so as to enter the next polling and restart the timing.
[0027] Preferably, it also includes:
[0028] The remaining timing duration configuration module is used to configure the second timer under the second chain list head before the system timing time enters the next polling to determine the remaining timing duration of the second timer.
[0029] Preferably, the remaining timing duration configuration module includes:
[0030] A first configuration unit, configured to configure the remaining timing duration of the timer to T1+S1-(P-1) after the system timing time is cleared when the timer is first assigned to the second linked list head in the current polling; wherein T1 represents the timing duration applied by the timer; S1 represents the system timing time corresponding to the timer application; and P represents the preset duration;
[0031] The second configuration unit is used to configure the remaining timing duration of the timer to T1-P after the system timing time is reset when the timer is not allocated to the second linked list head for the first time in the current poll.
[0032] Preferably, the reallocation module comprises:
[0033] A second judgment unit is used to judge whether the remaining timing duration of the second timer under the second linked list header exceeds the preset duration before the system timing time enters the next polling, and obtain a second judgment result;
[0034] A first processing unit, connected to the second judgment unit, configured to reallocate and store the second timer under a first linked list head matching the remaining timing duration when the second judgment result indicates that the remaining timing duration does not exceed the preset duration;
[0035] The second processing unit is connected to the second judgment unit and is used for not performing any processing when the second judgment result indicates that the remaining timing duration exceeds the preset duration.
[0036] Preferably, the preset duration is 60 seconds.
[0037] The advantages or beneficial effects of the technical solution of the present invention are:
[0038] The present invention adopts two linked list headers to respectively store timers with different trigger durations, wherein the first linked list header performs classification management on timers within a preset duration, and the second linked list header processes timers with extra-long durations and reallocates them before polling, thereby realizing efficient processing of a large number of timed tasks, reducing time complexity, ensuring that timers under the same linked list header can be processed synchronously, thereby avoiding the time error problem caused by an increase in the number of timers; at the same time, the system has the advantages of simple structure, easy implementation, and high performance, and is particularly suitable for scenarios where a large number of timer tasks need to be processed. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 A structural block diagram of a timer system in a preferred embodiment of the present invention;
[0040] Figure 2 The overall block diagram of the timer system in the preferred embodiment of the present invention;
[0041] Figure 3 A schematic diagram of the process of creating a linked list header memory in a preferred embodiment of the present invention;
[0042] Figure 4 This is a flow chart of the first thread and the second thread implementing the timing mechanism in a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0043] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0044] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0045] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments, but they are not intended to limit the present invention.
[0046] In a preferred embodiment of the present invention, based on the above problems existing in the prior art, a high-performance timer system is provided. Figure 1 and Figure 2 As shown, including:
[0047] A plurality of first link list headers 1, each of which corresponds to a fixed trigger duration and is used to store a first timer with the same fixed trigger duration, the fixed trigger duration increases from 1 second to a preset duration, and the system timing time is configured to perform a poll once every preset duration;
[0048] A second linked list header 2, the second linked list header 2 is used to store a second timer whose triggering duration exceeds a preset duration;
[0049] The reallocation module 3 is used for reallocating and storing the second timer under the second link list head 2 to the matching first link list head 1 before the system timing time enters the next polling;
[0050] The timing trigger module 4 is used to trigger the timer under the corresponding first linked list head 1 according to the current system timing time.
[0051] Specifically, in view of the limitations of timers implemented based on epoll in the prior art in terms of cross-platform capabilities and system resource consumption, in this embodiment, two linked list headers are used to store timers with different trigger durations, wherein the first linked list header 1 includes multiple first linked list headers 1, which classify and manage timers within a preset duration according to the trigger duration corresponding to the linked list header.
[0052] The second linked list header 2 is specifically used to process timers whose triggering duration exceeds the preset duration. Since these timers have a long triggering duration, each different triggering duration creates an independent first linked list header 1 for management, which not only occupies a large amount of system resources, but also leads to a significant increase in management complexity. Therefore, the embodiment of the present invention uses the second linked list header 2 for unified and centralized management of timers whose triggering duration exceeds the preset duration.
[0053] The system timer will poll once every preset time interval, that is, every second the system timer will add 1. After reaching the preset time, the system timer will be reset to zero to enter the next polling and restart the timing.
[0054] For the timers under the second linked list header 2, before the system timing time is about to enter the next polling, the reallocation module 3 will check all timers under the second linked list header 2, and according to the remaining trigger duration of these timers, the timers whose remaining timing duration is less than or equal to the preset duration will be reallocated and stored under the first linked list header 1 that matches the remaining timing duration.
[0055] During each polling process, the system timing time will be accumulated from 1 second to the preset duration. Every time the system timing time is accumulated, the timing trigger module 4 will match the first chain list head with a trigger duration equal to the current system timing time, and process the timer tasks of all timers mounted under the matching first chain list head, thereby realizing efficient processing of a large number of timer tasks, reducing time complexity, ensuring that the timers under the same chain list head can be processed synchronously, thereby avoiding the time error problem caused by the increase in the number of timers.
[0056] The system has the advantages of simple structure, easy implementation, and high performance, and is particularly suitable for scenarios that require processing a large number of scheduled tasks.
[0057] Furthermore, it also includes: timer system initialization, such as Figure 3 As shown, the initialization process is as follows:
[0058] S100, creating a memory pool for allocating timers to unused users. When applying for a timer, the timer duration is in seconds.
[0059] S101, create two task processor memories, process the first linked list header 1 and the second linked list header 2 respectively, wherein the first linked list header 1 is used to process the timer whose applied timing duration is less than or equal to the preset duration, and the second linked list header 2 is used to process the timer whose applied timing duration is greater than the preset duration.
[0060] In the following, the embodiment of the present invention takes the preset duration of 60 seconds as an example. The system timing time is polled once every 60 seconds, that is, the system timing time is accumulated and added by one every second, and is reset once every 60 seconds.
[0061] During initialization, 60 first linked list headers 1 are created, and the meaning of each first linked list header 1 is that the system timing time corresponds to the number of the first linked list header 1. Specifically, the 60 linked list headers are marked with numbers 1 second, 2 seconds, 3 seconds...59 seconds, 60 seconds, which correspond to the system timing time respectively.
[0062] For example, when the system timing time is 1 second, all timer tasks under the 1 second linked list header are processed, such as Figure 1 and Figure 2 Timer A, Timer E and other timing tasks.
[0063] During initialization, a second linked list header 2 is created, and the meaning of the second linked list header 2 is the number > 60 seconds. When the system timing time is 60 seconds, the system timing time will be reset once, and the remaining timing time of all timers under the second linked list header 2 will be processed.
[0064] For timers with an applied timing duration greater than 60 seconds, after multiple system timing polling, the applied timer duration will gradually decrease to less than or equal to 60 seconds. At this time, it will be deleted from the second linked list header 2 and added to the corresponding first linked list header 1.
[0065] As a preferred embodiment, wherein Figure 2 As shown, it also includes:
[0066] The allocation module 5 is used to allocate the newly applied timer to the corresponding first chain list head 1 or second chain list head 2 according to the timing duration of the newly applied timer.
[0067] Specifically, in this embodiment, the triggering time of each timer application is calculated in advance, that is, the timer is immediately allocated when it is applied, without waiting for the polling process, thereby reducing the time delay.
[0068] By assigning timers with the same trigger time together for processing, especially when there are a large number of timer tasks, multiple timers can be classified under the same first linked list head and triggered at the same second, which simplifies the management of timers and improves the processing efficiency of the system; at the same time, since timers with the same trigger time can be processed at one time without checking them one by one, there will be no error in the trigger time due to the number of timers.
[0069] In this embodiment, the trigger time is in units of 1 second to ensure that the time accuracy meets the requirements of most application scenarios.
[0070] As a preferred embodiment, the allocation module 5 includes:
[0071] The first judging unit 51 is used to judge whether the timing duration applied by the timer exceeds a preset duration, and obtain a first judging result;
[0072] The first allocation unit 52 is connected to the first judgment unit 51 and is used to allocate the timer to the corresponding first linked list head 1 when the first judgment result indicates that the timing duration applied by the timer does not exceed the preset duration;
[0073] The second allocation unit 53 is connected to the first judgment unit 51, and is used to allocate the timer to the second linked list head 2 when the first judgment result indicates that the timing duration applied by the timer exceeds the preset duration.
[0074] Specifically, in this embodiment, when a new timer task is applied for, a timer is created and allocated to the first linked list header 1 or the second linked list header 2 according to the timing duration of the timer task.
[0075] If the requested timing duration is less than or equal to 60 seconds, the requested timer is allocated to the first linked list head 1.
[0076] If the requested timing duration exceeds 60 seconds, the requested timer is allocated to the second linked list head 2.
[0077] As a preferred implementation, the first allocation unit 52 is used to allocate the timer to the nth first linked list head 1, where n satisfies the following conditions:
[0078]
[0079] Wherein, T1 represents the timing duration of the timer application;
[0080] S1 represents the system timing time corresponding to the timer application;
[0081] P indicates the preset duration.
[0082] Specifically, the timer system of the embodiment of the present invention adopts the same system timing polling mechanism to manage the timing of all timer tasks.
[0083] Considering that the timer task may not be applied before the polling starts, but generated during the polling process, in order to ensure that these newly applied timer tasks can also be managed in a timely and accurate manner, in this embodiment, when receiving the timer application, two key factors are comprehensively considered: the timing duration of the timer application and the system timing time corresponding to the timer application. These two factors jointly determine which first linked list head the timer should be assigned to, so as to ensure that it can be triggered at the predetermined time point.
[0084] Specifically, the allocation logic is as follows:
[0085] If the sum of the timing duration applied by the timer and the system timing time corresponding to the timer application is greater than 60 seconds, the first allocation unit 52 will allocate the timer to the nth first linked list head 1. The value of n here is calculated by subtracting 60 seconds from the sum of the timing duration applied by the timer and the system timing time corresponding to the timer application, so as to ensure that even if the triggering time of the timer crosses the limit of 60 seconds, it can be correctly placed under the corresponding linked list head and wait for subsequent triggering processing.
[0086] If the sum of the timing duration applied by the timer and the system timing time corresponding to the timer application is less than or equal to 60 seconds, the first allocation unit 52 will allocate the timer to the nth first linked list head 1. The value of n at this time is the sum of the timing duration applied by the timer and the system timing time corresponding to the timer application.
[0087] As an example, suppose that when the system timing time is 54 seconds, a timer C is applied for, and the timing duration applied by timer C is 5 seconds. At this time, timer C is assigned to the first linked list head corresponding to 59 seconds (i.e. 54 seconds + 5 seconds). When the system timing time reaches 59 seconds, the timer task of timer C is triggered.
[0088] As an example, suppose that when the system timing time is 54 seconds, a timer A is applied for, and the timing duration applied by timer A is 7 seconds. At this time, timer A is assigned to the first linked list head corresponding to 1 second (i.e. 54 seconds + 7 seconds - 60 seconds). When the system timing time is polled and cleared once, when it reaches 1 second, the timing task of timer A is triggered.
[0089] The timer requested when the system timing is 60 seconds uses the system timing after it is reset as the calculation starting point.
[0090] The timer system of the embodiment of the present invention ensures that even in the polling process, newly applied timer tasks can be managed in a timely and accurate manner. Moreover, through reasonable allocation of linked list headers, the efficiency and accuracy of timer trigger processing are further improved, so that the timing and task management of the entire system maintains a high degree of continuity and accuracy.
[0091] As a preferred embodiment, wherein Figure 4 As shown, the timing trigger module 4 includes:
[0092] The first thread 41 is used to send a message to the second thread 42 every 1 second;
[0093] The second thread 42 is used for, after receiving the message, accumulating the system timing time by one, taking the accumulated system timing time as the current system timing time, and triggering the timer under the corresponding first linked list head 1 according to the current system timing time.
[0094] Specifically, Figure 4 As shown, the timing mechanism of the timer is implemented by two threads, namely a first thread 41 and a second thread 42 .
[0095] The first thread 41 is an infinite loop, which executes the following process:
[0096] S200, infinite loop;
[0097] S201, wait for 1 second;
[0098] S202, sending a message to the second thread 42, and returning to S200.
[0099] The second thread 42 adopts the epoll model, waiting to receive the message sent by the first thread 41, and will process the timer task after receiving the message from thread 1.
[0100] The second thread 42 executes the following process:
[0101] S300, create epoll handle;
[0102] S301, epoll_wait waits for message processing;
[0103] S302, the system timing time is increased by one;
[0104] S303, process the scheduled task and return to S301 to continue waiting for the next message.
[0105] The timer system of the present invention implements the timer using the functions of the first thread 41 and the second thread 42, that is, using the epoll model, a timing task is processed every 1 second, and the system timing time is updated at the same time, which can efficiently handle a large number of event managements and reduce time complexity. The timer algorithm has no time error in timing.
[0106] For the timed tasks of all timers under the two types of linked list headers, the timer action is executed according to the current system timing time, that is, when the timer timing time is reached, the timed tasks of all timers under the corresponding linked list header are executed.
[0107] As a preferred implementation, the second thread 42 is further used to clear the system timing time when the system timing time reaches a preset duration, so as to enter the next polling and restart the timing.
[0108] As a preferred embodiment, the invention further comprises:
[0109] The remaining timing duration configuration module 6 is used to configure the second timer under the second chain list head 2 before the system timing time enters the next polling to determine the remaining timing duration of the second timer.
[0110] Specifically, for the timer under the second link list header 2, when the system timing time is 60 seconds, the system timing time will be reset once, and the remaining timing duration of all timers under the second link list header 2 will be processed at the same time.
[0111] As a preferred implementation, the remaining timing duration configuration module 6 includes:
[0112] The first configuration unit 61 is used to configure the remaining timing duration of the timer to T1+S1-P after the system timing time is cleared when the timer is first assigned to the second linked list head 2 in the current polling; wherein T1 represents the timing duration applied by the timer; S1 represents the system timing time corresponding to the timer application; and P represents the preset duration;
[0113] The second configuration unit 62 is used to configure the remaining timing duration of the timer to T1-P after the system timing time is reset when the timer is not allocated to the second linked list head 2 for the first time in the current polling.
[0114] Specifically, for the timer first allocated to the second linked list head 2 in the current polling, after the system timing time is cleared, the timing duration applied by the timer is added to the system timing time at the time of application, and then the preset duration is subtracted to obtain the remaining timing duration.
[0115] For the timer that is not assigned to the second list head 2 for the first time in the current polling, after the system timing time is cleared, the remaining timing duration is configured as T1-P. Since the timer has been polled, T1 at this time is not the timing duration initially applied by the timer, but the timing duration after the last polling.
[0116] For the timer under the second linked list header 2, the remaining timing duration is configured according to the following formula:
[0117]
[0118] Specifically, if the timer is applied within the current polling cycle, its remaining timing duration is the applied timing duration plus the system timing time at the time of application, minus 59 seconds (because the preset duration P is 60 seconds, so P-1 is equal to 59 seconds), ensuring that the timer can be triggered within the next full 60-second cycle.
[0119] If the timer is not applied in the current polling cycle, that is, it is left over from the previous polling cycle, then the remaining time after the last polling is directly subtracted from 60 seconds to get the remaining timing time after the current polling, which is suitable for timers with extra-long durations.
[0120] As a preferred embodiment, the redistribution module 3 includes:
[0121] The second judgment unit 31 is used to judge whether the remaining timing duration of the second timer under the second linked list head 2 exceeds the preset duration before the system timing time enters the next polling, and obtain a second judgment result;
[0122] The first processing unit 32 is connected to the second judging unit 31 and is used to reallocate and store the second timer under the first linked list head 1 matching the remaining timing duration when the second judging result indicates that the remaining timing duration does not exceed the preset duration;
[0123] The second processing unit 33 is connected to the second judging unit 31 and is configured to perform no processing when the second judging result indicates that the remaining timing duration exceeds the preset duration.
[0124] Specifically, if the remaining timing duration is greater than 60 seconds, no processing is performed.
[0125] If the remaining timing duration is less than or equal to 60 seconds, the timer is deleted from the linked list, and then the timer is added to a first linked list head 1 whose triggering duration is less than or equal to 60 seconds.
[0126] As an example, if a timer I is applied for when the system timing time is 40 seconds, and the timing duration applied by timer I is 120 seconds, then timer I will be allocated to the second linked list head corresponding to greater than 60 seconds when it is first allocated. When the system timing time increases from 40 seconds to 60 seconds, the system timing time is usually reset or understood as entering the next 60-second cycle.
[0127] At the moment when the system timing time reaches 60 seconds, timer 1 has actually "experienced" 20 seconds from 41 seconds to 60 seconds, so the remaining timing duration of timer 1 is 100 seconds (i.e. 120 seconds + 40 seconds - 60 seconds). Therefore, after the system timing time is reset or enters the next 60-second cycle, the remaining timing duration of timer 1 is updated to 100 seconds, and is still under the second linked list header corresponding to more than 60 seconds.
[0128] After the next 60-second cycle polling is completed, the remaining timing duration of timer I is updated to 40 seconds (i.e. 100 seconds - 60 seconds). At this time, the remaining timing duration of timer I is less than 60 seconds, and timer I needs to be assigned to the first linked list header corresponding to 40 seconds, and wait for the next system timing time to reach 40 seconds to trigger the timing task of timer I.
[0129] As a preferred implementation, the preset duration is 60 seconds.
[0130] Specifically, the embodiment of the present invention takes the preset time length of 60 seconds as an example, but in actual applications, the preset time length can be flexibly selected according to specific needs.
[0131] The advantages or beneficial effects of adopting the above technical solution are: the present invention adopts two linked list headers to store timers with different trigger durations respectively, wherein the first linked list header 1 classifies and manages timers within a preset duration, and the second linked list header 2 handles timers with extra-long durations and reallocates them before polling, thereby achieving efficient processing of a large number of timed tasks, reducing time complexity, and ensuring that timers under the same linked list header can be processed synchronously, thereby avoiding the time error problem caused by an increase in the number of timers; at the same time, the system has the advantages of simple structure, easy implementation, and high performance, and is particularly suitable for scenarios where a large number of timer tasks need to be processed.
[0132] The above are only preferred embodiments of the present invention, and are not intended to limit the implementation methods and protection scope of the present invention. Those skilled in the art should be aware that all solutions obtained by equivalent substitutions and obvious changes made using the contents of this specification and illustrations should be included in the protection scope of the present invention.
Claims
1. A timer system, characterized in that: include: A plurality of first link list headers, each of which corresponds to a fixed trigger duration and is used to store a first timer with the same fixed trigger duration, the fixed trigger duration increases from 1 second to a preset duration, and the system timing time is configured to perform a poll once every preset duration; A second linked list header, wherein the second linked list header is used to store a second timer whose triggering duration exceeds the preset duration; A reallocation module, used for reallocating and storing the second timer under the second link list header to the matching first link list header before the system timing time enters the next polling; The timing trigger module is used to trigger the corresponding timer under the first chain list head according to the current system timing time.
2. The timer system according to claim 1, characterized in that: Also includes: The allocation module is used to allocate the newly applied timer to the corresponding first chain list head or the second chain list head according to the timing duration of the newly applied timer.
3. The timer system according to claim 2, characterized in that: The allocation module comprises: A first judging unit, configured to judge whether the timing duration applied by the timer exceeds the preset duration, and obtain a first judging result; A first allocation unit, connected to the first judgment unit, configured to allocate the timer to the corresponding first chain list head when the first judgment result indicates that the timing duration applied by the timer does not exceed the preset duration; The second allocation unit is connected to the first judgment unit, and is used to allocate the timer to the second linked list head when the first judgment result indicates that the timing duration applied by the timer exceeds the preset duration.
4. The timer system according to claim 3, characterized in that: The first allocation unit is used to allocate the timer to the nth first linked list head, where n satisfies the following conditions: Wherein, T1 represents the timing duration of the timer application; S1 represents the system timing time corresponding to the timer application; P represents the preset duration.
5. The timer system according to claim 1, characterized in that: The timing trigger module comprises: The first thread is used to send a message to the second thread every 1 second; The second thread is used to, after receiving the message, add one to the system timing time, use the accumulated system timing time as the current system timing time, and trigger the corresponding timer under the first linked list head according to the current system timing time.
6. The timer system according to claim 5, characterized in that: The second thread is also used to clear the system timing time when the system timing time reaches the preset duration, so as to enter the next polling and restart the timing.
7. The timer system according to claim 1, characterized in that: Also includes: The remaining timing duration configuration module is used to configure the second timer under the second chain list head before the system timing time enters the next polling to determine the remaining timing duration of the second timer.
8. The timer system according to claim 1, characterized in that: The remaining timing duration configuration module includes: A first configuration unit, configured to configure the remaining timing duration of the timer to T1+S1-P after the system timing time is cleared when the timer is first allocated to the second linked list head in the current polling; wherein T1 represents the timing duration applied by the timer; S1 represents the system timing time corresponding to the timer application; and P represents the preset duration; The second configuration unit is used to configure the remaining timing duration of the timer to T1-P after the system timing time is reset when the timer is not allocated to the second linked list head for the first time in the current poll.
9. The timer system according to claim 1, characterized in that: The reallocation module comprises: A second judgment unit is used to judge whether the remaining timing duration of the second timer under the second linked list header exceeds the preset duration before the system timing time enters the next polling, and obtain a second judgment result; A first processing unit, connected to the second judgment unit, configured to reallocate and store the second timer under a first linked list head matching the remaining timing duration when the second judgment result indicates that the remaining timing duration does not exceed the preset duration; The second processing unit is connected to the second judgment unit and is used for not performing any processing when the second judgment result indicates that the remaining timing duration exceeds the preset duration.
10. The timer system according to claim 1, characterized in that: The preset duration is 60 seconds.