[go: up one dir, main page]

CN101840353A - 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
CN101840353A
CN101840353A CN201010172121A CN201010172121A CN101840353A CN 101840353 A CN101840353 A CN 101840353A CN 201010172121 A CN201010172121 A CN 201010172121A CN 201010172121 A CN201010172121 A CN 201010172121A CN 101840353 A CN101840353 A CN 101840353A
Authority
CN
China
Prior art keywords
time
task
timer
timing
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.)
Granted
Application number
CN201010172121A
Other languages
Chinese (zh)
Other versions
CN101840353B (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.(as 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 as follows: 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 task is joined 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 enter 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 above-mentioned the deficiencies in the prior art.
For achieving the above object, 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; Constantly deduct system time otherwise then the task of linked list head need be carried out, with 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 described timer is set maximum cycle.
Among the described 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, in the moment that the task of obtaining need be carried out, the sequencing that need carry out according to task is inserted in the delayed tasks chained list then.
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
The invention will be further described below in conjunction with drawings and Examples:
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.Chained list shift out the operation be that the linked list head pointer variable is pointed to the next task of this chained list; The insertion work of chained list is, 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 task than current insertion chained list, 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.Because the delayed tasks chained list is need carry out ascending order arrangement constantly according to each task, so it constantly is that minimum in all delayed tasks is carried out constantly 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, illustrate that then this task needs to carry out, this task is shifted out the delayed tasks chained list, add in the corresponding ready task chained list.Generally speaking, the minimum execution equals current system time constantly, but turn-offed system break when certain task is carried out, and causes system in time not carry out when timer interrupts and interrupts, and this minimum can occur this moment and 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, calculating this delayed tasks also needs time-delay how long just to need to carry out, if this delay time is the maximum timing cycle that hardware timer is set greater than the maximum timing cycle MaxPeriod of the maximum timing cycle MaxPeriod(of timer timer, the maximum timing cycle of each hardware timer 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, the current time in system is added that task needs delay time, 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 concrete enforcement 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 of needing the earliest in the delayed tasks chained list the to carry out 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 carry out also needs the 20ms that delays time, and it is 20ms that timer value is set.Among Fig. 3, the task delay time is greater than the maximum timing MaxPeriod1.6s of timer, 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 (3)

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, 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; Constantly deduct system time otherwise then the task of linked list head need be carried out, with 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.
2. the dynamic timing method of a kind of real-time embedded operating system described in claim 1 is characterized in that, it is the maximum timing cycle that hardware timer is set that described timer is set maximum cycle.
3. the dynamic timing method of a kind of real-time embedded operating system described in claim 1, it is characterized in that, among the described 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 is inserted in the delayed tasks chained list then.
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 true CN101840353A (en) 2010-09-22
CN101840353B 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)

Cited By (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
CN102722402A (en) * 2012-05-28 2012-10-10 上海微频莱机电科技有限公司 Processing system and method for dispatching multiple tasks in real time in non-preemptive mode
CN104142829A (en) * 2014-08-04 2014-11-12 中国科学院上海高等研究院 Method and system for intelligently optimizing operating system timer function
CN104375620A (en) * 2014-11-25 2015-02-25 珠海全志科技股份有限公司 Method for reducing power dissipation of ucos-ii system
CN104679583A (en) * 2013-11-28 2015-06-03 华为技术有限公司 Method and device for dynamically adjusting clock interruption
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 蓝箭航天空间科技股份有限公司 Operating system task delay real-time management method, storage medium and server

Citations (4)

* 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
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
CN101183316A (en) * 2007-11-28 2008-05-21 北京中星微电子有限公司 Tasks delayed time processing method and system in real-time operating system

Patent Citations (4)

* 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
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
CN101183316A (en) * 2007-11-28 2008-05-21 北京中星微电子有限公司 Tasks delayed time processing method and system in real-time operating system

Cited By (22)

* 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
CN102722402A (en) * 2012-05-28 2012-10-10 上海微频莱机电科技有限公司 Processing system and method for dispatching multiple tasks in real time in non-preemptive mode
CN102722402B (en) * 2012-05-28 2014-03-05 上海微频莱机电科技有限公司 Processing system and method for dispatching multiple tasks in real time in non-preemptive mode
CN104679583A (en) * 2013-11-28 2015-06-03 华为技术有限公司 Method and device for dynamically adjusting clock interruption
CN104142829A (en) * 2014-08-04 2014-11-12 中国科学院上海高等研究院 Method and system for intelligently optimizing operating system timer function
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
US11216023B2 (en) 2017-06-27 2022-01-04 Alibaba Group Holding Limited Clock tick interrupt configuration method and apparatus
WO2019075745A1 (en) * 2017-10-20 2019-04-25 深圳市汇顶科技股份有限公司 Timing method of virtual timer, apparatus thereof, and electronic apparatus
CN109952560A (en) * 2017-10-20 2019-06-28 深圳市汇顶科技股份有限公司 Timing method and its device, the electronic device of virtual timer
CN109952560B (en) * 2017-10-20 2022-12-23 深圳市汇顶科技股份有限公司 Timing method and device of virtual timer and electronic device
WO2019140551A1 (en) * 2018-01-16 2019-07-25 深圳市汇顶科技股份有限公司 Timer implementation method and device
CN110447013A (en) * 2018-01-16 2019-11-12 深圳市汇顶科技股份有限公司 Timer realization method and device
EP3550431A4 (en) * 2018-01-16 2020-03-11 Shenzhen Goodix Technology Co., Ltd. Timer implementation method and device
EP3550431B1 (en) * 2018-01-16 2021-12-08 Shenzhen Goodix Technology Co., Ltd. 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 蓝箭航天空间科技股份有限公司 Operating system task delay real-time management method, storage medium and server

Also Published As

Publication number Publication date
CN101840353B (en) 2012-10-24

Similar Documents

Publication Publication Date Title
CN101840353B (en) Dynamic timing method for real-time embedded operating system
CN102591815B (en) A kind of method of loop data buffer read-write batch data and device
CN106773711B (en) A kind of the hybrid tasks scheduling method and model of railway locomotive operation steerable system
CN102135906B (en) Power consumption control method and system orienting to embedded real-time operating system
US8402463B2 (en) Hardware threads processor core utilization
CN102722234B (en) Controller and program product
CN103955491B (en) Method for synchronizing timing data increment
US10281970B2 (en) Control device, system, and computer program product
CN102081555B (en) Method and device for adjusting clock interrupt cycle
US9619290B2 (en) Hardware and runtime coordinated load balancing for parallel applications
JP2007034414A5 (en)
KR102164099B1 (en) System on chip, method thereof, and device including the same
WO2013126415A3 (en) Method and system for scheduling requests in a portable computing device
CN105718257B (en) Timer arrangement and timing method based on embedded system
CN103810043B (en) A kind of energy-saving scheduling method being applicable to digital control system periodic duty
CN102222022A (en) Real-time task scheduling method based on multicore processor
CN102270156A (en) Method for managing real-time embedded system timers
US20140372649A1 (en) Operating System-Managed Interrupt Steering in Multiprocessor Systems
CN109739332B (en) A multi-task general energy consumption optimization method
CN109324891A (en) A kind of periodic duty low-power consumption scheduling method of ratio free time distribution
CN101561766B (en) Low-expense block synchronous method supporting multi-core assisting thread
CN100511155C (en) Method for implementing non accumulation inaccuracy and self-adaption timer
KR101725408B1 (en) Tasks scheduling method for realtime operating system
CN102662770A (en) Node synchronization method of distributed virtual test system
CN106933535B (en) A method of realizing that high-precision is delayed in SCM 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
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

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

CP03 Change of name, title or address