CN1870767A - Method for managing timer task - Google Patents

Method for managing timer task Download PDF

Info

Publication number
CN1870767A
CN1870767A CN 200510130535 CN200510130535A CN1870767A CN 1870767 A CN1870767 A CN 1870767A CN 200510130535 CN200510130535 CN 200510130535 CN 200510130535 A CN200510130535 A CN 200510130535A CN 1870767 A CN1870767 A CN 1870767A
Authority
CN
China
Prior art keywords
timer
task
formation
fixed cycle
queue
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN 200510130535
Other languages
Chinese (zh)
Inventor
张民卫
伽亚吉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN 200510130535 priority Critical patent/CN1870767A/en
Publication of CN1870767A publication Critical patent/CN1870767A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

This invention provides a method for managing timer task including: creating at least a timer task queue of a fixed period, the attribute of the queue includes a specific triggfer period, the timer task in the system is put in said fixed period timer task queue same to the trigger period to be managed, which can reduce single time plug or delete the time for operating the timer task to increase its management efficiency.

Description

The method that task of timer is managed
Technical field
The present invention relates to communication field, relate in particular to a kind of method that Timer (timer) task is managed.
Background technology
Need the system of Timer task on a large scale at some, such as, among the iSAP server (IntegratedService Application Platform server, a carrier-class use in conjunction/service platform), need to create a large amount of Timer tasks, be used for carrying out Timing Processing.Said system realizes often having following two characteristics for Timer:
1, needs to support a large amount of Timer tasks.With SIP (Session InitiatedProtocol, initial session protocol) is applied as example, each calls out the Timer task that approximately needs more than 10, therefore, the quantity of the Timer task that whole system need be supported is often above 10000, even more, under the situation of top load, need to support to surpass 20000 Timer task.
2, Jue Daduoshuo Timer task will trigger in a short period of time.In typical SIP used, the Timer task triggering cycle above 50% was 500 milliseconds.Simultaneously, Jue Daduoshuo Timer task has the fixing triggering cycle.For example, with 500 milliseconds be the Timer task in cycle account for sum greatly about 60%, 1 second being that the Timer task in cycle accounts for 20% of sum greatly, with 2 seconds be the cycle account for 5% of sum greatly, with 4 seconds be the cycle account for 1% of sum greatly.
A kind of method that the Timer task is managed is in the prior art: based on the Timer task management method of balance heap.The structural representation of balance heap can be referring to Fig. 1.This method is used a task queue in whole system, formation adopts the balance heap to sort according to triggered time of task, has very high ordering efficient, is log at the ordering complexity of each insertion and deletion Timer task operating 2N (N represent to pile in the total quantity of Timer task).Element queue[n in the heap] two children be respectively queue[2*n] and queue[2*n+1].Task minimum in the heap is queue[1]. for each the element node n in the heap, we suppose that its child is d, and the triggered time of node n necessarily is less than or equal to the triggered time of child d so.When a new task was inserted in this heap, heap was reset balanced tree automatically and is guaranteed that this task is placed on the correct position.When a task was deleted, balanced tree was reset remaining task.
The shortcoming of the above-mentioned method that the Timer task is managed is: because whole system is used a Timer task queue, the triggering cycle of each Timer task is inequality, need be to the Timer task ranking, and ordering needs the regular hour cost.Along with increasing Timer task is inserted into, the length of formation can be more and more longer.Therefore, the also corresponding prolongation of time that single inserts or deletion Timer task operating needs will cause the continuous decline of systematic function.
Summary of the invention
The purpose of this invention is to provide a kind of method that the Timer task is managed, thereby can reduce the time that single inserts or deletion Timer task operating needs, improve the efficiency of management of Timer task.
The objective of the invention is to be achieved through the following technical solutions:
A kind of method that task of timer is managed comprises step:
A, at least one fixed cycle task of timer formation of establishment in system, the attribute of described fixed cycle task of timer formation comprises a certain trigger cycle;
B, the task of timer in the system is put into the described fixed cycle task of timer formation identical with its triggering cycle, this task of timer is managed.
Described steps A specifically comprises:
The triggering cycle of the fixed cycle task of timer formation that needs are created is configured in the configuration file of system, when system start-up, according to the triggering cycle information that disposes in this configuration file, creates corresponding fixed cycle task of timer formation.
Task of timer in the described fixed cycle task of timer formation carries out ascending order according to its triggered time and arranges.
Described step B specifically comprises:
The task of timer of creating in the system is inserted into the described fixed cycle task of timer rear of queue identical with its triggering cycle, and task of timer is managed.
Described task of timer is managed specifically comprises:
When the triggered time of the task of timer of the head of the queue of described fixed cycle task of timer formation arrives, carry out this task of timer, then, with of the head of the queue deletion of this task of timer from this fixed cycle task of timer formation.
Described task of timer is managed also comprises:
When the task of timer in the described fixed cycle task of timer formation is cancelled, this task of timer is deleted from described fixed cycle task of timer formation.
Described fixed cycle task of timer formation adopts doubly linked list to realize.
Also comprise step:
C, establishment general timer task queue in system;
D, will put into described general timer task queue less than the task of timer identical and manage with the triggering cycle of described fixed cycle timer queue.
Described general timer task queue adopts the balance heap to realize.
Described system is: based on the telecommunications application system of initial session protocol SIP.
As seen from the above technical solution provided by the invention, the present invention manages corresponding task of timer by create the fixed cycle timer queue in system, owing to the triggering cycle of all task of timer in the fixed cycle timer queue is identical, do not need the task of timer in the formation is carried out complicated sorting operation, simplify the operating process of inserting or deleting task of timer greatly, improved the efficiency of management of task of timer.
Manage by task of timer being put in the corresponding fixed cycle timer queue in addition, can reduce the length of general timer task queue, improved the efficiency of management of general timer task queue.
In the present invention, can also be according to the triggering cycle characteristics of the task of timer of system, in system, reasonably create fixed cycle timer queue and a general timer task queue of some simultaneously, thereby greatly improved the efficiency of management of task of timer with certain trigger cycle, and significantly reduced the length of general timer task queue, the reduction system is subjected to the total load effect, for whole system provides preferable performance.
Description of drawings
Fig. 1 is the balance pile structure schematic diagram of prior art;
Fig. 2 is the process chart of the embodiment 1 of the method for the invention;
Fig. 3 is the structural representation based on the fixed cycle task of timer formation of doubly linked list;
Fig. 4 is three kinds of basic operation schematic diagrames based on the fixed cycle task of timer formation of doubly linked list;
Fig. 5 is the process chart of the embodiment 2 of the method for the invention.
Embodiment
The invention provides a kind of method that the Timer task is managed, core of the present invention is: create one or more fixed cycle task of timer formations in system, utilize this fixed cycle task of timer formation that the task of timer that has the certain trigger cycle in the system is managed.
Describe the present invention in detail below in conjunction with accompanying drawing.
The handling process of the embodiment 1 of the method for the invention comprises the steps: as shown in Figure 2
Step 2-1, at least one fixed cycle task of timer formation of establishment in system.
The Timer task is triggered by the Timer thread, introduces the effect of Timer thread below earlier.
The realization of Timer task is based on the Timer task queue.System is that each Timer task queue distributes a Timer thread, and this thread is responsible for dispatching the task in the Timer task queue.If the Timer thread finds in the formation Timer task is arranged, so, it is just taken out the nearest Timer task that needs to trigger, and does following inspection then:
If the triggered time of 1 Timer task is to be less than or equal to the current time, then trigger this Timer task at once.
If the triggered time of 2 Timer tasks is greater than the current time, after then this thread will be waited for corresponding time difference value (triggered time-current time), trigger this Timer task again.
In the time of waiting for, if there is new Timer task to be inserted into, the Timer thread can obtain notice, so, the Timer thread can be waken up, and takes out nearest Timer task of triggered time again in formation, continues to wait for or trigger (depending on the triggered time of this Timer).Why will retrieve the Timer task, be because the Timer task that just has been inserted into may have the littler triggering cycle.Certainly, Timer thread based on fixed cycle task of timer formation can not need to carry out this operation, because the Timer task triggered time of the new fixed cycle task of timer formation of creating is later than original Timer task certainly, unless do not have the Timer task in the original formation.
The present invention at first classifies to the Timer task in the system based on the triggering cycle of Timer task.By the Timer task in the system is classified,, just this triggering cycle is configured to the fixed cycle in case a large amount of Timer tasks with identical triggering cycle is arranged in the discovery system.
Then, in system, create the cycle timer task queue of described fixed cycle correspondence, and distribute to thread of this cycle timer task queue, in system, can create a plurality of fixed cycle task of timer formations.For example, can create two fixed cycle task of timer formations in the system, triggering cycle is 500 milliseconds, and triggering cycle is 1 second.
In actual applications, also the triggering cycle of fixed cycle task of timer formation can be configured in xml (extend markup language) configuration file of system, when system start-up, corresponding fixed cycle task of timer formation just can be created according to the triggering cycle information of the configuration in the xml configuration file by system.
Task of timer in the fixed cycle task of timer formation carries out ascending order according to its triggered time to be arranged, and the task in the formation obtains ordering automatically according to its triggered time.Fixed cycle task of timer formation can realize that its structural representation can be referring to Fig. 3 by a doubly linked list.
Step 2-2, task of timer is put into the fixed cycle task of timer formation identical with its triggering cycle manage.
In this example, when a Timer task was created in the system, the Timer Facility in the system (timer equipment) determined at first according to the triggering cycle of this task which formation is this Timer task should put into.If system be this task the triggering period allocated corresponding fixed cycle task of timer formation, then this Timer task is inserted in the corresponding fixed cycle task of timer formation.
Fixed cycle task of timer formation is a FIFO (First in, first out, first in first out) formation, can realize by a doubly linked list, because the operating time of doubly linked list is a constant, irrelevant with the length of formation, this has guaranteed that system can support more load.As shown in Figure 4, the fixed cycle task of timer formation based on doubly linked list has three kinds of basic operations:
1, insert: the Timer task in the fixed cycle task of timer formation all has the identical triggering cycle, and is to insert with the order of creating.Therefore, when needs insert the fixed cycle Timer task of a new establishment, because its triggered time is late than previous insertion necessarily, so, directly this Timer task being inserted tail of the queue gets final product, do not need to remake any ordering work, whole formation remains arranges according to the triggered time ascending order.
2, deletion: when a Timer task is cancelled, directly this Timer task is deleted from formation and get final product.The same with above-mentioned insertion operation, deletion action does not need to remake any ordering work yet.
3, trigger:, just mean that this Timer task need be triggered in case the Timer thread waits of a Timer task is finished.This Timer thread will obtain a thread and come this Timer task of asynchronous execution from thread pool.Then, directly from head of the queue this task is deleted, the Timer thread obtains next Timer task again from the Timer formation.
The triggering cycle for the Timer task in the system is not a lot of situation, by creating limited corresponding fixed cycle timer queue, can finish the management of Timer task very efficiently.
The handling process of the embodiment 2 of the method for the invention comprises the steps: as shown in Figure 5
Step 5-1, in system, create fixed cycle task of timer formation and general timer task queue simultaneously.
This embodiment is applicable in the system except the Timer task in the certain trigger cycle with some also have the situation of the bigger Timer task of a large amount of triggering cycle excursions.Such as the system that uses based on the telecommunications of SIP that needs the Timer task on a large scale.
In the present embodiment, in system except will creating several embodiment 1 described fixed cycle timer queues, also to create a general timer task queue, be used to manage the not all task of timer identical with the triggering cycle of fixed cycle timer queue.
The general timer task queue is used balance to pile and is realized, sorts according to the triggered time of task, determines element in the formation according to digital coordinates.Element queue[n in the general timer task queue] two children be respectively queue[2*n] and queue[2*n+1], task minimum in the heap is queue[1], for each the element node n in the heap, we suppose that its child is d, and the triggered time of node n necessarily is less than or equal to the triggered time of child d so.
The general timer task queue can also adopt other method to realize, as realizing with the double-purpose chained list, the Timer task in the chained list is directly sorted by the triggered time.
Step 5-2, task of timer is put into fixed cycle task of timer formation respectively and the general timer task queue manages.
When a Timer task is created in the system, if the triggering cycle of this Timer task has been configured to fixed cycle task of timer formation, then this Timer task is inserted in the corresponding fixed cycle task of timer formation, this Timer task is managed according to embodiment 1 described management method; Otherwise, this Timer task is inserted in the general timer task queue, in the general timer task queue, this Timer task is managed.
General timer task queue for using the balance heap to realize also has insertion, deletion and three kinds of operations of triggering.When a new Timer task was inserted in this heap, heap was reset balanced tree automatically and is guaranteed that this task is placed on the correct position.After a Timer task is triggered, need this Timer task deletion.When a Timer task was deleted, balanced tree was reset remaining Timer task, to satisfy the requirement of general timer task queue.
In this embodiment,, be put in the fixed cycle task of timer formation, reduced the length of general timer task queue greatly owing to there is a large amount of Timer tasks from the general timer task queue, to separate with certain trigger cycle.Therefore, the insert or delete operation of general timer task queue also because formation shortens and correspondingly accelerates, has significantly reduced the ordering pressure of general timer task queue.Particularly to the system of the Timer task that has a large amount of same period, this advantage is very obvious.Thereby for whole system provides good performance.
Such as, adopt the described method of this embodiment, by in iSAP Server, creating 500 milliseconds, 1 second, 2 seconds, 4 seconds the fixed cycle timer queue and the general timer task queue of employing balance heap realization respectively, under very high load, iSAP server can support to surpass 20000 Timer task.
The above; only for the preferable embodiment of the present invention, but protection scope of the present invention is not limited thereto, and anyly is familiar with those skilled in the art in the technical scope that the present invention discloses; the variation that can expect easily or replacement all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection range of claim.

