CN1304949C - Timer dispatching method for real-time multi-task operating system - Google Patents

Timer dispatching method for real-time multi-task operating system Download PDF

Info

Publication number
CN1304949C
CN1304949C CNB2005100489470A CN200510048947A CN1304949C CN 1304949 C CN1304949 C CN 1304949C CN B2005100489470 A CNB2005100489470 A CN B2005100489470A CN 200510048947 A CN200510048947 A CN 200510048947A CN 1304949 C CN1304949 C CN 1304949C
Authority
CN
China
Prior art keywords
node
linked list
timer
circular linked
time
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
CNB2005100489470A
Other languages
Chinese (zh)
Other versions
CN1645334A (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.)
NINGBO SUNRUN ELECTRONIC INFORMATION TECHNOLOGY DEVELOPMENT Co Ltd
Ningbo University
Original Assignee
NINGBO SUNRUN ELECTRONIC INFORMATION TECHNOLOGY DEVELOPMENT Co Ltd
Ningbo University
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 NINGBO SUNRUN ELECTRONIC INFORMATION TECHNOLOGY DEVELOPMENT Co Ltd, Ningbo University filed Critical NINGBO SUNRUN ELECTRONIC INFORMATION TECHNOLOGY DEVELOPMENT Co Ltd
Priority to CNB2005100489470A priority Critical patent/CN1304949C/en
Publication of CN1645334A publication Critical patent/CN1645334A/en
Application granted granted Critical
Publication of CN1304949C publication Critical patent/CN1304949C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The present invention provides a timer dispatching method for a real-time operating system based on a clock structure, which comprises: M circular linked lists are established; the circular linked lists are orderly marked as T1, T2 to TM from short to long distance according to time intervals; the linked lists are respectively and equally divided into N<1>, N<2> to N<M> nodes; the circular linked lists are formed into a structure similar to that of a clock; each node of the linked lists can be hung with a plurality of timers formed into a longitudinal linked list; a pointer of a 'stopwatch' T1 backwards moves to one node in each time-count cycle, and then, the existing node pointed by the pointer is examined; when the existing node has no timer, the next time-count cycle is in waiting; when the existing node is provided with the timers, tasks of all of the timers on the node are carried out; when the pointer of the 'stopwatch' T1 moves for N1 times to complete one cycle, the pointer of T1 repeatedly points to the No. 0 node, simultaneously, a pointer of a 'minute watch' T2 points to the next node, all of the timers on the node are orderly transferred to the corresponding nodes on the 'stopwatch' T1 according to the set time, and the update of pointers of other linked lists is deduced by analogy.

Description

