CN1275423C - Timing method of timer in embedded real-time operation system - Google Patents

Timing method of timer in embedded real-time operation system Download PDF

Info

Publication number
CN1275423C
CN1275423C CN 02110936 CN02110936A CN1275423C CN 1275423 C CN1275423 C CN 1275423C CN 02110936 CN02110936 CN 02110936 CN 02110936 A CN02110936 A CN 02110936A CN 1275423 C CN1275423 C CN 1275423C
Authority
CN
China
Prior art keywords
timer
array
timing
multiple value
cycle index
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.)
Expired - Fee Related
Application number
CN 02110936
Other languages
Chinese (zh)
Other versions
CN1441570A (en
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.)
ZTE Corp
Original Assignee
ZTE Corp
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 ZTE Corp filed Critical ZTE Corp
Priority to CN 02110936 priority Critical patent/CN1275423C/en
Publication of CN1441570A publication Critical patent/CN1441570A/en
Application granted granted Critical
Publication of CN1275423C publication Critical patent/CN1275423C/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The present invention provides a timing method of timers in an embedded real-time operating system. The method comprises: setting a timer description array of the maximal timer number; using the array with certain length and a circulating pointer variable to form into a circulating timing queue. When each timing period arrives, the circulating pointer variable moves backwards to enquire whether a list queue of the elements of the array is empty or not; the arrival of the next timing period is awaited if the list queue is empty; whether a multiple value in the description structure of the timer in the list queue is 0 or not is judged one by one if the list queue is not empty. If the multiple value is 0, the timing time of the timer arrives, and corresponding operations of giving the correct time and inserting the timer again are carried out; if the multiple value is not 0, the multiple value is subtracted from 1, and the next timer is judged. The present invention solves the disadvantage that redundant operation and ordering operations exist in the existing timing method. After simulated and tested, the average performance of the timer under various loads is enhanced by more than five times; the computational resources required by the timing management of embedded systems are saved.

Description

