CN110502322A - The triggering method and device of timer-triggered scheduler - Google Patents

The triggering method and device of timer-triggered scheduler Download PDF

Info

Publication number
CN110502322A
CN110502322A CN201910628452.7A CN201910628452A CN110502322A CN 110502322 A CN110502322 A CN 110502322A CN 201910628452 A CN201910628452 A CN 201910628452A CN 110502322 A CN110502322 A CN 110502322A
Authority
CN
China
Prior art keywords
time
period
wheel
sub
timer
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
CN201910628452.7A
Other languages
Chinese (zh)
Other versions
CN110502322B (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.)
Jiangsu Suning Cloud Computing Co ltd
SuningCom Co ltd
Original Assignee
Suning Cloud Computing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suning Cloud Computing Co Ltd filed Critical Suning Cloud Computing Co Ltd
Priority to CN201910628452.7A priority Critical patent/CN110502322B/en
Publication of CN110502322A publication Critical patent/CN110502322A/en
Application granted granted Critical
Publication of CN110502322B publication Critical patent/CN110502322B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Abstract

This application involves a kind of triggering method of timer-triggered scheduler and devices;The described method includes: determining timing cycles and controlling the duration in period, wherein the timing cycles and the control period are end to end cycle period, and the timing cycles are equally divided into multiple sub-periods;Within a control period, the execution queue of several sub-periods after the start time in control period is successively determined;In a sub-period, the execution queue of the sub-period is taken out, and triggers all timer-triggered schedulers in the execution queue.The scheme of the application, in the case where machine resources require extremely low, can support a large amount of timing operation functions by way of the time point run will be needed to generate related operation data in advance recently, while guarantee to trigger low delay;Solve that handover overhead existing for multithreading, a large amount of timing are unbalanced to cause thread utilization rate not high and timing form supports the problems such as single.

Description