Claims (10)

1, a kind of method that task of timer is managed is characterized in that, comprises step:
A, at least one fixed cycle task of timer formation of establishment in system, the attribute of described fixed cycle task of timer formation comprises a certain trigger cycle;
B, the task of timer in the system is put into the described fixed cycle task of timer formation identical with its triggering cycle manage.
2, method according to claim 1 is characterized in that, described steps A specifically comprises:
The triggering cycle of the fixed cycle task of timer formation that needs are created is configured in the configuration file of system, when system start-up, according to the triggering cycle information that disposes in this configuration file, creates corresponding fixed cycle task of timer formation.
3, method according to claim 1 is characterized in that, the task of timer in the described fixed cycle task of timer formation carries out ascending order according to its triggered time and arranges.
4, method according to claim 1 is characterized in that, described step B specifically comprises:
The task of timer of creating in the system is inserted into the described fixed cycle task of timer rear of queue identical with its triggering cycle, and task of timer is managed.
5, method according to claim 4 is characterized in that, described task of timer is managed specifically comprises:
When the triggered time of the task of timer of the head of the queue of described fixed cycle task of timer formation arrives, carry out this task of timer, then, with of the head of the queue deletion of this task of timer from this fixed cycle task of timer formation.
6, method according to claim 5 is characterized in that, described task of timer is managed also comprises:
When the task of timer in the described fixed cycle task of timer formation is cancelled, this task of timer is deleted from described fixed cycle task of timer formation.
7, method according to claim 1 is characterized in that, described fixed cycle task of timer formation adopts doubly linked list to realize.
8, according to each described method of claim 1 to 7, it is characterized in that, also comprise step:
C, establishment general timer task queue in system;
D, will put into described general timer task queue less than the task of timer identical and manage with the triggering cycle of described fixed cycle timer queue.
9, method according to claim 8 is characterized in that, described general timer task queue adopts the balance heap to realize.
10, method according to claim 8 is characterized in that, described system is: based on the telecommunications application system of initial session protocol SIP.
CN 200510130535 2005-12-14 2005-12-14 Method for managing timer task Pending CN1870767A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 200510130535 CN1870767A (en) 2005-12-14 2005-12-14 Method for managing timer task

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 200510130535 CN1870767A (en) 2005-12-14 2005-12-14 Method for managing timer task