The clocking method of timer in the embedded real-time operating system
Technical field
The present invention relates to computer realm, specifically, relate to the timer in the embedded real-time multi-task operating system in the computer realm.
Background technology
Real-time system is meant if the system that deviation can lead to grave consequences appears in logic and sequential, is widely used in fields such as process of factory production control, car industry, office automation, computer peripheral equipment, communication equipment, robot, Aero-Space, civilian consumption.
For not too complicated real-time system, desk-top or hypercycle formula before and after generally can being designed to.For most of real-time systems, because the requirement of multitasking and shared resource is arranged, then the operating system support must be arranged, this operating system just is called real time operating system.Be referred to as embedded system for the department of computer science that is hidden in internal system, and most real time operating system is Embedded, then is called embedded real-time operating system.
Embedded real-time operating system generally by task scheduling management, time management, tasks synchronization and communicate by letter, several parts such as memory management form.Because real time operating system is very strong to the deviation dependence of sequential, so timer just seems very important as the core of operating system time management.
In the product of communication field, as large-scale stored-program control exchange, its service call needs several different timings, when simultaneously treated service call reaches up to ten thousand, then needs the timer of extensive (such as 20000); If the clocking method efficient of timer is relatively poor, then can cause Timing Processing consumption system CPU resource excessive too much because of the timer number, influence timing accuracy, influence the promptness that call business is handled, thereby become the bottleneck that influences overall system performance, so timer is to influence a very important link of real-time system performance.
The clock source of timer derives from hardware clock and interrupts, and clock interrupts producing at regular intervals, and this time interval is minimum timing duration, the accuracy of timekeeping of timer just, and each is called time-count cycle to the hardware clock Interrupt Process.
The clocking method of timer has two kinds at present.A kind of method is when arrive in each time-count cycle, and the timing number with all timers subtracts 1 earlier, and whether judged result is 0 then, if be 0, then represent timing time to and then handle, otherwise proceed timing operation, this method is called simple chronometry.
Another kind is many formations chronometry.At first according to system's application characteristic regularly, timer is divided into the formation of different durations, purpose is to reduce the timer number of each participation counting.When setting timer, the timing duration is decomposed into several sections such as millisecond position, individual position, ten, hundred, kilobit, again timer be inserted into the most very much not be 0 the position place formation, timing is just from this formation, count one by one after finishing with the next, to millisecond position formation, after this formation timing was finished, this timer finished when amounting at last until timing.
Because what individual queue was calculated except that a timer all is time relative values with respect to last timer, then timing the time only need do formation head timer time and subtract computing, can determine whether that just timer expires in this timing.
In sum, no doubt method is simple for simple chronometry, realize easily, but when the timer number was fully loaded with (as 20000), then each counting needed all timers to do subtraction, and promptly per second need be done 200,000 subtractions (supposing 100 milliseconds of each time-count cycles), and the cpu resource of embedded system is quite limited, the task of timer itself can not account for too many resource, so if adopt this method, will take more cpu resource.
And the simple relatively chronometry of many formations chronometry is more efficient, when arrive each time-count cycle, only need do judgement and the subtraction identical with the formation number of times, and the possible operation of giving the correct time, and just can satisfy the timing demand of embedded system substantially.But also there are a lot of redundant operations in this method simultaneously, checks all formations when carrying as idling, will do 2 times to the addition and subtractions operation of checking to all formations during full load, and real valid function only accounts for giving the correct time of small part wherein and inserts operation; And in queue processing, there is the sorting operation expend computational resource.
Summary of the invention
Technical problem to be solved by this invention provides a kind of clocking method of new timer, solve the shortcoming that has redundant operation and sorting operation in many formations chronometry, improve regularly efficient, and had retractility, can adapt to the embedded system of different scales.
Timer clocking method of the present invention is single-cycle formation chronometry, may further comprise the steps:
The first step is provided with the timer of required maximum timer number and describes array, and structure of arrays comprises the index sign of a previous and back timer, by index sign structure doubly linked list;
Second step adopted the array of certain-length and cycle index variable to form a circulation timing formation, and the cycle index variable points to each array element in the mode of circulation;
The 3rd step is when upper level applications needs task of timer, calculate the remainder of timer duration earlier divided by the array length gained, again with this remainder and the summation of current cycle index variate-value, and then, required new timer is inserted in the chained list of position of resultant remainder divided by array length;
The 4th step, the cycle index variable moved backward when arrive each time-count cycle, and whether the chained list formation of inquiry indication array element is empty, if be empty, and the then arrival of waiting for next time-count cycle; If be not empty, judge one by one then whether the multiple value in the description scheme of timer in this chained list formation is 0, as be that 0 timing of representing this timer arrives, giving the correct time accordingly to operate and insert once more timer operation, this timer of deletion is described array from this chained list formation simultaneously; Be not 0 as multiple value multiple value is subtracted 1, judge next timer then.
Adopt single cycle formation chronometry of the present invention, through simulation test, compared with prior art, timer improves more than 5 times in the average behavior under the various loads, reach high-performance, high efficiency, high harmonious, the effect that realizes simplicity, scalability, saved the required computational resource of time control of embedded system.
Description of drawings
Below in conjunction with accompanying drawing, concrete enforcement of the present invention is described in further detail.
Fig. 1 is the schematic diagram that timer of the present invention is described array and round-robin queue.
Fig. 2 is the schematic diagram that new timer inserts.
Fig. 3 is the flow chart of timer clocking method of the present invention.
Embodiment
Fig. 1 has shown that timer describes the principle that is provided with of array and round-robin queue.Suppose that required maximum timer number is M, then is provided with M timer and describes array.Timer is described array and is represented that with structure this structure comprises the index sign (ID represents with formation) of a previous and back timer, can construct doubly linked list by the index sign, is initialized as an idle doubly linked list.For simplicity, set 0 * FF and represent invalid value.For example, the description array of timer 2 is (0 * FF, 3), and expression timer 2 front does not have timer, and the back is a timer 3; In like manner, the description array of timer 4 is that (1,5) represents that then the front of timer 4 is timers 1, and the back is a timer 5.Describe array by timer like this and timer can be constituted doubly linked list.
Round-robin queue is that array and the cycle index variable of L formed by length, the length of round-robin queue is L just so, the value of L is followed the big or small basic identical of following rule: L and M, the timer that uses with box lunch is during near M, and timer can be distributed in each array element of round-robin queue at random equably.Cause the reducing of multiple value too much easily if L is too little, efficient can not get improving; L too greatly then wastes memory space; Simultaneously L preferably is taken as 2 index, so that utilize displacement and calculate multiple value and remainder, raise the efficiency with operation, such as, when M is 20000, L can be taken as 2 14=16384.
Length is that the element of the array of L is described the active time chained list that is positioned at this element place with an ID and tail ID, the timer of constructing in front by an ID and tail ID is described and is found the timer of forming this place chained list and the structure of tail timer in the array, and then identifies element in the used doubly linked list that finds this place by index easily.
Round-robin queue is made of array and the cycle index of 0-(L-1).The moving method of cycle index is: in each time-count cycle, the new value of cycle index is that cycle index adds 1 and be divided by with L and get remainder, can constitute circulation like this and moving.In Fig. 1, it is 0 timer that the linked list element of round-robin queue position 0 has only an ID; The linked list element of position 1 does not have; The linked list element of position 2 has timer 1,4,5; The linked list element at 5 places, position has timer 2,3.Idle timer chain meter unit have timer 6,7 ..., M-1.
With array ID indicate timer and in round-robin queue the constructing virtual doubly linked list, its purpose is to get in touch timer and describes formation and round-robin queue, can save memory space, avoids the structure copy function, improves computational efficiency.
Fig. 2 has provided the insertion method schematic diagram of new timer.In the time will inserting new timer, at first according to the remainder of current cycle index position, timing duration, calculate this timer timing cycle index position then, i.e. the insertion position of new timer.The new insertion position computational methods of timer in round-robin queue are, calculate the be divided by remainder of gained of timer duration (representing) and L earlier with the timing periodicity, again with this remainder and the summation of cycle index variate-value, be divided by with L then, the remainder of gained promptly is the insertion position of new timer, can be formulated as follows:
The insertion position of new timer=(cycle index variate-value+new length of timer is divided by the remainder of L gained) got remainder divided by L.
Then new timer is inserted in the chained list at this place according to the position.
When new timer inserted, its multiple value computing formula was:
The multiple value of new timer=new timer duration divided by L after the merchant of gained.
The timer that surpasses L length cooperates timing by multiple value.Suppose L>6, the timing duration that newly inserts timer 6 is 3, is insertion in 2 o'clock in cycle index.At this moment the position of inserting according to the formula calculating of new timer insertion position is 5, and then new timer is inserted into the chained list end at 5 places, round-robin queue position.Timing duration as new timer 6 is 203, and L is 100, and then the multiple value of timer 6 is 2, and calculating the insertion position is 5.After new timer 6 inserted, the timer chain meter unit at 5 places, position have 2,3,6; Delete timer 6 simultaneously from idle chained list, remaining idle chain list cell have timer 7,8 ... M-1.Fig. 2 has shown the result who inserts.
Fig. 3 is the timing flow process of timer.When arrived each time-count cycle, the cycle index variable moved backward according to the cycle index formula.
It is as follows that cycle index moves formula: new cycle index variate-value=(former cycle index variate-value+1) is divided by getting remainder behind the L.
According to above-mentioned formula, if former cycle index variable is 1, moving formula according to cycle index, to walk one backward then be 2; If former cycle index variable is L-1, then moving formula according to cycle index, to walk one backward then be 0.
Whether the chained list formation of inquiring about the element of cycle index indication then is empty.When cycle index pointed to 1, its chained list formation was empty; When cycle index was 2, the chained list formation was not empty, and it is timer 1,4,5 that element is arranged.If chained list is to classifying sky as, next time-count cycle is waited in the operation that then is left intact.If formation is not empty, judge one by one then whether the multiple value in all timer description schemes is 0 in this place's chained list formation.For Fig. 2, when being 2, cycle index should judge timer 1,4,5, when being 5, cycle index should judge timer 2,3,6.If multiple value is 0, represent that then this timer timing time arrives, give the correct time accordingly and insert timer operation once more, simultaneously this timer description scheme of deletion from the chained list formation; As multiple value is not 0, then multiple value is subtracted 1, judges next timer again.As Fig. 2, point to 5 when cycle index, when judging the multiple value of timer 6, suppose that L is 100, if the timing duration of timer 6 is 3, then multiple value is 0, timer 6 is then done and is given the correct time and insertion operation once more; If the timing duration of timer 6 is 203, then multiple value is 2, and it is 1 that multiple value 2 is subtracted 1, continues later operation, and the multiple value of timer 6 just is 0 after cycle index is through 2 circulations, at this moment just gives the correct time and insertion operation again.
When timing finishes, when upper level applications no longer needs timer, can this timer of deletion the array be described from round-robin queue and timer.
In sum, the present invention adopts single cycle formation timing, realizes simply, and the efficient height has been saved the resource of system.