The triggering method and device of timer-triggered scheduler
Technical field
This application involves dispatching algorithm technical fields, and in particular to a kind of triggering method and device of timer-triggered scheduler.
Background technique
The field Java Timer, ScheduledExecutor, Quartz realize that basal latency wheel is realized.
Timer timer-triggered scheduler mode is too simple, supports timing form too single, can not dynamically increase timing form, It is unable to satisfy the application of complicated business scene;Furthermore all tasks of Timer are dispatched by the same thread, therefore all Business all serially executes, and the same time can only have a task executing, and the delay of previous task or exception all will shadows Ring the task after arriving.
In view of the drawbacks described above of Timer, Java5 is proposed the ScheduledExecutor based on thread pool design;It sets Counting thought is that each scheduled task can be gone to execute by a thread in thread pool, therefore task concurrently executes, It will not be interfered between each other;It should be noted that only when the execution time of task arrives, ScheduedExecutor It just can really start a thread, remaining time is all the state in polling tasks, but does not also solve the problems, such as that timing is in the form of a single.
Quartz can be accurate to by Cron expression formula specific time execution, Quartz possess Timer, ScheduledExecutor all functions, and can dynamically increase modification timing form.
The realization of Timer, ScheduledExecutor, Quartz technology is dependent on thread or thread pool to realize that timing is touched Hair, the problem of such mode maximum are exactly to need to will lead to too much in the case that the task quantity triggered is bigger in the same time Thread switching so as to cause triggering timeliness substantially reduce, the pain spot problem of most critical is that the timer-triggered scheduler triggered time is indefinite, Sometimes do not have several tasks, concentrate outburst sometimes, caused thread setting big many times be all waste, lacked material time again Not this enough awkward condition.
Basal latency wheel algorithm can solve above said pain spot problem, can realize that timing is adjusted only with a thread The accurate scheduling triggering of degree, so as calculated in Transmission Control Protocol, Netty network frame by basal latency wheel in many application scenarios Method manages thousands of or even 100,000,000,000 grades network linking overtime control events.
In the related technology, the use of basal latency wheel algorithm is in a kind of single scene, the network timeout for example mentioned above Control, it is also relatively difficult for a kind of business complexity, the scenes of a variety of timing form controls of needs.
Summary of the invention
To be overcome the problems, such as present in the relevant technologies at least to a certain extent, the application provides a kind of touching of timer-triggered scheduler Forwarding method and device.
According to the embodiment of the present application in a first aspect, providing a kind of triggering method of timer-triggered scheduler, comprising:
It determines timing cycles and controls the duration in period, wherein the timing cycles and the control period are from beginning to end Connected cycle period, the timing cycles are equally divided into multiple sub-periods;
Within a control period, the execution team of several sub-periods after the start time in control period is successively determined Column;
In a sub-period, the execution queue of the sub-period is taken out, and triggers all timing tune in the execution queue Degree.
Further, the duration of the timing cycles and the duration in the control period are preset fixed value;
Duration of the duration of the timing cycles not less than the control period;
The control period when an a length of sub-period duration integral multiple.
Further, the method also includes:
Determine start time point, the common starting point as timing cycles and control period.
Further, the execution queue for successively determining several sub-periods after the start time in control period, packet It includes:
When controlling the period and starting, first sub-period domestic demand timer-triggered scheduler to be generated that current time starts is determined, It puts it into the execution queue of the sub-period;
Successively determine second sub-period after first sub-period, third sub-period until n-th sub-period Execute queue;
The stopping when n is equal to the period of the day from 11 p.m. to 1 a.m segment number that the timing cycles are included.
Further, the timing cycles are realized by time wheel, and the duration of the timing cycles is time wheel length, The sub-period of the timing cycles is the grid of time wheel;
The then duration of the determining timing cycles and control period, comprising:
The initial time that time wheel is arranged is T0, and the time takes turns a length of T Δ, and indicates the finger of time wheel for seasonable with Tp Between.
Further, the execution queue for successively determining several sub-periods after the start time in control period, packet It includes:
At the T0 moment, start the control thread that a duration is Td, and every the Td time, all starting is primary continues Time is the control thread of Td;Wherein Td is the duration for controlling the period;
The control thread calculates the timer-triggered scheduler that each trigger needs to generate in T delta time;
The control thread successively calculates each time triggered time of each trigger in T delta time, and each timing is adjusted Degree is put into corresponding time wheel grid.
Further, the method also includes:
Every the Td time, starts the control thread that a duration is Td, form new trigger timer-triggered scheduler.
Further, the execution queue for taking out the sub-period, and all timer-triggered schedulers in the execution queue are triggered, Include:
When grid one lattice of advance that the pointer Tp of time wheel takes turns along the time, all execution queues in current grid are checked Wheel number;
It takes out wheel number and is equal to time wheel when the execution queue of front-wheel number, and take out these all timings executed in queue and adjust Degree is triggered.
Further, the method also includes:
If it find that wheel number is less than the execution queue that time wheel works as front-wheel number, then these are executed into queue according to MisFire Strategy is handled.
Further, grid one lattice of advance that the pointer Tp of the time wheel takes turns along the time, comprising:
When initialization, Tp=Tc is enabled, wherein Tc is current time;
By a timing thread, every pointer one lattice of advance of a regular time Ts traveling time wheel, and Tp is enabled =Tp+Ts, wherein Tc is the duration of a grid.
Further, the method also includes:
The time wheel is int ((Tc-T0)/T Δ) when front-wheel number;
It is int ((Tp-T0) %T Δ) that the pointer of the time wheel, which corresponds to grid,.
Further, the method also includes:
Whether consistent compare Tc and Tp;
If Tp lags behind Tc, Tp is adjusted to current time Tc, and wheel number will be corresponded in all grid of leap The timer-triggered scheduler executed in queue takes out and triggers;
If Tp is faster than Tc, suspends and update Tp, restores to update when waiting Tc consistent with Tp.
According to the second aspect of the embodiment of the present application, a kind of trigger device of timer-triggered scheduler is provided, comprising:
Period determination module, for determining timing cycles and controlling the duration in period, wherein timing cycles and described Controlling the period is end to end cycle period, and the timing cycles are equally divided into multiple sub-periods;
Queue determining module was used within a control period, if after successively determining the start time in control period The execution queue of dry sub-period;
Trigger module, for taking out the execution queue of the sub-period, and trigger in the execution queue in a sub-period All timer-triggered schedulers.
According to the third aspect of the embodiment of the present application, provide a kind of calculating equipment, the calculating equipment include: processor and Memory;
The memory is for storing computer program instructions;
When the calculating equipment is run, the processor executes the computer program instructions in the memory, to execute The operating procedure of any method as described above.
Embodiments herein provide technical solution have it is following the utility model has the advantages that
The scheme of the application by way of it will need the time point run to generate related operation data in advance recently, in machine In the case that device resource requirement is extremely low, a large amount of timing operation functions can be supported, while guaranteeing to trigger low delay;It solves more Handover overhead existing for thread, a large amount of timing be unbalanced to cause thread utilization rate not high and timing form supports single etc. ask Topic.
It should be understood that above general description and following detailed description be only it is exemplary and explanatory, not The application can be limited.
Detailed description of the invention
The drawings herein are incorporated into the specification and forms part of this specification, and shows the implementation for meeting the application Example, and together with specification it is used to explain the principle of the application.
Fig. 1 is a kind of flow chart of the triggering method of timer-triggered scheduler shown according to an exemplary embodiment.
Fig. 2 is the schematic diagram of time wheel algorithm shown according to an exemplary embodiment.
Fig. 3 is a kind of algorithm schematic diagram of scheduling scheme shown according to an exemplary embodiment.
Fig. 4 is the status diagram after state shown in Fig. 3 is run 5 seconds.
Fig. 5 is the status diagram after state shown in Fig. 3 is run 15 seconds.
Fig. 6 is a kind of circuit block diagram of the trigger device of timer-triggered scheduler shown according to an exemplary embodiment.
Specific embodiment
Example embodiments are described in detail here, and the example is illustrated in the accompanying drawings.Following description is related to When attached drawing, unless otherwise indicated, the same numbers in different drawings indicate the same or similar elements.Following exemplary embodiment Described in embodiment do not represent all embodiments consistent with the application.On the contrary, they be only with it is such as appended The example of the consistent method and apparatus of some aspects be described in detail in claims, the application.
Fig. 1 is a kind of flow chart of the triggering method of timer-triggered scheduler shown according to an exemplary embodiment.This method packet Include following steps:
Step S1: determining timing cycles and controls the duration in period, wherein the timing cycles and the control period are equal For end to end cycle period, the timing cycles are equally divided into multiple sub-periods;
Step S2: within a control period, several sub-periods after the start time in control period are successively determined Execute queue;
Step S3: in a sub-period, taking out the execution queue of the sub-period, and triggers all in the execution queue Timer-triggered scheduler.
This method is a kind of under the requirement of timer-triggered scheduler enormous amount, guarantees the method for the scheduling triggering of efficient stable.
The scheme of the application by way of it will need the time point run to generate related operation data in advance recently, in machine In the case that device resource requirement is extremely low, a large amount of timing operation functions can be supported, while guaranteeing to trigger low delay;It solves more Handover overhead existing for thread, a large amount of timing be unbalanced to cause thread utilization rate not high and timing form supports single etc. ask Topic.
In some embodiments, the duration in the duration of the timing cycles and the control period is preset fixed value;
Duration of the duration of the timing cycles not less than the control period;
The control period when an a length of sub-period duration integral multiple.
In some embodiments, the method also includes:
Determine start time point, the common starting point as timing cycles and control period.
In some embodiments, the execution team for successively determining several sub-periods after the start time in control period Column, comprising:
When controlling the period and starting, first sub-period domestic demand timer-triggered scheduler to be generated that current time starts is determined, It puts it into the execution queue of the sub-period;
Successively determine second sub-period after first sub-period, third sub-period until n-th sub-period Execute queue;
The stopping when n is equal to the period of the day from 11 p.m. to 1 a.m segment number that the timing cycles are included.
Below with reference to concrete implementation mode, expansion explanation is carried out to the scheme of the application.
As a kind of embodiment of the application, it can be taken turns and be calculated by the time based on Redis and support Cron timing form Method realizes the program.From basal latency wheel algorithm, the dependency structure that algorithm is related to is deposited by cache Redis Storage and calculating meet high availability again, while meet algorithm relevant operation by Redis characteristic while realizing supercomputing Idempotent characteristic uses to extend.
The time point for needing to run recently by calculating Cron expression formula generates the mode of related operation data, In in advance In the case that machine resources requirement is extremely low, a large amount of timing operation functions can be supported, while guaranteeing to trigger low delay.
By being then based on Redis design, avoids and only may be because that the timer-triggered scheduler that delay machine causes is lost in memory operation Problem, high availability have obtained very big guarantee.
In some embodiments, the timing cycles are realized by time wheel, and the duration of the timing cycles is the time Wheel length, the sub-period of the timing cycles are the grid of time wheel;
The then duration of the determining timing cycles and control period, comprising:
The initial time that time wheel is arranged is T0, and the time takes turns a length of T Δ, and indicates the finger of time wheel for seasonable with Tp Between.
Referring to Fig. 2, the condition that the time takes turns algorithm is as follows:
1. giving an initial time T0, the designated time takes turns a length of T Δ, and current time indicates that the next time uses Tn with Tc It indicates, time wheel pointer corresponds to the time to be indicated with Tp;
2. taking turns number calculates formula: int ((Tc-T0)/T Δ);
3. time wheel pointer corresponds to grid and calculates formula: int ((Tp-T0) %T Δ);
4. program initialization is seasonal: Tp=Tc.
Program execution flow is as follows:
1. be less than the timed thread of T Δ using a cycle, after blocking current time Tc out in slave flipflop SortedSet The trigger of T Δ second generates timer-triggered scheduler insertion time wheel lattice according to the next triggered time TrigTn and frequency of the trigger In the corresponding wheel number queue of son and the next triggered time is updated, is calculated repeatedly until TrigTn > Tc+T Δ;
2. constantly advancing a lattice using thread by sleep (1s) traveling time wheel pointer, and Tp=Tp+1 is enabled, so The corresponding whole timer-triggered schedulers of the wheel number queue in corresponding grid are taken out afterwards to issue.
The control method of program is as follows:
1. thread-safe controls, by comparing initial value when calculating next triggered time update in a program into Redis Atomic update is carried out, wheel number counter structure can prevent from being repeatedly inserted into Set;
2. whether Tc and Tp is compared in time deviation amendment consistent, if backwardness settles to current time, and from present to Just now the example taking-up in the corresponding wheel number queue of all grid crossed over issues;If fast do not change the lower 1s such as Tp;
3. delay machine restore after need current pointer forward T Δ lattice it is corresponding wheel number queue < when front-wheel number whole processing (can continue by corresponding MisFire strategy is discardable).
It is as follows that trigger starts over control rule of the time in time wheel:
1. when newly-increased, the time started≤current end time time and > current time, will sentence when being inserted into Redis It is disconnected;
2. when modification, the time started≤current end time time and > current time, will sentence when being inserted into Redis It is disconnected, if there is without operation when trigger in handling time wheel in Redis structure, if there is no needing to relay Enter, the operation that data are related in this modification Redis needs to guarantee atomicity with Lua script;
3. restore, first judge at the beginning of trigger and the end time whether meet section it is regular (time started≤ Time and end time > current time at present), meet section rule and trigger is restored in time wheel trigger structure, no Satisfaction is not restored;
4. when processing, if current triggered time≤current time next time, needs to handle MisFire strategy, if counted again The next triggered time of calculation is greater than the end time, directly trigger is taken turns from the time place deletion for placing trigger.
In some embodiments, the execution team for successively determining several sub-periods after the start time in control period Column, comprising:
At the T0 moment, start the control thread that a duration is Td, and every the Td time, all starting is primary continues Time is the control thread of Td;Wherein Td is the duration for controlling the period;
The control thread calculates the timer-triggered scheduler that each trigger needs to generate in T delta time;
The control thread successively calculates each time triggered time of each trigger in T delta time, and each timing is adjusted Degree is put into corresponding time wheel grid.
In some embodiments, the method also includes:
Every the Td time, starts the control thread that a duration is Td, form new trigger timer-triggered scheduler.
In some embodiments, the execution queue for taking out the sub-period, and trigger all timings in the execution queue Scheduling, comprising:
When grid one lattice of advance that the pointer Tp of time wheel takes turns along the time, all execution queues in current grid are checked Wheel number;
It takes out wheel number and is equal to time wheel when the execution queue of front-wheel number, and take out these all timings executed in queue and adjust Degree is triggered.
In some embodiments, the method also includes:
If it find that wheel number is less than the execution queue that time wheel works as front-wheel number, then these are executed into queue according to MisFire Strategy is handled.
In some embodiments, grid one lattice of advance that the pointer Tp of time wheel take turns along the time, comprising:
When initialization, Tp=Tc is enabled, wherein Tc is current time;
By a timing thread, every pointer one lattice of advance of a regular time Ts traveling time wheel, and Tp is enabled =Tp+Ts, wherein Tc is the duration of a grid.
In some embodiments, the method also includes:
The time wheel is int ((Tc-T0)/T Δ) when front-wheel number;
It is int ((Tp-T0) %T Δ) that the pointer of the time wheel, which corresponds to grid,.
In some embodiments, the method also includes:
Whether consistent compare Tc and Tp;
If Tp lags behind Tc, Tp is adjusted to current time Tc, and wheel number will be corresponded in all grid of leap The timer-triggered scheduler executed in queue takes out and triggers;
If Tp is faster than Tc, suspends and update Tp, restores to update when waiting Tc consistent with Tp.
For the technical solution that the application is described in further detail, it is illustrated in conjunction with specific application scenarios.
Referring to Fig. 3, the schematic diagram of a specific time wheel is given in figure.The time, wheel length was 8 seconds in figure, Mei Gege Son 1 second.Operational process is as follows:
1. Tp is directed toward 0 lattice using T0 as starting point, trigger SortedSet starts the control line of a timing 5s with the T0 moment Journey (Td=5s), start calculate trig1, the trigger timer-triggered scheduler that two triggers of trig2 should generate in T delta time, The position of the next triggered time promotion trigger of calculating is more than Tc+T Δ until the next triggered time of trigger repeatedly, while right Just now each time point trigger timer-triggered scheduler generated is put into the specified grid of time wheel.
2. every 1s, Tp gos ahead a lattice along time wheel grid, if it find that there is wheel number to be equal to the queue when front-wheel number, The whole timer-triggered schedulers then taken out in queue are triggered, and are carried out when front-wheel number by MisFire strategy if wheel number is less than Reason.
Referring to Fig. 4, after 5s, last control thread terminates, and program continues to run:
3. continue the operation of step 1 after the control thread of 5s reaches runing time point, start new control thread, And form new trigger timer-triggered scheduler.
4.Tp pointer continues to go ahead a lattice every 1s, and the operation carried out is identical as step 2.
Referring to Fig. 5, in one cycle, the trigger timing on whole triggers of above-mentioned generation and the time passed by wheel Scheduling opens the reciprocation cycle operation in new period again after from the 15s of starting.
In actual use, the scheme of the application and the performance comparison of other schemes are as follows:
Fig. 6 is a kind of circuit block diagram of the trigger device of timer-triggered scheduler shown according to an exemplary embodiment.Referring to figure 6, which includes:
Period determination module 601, for determine timing cycles and control the period duration, wherein the timing cycles and The control period is end to end cycle period, and the timing cycles are equally divided into multiple sub-periods;
Queue determining module 602, within a control period, after successively determining the start time in control period The execution queue of several sub-periods;
Trigger module 603, for taking out the execution queue of the sub-period, and trigger the execution team in a sub-period All timer-triggered schedulers in column.
About the device in above-described embodiment, wherein modules execute the specific steps of operation in related this method Embodiment in be described in detail, no longer elaborate explanation herein.
The application also provides following embodiment:
A kind of calculating equipment, the calculating equipment includes: processor and memory;
The memory is for storing computer program instructions;
When the calculating equipment is run, the processor executes the computer program instructions in the memory, to execute The operating procedure of any method as described above.
It is understood that same or similar part can mutually refer in the various embodiments described above, in some embodiments Unspecified content may refer to the same or similar content in other embodiments.
It should be noted that term " first ", " second " etc. are used for description purposes only in the description of the present application, without It can be interpreted as indication or suggestion relative importance.In addition, in the description of the present application, unless otherwise indicated, the meaning of " multiple " Refer at least two.
Any process described otherwise above or method description are construed as in flow chart or herein, and expression includes It is one or more for realizing specific logical function or process the step of executable instruction code module, segment or portion Point, and the range of the preferred embodiment of the application includes other realization, wherein can not press shown or discussed suitable Sequence, including according to related function by it is basic simultaneously in the way of or in the opposite order, Lai Zhihang function, this should be by the application Embodiment person of ordinary skill in the field understood.
It should be appreciated that each section of the application can be realized with hardware, software, firmware or their combination.Above-mentioned In embodiment, software that multiple steps or method can be executed in memory and by suitable instruction execution system with storage Or firmware is realized.It, and in another embodiment, can be under well known in the art for example, if realized with hardware Any one of column technology or their combination are realized: having a logic gates for realizing logic function to data-signal Discrete logic, with suitable combinational logic gate circuit specific integrated circuit, programmable gate array (PGA), scene Programmable gate array (FPGA) etc..
Those skilled in the art are understood that realize all or part of step that above-described embodiment method carries It suddenly is that relevant hardware can be instructed to complete by program, the program can store in a kind of computer-readable storage medium In matter, which when being executed, includes the steps that one or a combination set of embodiment of the method.
It, can also be in addition, can integrate in a processing module in each functional unit in each embodiment of the application It is that each unit physically exists alone, can also be integrated in two or more units in a module.Above-mentioned integrated mould Block both can take the form of hardware realization, can also be realized in the form of software function module.The integrated module is such as Fruit is realized and when sold or used as an independent product in the form of software function module, also can store in a computer In read/write memory medium.
Storage medium mentioned above can be read-only memory, disk or CD etc..
In the description of this specification, reference term " one embodiment ", " some embodiments ", " example ", " specifically show The description of example " or " some examples " etc. means specific features, structure, material or spy described in conjunction with this embodiment or example Point is contained at least one embodiment or example of the application.In the present specification, schematic expression of the above terms are not Centainly refer to identical embodiment or example.Moreover, particular features, structures, materials, or characteristics described can be any One or more embodiment or examples in can be combined in any suitable manner.
Although embodiments herein has been shown and described above, it is to be understood that above-described embodiment is example Property, it should not be understood as the limitation to the application, those skilled in the art within the scope of application can be to above-mentioned Embodiment is changed, modifies, replacement and variant.

