CN101840353B - Dynamic timing method for real-time embedded operating system - Google Patents

Dynamic timing method for real-time embedded operating system Download PDF

Info

Publication number
CN101840353B
CN101840353B CN201010172121A CN201010172121A CN101840353B CN 101840353 B CN101840353 B CN 101840353B CN 201010172121 A CN201010172121 A CN 201010172121A CN 201010172121 A CN201010172121 A CN 201010172121A CN 101840353 B CN101840353 B CN 101840353B
Authority
CN
China
Prior art keywords
task
time
chained list
timer
need
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.)
Active
Application number
CN201010172121A
Other languages
Chinese (zh)
Other versions
CN101840353A (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.)
Shaanxi Zhongtian Eternal Energy Management Co ltd
Original Assignee
Individual
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 Individual filed Critical Individual
Priority to CN201010172121A priority Critical patent/CN101840353B/en
Publication of CN101840353A publication Critical patent/CN101840353A/en
Application granted granted Critical
Publication of CN101840353B publication Critical patent/CN101840353B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention provides a timing method for system time in a real-time embedded operating system. The timing method comprises the following steps of: when a timer is time over, maintaining the system time, and then shifting out a ready task from a delay task link list; if the delay task link list is empty, finishing the operation, and if the delay task link list is not empty, subtracting the current system time from the next task revival time to work out a task revival time difference; and if the time difference is greater than an allowable timing period of the timer, setting the timing period as a maximum timing period, and if the time difference is smaller than the allowable timing period of the timer, setting the timing period as the time difference. By replacing the conventional fixed timing time with the variable timing time, and replacing the conventional time unit of a hardware timing time with a time unit of a clock source period of a hardware timer, the method reduces the unnecessary overhead of maintaining the system time when the system is idle and improves the response time of the system at the same time.

Description