Claims (5)

1, the clocking method of timer in the embedded real-time operating system is characterized in that, may further comprise the steps:
The first step is provided with the timer of required maximum timer number and describes array, and structure of arrays comprises the index sign of a previous and back timer, by index sign structure doubly linked list;
Second step adopted the array of certain-length and cycle index variable to form a circulation timing formation, and the cycle index variable points to each array element in the mode of circulation;
The 3rd step is when upper level applications needs task of timer, calculate the remainder of timer duration earlier divided by the array length gained, again with this remainder and the summation of current cycle index variate-value, and then, required new timer is inserted in the chained list of position of resultant remainder divided by array length;
The 4th step, the cycle index variable moved backward when arrive each time-count cycle, and whether the chained list formation of inquiry indication array element is empty, if be empty, and the then arrival of waiting for next time-count cycle; If be not empty, judge one by one then whether the multiple value in the description scheme of timer in this chained list formation is 0, as be that 0 timing of representing this timer arrives, giving the correct time accordingly to operate and insert once more timer operation, this timer of deletion is described array from this chained list formation simultaneously; Be not 0 as multiple value multiple value is subtracted 1, judge next timer then.
2, the clocking method of timer as claimed in claim 1 is characterized in that: also comprise, when upper level applications no longer needs timer, describe this timer of deletion the array from round-robin queue and timer.
3, the clocking method of timer as claimed in claim 1 is characterized in that: the length scale and the maximum timer number of array is basic identical in described second step, and adopts the form of 2 index.
4, the clocking method of timer as claimed in claim 1 is characterized in that: the formula that the cycle index variable moves in described the 4th step is that new cycle index variate-value=(former cycle index variate-value+1) is divided by getting remainder behind the L.
5, the clocking method of timer as claimed in claim 1 is characterized in that: the computing formula of described the 4th step medium multiple value is, the multiple value=timer duration of timer divided by L after the merchant of gained.
CN 02110936 2002-02-28 2002-02-28 Timing method of timer in embedded real-time operation system Expired - Fee Related CN1275423C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 02110936 CN1275423C (en) 2002-02-28 2002-02-28 Timing method of timer in embedded real-time operation system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 02110936 CN1275423C (en) 2002-02-28 2002-02-28 Timing method of timer in embedded real-time operation system