Publications (1)

Publication Number Publication Date
CN1870767A true CN1870767A (en) 2006-11-29

Family

ID=37444303

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 200510130535 Pending CN1870767A (en) 2005-12-14 2005-12-14 Method for managing timer task

Country Status (1)

Country Link
CN (1) CN1870767A (en)

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2012065537A1 (en) * 2010-11-19 2012-05-24 华为终端有限公司 Method and device of data interaction
CN102761541A (en) * 2012-05-31 2012-10-31 汉柏科技有限公司 Timer processing method and system
CN103236937A (en) * 2013-03-01 2013-08-07 上海卫星工程研究所 Functional redundancy design method for satellite carrying system default scheduled operations
CN103324469A (en) * 2012-03-21 2013-09-25 腾讯科技(深圳)有限公司 Timer implementation method and device
CN103368761A (en) * 2012-04-01 2013-10-23 腾讯科技(深圳)有限公司 Method and device for processing timing services
CN103902586A (en) * 2012-12-27 2014-07-02 腾讯科技(深圳)有限公司 Method and device for processing webpage multimedia information tasks
CN103942104A (en) * 2014-04-23 2014-07-23 北京金山网络科技有限公司 Task managing method and device
CN104731651A (en) * 2013-12-20 2015-06-24 南京南瑞继保电气有限公司 Power automation task scheduling and triggering method, system and processor
CN106844043A (en) * 2016-12-29 2017-06-13 北京五八信息技术有限公司 The treating method and apparatus of cluster task
CN107391271A (en) * 2017-05-17 2017-11-24 阿里巴巴集团控股有限公司 A kind of delayed tasks triggering method and device based on Message Queuing system
CN103368761B (en) * 2012-04-01 2018-02-09 腾讯科技(深圳)有限公司 A kind of scheduled service processing method and processing device
CN107870812A (en) * 2017-11-17 2018-04-03 南京国电南自轨道交通工程有限公司 One kind is based on single thread concurrently more timer application management methods
CN108021439A (en) * 2016-10-31 2018-05-11 阿里巴巴集团控股有限公司 A kind of task polling method, task arrangement method and relevant apparatus
CN109524031A (en) * 2017-09-19 2019-03-26 华为技术有限公司 A kind of collision detection method and system
CN110471752A (en) * 2019-08-07 2019-11-19 网易(杭州)网络有限公司 Task executing method, device, electronic equipment and computer readable storage medium