Claims (10)

1. a kind of triggering method of timer-triggered scheduler characterized by comprising
It determines timing cycles and controls the duration in period, wherein the timing cycles and the control period are to join end to end Cycle period, the timing cycles are equally divided into multiple sub-periods;
Within a control period, the execution queue of several sub-periods after the start time in control period is successively determined;
In a sub-period, the execution queue of the sub-period is taken out, and triggers all timer-triggered schedulers in the execution queue.
2. the method according to claim 1, wherein it is described successively determine the start time in control period after The execution queue of several sub-periods, comprising:
When controlling the period and starting, first sub-period domestic demand timer-triggered scheduler to be generated that current time starts is determined, by it It is put into the execution queue of the sub-period;
Successively determine first sub-period after second sub-period, third sub-period until n-th of sub-period execution Queue;
The stopping when n is equal to the period of the day from 11 p.m. to 1 a.m segment number that the timing cycles are included.
3. method according to claim 1 or 2, which is characterized in that the timing cycles are realized by time wheel, described The duration of timing cycles is time wheel length, and the sub-period of the timing cycles is the grid of time wheel;
The then duration of the determining timing cycles and control period, comprising:
The initial time that time wheel is arranged is T0, and the time takes turns a length of T Δ, and indicates that the time pointer of wheel corresponds to the time with Tp.
4. according to the method described in claim 3, it is characterized in that, it is described successively determine the start time in control period after The execution queue of several sub-periods, comprising:
At the T0 moment, start the control thread that a duration is Td, and every the Td time, all starts a duration For the control thread of Td;Wherein Td is the duration for controlling the period;
The control thread calculates the timer-triggered scheduler that each trigger needs to generate in T delta time;
The control thread successively calculates each time triggered time of each trigger in T delta time, and each timer-triggered scheduler is put Enter in corresponding time wheel grid.
5. according to the method described in claim 3, it is characterized in that, it is described take out the sub-period execution queue, and trigger should Execute all timer-triggered schedulers in queue, comprising:
When grid one lattice of advance that the pointer Tp of time wheel takes turns along the time, the wheel of all execution queues in current grid is checked Number;
Take out wheel number be equal to the time wheel work as front-wheel number execution queue, and take out these execute queues in whole timer-triggered schedulers into Row triggering.
6. according to the method described in claim 5, it is characterized by further comprising:
If it find that wheel number is less than the execution queue that time wheel works as front-wheel number, then these are executed into queue according to MisFire strategy It is handled.
7. according to the method described in claim 5, it is characterized in that, before the grid that the pointer Tp of time wheel took turns along the time Into a lattice, comprising:
When initialization, Tp=Tc is enabled, wherein Tc is current time;
By a timing thread, every pointer one lattice of advance of a regular time Ts traveling time wheel, and Tp=Tp+ is enabled Ts, wherein Tc is the duration of a grid.
8. the method according to the description of claim 7 is characterized in that further include:
The time wheel is int ((Tc-T0)/T Δ) when front-wheel number;
It is int ((Tp-T0) %T Δ) that the pointer of the time wheel, which corresponds to grid,.
9. the method according to the description of claim 7 is characterized in that further include:
Whether consistent compare Tc and Tp;
If Tp lags behind Tc, Tp is adjusted to current time Tc, and the execution for wheel number being corresponded in all grid of leap Timer-triggered scheduler in queue takes out and triggers;
If Tp is faster than Tc, suspends and update Tp, restores to update when waiting Tc consistent with Tp.
10. a kind of calculating equipment, which is characterized in that the calculating equipment includes: processor and memory;
The memory is for storing computer program instructions;
When the calculating equipment is run, the processor executes the computer program instructions in the memory, with perform claim It is required that the operating procedure of any one of 1 to 9 the method.
CN201910628452.7A 2019-07-12 2019-07-12 Triggering method and device for timing scheduling Active CN110502322B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910628452.7A CN110502322B (en) 2019-07-12 2019-07-12 Triggering method and device for timing scheduling

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910628452.7A CN110502322B (en) 2019-07-12 2019-07-12 Triggering method and device for timing scheduling