A kind of dynamic timing method of real-time embedded operating system
Technical field
The present invention relates to a kind of dynamic timing method of real-time embedded operating system.
Background technology
Real time operating system need adopt the clock timing function to carry out the management of delay task recovery time and to the management of same priority task sharing processor resource.(like FreeRTOS, uc/os-2) adopted the management method of fixed time slicing, CPU revives on each timeslice and the task of each delay is carried out upgrading operation time delay and same priority task wheel changes operation etc. present real time operating system.The size of this timeslice is the minimum value during all tasks postpone, and concrete operation method is following: at first, utilize hardware timer to set fixing timing cycle, timing cycle interrupts to then producing regularly.Then, update system time and visit the delayed tasks chained list in the handling procedure that regularly interrupts, upgrade the residue delay time of delayed tasks.If delay time arrives, then join task in the ready queue.Although this method is simple and realize that easily there are some performance issues in it.At first, when the minimum time-delay of system hour, need to adopt little timing cycle, low even if minimum like this delayed tasks is carried out frequency, still need system frequently to get into regularly interruption, increased the processor burden; Secondly, the timing cycle of fixing has limited the resolution of system delay.For example, 1 millisecond timing cycle has determined that the task time-delay can be unit with the millisecond only, and this needs the application of accurate delay to constitute obstacle to some.
Summary of the invention
The objective of the invention is provides a kind of dynamic timing method of real-time embedded operating system for overcoming the deficiency of above-mentioned prior art.
For realizing above-mentioned purpose, the present invention adopts following technical proposals:
A kind of dynamic timing method of real-time embedded operating system, this method may further comprise the steps:
Step1: when timer interrupts, record system time at this moment;
Step2: operating system need be carried out moment ascending order with each task and rearrange the delayed tasks chained list; The task of linked list head need be carried out constantly and system time compares; If the task of linked list head need be carried out constantly smaller or equal to system time; Then the task with linked list head shifts out, and adds in the corresponding ready task chained list; Otherwise then the task of linked list head need be carried out and constantly deduct system time, the task delay time of difference as linked list head;
Step3: if this delay time greater than the maximum cycle of timer setting, then is set at down this maximum cycle the timer interrupt cycle of subtask; If the maximum cycle that delay time is set less than timer, then with this delay time as the timer interrupt cycle of subtask down, withdraw from the timer interruption;
Step4: judge whether the delayed tasks chained list is empty,, continue to carry out otherwise then return step1 as interrupting for sky then withdraws from timer.
It is the maximum timing cycle that hardware timer is set that said timer is set maximum cycle.
Among the said step2; All there is a variable to represent the moment that the needs of this task are carried out in the description block of each task; When task need be delayed time; Current time in system adds that task needs delay time, and in the moment that the task of obtaining need be carried out, the sequencing that need carry out according to task then is inserted in the delayed tasks chained list.
Beneficial effect of the present invention: dynamic timing method of the present invention adopts the variable timing time to replace existing fixedly timing; With the hardware timer clock source cycle is that to replace existing be chronomere with the hardware timing in chronomere; Reduced the unnecessary expense of maintenance system time when system is idle; Improved the response time of system simultaneously, reduced processor load and improved timing accuracy.
Description of drawings
Fig. 1 is a process flow diagram of the present invention;
Fig. 2 is the task delay time is set maximum cycle MaxPeriod less than timer embodiment;
Fig. 3 is the task delay time is set maximum cycle MaxPeriod greater than timer embodiment.
Embodiment
Below in conjunction with accompanying drawing and embodiment the present invention is described further:
As shown in Figure 1: when the timer timing cycle then, at first the maintenance system time, system time comes record by a variable, each timing arrives, this variable adds this timing.The chained list of inquiry time delay task then, this chained list are single-track link tables, and element is for needing the task of time-delay in the chained list, and this storage of linked list is in hardware RAM storer.The operation of shifting out of chained list is that the linked list head pointer variable is pointed to the next task of this chained list; The insertion work of chained list is; Begin from linked list head; Compare the task execution moment that task is carried out the moment and current insertion chained list in the chained list one by one; Carry out constantly big task up to finding, make the next pointer variable of the task of current insertion chained list point to finding of task, make the next pointer variable of the previous task of finding of task point to the task of current insertion chained list than the task of current insertion chained list.Because the delayed tasks chained list is need carry out ascending order arrangement constantly according to each task; So it constantly is the minimum execution moment in all delayed tasks that the delayed tasks of linked list head need be carried out; If should minimum carry out constantly smaller or equal to current system time; Explain that then this task needs to carry out, shift out the delayed tasks chained list to this task, add in the corresponding ready task chained list.Generally speaking, the minimum execution equals current system time constantly, but when certain task is carried out, turn-offed system break, causes system when timer interrupts, in time not carry out and interrupts, and can occur this moment and should minimum carry out constantly less than current system time.
Up to being arranged, need carry out constantly delayed tasks greater than the current time in system; Need the execution time to deduct system time with delayed tasks; Calculate this delayed tasks and also need delay time how long just need execution; (timer maximum timing cycle MaxPeriod is the maximum timing cycle that hardware timer is set if this delay time is greater than timer maximum timing cycle MaxPeriod; Each hardware timer maximum timing cycle is according to actual hardware timer performance this timing cycle to be set), then MaxPeriod is set at down the timer interrupt cycle of subtask; If delay time is less than MaxPeriod, then with this delay time as the timer interrupt cycle of subtask down, withdraw from timer and interrupt.
Each task delay time computing method is all to have a variable to represent the moment that the needs of this task are carried out in the description block of each task.When task need be delayed time, add that task needs delay time to the current time in system, the moment that the task of obtaining need be carried out, and then be inserted in the delayed tasks chained list according to the sequencing that task need be carried out.
According to Fig. 2 and Fig. 3 the practical implementation of technical scheme once is described below.Suppose a certain moment, 4 tasks are arranged, A, B, C, D in the delayed tasks chained list.Among Fig. 2, the task A that need carry out the earliest in the delayed tasks chained list 30ms that need delay time, it is 30ms that system is provided with current timer value.Timer time arrives behind the 30ms; The time that this moment, task A need carry out is shifted out the delayed tasks chained list smaller or equal to the current time in system, and task B becomes first task in the delayed tasks chained list; The time that task B need the carry out 20ms that also need delay time, it is 20ms that timer value is set.Among Fig. 3, the task delay time is greater than timer maximum timing time MaxPeriod1.6s, and it is 1.6s that timer value is set, and waits for that then delay time arrives, and task A delay time is 0.4s, and less than the timer maximum delay time, it is 0.4s that timer value is set.

Claims (1)