Publications (2)

Publication Number Publication Date
CN1441570A CN1441570A (en) 2003-09-10
CN1275423C true CN1275423C (en) 2006-09-13

Family

ID=27768551

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 02110936 Expired - Fee Related CN1275423C (en) 2002-02-28 2002-02-28 Timing method of timer in embedded real-time operation system

Country Status (1)

Country Link
CN (1) CN1275423C (en)

Families Citing this family (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1327352C (en) * 2003-09-23 2007-07-18 中兴通讯股份有限公司 Method of detecting and location of leakage of internal storage of real-time system localization
CN1328925C (en) * 2004-01-14 2007-07-25 中兴通讯股份有限公司 Method for timed monitoring of memory database in mobile communication equipment
WO2007076636A1 (en) * 2005-12-31 2007-07-12 Zte Corporation A management system and management method of the timer in the software system
CN100426240C (en) * 2006-11-22 2008-10-15 北京中星微电子有限公司 A time processing method of message and embedded multiple task operating system
CN100440158C (en) * 2006-11-23 2008-12-03 北京中星微电子有限公司 A testing method and system for timer in embedded system
CN101060679A (en) * 2007-06-06 2007-10-24 中兴通讯股份有限公司 Event insertion method
CN101179434B (en) * 2007-10-24 2010-06-09 中兴通讯股份有限公司 Automatic time-counting method in network management system
CN101534243B (en) * 2008-12-04 2011-10-12 苏州迈科网络安全技术股份有限公司 Method for dispatching timer under IP network environment
CN101673222B (en) * 2009-11-03 2012-02-29 东方电子股份有限公司 Implementation method of task timer in multi-path selection mode of VxWorks system
CN101833450B (en) * 2010-04-21 2015-01-28 中兴通讯股份有限公司 Timing method and device
CN101957779B (en) * 2010-09-16 2013-04-03 深圳天源迪科信息技术股份有限公司 Management method of timer
CN103019805A (en) * 2011-09-20 2013-04-03 佳都新太科技股份有限公司 Timer setting method under multithreading environment
CN103106222B (en) * 2011-11-15 2017-03-08 阿里巴巴集团控股有限公司 The processing method and processing device of intervalometer
CN103901941A (en) * 2012-12-28 2014-07-02 北京大唐高鸿软件技术有限公司 Method for improving timer execution efficiency through memory overheads
CN103473071B (en) * 2013-09-24 2016-05-11 深圳市路通网络技术有限公司 The implementation method of software timer and system
CN104391702A (en) * 2014-11-15 2015-03-04 郑州飞机装备有限责任公司 Method for extending timer by using embedded system software
CN104597820B (en) * 2015-02-11 2017-07-28 四川天邑康和通信股份有限公司 A kind of method for extending single-chip microcomputer hardware timer
CN106598547B (en) * 2016-09-13 2018-09-14 中国计量大学 Dynamic circulation storage of array method
CN109901879B (en) * 2017-12-07 2020-10-20 普天信息技术有限公司 Method for realizing cycle software timer
EP3550431B1 (en) * 2018-01-16 2021-12-08 Shenzhen Goodix Technology Co., Ltd. Timer implementation method and device
CN111966505A (en) * 2020-10-26 2020-11-20 成都掌控者网络科技有限公司 Time-based trigger event control method and device and storage medium

Also Published As

Publication number Publication date
CN1441570A (en) 2003-09-10

Similar Documents

Publication Publication Date Title
CN1275423C (en) Timing method of timer in embedded real-time operation system
CN1304949C (en) Timer dispatching method for real-time multi-task operating system
Narahari et al. Transient analysis of manufacturing systems performance
Prakash et al. A nonblocking algorithm for shared queues using compare-and-swap
Harbour et al. Fixed priority scheduling periodic tasks with varying execution priority.
Peng et al. Modeling of concurrent task execution in a distributed system for real-time control
US5696942A (en) Cycle-based event-driven simulator for hardware designs
CN101414271A (en) Scheduling method based on hardware timer and task queue for multi-nuclear platform
CN105700941A (en) Three-dimensional scheduler model and scheduling algorithm thereof
Vasudevan et al. G-charm: an adaptive runtime system for message-driven parallel applications on hybrid systems
CN1877535A (en) Timing method for high efficient traverse of embedded real-time operating system
Kim et al. Execution time analysis of communicating tasks in distributed systems
CN109582457A (en) Network-on-chip heterogeneous multi-core system task schedule and mapping
CN1710543A (en) Two-stage timing method for inlaid real-time operation system timer
Naji et al. A high-speed, performance-optimization algorithm based on a gravitational approach
Liu et al. Using Petri nets to solve FMS problems
Anderson et al. Value-maximizing deadline scheduling and its application to animation rendering
Bagrodia et al. Parallel simulation of the sharks world problem
Preiss Performance of Discrete Event Simulation on a Multiprocessor Using Optimistic and Conservative Synchronization.
McAffer A unified distributed simulation system
Kareem et al. Optimal CPU Jobs Scheduling Method Based on Simulated Annealing Algorithm
Karimabadi et al. Parallel discrete event simulations of grid-based models: asynchronous electromagnetic hybrid code
Athanasaki et al. Scheduling of tiled nested loops onto a cluster with a fixed number of SMP nodes
Putra et al. Average Max Round Robin Algorithm: A Case Study
Nicol Analysis of synchronization in massively parallel discrete-event simulations

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
ASS Succession or assignment of patent right

Owner name: SHENZHENG CITY ZTE CO., LTD.

Free format text: FORMER OWNER: SHENZHENG CITY ZTE CO., LTD. SHANGHAI SECOND INSTITUTE

Effective date: 20030723

C41 Transfer of patent application or patent right or utility model
TA01 Transfer of patent application right

Effective date of registration: 20030723

Applicant after: Zhongxing Communication Co., Ltd., Shenzhen City

Applicant before: Shanghai Inst. of No.2, Zhongxing Communication Co., Ltd., Shenzhen City

C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20060913

Termination date: 20180228