A kind of scheduling method for timer of real-time multi-task operating system
Technical field
The present invention relates to the operating system field in the computing machine, specifically, relate to a kind of scheduling method for timer of real-time multi-task operating system.
Background technology
In computer utility, operating system is the bridge between user and the computer hardware, and it has made things convenient for the management of user to computer resource.In operating system, some customer requirements computing machine is finished specific task in specific time and space, and this has proposed the real-time requirement to operating system.Real time operating system is meant that customer requirements must have the system of respective reaction in limiting time, can lead to grave consequences if deviation appears in logic and sequential.Real time operating system is widely used in fields such as production run control, auto industry, computer peripheral equipment, communication facilities, robot, Aero-Space, civilian consumption.
For general operating system, if only require certain result, then the operating system operational motion that only needs system resource to be managed and responds the user gets final product.For real time operating system, then response user operation in time.Along with the increase of task amount and the increase of resource, real time operating system should be carried out the management of multitasking and shared resource, in time responds user's operation again, thereby to the demands for higher performance of real time operating system.
Operating system generally by process scheduling management, resource management, process synchronously with communicate by letter, several parts such as time control form.Real time operating system is very strong to the deviation requirement of sequential, so timer dispatching is just very important as the core of real time operating system time management.
In network service, one time communication process needs a plurality of timers to finish different timing tasks.When the number of users of communication simultaneously increased, the number of required timer sharply increased.If the dispatching method efficient of timer is low, then can prolong reaction time because of the timer number causes Timing Processing consumption system resource excessive too greatly to the user, influence timing accuracy, and then influence the performance of total system.Therefore, the efficient of scheduling method for timer just is one of important indicator of reflection real-time oss behaviour performance.
The clock of timer derives from hardware clock and interrupts.Clock interrupts and can produce every some cycles, and this cycle is minimum timing duration, i.e. the accuracy of timekeeping of timer is called time-count cycle to the Interrupt Process of hardware clock.
The dispatching method of timer is a lot of at present, mainly contains following three types:
First type: referring to accompanying drawing 2, all timers are lined up an order chained list according to the priority of expiration time.In each time-count cycle, move a node behind the chain list index, investigate current chained list node then:, then wait next time-count cycle if there is not timer to expire; If there is timer to expire, just carry out the task and the corresponding timer of deletion of all timers on this node.This clocking method is called simple chronometry.
Second type: referring to accompanying drawing 3, timer is by overdue time span linear segmented, such as by 0~99,100~199,200~299 ... carry out segmentation, each timer sorted in the period under own, can reduce the quantity of ordering like this.Processing to timer is identical with type one.
The third type: referring to accompanying drawing 4, timer is by the non-linear segmentation of overdue time span, such as by 0~3,4~7,8~15,16~31 ... segmentation, burst length are index rises, and compares this type with type two and can further reduce the segmentation number.Processing to timer is identical with type one.
In above-mentioned three types, the scheduling process of timer is determined just new timer joins the process on which node of chained list.First type of extra occupying system resources wherein to the operation of timer with judge time-consumingly hardly, sorts to all timers again but need take a long time when increasing new timer; Though second type of sorting operation number of times had certain reducing, compare essence with first type constant, when needs when to add expiration time be 100000 timer, needs 1000 segmentations at least, i.e. 1000 nodes, and its efficient is still very low.The third algorithm has carried out some on second kind basis improves, and has reduced the number of segmentation, and timing efficient improves, but when increasing timer newly, must carry out segmentation again to current all timers, increase unnecessary operation, reduce efficient.
Summary of the invention
Technical matters to be solved by this invention provides a kind of scheduling method for timer of real-time multi-task operating system of segmentation ordering, it has overcome the shortcoming that has the bulk redundancy operation in the existing real-time operation system timer dispatching method and repeat sorting operation, improved regularly efficient, and have retractility, be applicable to the real time operating system of different scales.
The present invention solves the problems of the technologies described above the technical scheme that is adopted and comprises following link:
1) M circular linked list is set, M is not less than 2 integer;
2) initialization of circular linked list: according to the number M of the circular linked list that is provided with, set up M circular linked list, these circular linked lists constitute the structure that is similar to clock: timing the shortest circular linked list at interval is the first circular linked list T 1, it is divided into N 1Individual node, number consecutively 0~N 1-1, the time interval of adjacent node equals τ time-count cycle of the timer of operating system; The second circular linked list T 2Be divided into N 2Individual node, number consecutively 0~N 2-1, the time interval between adjacent node equals the first circular linked list T 1Cycle period N 1τ; The 3rd circular linked list T 3Be divided into N 3Individual node, number consecutively 0~N 3-1, the time interval between adjacent node equals the second circular linked list T 2Cycle period N 2N 1τ; By that analogy, the structure of remaining circular linked list and relation similarly can be referred to as the 4th circular linked list T respectively 4, the 5th circular linked list T 5, the 6th circular linked list T 6Until M circular linked list T M, the interstitial content in each circular linked list equates or does not wait;
3) adding of new timer: when upper level applications produces new task of timer, at first calculate the interval D of the setting-up time and the current time of new timer; If the setting-up time of new timer is at M circular linked list T MN MOutside the timing range of-No. 1 node, i.e. D>N 1N 2(N M-1) τ just is added to M circular linked list T with new timer MN MOn-No. 1 node; Otherwise the size according to D joins new timer on the appropriate node of certain circular linked list as follows;
1. put i=M, note is from T 1To T MThe present node numbering of each circular linked list is followed successively by A 1, A 2..., A M
2. calculate
Figure C20051004894700061
Be that Q is merchant's a integral part;
If 3. Q=0, and i>1, then 2. i=i-1 returns step;
4. new timer is joined circular linked list T iThe n node on, n=[(Q+A i) mod N i], promptly n is (Q+A i) divided by N iRemainder; Finish the adding operation of new timer.
4) scheduling of timer position is upgraded: in each time-count cycle, and the first circular linked list T 1Pointer move a node backward, investigate the node of current sensing then:, just wait next time-count cycle if there is not timer on the present node; If timer is arranged on the present node, just carry out the task and the corresponding timer of deletion of all timers on this node; As the first circular linked list T 1Pen travel N 1Inferior finish a circulation after, T 1Pointer point to node again No. 0, simultaneously with the second circular linked list T 2Node of pen travel, and all timers that will newly point on the node are transferred to the first circular linked list T as follows respectively 1Respective nodes on:
1. calculate the poor D of timer setting-up time and current time;
2. calculate R=D mod N 1, promptly R is that D is divided by N 1Remainder;
3. timer is joined T 1The R node on.
The rest may be inferred in the renewal of other circular linked list;
As circular linked list T MPointed N MDuring-No. 1 node, to setting the poor D<N expire constantly with current time on this node 1N 2(N M-1) that part of timer of τ is transferred on the node of other chained list by the adding method of new timer, and other timer that does not meet above-mentioned condition is not changed, and will show T then MPen travel to 0 node.
Adopt many round-robin queues of the present invention scheduling method for timer, through simulation test, compared with prior art, timer improves more than 10 times in the average behavior under the various loads, high-performance, high-level efficiency, high balanced unification have been reached, and realize simply, saved the timer management of real time operating system, the computational resource that dispatching office needs.
Description of drawings
Fig. 1 is the timer circular linked list structural representation in the embodiment of the invention.
Fig. 2 is the scheduling method for timer synoptic diagram of first kind of prior art.
Fig. 3 is the scheduling method for timer synoptic diagram of second kind of prior art.
Fig. 4 is the scheduling method for timer synoptic diagram of the third prior art.
Embodiment
Below in conjunction with accompanying drawing embodiment invention is described in further detail.
Because the ranking and searching of timer is different with general situation, processor is concerned about current overdue timer most, and later overdue timer is concerned about later on again.Therefore, there is no need later for a long time timer is sorted, only need arrange the timer in the nearest finite time just properly.
Therefore, divide into groups, as shown in Figure 1, dispatch an embodiment of the circular linked list of timer for the present invention according to the timing length of timer:
Suppose that the circular linked list number M is 4, M circular linked list sorts from short to long by fixed time interval, is designated as T successively 1, T 2..., T 4(be T M), the node number is taken as N respectively in each circular linked list 1=8, N 2=8, N 3=4, N 4=4, their structure is similar to clock.The pointer of each chained list is Index[i] on the circular linked list each round dot represent a node Vor[i] each node Vor[i] and on can hang a string timer.When pointer is gone to certain Vor[i] time, just all timers on this node are carried out relevant processing.T 1Be the most basic circular linked list, at each clock period, T 1Node of pen travel, the task of the timer correspondence of hanging on the XM.T 1Pointer finish once circulation after, T 2Thereby node of pen travel point to T 2.Vor[4], four timers on this node are articulated to T according to the time of setting by the step described in the timer position scheduling update method 1Respective nodes get on, work as T like this 1Pen travel the time can carry out the task of timer successively.The rest may be inferred in the renewal of other circular linked list.
If the first circular linked list T 1Be called ' stopwatch ', the second circular linked list T 2Be called ' submeter ', above-mentioned dispatching method about timer can be described as: carry out the task of timer that current ' stopwatch ' goes up all ' seconds ' at first successively; After having crossed one ' branch ', with the next one ' branch ' node (T 2.Vor[4]) all timers are that unit transfers to ' stopwatch ' T with ' second ' 1Respective nodes on; In like manner, as ' submeter ' T 2When finishing once circulation and pointing to No. 0 node, will ' time table ' T 3Next ' time ' node (T 3.Vor[3]) all timers on are that unit transfers to ' submeter ' T with ' branch ' 2Respective nodes on, and continue ' submeter ' T 2Present node (is T 2.Vor[0]) all timers on are that unit transfers to ' stopwatch ' T with ' second ' 1Respective nodes on; The rest may be inferred.When a certain timer expired, operating system can be deleted this timer after executing the corresponding task of timer automatically.
When inserting new timer, need to investigate the setting-up time that inserts timer.Remember that the setting-up time of new timer and the time interval of current time are D.If D (is D<N in one ' branch ' 1τ), then directly new timer is joined T 1Certain node on, new node numbering=(T 1Present node numbering+time difference D)/N 1Remainder; Be shorter than one if D is longer than one ' branch ' ' time ' (N 1τ<D<N 1N 2τ), then new timer is joined T 2Certain node on, new node numbering=(T 2Present node numbering+time difference D/N 1Integral part)/N 2Remainder; The rest may be inferred for all the other; If D>N 1N 2(N M-1) τ then joins M circular linked list T with new timer MN MOn-No. 1 node.
In sum, the present invention adopts the timing topology of many round-robin queues to carry out the scheduling of timer, realizes that simply efficient is all very high on room and time, has saved the resource of system.