1. the dynamic timing method of a real-time embedded operating system is characterized in that, this method may further comprise the steps:
Step1: when timer interrupts, record system time at this moment;
Step2: operating system need be carried out moment ascending order with each task and rearrange the delayed tasks chained list, and this chained list is a single-track link table, and element is for needing the task of time-delay in the chained list, and this storage of linked list is in hardware RAM storer;
The operation of shifting out of chained list is that the linked list head pointer variable is pointed to the next task of this chained list; The insertion work of chained list is; Begin from linked list head; Compare the task execution moment that task is carried out the moment and current insertion chained list in the chained list one by one; Carry out constantly big task up to finding, make the next pointer variable of the task of current insertion chained list point to finding of task, make the next pointer variable of the previous task of finding of task point to the task of current insertion chained list than the task of current insertion chained list;
Because the delayed tasks chained list is need carry out ascending order arrangement constantly according to each task; So it constantly is the minimum execution moment in all delayed tasks that the delayed tasks of linked list head need be carried out; If should minimum carry out constantly smaller or equal to current system time; Explain that then this task needs to carry out, shift out the delayed tasks chained list to this task, add in the corresponding ready task chained list;
Step3: up to there being delayed tasks need carry out constantly greater than the current time in system; Need the execution time to deduct system time with delayed tasks; Calculate this delayed tasks and also need delay time how long just need execution; If this delay time is greater than timer maximum timing cycle MaxPeriod, timer maximum timing cycle MaxPeriod is the maximum timing cycle that hardware timer is set, and each hardware timer maximum timing cycle is according to actual hardware timer performance this timing cycle to be set; Then MaxPeriod is set at down the timer interrupt cycle of subtask, withdraws from timer and interrupt; If delay time is less than MaxPeriod, then with this delay time as the timer interrupt cycle of subtask down, withdraw from timer and interrupt;
Each task delay time computing method is all to have a variable to represent the moment that the needs of this task are carried out in the description block of each task; When task need be delayed time, add that task needs delay time to the current time in system, the moment that the task of obtaining need be carried out, and then be inserted in the delayed tasks chained list according to the sequencing that task need be carried out;
Step4: judge whether the delayed tasks chained list is empty,, continue to carry out otherwise then return step1 as interrupting for sky then withdraws from timer.
CN201010172121A 2010-05-14 2010-05-14 Dynamic timing method for real-time embedded operating system Active CN101840353B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201010172121A CN101840353B (en) 2010-05-14 2010-05-14 Dynamic timing method for real-time embedded operating system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201010172121A CN101840353B (en) 2010-05-14 2010-05-14 Dynamic timing method for real-time embedded operating system

Publications (2)

Publication Number Publication Date
CN101840353A CN101840353A (en) 2010-09-22
CN101840353B true CN101840353B (en) 2012-10-24

Family

ID=42743739

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201010172121A Active CN101840353B (en) 2010-05-14 2010-05-14 Dynamic timing method for real-time embedded operating system

Country Status (1)

Country Link
CN (1) CN101840353B (en)

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102103520A (en) * 2010-12-14 2011-06-22 深圳市金宏威实业发展有限公司 Method and device for realizing timers
CN102270156A (en) * 2011-05-30 2011-12-07 北京华源格林科技有限公司 Method for managing real-time embedded system timers
CN102722402B (en) * 2012-05-28 2014-03-05 上海微频莱机电科技有限公司 Processing system and method for dispatching multiple tasks in real time in non-preemptive mode
CN104679583B (en) * 2013-11-28 2019-02-05 华为技术有限公司 A kind of method and device of dynamic adjustment clock interrupt
CN104142829B (en) * 2014-08-04 2017-03-15 中国科学院上海高等研究院 The method and system of intelligent optimization operating system timer function
CN104375620A (en) * 2014-11-25 2015-02-25 珠海全志科技股份有限公司 Method for reducing power dissipation of ucos-ii system
CN106528286A (en) * 2016-11-22 2017-03-22 北京智芯微电子科技有限公司 Method and device for realizing timer
CN107220030A (en) * 2017-05-31 2017-09-29 北京北信源软件股份有限公司 Delayed tasks perform method and device
CN109144680A (en) * 2017-06-27 2019-01-04 阿里巴巴集团控股有限公司 A kind of clock ticktack interrupts setting method and device
WO2019075745A1 (en) * 2017-10-20 2019-04-25 深圳市汇顶科技股份有限公司 Timing method of virtual timer, apparatus thereof, and electronic apparatus
WO2019140551A1 (en) * 2018-01-16 2019-07-25 深圳市汇顶科技股份有限公司 Timer implementation method and device
CN110083524A (en) * 2019-03-15 2019-08-02 深圳壹账通智能科技有限公司 Upload data test method, apparatus, computer equipment and storage medium
CN110333938A (en) * 2019-05-31 2019-10-15 苏州简约纳电子有限公司 A method of improving embedded timer efficiency
CN110928652A (en) * 2019-10-18 2020-03-27 蓝箭航天空间科技股份有限公司 Real-time task delay management method for operating system, storage medium and server

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1873615A (en) * 2006-01-20 2006-12-06 华为技术有限公司 Method for servicing task of timer
CN1877535A (en) * 2006-07-07 2006-12-13 浙江大学 Timing method for high efficient traverse of embedded real-time operating system

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6732287B1 (en) * 2000-06-22 2004-05-04 Rockwell Automation Technologies, Inc. Method for processing dynamically allocated timers in a real time operating system
CN101183316A (en) * 2007-11-28 2008-05-21 北京中星微电子有限公司 Tasks delayed time processing method and system in real-time operating system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1873615A (en) * 2006-01-20 2006-12-06 华为技术有限公司 Method for servicing task of timer
CN1877535A (en) * 2006-07-07 2006-12-13 浙江大学 Timing method for high efficient traverse of embedded real-time operating system