Cited By (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9203896B2 (en) 2010-11-19 2015-12-01 Huawei Device Co., Ltd. Method and apparatus for data interaction
US9686376B2 (en) 2010-11-19 2017-06-20 Huawei Device Co., Ltd. Method and apparatus for data interaction
WO2012065537A1 (en) * 2010-11-19 2012-05-24 华为终端有限公司 Method and device of data interaction
CN103324469A (en) * 2012-03-21 2013-09-25 腾讯科技(深圳)有限公司 Timer implementation method and device
CN103368761B (en) * 2012-04-01 2018-02-09 腾讯科技(深圳)有限公司 A kind of scheduled service processing method and processing device
CN103368761A (en) * 2012-04-01 2013-10-23 腾讯科技(深圳)有限公司 Method and device for processing timing services
CN102761541B (en) * 2012-05-31 2015-08-19 汉柏科技有限公司 timer processing method and system
CN102761541A (en) * 2012-05-31 2012-10-31 汉柏科技有限公司 Timer processing method and system
CN103902586A (en) * 2012-12-27 2014-07-02 腾讯科技(深圳)有限公司 Method and device for processing webpage multimedia information tasks
CN103902586B (en) * 2012-12-27 2017-11-17 腾讯科技(深圳)有限公司 The processing method and processing device of Web-page Multi-media information task
CN103236937A (en) * 2013-03-01 2013-08-07 上海卫星工程研究所 Functional redundancy design method for satellite carrying system default scheduled operations
CN104731651A (en) * 2013-12-20 2015-06-24 南京南瑞继保电气有限公司 Power automation task scheduling and triggering method, system and processor
CN104731651B (en) * 2013-12-20 2018-08-17 南京南瑞继保电气有限公司 The power automation task scheduling and method of trigger mechanism, system and processor
CN103942104A (en) * 2014-04-23 2014-07-23 北京金山网络科技有限公司 Task managing method and device
CN108021439A (en) * 2016-10-31 2018-05-11 阿里巴巴集团控股有限公司 A kind of task polling method, task arrangement method and relevant apparatus
CN108021439B (en) * 2016-10-31 2022-07-15 阿里巴巴集团控股有限公司 Task polling method, task arrangement method and related device
CN106844043A (en) * 2016-12-29 2017-06-13 北京五八信息技术有限公司 The treating method and apparatus of cluster task
CN107391271B (en) * 2017-05-17 2020-10-20 创新先进技术有限公司 Message queue system-based delayed task triggering method and device
CN107391271A (en) * 2017-05-17 2017-11-24 阿里巴巴集团控股有限公司 A kind of delayed tasks triggering method and device based on Message Queuing system
CN109524031A (en) * 2017-09-19 2019-03-26 华为技术有限公司 A kind of collision detection method and system
CN107870812A (en) * 2017-11-17 2018-04-03 南京国电南自轨道交通工程有限公司 One kind is based on single thread concurrently more timer application management methods
CN107870812B (en) * 2017-11-17 2021-06-15 南京国电南自轨道交通工程有限公司 Application management method based on single thread concurrent multi-timer
CN110471752A (en) * 2019-08-07 2019-11-19 网易(杭州)网络有限公司 Task executing method, device, electronic equipment and computer readable storage medium

Similar Documents

Publication Publication Date Title
CN1870767A (en) Method for managing timer task
CN1230737C (en) Device data polling dispatching method
CN1306430C (en) User self-defining event mechanism based on structure
CN101039271A (en) Method and apparatus for taking effect rules of access control list
CN1901568A (en) Method for realizing historical property collection in net managing system
CN1317653C (en) High-efficient administration method for database connection
CN1929488A (en) Method and device for operation in multiple pages based on server paging
CN1933454A (en) Synchronous information interface realizing method based on JAVA information service
CN100351799C (en) Telecommunication between tasks based on news objects in embedded real-time operation system
CN1852131A (en) Timer scheduling method
CN1879368A (en) Using ordered locking mechanisms to maintain sequences of items such as packets
CN1917667A (en) System for processing numbers and processing method in service of sending grouped short message
CN1753402A (en) Method of using simple network management protocol to act multirariant block inquiry
CN1277196C (en) Method for applied server of computer system
CN1859205A (en) Method and system for single board soft ware storage and loading
CN100341270C (en) Method for reflecting task progress of message based distributed platform client
CN1225105C (en) Call processing system adapted for application server and its realizing method
CN1933619A (en) Short message group sending method and short message center
CN1129281C (en) Method of raising IP message forwarding speed utilizing slow storage technology
CN1145317C (en) Method for realizing business phonetic dynamic loading in intelligent network and system network establishment
CN1819532A (en) Management information base processing method
CN1913448A (en) Method of synchronous operating network element by network management and its system
CN115248887A (en) Crawler method based on streaming download
CN1758605A (en) Scheduling method of mobile data service
CN1955992A (en) Method of operating web service working flow based on stack mode

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C12 Rejection of a patent application after its publication
RJ01 Rejection of invention patent application after publication

Open date: 20061129