Claims (2)

1, a kind of scheduling method for timer of real-time multi-task operating system is characterized in that comprising following link:
1) M circular linked list is set, M is not less than 2 integer;
2) initialization of circular linked list: according to the number M of the circular linked list that is provided with, set up M circular linked list, these circular linked lists constitute the structure that is similar to clock: timing the shortest circular linked list at interval is the first circular linked list T 1, it is divided into N 1Individual node, number consecutively 0~N 1-1, the time interval of adjacent node equals τ time-count cycle of the timer of operating system; The second circular linked list T 2Be divided into N 2Individual node, number consecutively 0~N 2-1, the time interval between adjacent node equals the first circular linked list T 1Cycle period N 1τ; The 3rd circular linked list T 3Be divided into N 3Individual node, number consecutively 0~N 3-1, the time interval between adjacent node equals the second circular linked list T 2Cycle period N 2N 1τ; By that analogy, the structure of remaining circular linked list and relation similarly can be referred to as the 4th circular linked list T respectively 4, the 5th circular linked list T 5, the 6th circular linked list T 6Until M circular linked list T M, the interstitial content in each circular linked list equates or does not wait;
3) adding of new timer: when upper level applications produces new task of timer, at first calculate the interval D of the setting-up time and the current time of new timer; If the setting-up time of new timer is at M circular linked list T MN MOutside the timing range of-No. 1 node, i.e. D>N 1N 2(N M-1) τ just is added to M circular linked list T with new timer MN MOn-No. 1 node; Otherwise the size according to D joins new timer on the appropriate node of certain circular linked list as follows;
1. put i=M, note is from T 1To T MThe present node numbering of each circular linked list is followed successively by A 1, A 2..., A M
2. calculate
Figure C2005100489470002C1
Be that Q is merchant's a integral part;
If 3. Q=0, and i>1, then 2. i=i-1 returns step;
4. new timer is joined circular linked list T iThe n node on, n=[(Q+A i) mod N i], promptly n is (Q+A i) divided by N iRemainder; Finish the adding operation of new timer.
4) scheduling of timer position is upgraded: in each time-count cycle, and the first circular linked list T 1Pointer move a node backward, investigate the node of current sensing then:, just wait next time-count cycle if there is not timer on the present node; If timer is arranged on the present node, just carry out the task and the corresponding timer of deletion of all timers on this node; As the first circular linked list T 1Pen travel N 1Inferior finish a circulation after, T 1Pointer point to node again No. 0, simultaneously with the second circular linked list T 2Node of pen travel, and all timers that will newly point on the node are transferred to the first circular linked list T as follows respectively 1Respective nodes on:
1. calculate the poor D of timer setting-up time and current time;
2. calculate R=D mod N 1, promptly R is that D is divided by N 1Remainder;
3. timer is joined T 1The R node on.
The rest may be inferred in the renewal of other circular linked list.
2, scheduling method for timer as claimed in claim 1 is characterized in that also comprising following link: as circular linked list T MPointed N MDuring-No. 1 node, to setting the poor D<N expire constantly with current time on this node 1N 2(N M-1) that part of timer of τ is transferred on the node of other chained list by the adding method of new timer, and other timer that does not meet above-mentioned condition is not changed, and will show T then MPen travel to 0 node.
CNB2005100489470A 2005-01-12 2005-01-12 Timer dispatching method for real-time multi-task operating system Expired - Fee Related CN1304949C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2005100489470A CN1304949C (en) 2005-01-12 2005-01-12 Timer dispatching method for real-time multi-task operating system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2005100489470A CN1304949C (en) 2005-01-12 2005-01-12 Timer dispatching method for real-time multi-task operating system

