The timer management device and the management method that are used for operating system
Technical field
The present invention relates to the operating system field, particularly be used for the timer management device and the management method of operating system.
Background technology
In computer utility, the user uses and supervisory computer hardware and software resource by operating system.For general operating system, mainly pursue system throughput and user's average response time, then there is not strict time restriction for response time of unique user.But for real time operating system, the time is a kind of important system resource, all must finish in the time that limits the response and the task executions of external event.Real time operating system output result's correctness not only depends on calculates formed logical consequence, also will depend on the resultant time.Therefore real time operating system must be finished specific task in time that limits and space, can lead to grave consequences if deviation appears in logic and sequential.Such as the embedded OS that is used to control rocket engine, the instruction that it sends not only requires speed fast, and the sequential between a plurality of engines is required also very strict, requirement for the real-time aspect may reach microsecond even nanosecond order, the delay of a certain instruction manipulation is carried out in its operational process, all will cause imponderable heavy losses.Operating system provides timer mechanism, can specify in following execution that triggers certain incident sometime.Therefore timer just seems most important as the core of real time operating system time management.
Most of embedded OSs all require very strong to real-time.Embedded real-time operating system is widely used in process of factory production control, car industry, office automation, computer peripheral equipment, communication facilities, robot, Aero-Space, fields such as civilian consumption.In network service, one time communication process needs a plurality of timers to finish different timing tasks, and when the number of users of communication simultaneously increased, the number of required timer sharply increased.If the management method efficient of timer aspect time and internal memory is low, then can prolong user's response time, and then influence the performance of total system because of the timer number causes Timing Processing consumption system resource excessive too greatly.Embedded OS itself has the memory source features of limited, has aggravated the dependence to timer management again, and therefore, the efficient of method for managing timer just is one of important indicator of reflection embedded real-time operating system performance.
Method for managing timer to various embedded OSs in the prior art is a lot, mainly contains following three types.
First kind: with uc/os embedded OS etc. is typical case's representative, and back off timer is to realize by the current timing value of scanning, each task of successively decreasing, so need continuous scan task chain in the interrupt service routine of hardware timer.When regularly task more for a long time, can influence the response of interrupt service routine to real-time task, become system real time can bottleneck.
Second kind: with Linux series operating system is typical case's representative, by the classification of multistage chained list realization to the different timer of time-out time, can share a timer chain meter from the timer that current point in time is far away in a time interval, can only be that identical timing point could be shared a timer chain meter from the nearer timer of current point in time.Linux adopts the method for hash index to avoid the inquiry repeatedly of timer chain meter, is particularly suitable for timer and uses more occasion.
The precision of timer of Linux series operating system is higher, as precision of timer in Linux2.4 is 10ms, in Linux2.6, further be improved to 1ms, but real-time is required very high application for some, can reach nanosecond as the response time requirement to real time business in the Aero-Space, the Millisecond timer of Linux still can not satisfy in the real-time embedded operating system high-precision requirement to real-time.
The third: with RTAI (Real-Time Application Interface) is typical case's representative, and RTAI improves on the Linux basis in real time.RTAI is with the mechanism of all and process scheduling time correlation, realize as timer, semaphore wait, transmission, the processing of receive time-out time etc., all focus on the process operation, scheduling for process is mainly dispatched between time-delay formation and ready queue, more can embody real-time, and, operate also convenient the scheduling time centralized management.
Provided in the RTAI system synoptic diagram with the relevant module of timer management in Fig. 1, these modules comprise process scheduling module, hardware clock module, process timer management module.Wherein, the process scheduling module is used for managing the ready queue and the waiting list of RTAI system, in resume operation time and all period interval of each dispatching point according to process, selects pending process.The module of process scheduling simultaneously also can dynamically update the next triggered time of hardware clock module according to the process temporal information in the RTAI system.The hardware clock module is used for triggering the execution of process scheduling module when its set triggered time arrives.Process timer management module is used for according to the process that the user is provided with resume operation time and all period interval, and this process dynamically is inserted into ready queue and waiting list under the RTAI.
Realize that by process the main flow process of timing mechanism is as follows in the RTAI system: at first, create the process that is associated with this timed task, the time of resuming operation and all period interval in the process are set for the timed task that the user sets; Then, process timer management module is inserted into this process in the waiting list according to the time of resuming operation and all period interval of process, waits for the regularly arrival in the moment.Then, the process scheduling module dynamically updates the next triggered time of hardware clock module according to ready queue and waiting list under the whole RTAI.At last, when regularly constantly arriving, the hardware clock module triggers the process scheduling module, and the process scheduling module is transferred to aforementioned process in the ready queue from waiting list, prepare to carry out user's timed task.
From top explanation as can be seen, in the RTAI system, need to create corresponding process, and each process all to be assigned with certain memory headroom for each timed task.For the application scenarios that needs to use a large amount of timers in the communication system, do to take a large amount of memory headrooms like this.Can cause the embedded OS of internal memory resource-constrained and to seriously influence.
Summary of the invention
The objective of the invention is to overcome existing RTAI system is that timed task distributes detached process can take a large amount of memory headrooms, the defective that system resource is impacted, thus a kind of timer management device is provided.
To achieve these goals, the invention provides a kind of timer management device that is used for operating system, comprise process scheduling module, hardware clock module, process timer management module, also comprise timer interface, timer data storehouse and timer management module; Wherein,
Described timer interface is used for providing to the user interface of operation timer;
Described timer data storehouse is used to preserve timer chain meter, and the bookkeeping to described timer chain meter is provided; Described timer chain meter is linked successively according to its triggered time by timer and forms, and a timer is represented a timed task, except comprising the described triggered time, also comprises the Interrupt Process function at least in the described timer;
Described timer management module is used to realize the initialization and the end operation in described hardware clock module, process timer management module and described timer data storehouse, also is used for calling the Interrupt Process function that described timer comprises.
In the technique scheme, described timer chain meter comprises Active Timer chained list and pause timer chained list; Described Active Timer chained list is used to arrange and is using and waiting for the timer of trigger carrying out, and described pause timer chained list is used to arrange and has triggered the timer of carrying out or the timer that is cancelled non-periodic.
In the technique scheme, the operation that described timer interface provides to the user comprises the establishment timer, timer time is set, obtains timer time, obtains timer Interrupt Process function parameters, cancels timer, deletes timer.
In the technique scheme, comprise also in the described timer that timer triggers input parameter, timer service marking and the front and back pointer of cycle, timer Interrupt Process function.
The present invention also provides a kind of and has adopted the described timer management device that is used for operating system to realize the method for timer management, comprising:
Step 1), be that timed task is created timer by the timer interface;
Step 2), described process timer management module dynamically updates the next triggered time of hardware clock module according to current process implementation status, when next time, the triggered time arrived, trigger described timer Interrupt Process process by described hardware clock module, from described Active Timer chained list, take out timer by timer Interrupt Process process successively, carry out corresponding timed task;
Step 3), after timer Interrupt Process process executes timed task, upgrade described timer chain meter.
In the technique scheme, described step 1) comprises:
Step 1-1), judge that whether the timer that will create is first timer in the system, if, carry out next step, otherwise, direct execution in step 1-5);
Step 1-2), utilize the trigger mode of described hardware clock module hardware clock to be set to the oneshot pattern, and start hardware clock;
Step 1-3), Active Timer chained list and the pause timer chained list in the described timer data of the initialization storehouse;
Step 1-4), utilize described process timer management module creation timer Interrupt Process process, the time of resuming operation in this process and all period interval be set to the triggered time and the periodic quantity of the timer that will create respectively, then this timer Interrupt Process process be inserted in the process waiting list of described process scheduling module;
Step 1-5), for the timer that will create triggered time, triggering cycle and Interrupt Process function are set according to timed task;
Step 1-6), the timer created was inserted in the Active Timer chained list in the described timer data storehouse according to the triggered time of timer;
Step 1-7), judge whether the new timer of creating is positioned at the gauge outfit of Active Timer chained list, if carry out next step, otherwise end step 1) operation;
Step 1-8), the time of resuming operation in the timer Interrupt Process process and all period interval are set to the triggered time and the periodic quantity of the new timer of creating, end step 1 respectively) operation.
In the technique scheme, in described step 2) in, from described Active Timer chained list, take out timer by timer Interrupt Process process successively, carry out corresponding timed task and comprise:
Step 2-1), from the Active Timer chained list, take out expired timer recently;
Step 2-2), judge that whether the Active Timer chained list is empty, if empty, execution in step 2-11), otherwise, execution in step 2-3);
Step 2-3), judge whether the time that sets in the timer taken out arrived, if, execution in step 2-4), otherwise, execution in step 2-10);
Step 2-4), carry out the Interrupt Process function in institute's taking-up timer, the timer that deletion has been performed from the Active Timer chained list then;
Step 2-5), judge whether the timer be performed has periodically, if, execution in step 2-6), otherwise, execution in step 2-7);
Step 2-6), upgrade the triggered time of the timer that has been performed;
Step 2-7), after the timer that will upgrade is inserted into relevant position in the described Active Timer chained list according to the triggered time, end step 2) operation;
Step 2-8), the execution mark of the timer that will be performed is made as the state that has been performed;
Step 2-9), the timer that will be performed is inserted in the pause timer chained list end step 2) operation;
Step 2-10), the triggering of the timer that taken out is set to time of resuming operation in the timer Interrupt Process process, execution in step 2-12 then constantly);
Step 2-11), the RTAI process waits for that the maximal value of working time is set to resuming operation the time of timer Interrupt Process process, execution in step 2-12 then);
Step 2-12), timer Interrupt Process process is moved on to from ready queue in the time-delay formation;
Step 2-13), trigger the process scheduling module, the next pending process of selection from ready process queue.
In the technique scheme, in described step 3), described renewal timer chain meter comprises:
When the pairing timer of described timed task is periodic timer, this timer is inserted in the described Active Timer chained list again, and resume operation the time next time of renewal timer Interrupt Process process; When this timer is not periodic timer, this timer is inserted in the described pause timer chained list.
In the technique scheme, also comprise the step 4) of revising the timer triggered time or the cycle of triggering, this step comprises:
Step 4-1), judge whether the timer that will revise uses, if this timer uses, then needs this timer is deleted from the Active Timer chained list, otherwise needs be deleted this timer from the pause timer chained list;
Step 4-2), reset triggered time or triggering cycle for this timer;
Step 4-3), the usage flag with timer is re-set as the status indication that triggering is waited in representative;
Step 4-4), amended timer is inserted into relevant position in the Active Timer chained list according to trigger time value;
Step 4-5), judge whether amended timer is nearest expired timer, if words, then with trigger time value the resuming operation the time of this timer as timer Interrupt Process process, if not, otherwise need not to upgrade resuming operation the time of timer Interrupt Process process.
In the technique scheme, also comprise the step 5) of cancelling timer, this step comprises:
Step 5-1), judge whether the timer that will cancel uses, if, end operation, otherwise carry out next step;
Step 5-2), judge whether the timer that will cancel is nearest expired timer in the Active Timer chained list, if carry out next step, otherwise execution in step 5-6);
Step 5-3), judge in the Active Timer chained list at the timer place that will cancel whether also have next timer, if present, carry out next step, otherwise execution in step 5-5);
Step 5-4), the time of resuming operation of timer Interrupt Process process is set to the trigger time value of the next timer in the Active Timer chained list, execution in step 5-6 then);
Step 5-5), the time of resuming operation of timer Interrupt Process process is set to RTAI process maximum latency, execution in step 5-6 then);
Step 5-6), the timer that deletion will be cancelled from the Active Timer chained list;
Step 5-7), the usage flag of the timer that will cancel is set to represent the current status indication that is in the pause timer chained list of timer;
Step 5-8), the timer that will cancel is inserted in the pause timer chained list.
In the technique scheme, also comprise the step 6) of deleting timer, this step comprises:
Step 6-1), judge whether the timer that will delete uses, if carry out next step, otherwise execution in step 6-7);
Step 6-2), judge whether the timer that will delete is nearest expired timer in the Active Timer chained list, if, execution in step 6-3), otherwise execution in step 6-6);
Step 6-3), judge whether the timer that will delete also exists next timer in the Active Timer chained list, if present, execution in step 6-4), otherwise execution in step 6-5);
Step 6-4), the time of resuming operation of timer Interrupt Process process is set to the trigger time value of the next timer in the Active Timer chained list, execution in step 6-6 then);
Step 6-5), the time of resuming operation of timer Interrupt Process process is set to RTAI process maximum latency, execution in step 6-6 then);
Step 6-6), from the Active Timer chained list, delete the timer that to delete, execution in step 6-8 then);
Step 6-7), from the pause timer chained list, delete the timer that to delete, execution in step 6-8 then).
Step 6-8), judge whether the timer number in Active Timer chained list and the pause timer chained list all is 0, if, carry out next step, otherwise, end operation;
Step 6-9), stop timer, release timer chained list, stop timing Interrupt Process process, end operation then.
The invention has the advantages that:
Timer management device of the present invention has high precision and the little advantage of internal memory use amount.
Description of drawings
Fig. 1 be in the existing RTAI system with the structural representation of the relevant module of timer management;
Fig. 2 is the structural representation of timer management device of the present invention;
Fig. 3 is the process flow diagram that timer management device of the present invention is created the timer process;
Fig. 4 is the process flow diagram that timer management device of the present invention is revised timer trigger time value and/or triggering periodic process;
Fig. 5 is the process flow diagram of timer management device cancellation timer process of the present invention;
Fig. 6 is the process flow diagram of timer management device deletion timer process of the present invention;
Fig. 7 is the process flow diagram that timer management device of the present invention realizes the Interrupt Process process;
Fig. 8 is the timer state transition graph.
Embodiment
Below in conjunction with the drawings and specific embodiments the present invention is illustrated.
Provided the synoptic diagram of timer management device of the present invention among Fig. 2, relevant module is identical with timer management in the left-half of Fig. 2 and the existing RTAI system, the process scheduling module, hardware clock module and the process timer management module that comprise in the background technology being mentioned, the function of these modules does not compared with prior art change.And at the right half part of Fig. 2, the timer module in the timer management device is described, described timer module comprises three submodules, they are respectively timer interface (API), timer data storehouse and timer management module.Function to the submodule in the timer module is illustrated respectively below.
The timer interface is used for providing to the user interface of operation timer, the operation of timer is comprised create timer, timer time is set, obtains timer time, obtains timer Interrupt Process function parameters, cancellation timer, deletion timer etc.
The timer data storehouse is used to preserve timer chain meter, and the bookkeeping to timer chain meter is provided.These bookkeepings comprise the user by described timer interface create timer, insert timer, delete timer, when searching operation such as timer, to the renewal operation of timer chain meter.Timer chain meter comprises two classes, and a class is the Active Timer chained list, and another kind of is the pause timer chained list.Described Active Timer chained list is used to arrange and is using and waiting for the timer of trigger carrying out, and described pause timer chained list then is used to arrange and triggers the timer of carrying out non-periodic, or the timer of cancelling.Timer in the pause timer chained list can be transferred in the Active Timer chained list again by reseting timing.
Active Timer chained list and pause timer linked list data structure are basic identical, they are all formed by a plurality of timer links, each timer is shown in following table 1, comprise the timer triggered time, the triggering cycle, timer Interrupt Process function (the Interrupt Process function also can be called as the triggering function) and input parameter, timer service marking and sensing be front and back timer pointer in Active Timer chained list or pause timer chained list.
The timer data item |
Describe |
??RTIME?expires |
The timer triggered time (is unit with tick) |
??RTIME?interval |
Timer triggers the cycle (is unit with tick) |
??TIMERFUNC?func |
Timer Interrupt Process function |
??INT32?arg |
The input parameter of timer Interrupt Process function |
??INT32?used |
The timer service marking |
??NodeType?ln; |
Ln timer chain meter node structure, pointer before and after comprising |
Table 1
The process relevant with timed task in the RTAI described corresponding timed task with the timer in the timer chain meter among the present invention, adopts timer chain meter to realize that the great advantage of timer mechanism is to save the occupancy of timer to internal memory.As shown in Table 1, each timer only need take tens bytes in internal memory, and each process then needs to take the internal memory of a few K bytes at least.This can greatly save the internal memory use amount for needs use the less embedded system of the communication system of a large amount of timers and amount of ram.
The timer management module is used to realize the initialization and the end operation of timer module, also is used to call timer Interrupt Process function.The initialization of timer module comprises that the hardware clock trigger mode in the hardware clock module is set to oneshot to start hardware timer, initialization timing device chained list, to create timer Interrupt Process process.The end operation of timer module comprises hardware timer, release timer chained list, the stop timing device Interrupt Process process etc. of stopping.Though the timer Interrupt Process function that arrives mentioned herein is similar to timer Interrupt Process process title, but two diverse notions of implication.Timer Interrupt Process function is meant will carrying out of task when the time that timer sets arrives, therefore be also referred to as the triggering function, can be provided with flexibly when using timer by the user.Just be used for representing timer Interrupt Process function in the aforesaid TIMERFUNC func sign that is used for describing the table 1 of timer.Timer Interrupt Process process then is a real-time process of creating when the timer management module starts, and when the time that certain timer sets arrives, is removed to call the Interrupt Process function of corresponding timer by this process.In brief, in the present invention, timer Interrupt Process process has only one, and timer Interrupt Process function can have much the use of timer along with the user, and all timer Interrupt Process functions all are to carry out by a unique timer Interrupt Process process.
More than be explanation, how the present invention realized that the process of timer management is illustrated below in conjunction with timer management device of the present invention to the effect of each submodule in the timer module.
In step 10, the user creates timer by timer interface API.When creating timer, first timer that whether belongs in the system according to the timer of being created has different operations.
With reference to figure 3, when the timer of being created belongs to first timer in the system, need do initialization operation by the timer management module, described initialization operation may further comprise the steps: utilize the trigger mode of described hardware clock module hardware clock to be set to the oneshot pattern, and start hardware clock (step 11).Active Timer chained list in the described timer data of the initialization storehouse and pause timer chained list (step 12).Utilize described process timer management module creation timer Interrupt Process process, the time of resuming operation in this process and all period interval be set to the triggered time and the periodic quantity of the timer that will create respectively, then this timer Interrupt Process process be inserted into (step 13) in the process waiting list of RTAI system.
After finishing above-mentioned initialization operation, then to finish the operation relevant with timer creation itself.Whether the timer that no matter will create belongs to first timer in the system, and the operation of this part there is no difference, therefore is illustrated in the lump.For the timer that will create is provided with triggered time, triggering cycle and triggers function (step 14).Then the timer created is inserted (step 15) in the Active Timer chained list in the timer data storehouse according to the triggered time of timer, (promptly the triggered time of the timer of new establishment is nearest if the new timer of creating is positioned at the gauge outfit of Active Timer chained list, just expired recently) (step 16), then also need the time of resuming operation in the timer Interrupt Process process and all period interval are set to the newly triggered time and the periodic quantity (step 17) of the timer of establishment respectively, otherwise, directly finish to create the operation of timer.
In step 20, process timer management module among the RTAI dynamically updates the next triggered time of hardware clock module according to current process implementation status, when next time, the triggered time arrived, trigger process timer management module by the hardware clock module, and then triggering timer Interrupt Process process, from the Active Timer chained list, take out timer successively by timer Interrupt Process process, carry out corresponding timed task.
In step 30, after timer Interrupt Process process executes timed task, if this timer is the timer of recurrent event, then this timer is inserted in the Active Timer chained list again, and resume operation the time next time of renewal timer Interrupt Process process; If this timer is not the timer of recurrent event, then this timer is inserted in the pause timer chained list.
In above-mentioned step 20, the process how timer Interrupt Process process realizes Interrupt Process has simply been described, below in conjunction with Fig. 7, this process is elaborated.
Step 60, from the Active Timer chained list, take out the timer be positioned at gauge outfit (promptly expired recently).
After step 61, judgement were taken out and be positioned at the timer of gauge outfit, whether described Active Timer chained list was empty, if empty, execution in step 610, otherwise, execution in step 62.
Whether the time that sets in the timer that step 62, judgement are taken out has arrived, if, execution in step 63, otherwise, execution in step 69.
Triggering function in step 63, the execution institute taking-up timer, the timer that deletion has been performed from the Active Timer chained list then.
Whether the timer that step 64, judgement have been performed has periodically, if, execution in step 65, otherwise, execution in step 66.
Step 65, the triggering moment of upgrading the timer that has been performed.
Step 66, the timer that will upgrade be according to after triggering the relevant position that constantly is inserted in the Active Timer chained list, end operation.
The execution mark of step 67, the timer that will be performed is made as and is performed.
Step 68, the timer that will be performed are inserted in the pause timer chained list, end operation.
Step 69, the triggering of the timer that taken out is set to time of resuming operation in the timer Interrupt Process process constantly, execution in step 611 then.
Do not had timer in step 610, the current Active Timer chained list, therefore the RTAI process waits for that the maximal value of working time is set to resuming operation the time of timer Interrupt Process process, and execution in step 611 then.
Step 611, with timer Interrupt Process process from ready queue, move on to the time-delay formation in.
Step 612, triggering process scheduling module are selected next pending process from ready process queue.
In the timer implementation, except establishment timer noted earlier, execution timer operation, also include operations such as revising timer trigger time value, cancellation timer, deletion timer.These operations are triggered according to user's needs, and the realization to these operations is illustrated below.
As shown in Figure 4, the modification timer trigger time value and/or the operation in the cycle of triggering comprise:
Whether the timer that step 31, judgement will be revised uses;
If this timer of step 38 uses, then need this timer is deleted from the Active Timer chained list;
If this timer of step 32 is not used, then need this timer is deleted from the pause timer chained list.
Step 33, reset trigger time value and/or trigger periodic quantity for this timer.
Step 34, the usage flag of timer is re-set as representative waits for the status indication that triggers.
Step 35, amended timer is inserted into relevant position in the Active Timer chained list according to trigger time value.
Step 36, judge whether amended timer is nearest expired timer (being the gauge outfit whether amended timer is positioned at the Active Timer chained list).
Step 37 if words, upgrade resuming operation the time of timer Interrupt Process process, the trigger time value that is about to this timer is resumed operation the time as timer Interrupt Process process, if not, then need not to upgrade resuming operation the time of timer Interrupt Process process.
As shown in Figure 5, the operation of cancellation timer comprises:
Whether the timer that step 41, judgement will be cancelled uses, if, end operation, otherwise carry out next step.
Whether the timer that step 42, judgement will be cancelled is the timer that is positioned at gauge outfit in the Active Timer chained list, if, carry out next step, otherwise execution in step 45.
Whether also there is next timer in the Active Timer chained list at the timer place that step 43, judgement will be cancelled, if present, carries out next step, otherwise execution in step 48.
The time of resuming operation of step 44, timer Interrupt Process process is set to the trigger time value of the next timer in the Active Timer chained list, and execution in step 45 then.
The time of resuming operation of step 48, timer Interrupt Process process is set to RTAI process maximum latency, and execution in step 45 then.
Step 45, the timer that deletion will be cancelled from the Active Timer chained list.
The usage flag of step 46, this timer is set to represent the current status indication that is in the pause timer chained list of timer.
Step 47, this timer is inserted in the pause timer chained list.
As shown in Figure 6, the operation of deletion timer comprises:
Whether the timer that step 51, judgement will be deleted uses, if, carry out next step, otherwise execution in step 59.
Whether the timer that step 52, judgement will be deleted is the timer that is positioned at gauge outfit in the Active Timer chained list, if, execution in step 57, otherwise execution in step 54.
Whether the timer that step 57, judgement will be deleted also exists next timer in the Active Timer chained list, if present, and execution in step 53, otherwise execution in step 58.
The time of resuming operation of step 53 timer Interrupt Process process is set to the trigger time value of the next timer in the Active Timer chained list, and execution in step 54 then.
The time of resuming operation of step 58, timer Interrupt Process process is set to RTAI process maximum latency, and execution in step 54 then.
Step 54, the timer that deletion will be deleted from the Active Timer chained list, execution in step 55 then.
Step 59, the timer that deletion will be deleted from the pause timer chained list, execution in step 55 then.
Step 55, judge whether the timer number in Active Timer chained list and the pause timer chained list all is 0, if, execution in step 56, otherwise, end operation.
Step 56, stop timer, release timer chained list, stop timing Interrupt Process process, end operation then.
In Fig. 8, timer has been done unified explanation how switching under the aforesaid operations between Active Timer chained list and pause timer chained list.As can be seen from the figure, when creating timer, the new timer of creating will trigger moment order according to it and insert in the Active Timer chained list.When timer triggers when constantly arriving, execute after timer triggers function, for cycle timer, will insert again in the Active Timer chained list by its triggering cycle, for timer non-periodic, then be inserted in the pause timer chained list.When resetting that timer triggers constantly or during the cycle of triggering, no matter current which timer chain meter that is in of this timer all inserts it in Active Timer chained list again.When the cancellation timer, this timer is inserted in the pause timer chained list.When deletion during timer, then current which timer chain meter that is in of this timer no matter is all deleted it from current timer chain meter.
Than Linux series operating system is the precision of timer of unit with the millisecond, and timer management device of the present invention can provide the timing accuracy of nanosecond for real time business by adopting the hardware clock timing and utilizing the high priority that clock interrupts among the RTAI.Use according to reality simultaneously and use the timer scale in the scene, select the timer chain meter structure flexibly, realize that the running time complexity that timer dynamically inserts in the delete procedure is optimized for O (logn) by O (n).
In addition, when the real-time that makes full use of RTAI realizes high-resolution timer, at the big deficiency of former RTAI timing mechanism committed memory, the present invention has reduced the internal memory use amount of timer greatly by realize the independent timer management mechanism of a cover in RTAI.
It should be noted last that above embodiment is only unrestricted in order to technical scheme of the present invention to be described.Although the present invention is had been described in detail with reference to embodiment, those of ordinary skill in the art is to be understood that, technical scheme of the present invention is made amendment or is equal to replacement, do not break away from the spirit and scope of technical solution of the present invention, it all should be encompassed in the middle of the claim scope of the present invention.