Also Published As

Publication number Publication date
CN101840353A (en) 2010-09-22

Similar Documents

Publication Publication Date Title
CN101840353B (en) Dynamic timing method for real-time embedded operating system
CN106773711B (en) A kind of the hybrid tasks scheduling method and model of railway locomotive operation steerable system
CN102591815B (en) A kind of method of loop data buffer read-write batch data and device
CN102135906B (en) Power consumption control method and system orienting to embedded real-time operating system
CN102566974B (en) Instruction acquisition control method based on simultaneous multithreading
JP2007034414A5 (en)
CN102412957B (en) High-precision synchronous clock adjusting method
CN102081555B (en) Method and device for adjusting clock interrupt cycle
WO2013126415A3 (en) Method and system for scheduling requests in a portable computing device
CN105718257B (en) Timer arrangement and timing method based on embedded system
CN105516024B (en) A kind of task flux monitoring method and system based on queue
KR102164099B1 (en) System on chip, method thereof, and device including the same
US9251308B2 (en) Simulation method, system, and program
US9424212B2 (en) Operating system-managed interrupt steering in multiprocessor systems
CN103810043B (en) A kind of energy-saving scheduling method being applicable to digital control system periodic duty
CN103995742A (en) Embedded type real-time scheduling control device and method based on MCU
CN104536835A (en) Self-adaption task scheduling method in hot backup real-time control system
CN103823706A (en) RTLinux (real-time Linux) based real-time scheduling method for analog simulation of controlled object model
KR101770736B1 (en) Method for reducing power consumption of system software using query scheduling of application and apparatus for reducing power consumption using said method
CN104679583B (en) A kind of method and device of dynamic adjustment clock interrupt
CN102707765B (en) Timekeeping method using mixed clock source
CN100511155C (en) Method for implementing non accumulation inaccuracy and self-adaption timer
CN106933535B (en) A method of realizing that high-precision is delayed in SCM system
CN103078870A (en) Correlating-anti-correlating system and method for virtual machine in cloud data center operation system
JP2011108140A (en) Data processor

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
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20230215

Address after: 710000 Room 1604, Block C, Phase II, New Chang'an Square, No. 34, Fenghui South Road, High-tech Zone, Xi'an City, Shaanxi Province

Patentee after: Shaanxi Zhongtian eternal Energy Management Co.,Ltd.

Address before: A506, No. 1768, Xinluo Street, High-tech Zone, Jinan City, Shandong Province, 250101

Patentee before: Chen Dongyan

CP03 Change of name, title or address
CP03 Change of name, title or address

Address after: Room 2401, Building B, New Chang'an Square, No. 34 Fenghui South Road, High tech Zone, Xi'an City, Shaanxi Province, 710000

Patentee after: Shaanxi Zhongtian eternal Energy Management Co.,Ltd.

Country or region after: China

Address before: 710000, Room 1604, Block C, Phase II, New Chang'an Square, No. 34 Fenghui South Road, High tech Zone, Xi'an City, Shaanxi Province, China

Patentee before: Shaanxi Zhongtian eternal Energy Management Co.,Ltd.

Country or region before: China