Publications (2)

Publication Number Publication Date
CN1645334A CN1645334A (en) 2005-07-27
CN1304949C true CN1304949C (en) 2007-03-14

Family

ID=34876475

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2005100489470A Expired - Fee Related CN1304949C (en) 2005-01-12 2005-01-12 Timer dispatching method for real-time multi-task operating system

Country Status (1)

Country Link
CN (1) CN1304949C (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100346307C (en) * 2006-01-17 2007-10-31 浙江大学 Method of real time task regulation in Java operation system
KR101366802B1 (en) * 2007-01-05 2014-02-21 삼성전자주식회사 Method and apparatus for scheduling tasks in Real-Time Operating System
CN101645024B (en) * 2009-08-21 2012-09-19 无锡威泰迅电力科技有限公司 Dispatching method of annular propulsion timer
CN101859260B (en) * 2010-05-14 2012-12-12 中国科学院计算技术研究所 Timer management device and management method for operating system
CN103530179A (en) * 2013-09-30 2014-01-22 大唐移动通信设备有限公司 Method and device for processing timed task
CN103677976B (en) * 2013-12-09 2017-12-05 大唐移动通信设备有限公司 A kind of event-handling method and device based on time wheel timer
CN105808329A (en) * 2016-02-25 2016-07-27 北京京东尚科信息技术有限公司 Distributed overtime task scheduling method and device
CN105939345A (en) * 2016-04-25 2016-09-14 杭州迪普科技有限公司 Management method and device of protocol table item timer
CN107659305A (en) * 2017-10-19 2018-02-02 郑州云海信息技术有限公司 A kind of clock count method, apparatus and medium based on CPLD
CN109901879B (en) * 2017-12-07 2020-10-20 普天信息技术有限公司 Method for realizing cycle software timer
CN110109741B (en) * 2019-05-09 2021-08-27 北京旷视科技有限公司 Method and device for managing circular tasks, electronic equipment and storage medium
CN111966505A (en) * 2020-10-26 2020-11-20 成都掌控者网络科技有限公司 Time-based trigger event control method and device and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH11327928A (en) * 1998-05-19 1999-11-30 Mitsubishi Electric Corp Computer-readable recording medium where real-time application support program is recorded, and computer system
US6195701B1 (en) * 1994-03-16 2001-02-27 International Business Machines Corporation Method and apparatus for synchronization and scheduling of multiple data streams and real time tasks
CN1409209A (en) * 2001-09-24 2003-04-09 深圳市中兴通讯股份有限公司上海第二研究所 Realizing method for multiple task real-time operation system
CN1545308A (en) * 2003-11-25 2004-11-10 中兴通讯股份有限公司 Multiple binary tree cycle timer scheduling method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6195701B1 (en) * 1994-03-16 2001-02-27 International Business Machines Corporation Method and apparatus for synchronization and scheduling of multiple data streams and real time tasks
JPH11327928A (en) * 1998-05-19 1999-11-30 Mitsubishi Electric Corp Computer-readable recording medium where real-time application support program is recorded, and computer system
CN1409209A (en) * 2001-09-24 2003-04-09 深圳市中兴通讯股份有限公司上海第二研究所 Realizing method for multiple task real-time operation system
CN1545308A (en) * 2003-11-25 2004-11-10 中兴通讯股份有限公司 Multiple binary tree cycle timer scheduling method

Also Published As

Publication number Publication date
CN1645334A (en) 2005-07-27

Similar Documents

Publication Publication Date Title
CN1304949C (en) Timer dispatching method for real-time multi-task operating system
CN1275423C (en) Timing method of timer in embedded real-time operation system
Xie et al. Improving mapreduce performance through data placement in heterogeneous hadoop clusters
Varghese et al. Hashed and hierarchical timing wheels: Data structures for the efficient implementation of a timer facility
CN103399798A (en) Multitask control method and multitask control device of PLC (programmable logic controller)
CN109697111A (en) The scheduler task in multiline procedure processor
WO2019076713A1 (en) Combining states of multiple threads in a multi-threaded processor
CN104036451A (en) Parallel model processing method and device based on multiple graphics processing units
CN103744726B (en) A kind of two-level scheduler method of Windows system real-time extension
Wu et al. Real-time load balancing scheduling algorithm for periodic simulation models
CN103412794A (en) Dynamic dispatching distribution method for stream computing
GB2569273A (en) Synchronization in a multi-tile processing arrangement
CN106201695A (en) It is applicable to the multi-task scheduling method of embedded software system
Naji et al. A high-speed, performance-optimization algorithm based on a gravitational approach
Chen et al. Hare: Exploiting inter-job and intra-job parallelism of distributed machine learning on heterogeneous gpus
CN103049310A (en) Multi-core simulation parallel accelerating method based on sampling
Naik et al. A review of adaptive approaches to MapReduce scheduling in heterogeneous environments
CN1710543A (en) Two-stage timing method for inlaid real-time operation system timer
CN110502322A (en) The triggering method and device of timer-triggered scheduler
Liu et al. Brps: A big data placement strategy for data intensive applications
CN116795503A (en) Task scheduling method, task scheduling device, graphic processor and electronic equipment
Qin et al. Dependent task scheduling algorithm in distributed system
Patel Pipelines with internal buffers
Han et al. SPIN: BSP job scheduling with placement-sensitive execution
CN109032772A (en) A kind of embedded software method for managing timer and system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
EE01 Entry into force of recordation of patent licensing contract

Assignee: Ningbo Sanxing Electric Co., Ltd.

Assignor: Ningbo University|Ningbo Sunrun Electronic Information Technology Development Co., Ltd.

Contract fulfillment period: 2008.9.17 to 2014.9.17 contract change

Contract record no.: 2008330000669

Denomination of invention: Timer dispatching method for real-time multi-task operating system

Granted publication date: 20070314

License type: Exclusive license

Record date: 2008.9.26

LIC Patent licence contract for exploitation submitted for record

Free format text: EXCLUSIVE LICENCE; TIME LIMIT OF IMPLEMENTING CONTACT: 2008.9.17 TO 2014.9.17

Name of requester: NINGBO SAMSUNG ELECTRIC CO., LTD.

Effective date: 20080926

CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20070314

Termination date: 20160112

CF01 Termination of patent right due to non-payment of annual fee