Publications (2)

Publication Number Publication Date
CN110502322A true CN110502322A (en) 2019-11-26
CN110502322B CN110502322B (en) 2022-07-12

Family

ID=68585202

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910628452.7A Active CN110502322B (en) 2019-07-12 2019-07-12 Triggering method and device for timing scheduling

Country Status (1)

Country Link
CN (1) CN110502322B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111309467A (en) * 2020-02-24 2020-06-19 拉扎斯网络科技(上海)有限公司 Task distribution method and device, electronic equipment and storage medium
CN112650566A (en) * 2020-12-21 2021-04-13 曙光信息产业股份有限公司 Timed task processing method and device, computer equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8275976B2 (en) * 2005-08-29 2012-09-25 The Invention Science Fund I, Llc Hierarchical instruction scheduler facilitating instruction replay
CN104951282A (en) * 2015-05-21 2015-09-30 中国人民解放军理工大学 Timer management system and method
CN105760378A (en) * 2014-12-15 2016-07-13 阿里巴巴集团控股有限公司 Transaction state monitor method and device
CN107797465A (en) * 2016-09-06 2018-03-13 北京百度网讯科技有限公司 Monitoring method and device
CN108337185A (en) * 2017-01-20 2018-07-27 谷歌有限责任公司 The device and method of scalable traffic shaping with time index data structure

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8275976B2 (en) * 2005-08-29 2012-09-25 The Invention Science Fund I, Llc Hierarchical instruction scheduler facilitating instruction replay
CN105760378A (en) * 2014-12-15 2016-07-13 阿里巴巴集团控股有限公司 Transaction state monitor method and device
CN104951282A (en) * 2015-05-21 2015-09-30 中国人民解放军理工大学 Timer management system and method
CN107797465A (en) * 2016-09-06 2018-03-13 北京百度网讯科技有限公司 Monitoring method and device
CN108337185A (en) * 2017-01-20 2018-07-27 谷歌有限责任公司 The device and method of scalable traffic shaping with time index data structure

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
把生命浪费在美好事物上: "时间轮算法解析(Netty HashedWheelTimer源码解读)", 《HTTPS://SQ.SF.163.COM/BLOG/ARTICLE/177510753845874688》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111309467A (en) * 2020-02-24 2020-06-19 拉扎斯网络科技(上海)有限公司 Task distribution method and device, electronic equipment and storage medium
CN111309467B (en) * 2020-02-24 2023-07-14 拉扎斯网络科技(上海)有限公司 Task distribution method and device, electronic equipment and storage medium
CN112650566A (en) * 2020-12-21 2021-04-13 曙光信息产业股份有限公司 Timed task processing method and device, computer equipment and storage medium
CN112650566B (en) * 2020-12-21 2022-03-22 曙光信息产业股份有限公司 Timed task processing method and device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN110502322B (en) 2022-07-12

Similar Documents

Publication Publication Date Title
CN106293919B (en) A kind of the built-in tasks dispatching device and method of time trigger
Baker et al. The cyclic executive model and Ada
CN111813552B (en) Scheduling execution method, device and medium based on multi-thread task
CN101339521B (en) Tasks priority dynamic dispatching algorithm
CN104536835B (en) Self-adapting task scheduling method in a kind of Hot Spare real-time control system
US9268526B2 (en) Dual-buffer serialization and consumption of variable-length data records produced by multiple parallel threads
US20150293787A1 (en) Method For Scheduling With Deadline Constraints, In Particular In Linux, Carried Out In User Space
CN110502322A (en) The triggering method and device of timer-triggered scheduler
EP2839370A1 (en) Time slack application pipeline balancing for multi/many-core plcs
CN106445659B (en) A kind of spacecraft periodically blendes together Random Task dispatching method
US20150339256A1 (en) Inter-processor synchronization system
US8225320B2 (en) Processing data using continuous processing task and binary routine
CN108563494A (en) A kind of thread scheduling system and method for adaptive dynamic adjustment
US20020010732A1 (en) Parallel processes run scheduling method and device and computer readable medium having a parallel processes run scheduling program recorded thereon
Nahas et al. Ways for implementing highly-predictable embedded systems using time-triggered co-operative (TTC) architectures
US20220300322A1 (en) Cascading of Graph Streaming Processors
CN110457120A (en) Aperiodic timer based on OSEK embedded real-time operating system is resident mechanism
CN108427606B (en) Time slice management and control device for scheduling connection and information exchange of motion controller and servo shaft
Wan et al. A predictable servant-based execution model for safety-critical systems
JP2004171167A (en) Multiprocessor computer and program
CN110109743B (en) Real-time process scheduling method
KR101083049B1 (en) Simulation system and simulation method
JPH11327928A (en) Computer-readable recording medium where real-time application support program is recorded, and computer system
Tripathi et al. Pre-scheduling for synchronization in hard real-time systems
CN103345426B (en) A kind of concurrent process processing method of non-real time operating system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP03 Change of name, title or address
CP03 Change of name, title or address

Address after: No.1-1 Suning Avenue, Xuzhuang Software Park, Xuanwu District, Nanjing, Jiangsu Province, 210000

Patentee after: Jiangsu Suning cloud computing Co.,Ltd.

Address before: No.1-1 Suning Avenue, Xuzhuang Software Park, Xuanwu District, Nanjing, Jiangsu Province, 210000

Patentee before: Suning Cloud Computing Co.,Ltd.

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20240108

Address after: 210000, 1-5 story, Jinshan building, 8 Shanxi Road, Nanjing, Jiangsu.

Patentee after: SUNING.COM Co.,Ltd.

Address before: No.1-1 Suning Avenue, Xuzhuang Software Park, Xuanwu District, Nanjing, Jiangsu Province, 210000

Patentee before: Jiangsu Suning cloud computing Co.,Ltd.