CN108021439A - A kind of task polling method, task arrangement method and relevant apparatus - Google Patents

A kind of task polling method, task arrangement method and relevant apparatus Download PDF

Info

Publication number
CN108021439A
CN108021439A CN201610942962.8A CN201610942962A CN108021439A CN 108021439 A CN108021439 A CN 108021439A CN 201610942962 A CN201610942962 A CN 201610942962A CN 108021439 A CN108021439 A CN 108021439A
Authority
CN
China
Prior art keywords
queue
task
time
poll
decay 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.)
Granted
Application number
CN201610942962.8A
Other languages
Chinese (zh)
Other versions
CN108021439B (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.)
Alibaba Cloud Computing Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201610942962.8A priority Critical patent/CN108021439B/en
Publication of CN108021439A publication Critical patent/CN108021439A/en
Application granted granted Critical
Publication of CN108021439B publication Critical patent/CN108021439B/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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5038Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Telephonic Communication Services (AREA)

Abstract

The embodiment of the invention discloses a kind of task polling method, task arrangement method and relevant apparatus, multiple queues for task of arranging are set in computer systems, the decay time for task of arranging in queue meets the time interval corresponding to the queue, what it is for queue institute poll is only task in this queue, so once needing the quantity of polling tasks obviously fewer than traditional approach.For the first queue in the plurality of queue, according to the task in the polling cycle poll first queue of first queue, and calculate the decay time for the task that is polled to, if the decay time for being polled to first task is in the corresponding time interval of second queue, then first task is taken out from first queue and is arranged into the less second queue of polling cycle, it can arrange when the decay time of first task is shorter to the shorter second queue of polling cycle, by more frequent poll to improve the possibility that can be performed in time when the decay time of first task is zeroed.

Description

A kind of task polling method, task arrangement method and relevant apparatus
Technical field
The present invention relates to data processing field, more particularly to a kind of task polling method, task arrangement method and correlation Device.
Background technology
In computer system, some business need to realize in some following scheduled time, such as in the daily fixed period Pushed information, particular point in time or date reach the standard grade some activity descriptions etc..If relying on manual type merely, the scheduled time is waited This kind of business is implemented by computer system during arrival, very high cost and uncertainty can be brought.
Traditional way is to be delayed using the task with delay character being pre-created, this generic task when can set Between, such as 10 seconds, 10 minutes, 10 days etc..Decay time can be shortened as time go in a manner of countdown, such as 0 The decay time that a task is created during the moment is 10 seconds, then behind the 8 of 0 moment second, the decay time of this task will be changed into 10-8=2 seconds.Due to decay time, thus this generic task when creating can't at once performed by computer system, and It is to be performed when waiting decay time zero.Specifically, computer system is by monitoring the decay time of this generic task, one Transfer automatically during the decay time zero of a task and perform this task, so as to realize that its is corresponding by performing this task Business.
This kind of task with delay character is generally uniformly stored in a storage region by computer system, and with week Whether the task in the poll of the phase property storage region, the decay time that being polled to for task is calculated during poll have returned Zero, and the task of execution time delay time zero.
But the problem of this task polling mode, is, in order to ensure as far as possible all tasks with delay character when It can be monitored to, it is necessary to which computer system will be stored in the storage region in each polling cycle when being zeroed between delay All task whole polls one time, and in view of the decay time of some tasks is shorter so that the polling cycle of computer system Need accordingly to set it is shorter so that cause computer system needs under short time interval repeat the substantial amounts of task of poll, So that polling tasks consume substantial amounts of system resource, computer system performance have impact on.
The content of the invention
In order to solve the above technical problem, the present invention provides a kind of task polling method, task arrangement method and correlation Device, reduces the quantity of a polling tasks, avoids the longer task of frequent poll decay time, improves system resource Utilization rate.
The embodiment of the invention discloses following technical solution:
In a first aspect, the present invention provides a kind of task polling method, applied to computer system, the computer system In be provided with multiple queues with corresponding time interval, each queue in the multiple queue is used for decay time symbol of arranging The task of time interval corresponding to conjunction, the multiple queue include at least first queue and second queue, the first queue Polling cycle is more than the polling cycle of the second queue, the described method includes:
According to arranging in first queue described in the polling cycle poll of the first queue for task;
Calculate the decay time for the task that is polled to;
Time interval residing for the decay time for the task that judgement is polled to;Wherein, the time delay of first task is being judged During time interval residing for the time, the first task is a task in first queue institute arrangement task;
If the decay time of the first task is in the time interval corresponding to the second queue, by described first Task is taken out from the first queue, and arranges into the second queue.
Optionally, the time interval residing for the decay time for judging first task, further includes:
If the decay time of the first task is less than or equal to 0, the first task is taken out from the first queue, And perform the first task.
Optionally, the corresponding time interval of first queue time interval corresponding with the second queue is not overlapping.
Optionally, arranging in first queue described in the polling cycle poll according to the first queue for task, bag Include:
For the second task setting flag, second task is the be polled in the polling cycle of the first queue One task;
After complete second task of poll, by the tail of the queue of second task arrangement to the first queue;
According to the task in queue distributing order successively first queue described in poll, and by this after the complete task of poll Tail of the queue of a task arrangement to the first queue;
When being polled to second task with the mark, cancel the mark of second task and terminate to take turns Ask.
Optionally, described is the second task setting flag, is further included:
Second moment was saved in second task, second moment is to pass through the first moment and the first team The polling cycle of row determines, at the time of first moment is marks second task;
It is described when being polled to second task with the mark, further include:
Second moment is obtained from second task;
At the time of determining to be polled the first queue according to the 3rd moment and second moment next time, institute It is at the time of being polled to second task with the mark to state for the 3rd moment.
Optionally, arranging in first queue described in the polling cycle poll according to the first queue for task it Before, further include:
Judge whether be placed with task in the first queue;
If not arranging task, performed again described in the judgement after waiting the polling cycle of a first queue Whether task is placed with first queue.
Optionally, the queue type of the multiple queue includes setting memory queue in memory, is arranged in disk Document queue, combination any one or more in the queue of list structure form in the database is set.
Optionally, memory queue of the shortest queue of polling cycle for setting in memory in the multiple queue.
Optionally, the method further includes:
The 3rd task is obtained, the 3rd task is the task with decay time;
By the 3rd task arrangement into the 3rd queue in the multiple queue, the decay time of the 3rd task In the corresponding time interval of the 3rd queue.
Second aspect, the present invention provides a kind of task polling set-up, applied to computer system, the computer system In be provided with multiple queues with corresponding time interval, each queue in the multiple queue is used for decay time symbol of arranging The task of time interval corresponding to conjunction, the multiple queue include at least first queue and second queue, the first queue Polling cycle is more than the polling cycle of the second queue, and described device includes poll units, computing unit, judging unit and row Cloth unit:
The poll units, appoint for what is arranged in first queue described in the polling cycle poll according to the first queue Business;
The computing unit, for calculating the decay time for the task that is polled to;
The judging unit, for the time interval residing for the decay time for the judging to be polled to of the task;Wherein, sentencing During time interval residing for the decay time of disconnected first task, the first task is in first queue institute arrangement task One task;If the decay time of the first task is in the time interval corresponding to the second queue, described in triggering Arrangement unit;
The arrangement unit, for the first task to be taken out from the first queue, and arranges and arrives described second In queue.
Optionally, it is described first that the poll units, which are additionally operable to as the second task setting flag, second task, First task being polled in the polling cycle of queue;After complete second task of poll, second task arrangement is arrived The tail of the queue of the first queue;According to the task in queue distributing order successively first queue described in poll, and in poll complete one This task is arranged to the tail of the queue of the first queue after a task;When being polled to second task with the mark When, cancel the mark of second task and terminate poll.
Optionally, the poll units are additionally operable to the second moment being saved in second task, second moment To be determined by the polling cycle at the first moment and the first queue, first moment for mark second task when Carve;Second moment is obtained from second task;It is next time right to be determined according to the 3rd moment and second moment At the time of the first queue is polled, the 3rd moment be second task with the mark that is polled to when Carve.
The third aspect, the present invention provides a kind of task arrangement method, applied to computer system, the computer system In be provided with multiple queues with corresponding time interval, each queue in the multiple queue is used for decay time of arranging Meet the task of time interval corresponding to this queue, the described method includes:
Acquisition task, the task are the task with decay time;
If the decay time of the task is in the corresponding time interval of object queue, the task is arranged to described In object queue, the object queue is a queue in the multiple queue.
Optionally, the multiple queue includes at least first queue and second queue, the polling cycle of the first queue More than the polling cycle of the second queue, the described method includes:
According to arranging in first queue described in the polling cycle poll of the first queue for task;
Calculate the decay time for the task that is polled to;
Time interval residing for the decay time for the task that judgement is polled to;Wherein, the time delay of first task is being judged During time interval residing for the time, the first task is a task in first queue institute arrangement task;
If the decay time of the first task is in the time interval corresponding to the second queue, by described first Task is taken out from the first queue, and arranges into the second queue.
Optionally, the queue type of the multiple queue includes setting memory queue in memory, is arranged in disk Document queue, combination any one or more in the queue of list structure form in the database is set.
Optionally, memory queue of the shortest queue of polling cycle for setting in memory in the multiple queue.
Fourth aspect, the present invention provides a kind of task arrangement apparatus, applied to computer system, the computer system In be provided with multiple queues with corresponding time interval, each queue in the multiple queue is used for decay time of arranging Meet the task of time interval corresponding to this queue, described device includes acquiring unit and arrangement unit:
The acquiring unit, for obtaining task, the task is the task with decay time;
The arrangement unit, will if the decay time for the task is in the corresponding time interval of object queue Into the object queue, the object queue is a queue in the multiple queue for the task arrangement.
Multiple queues for task of arranging, queue are set in computer systems it can be seen from above-mentioned technical proposal The decay time of middle arranged task meets the time interval corresponding to the queue, since decay time is in different time intervals Task be arranged in by scattered in different queue, therefore for queue institute poll be only task in this queue, institute The obvious once number for needing whole tasks in polling computer system than in traditional approach with the once quantity for needing polling tasks Amount will be lacked.For the first queue in the plurality of queue, according to the task in the polling cycle poll first queue of first queue, And the decay time for the task that is polled to is calculated, if the decay time for being polled to first task is in second queue in the plurality of queue In corresponding time interval, then first task is taken out from first queue and arrange to the less second queue of polling cycle In, it is seen then that it can be placed on when the decay time of first task is longer in the longer first queue of polling cycle, avoid frequent wheel First task is ask, has saved system resource.It can arrange when the decay time of first task is shorter shorter to polling cycle Second queue, by more frequent poll to improve the possibility that can be performed in time when the decay time of first task is zeroed Property.
Brief description of the drawings
In order to illustrate more clearly about the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing There is attached drawing needed in technology description to be briefly described, it should be apparent that, drawings in the following description are only this Some embodiments of invention, for those of ordinary skill in the art, without having to pay creative labor, may be used also To obtain other attached drawings according to these attached drawings.
Fig. 1 is the schematic diagram of the multiple queues set in a kind of computer system provided in an embodiment of the present invention;
Fig. 2 is a kind of flow chart of polling method provided in an embodiment of the present invention;
Fig. 3 is the method flow diagram of task in a kind of snoop queue provided in an embodiment of the present invention;
Fig. 4 is a kind of flow chart for determining the method at poll moment next time provided in an embodiment of the present invention;
Fig. 5 is a kind of flow chart by task arrangement to the method in queue provided in an embodiment of the present invention;
Fig. 6 is a kind of structure drawing of device of task polling set-up provided in an embodiment of the present invention;
Fig. 7 is a kind of method flow diagram of task arrangement method provided in an embodiment of the present invention;
Fig. 8 is a kind of structure drawing of device of task arrangement apparatus provided in an embodiment of the present invention.
Embodiment
To make the purpose, technical scheme and advantage of the embodiment of the present invention clearer, below in conjunction with the embodiment of the present invention In attached drawing, the technical solution in the embodiment of the present invention is explicitly described, it is clear that described embodiment be the present invention Part of the embodiment, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art are not having All other embodiments obtained under the premise of creative work are made, belong to the scope of protection of the invention.
In computer systems, the business realized for some needs in some following scheduled time, general solution party Case is to be pre-created the task with decay time, when the decay time of a task is zeroed by way of countdown, this A task will be performed, and corresponding business can be realized by performing this task.
In order to ensure that this generic task can be performed, it is necessary to be monitored by way of poll in time when decay time is zeroed The decay time of this generic task.However, unified preservation, unified poll are generally taken this generic task in traditional approach.Moreover, by May be shorter in the decay time of some tasks, cycle of unified poll also must be provided with it is very short, when appointing for unified storage When quantity of being engaged in is more, the substantial amounts of task of poll of computer system needs under short time interval repeatedly can be caused so that poll Task consumes substantial amounts of system resource, have impact on computer system performance.And since task quantity is more, it is also possible to lead Cause in a polling cycle can not complete one time of whole poll, such as the task of the unified storage of lane database has 10,000,000, if The polling cycle put is 10 seconds, that is, need every 10 second wheel to ask the once whole tasks stored, due to the processing speed of processor Performance bottleneck, it is assumed that can inquire about within 1 second most 500,000 datas, time of 10 seconds can only most 5,000,000 tasks of poll, just must It must start the poll of a new round, can so cause a part of task can not to be all polled in long-time so that some time delays The task that time has been zeroed, should perform is held off, and causes the accumulation of task, and business releases time delays.
For this reason, an embodiment of the present invention provides a kind of task polling method, task arrangement method and relevant apparatus, calculating Multiple queues for task of arranging are set in machine system, this multiple queue all has corresponding time interval, wherein each team The decay time for task of arranging in row meets the time interval corresponding to the queue, for example, this multiple queue include queue a, The corresponding time interval of queue b etc., queue a is 10 to 20 seconds, and the corresponding time intervals of queue b are 30 to 40 seconds, then queue a In can arrange task of the decay time between 10 to 20 seconds, decay time can be arranged in queue b between 30 to 40 seconds Task.It should be noted that also may be used in the computer system except the above-mentioned queue with corresponding time interval can be set To set the queue in other traditional approach.
Task of different time intervals is in due to decay time is arranged in different queue by scattered, therefore for one Queue institute poll is only task in this queue, so once needing the quantity of polling tasks obviously than in traditional approach one The secondary quantity for needing whole tasks in polling computer system will be lacked.Such as the scene for above-mentioned 10,000,000 tasks, setting In the case of having put multiple queues, this 10,000,000 tasks can be arranged in this each queue respectively according to rule, one of them Task quantity is generally less than 10,000,000 in queue, then when carrying out task poll for this queue, required poll is appointed Business can be less than task of poll is needed in traditional approach, can effectively reduce or even prevent to cause one due to not being polled in time The long-delayed problem of task that a little decay times have been zeroed, should perform.
For the first queue in the plurality of queue, appointing in the polling cycle poll first queue of first queue Business, and the decay time for the task that is polled to is calculated, if the decay time for being polled to first task is in second in the plurality of queue In the corresponding time interval of queue, then first task is taken out from first queue and arrange to less second team of polling cycle In row, it is seen then that can be placed in the longer first queue of polling cycle, be avoided frequently when the decay time of first task is longer Poll first task, has saved system resource.It can arrange when the decay time of first task is shorter shorter to polling cycle Second queue, by more frequent poll with improve the decay time of first task be zeroed when can be performed in time can Can property.
Before specifically technical scheme is introduced, the present invention is first introduced in multiple teams set by computer system Row.Computer system there is provided multiple queues can be the server of local computer or network side.According to difference Scene demand, the database, disk and memory that this these queue can be arranged on to computer system be any one or more Combination in.Set queue in the database can be for the queue of list structure form, the queue being arranged in disk can be Document queue, it can be memory queue to set queue in memory.The plurality of queue do not limit have to be arranged on it is same In a memory space, can a part of queue set in memory, a part of queue is arranged on equiprobable combination shape in disk Formula.Such as:When computer system includes queue 1, queue 2 and these three queues of queue 3, queue 1 can be arranged on interior In depositing, queue 2 is arranged in disk, queue 3 is set in the database.Except above-mentioned more common storage medium:It is interior Deposit, beyond disk and database, queue can also be arranged in other storage mediums.
The executive agent being polled to task in set multiple queues can be the processing module of computer system, Polling cycle by the processing module according to each queue, is responsible for the poll to task in each queue.It can also be each team Row distribute corresponding processing module to be respectively responsible for the poll of task in queue, can also several queues by same processing module To complete the poll of task.
After the shorter task of decay time is put into second queue, since the polling cycle of first queue is more than the second team The polling cycle of row, thus it is relatively frequent to the poll of the task in the second queue, since the read-write efficiency of memory will Higher than disk, database storage medium, therefore the shorter queue of polling cycle such as second queue can be set in memory, In order to improve the read-write efficiency to task in these queues.
Set multiple queues can be with as shown in Figure 1, by N number of queue of setting, can be by with decay time Task is arranged in this N number of queue respectively, and for a queue, the task of required poll, which can be less than in traditional approach, needs poll Task, can effectively reduce or even prevent to cause some decay times to be zeroed, should hold due to not being polled in time The long-delayed problem of capable task.
Above specify that has the function that the task of decay time, can realize one by creating this generic task A little business for needing to provide in the set time.15 points, 18 points, 23 points such as No. 20 are required to new business of reaching the standard grade, and are respectively business A, business b and business c, staff can be created at No. 20 12 decay time for 3 it is small when task a, 6 it is small when task Task c when b and 11 is small, corresponds to line service in above three respectively.The decay time of task can be reduced as the time elapses, Such as decay times of the task a when creating (when the moment is 0 second) is 180 minutes, after a hour after establishment, i.e. the moment is At 60 minutes, the decay time of task a will be changed into 180-60=120 minutes.After three hours after establishment, i.e. the moment is 180 During minute, the decay time of task a will be zeroed, and reach the condition being performed.
The multiple queues set have corresponding time interval respectively, for a queue in this multiple queue, this Queue can be used for the task that arrangement decay time meets time interval corresponding to this queue.Arrange in a queue task Mode can have forms a variety of, such as that task can be arranged into a queue, after the joining the team of the task be queued at the end of queue;Also may be used Task is arranged into an end to end circle queue.It should be noted that when there is no task in a queue, this Thus queue can't be not present, this queue can be an empty queue.
It is understood that the corresponding time interval of each queue can be partly overlapping or nonoverlapping. If two queues each for time interval between there is lap, then when being polled at the decay time of a task When this lap, it is also necessary to determine whether this task being arranged in the two queues in which queue, be Simple flow, improves efficiency, in the inventive solutions, optionally, the corresponding time interval of the first queue with The corresponding time interval of the second queue is not overlapping.For example, when computer system includes 6 queues, 6 queue difference Corresponding time interval is not overlapping.Wherein, the time interval of queue 1 is greater than 3200 seconds, and the time interval of queue 2 is more than or equal to 800 and less than 3200 seconds, i.e., do not include the timing node of 3200 seconds;The time interval of queue 3 is more than or equal to 200 seconds and is less than 800 seconds, i.e., the timing node of 800 seconds is not included;The time interval of queue 4 is more than or equal to 40 seconds and less than 200 seconds, i.e., does not include The timing node of 200 seconds;The time interval of queue 5 was more than or equal to 10 seconds and less than 40 second, i.e., does not include the timing node of 40 seconds. If during carrying out task poll to queue 1, the decay time of a task being polled to is 200 seconds, in queue 3 pair The time interval answered, this task can be taken out, arranged from queue 1 into queue 3.
As it can be seen that by for the different nonoverlapping time intervals of queue sets, ensure that after user submits a task, A corresponding queue can be determined according to the decay time of the task, it is not necessary to determine this by judgement or other mechanism again Queue corresponding to task, simplifies the process of task arrangement, shortens processing time.
Time interval corresponding to one queue be able to can arrange the foundation of task as this queue is judged.In order to as far as possible When avoiding being polled to task in a polling cycle of queue, the situation that the decay time of the task has been zeroed for a long time is sent out Raw, the time interval corresponding to the queue can be set according to the polling cycle of the queue.Such as corresponding to a queue Polling cycle is 40 seconds, if the task that a decay time is 30 seconds is arranged in this queue, it is likely that be polled to this During a task, the decay time of this task was just zeroed before 10 seconds, so as to cause the delay of task.Therefore this Polling cycle is that the time interval corresponding to the queue of 40 seconds could be provided as being more than 40 seconds, such as 40 seconds to 100 seconds, so arrange The decay time of cloth to the task in this queue is typically greater than the polling cycle of this queue.
Wherein, the polling cycle of a queue refers to the cycle being spaced between adjacent poll twice, a poll week It is interim, it is desirable to can be to the equal poll of task all in queue once.Such as the polling cycle corresponding to a queue is 40 seconds, Then by every 40 second hands this queue is performed it is once to this queue in task poll, such as when the moment is 0 second, start pair Task carries out first time poll in this queue, when being constantly 40 seconds, starts to carry out the second next round to task in this queue Ask, and so on.
First queue and second queue can be included at least in set multiple queues, the polling cycle of first queue can With the polling cycle more than second queue.
The polling cycle of each queue in set multiple queues can be different, can have as the case may be Body sets the polling cycle of each queue.Such as:When being provided with 5 queues in computer system, the polling cycle of 5 queues It can be respectively set as 3200 seconds, 800 seconds, 200 seconds, 40 seconds and 10 seconds.Wherein, first queue can be except polling cycle is One of other four queues beyond the queue of 10 seconds, second queue can be one smaller than the polling cycle of first queue A queue.
Next with reference to attached drawing 2, a kind of task polling method provided in an embodiment of the present invention is described in detail.
S101:According to arranging in first queue described in the polling cycle poll of the first queue for task.
For example, the present invention does not limit the polling mode to task in first queue, as long as can reach in poll By the effect of each task poll once in first queue in cycle.Polling mode for example can be with from queue successively The mode of extraction task realizes poll or randomly selects the mode poll of task.
Judge whether there is arrangement task in queue before poll, if it is not, waiting the time of a polling cycle. And within the time of the polling cycle, since operation need not be polled, reduce the resource consumption of computer system. Choosing, it can judge whether there is the task of arrangement in first queue, if having before the task in first queue is polled Task, can perform step S101, begin a task with poll.If not having arrangement task in first queue, an institute can be waited The polling cycle of first queue is stated, performs S101 again.
S102:Calculate the decay time for the task that is polled to.
Decay time refers to the remaining time that the task distance in each queue is performed, over time constantly Reduce, the decay time that this step calculates refers to that at the time of a task is polled to, this task is at this moment Poll time.For example, when the corresponding polling cycles of queue a are 20 seconds, if implement the first subtask poll to queue a, Task T is polled to, the decay time of task T is 38 seconds, can continue to be arranged in queue a.When the poll week according to queue a Phase, when implementing to be polled to task T again during the second subtask poll, since the corresponding polling cycles of queue a are 20 seconds, this When poll pass by time of the corresponding polling cycles of queue a, that is, 20 seconds when taking office business T, then task T is corresponded at this time Decay time be -20 seconds 38 seconds=18 seconds.As can be seen that the decay time of task T is to subtract over time and constantly Small, rather than a constant numerical value.
S103:Time interval residing for the decay time for the task that judgement is polled to, wherein, judging first task During time interval residing for decay time, the first task is a task in first queue institute arrangement task.
For example, first task is any one task in institute's arrangement task in first queue, it is of the invention and unlimited Determine specific arrangement position of the first task in first queue, can be task of queue heads are in first queue, can also Be in first queue in rear of queue task or first queue in other positions arrange task.
It should be noted that successively in the task process in poll first queue, when being polled to first task, it is possible to The decay time of first task has been zeroed, and is even less than 0, in the case of this, can be by the first task from described first Taken out in queue, and perform the first task.
It is easily understood that during polling tasks, it is possible that when being polled to task, the task quilt has just been arrived The time of execution, at this time, the decay time of the task are equal to 0, then take out the task from queue, and perform the task; It is possible that when being polled to task, the time that the task is performed is had been subjected to, at this time, the decay time of the task is less than 0 (falling within a situation being zeroed), then take out the task, and perform the task from queue.
The contents of the section is described further below by citing.
Select, be illustrated for the decay time of task equal to 0 situation about being performed first.For example, certain queue m Time interval is 800 seconds~3200 seconds, and the polling cycle of queue m is 800 seconds, the decay time of certain task N is 1600 seconds, And the foremost head of the queue of the queue is arranged in, when being polled to task N for the first time, the decay time of task N is 1600 seconds, In time interval in queue m, then still task N is still arranged in queue m, when one queue m's of process After the polling cycle time of 800 seconds, task N has been polled to again in queue m, the decay time of task N is at this time - 800 seconds 1600 seconds=800 seconds, it is still within the time interval of queue m, when being polled to task N next time, the time Pass by the time of the polling cycle of a queue m, i.e., the time of 800 seconds, then, should when being polled to task N at this time The decay time of task N is -800 seconds 800 seconds=0 second, then task N is taken out from queue m, and perform task N.
Secondly, it is illustrated for the decay time of task less than 0 situation about being performed.For example, certain queue p when Between section be less than 10 seconds, the polling cycle of queue p is 1 second, the decay time of certain task Q is 0.4 second, and task Q arrange The centre position of queue p either tail of the queue or last position are listed in, in a polling procedure, from the foremost of queue p It is 0.5 second that the task of head of the queue, which was polled to the time of task Q, and when being polled to task Q, the decay time of task Q is 0.4-0.5=-0.1 seconds, i.e., when task Q has been subjected to, then at this time, task Q is taken out, and perform task Q.
S104:If the decay time of the first task is in the time interval corresponding to the second queue, by institute State first task to take out from the first queue, and arrange into the second queue.
As time goes by, the decay time of first task is gradually reduced, in polling procedure, work as judgement When the time interval gone out corresponding to the decay time of first task is second queue, then first task is arranged to second queue In.
For example, the time interval of queue b is 200 seconds~400 seconds, polling cycle is 200 seconds, the time zone of queue c Between be 100 seconds to~199 seconds, polling cycle is 100 seconds, and the decay time of task M is 350 seconds, is arranged in queue b.First When being polled to task M, since the decay time of task M is 350 seconds, judge that the decay time of task M is in the time zone of queue b In, then still task M is arranged in queue b, when after the polling cycle of a queue b, the decay time of task M is - 200 seconds 350 seconds=150 seconds, at this time, judge that the time interval residing for the decay time of task M is the corresponding time zones of queue c Between, therefore, task M is taken out from queue b, and arranges into second queue.
It should also be noted that, after first task is taken out from first queue, arrange into second queue, do not limit First task specific arrangement position in second queue, can be that first task is arranged to the position of second queue head of the queue, First task can be arranged to the position of second queue tail of the queue, first task can also be arranged to second queue other One position of meaning.
The present invention does not limit the relation of first queue and second queue in set multiple queues.Second queue and One queue can be two adjacent queues of time interval, it is also possible to which non-conterminous two queues of time interval, this needs root Corresponding queue is determined according to the decay time of task, so that task be taken out, and is arranged into corresponding queue.With reference to tool Body citing further illustrates this point.
When being provided with 6 queues in computer system, 6 queues are corresponding with respective time interval respectively:Queue d's Time interval is greater than 3200 seconds, and the time interval of queue e is 800 seconds~3200 seconds, and the time interval of queue f is 200 seconds~ 800 seconds, the time interval of queue g was 40 seconds~200 seconds, and the time interval of queue h is 10 seconds~40 seconds, and the section of queue i is Less than 10 seconds.Assuming that when storage has the task of 3205 seconds, 3230 seconds, 3250 seconds, 3430 seconds and 4030 seconds successively in queue d, In first time poll, what is be polled to first was the task of 3205 seconds, due to 3205 seconds time intervals 3200 for being more than queue d Second, then the task is still arranged in queue d, correspondingly, the task of 3230 seconds, 3250 seconds, 3430 seconds and 4030 seconds due to when It is both greater than 3200 seconds between delay, so being still arranged in queue d.When being polled to the task of 3205 seconds for the second time in queue d, The time of the polling cycle of a queue d is pass by, at this time, the decay time of the task of 3205 seconds is 3205 seconds -3200 Second=5 seconds, therefore, the corresponding time interval of the task is the decay time of queue i at this time, so the task is put into queue i Medium pending, correspondingly, at this time, the decay time of the task of 3230 seconds, 3250 seconds, 3430 seconds and 4030 seconds is 30 seconds, 50 Second, 230 seconds and 830 seconds (since task is less in queue, ignoring the poll time of all tasks in a time queue of poll), according to The corresponding decay time of each queue, the task of 3230 seconds are also 30 seconds surplus since distance is performed, queue h is arrived in arrangement In, the task arrangement of 3250 seconds is arranged the task of 3430 seconds into queue f, by the task of 4030 seconds to queue g accordingly Arrange into queue e.
As seen from the above-described embodiment, multiple queues for task of arranging are set in computer systems, are arranged in queue The decay time of cloth task meets the time interval corresponding to the queue, since decay time is in the task of different time intervals It is arranged in by scattered in different queue, therefore for queue institute poll is only task in this queue, so once Need the quantity of polling tasks obviously than in traditional approach it is once need whole tasks in polling computer system quantity it is few. For the first queue in the plurality of queue, according to the task in the polling cycle poll first queue of first queue, and calculate The decay time of task is polled to, if to be in second queue in the plurality of queue corresponding for the decay time for being polled to first task In time interval, then first task is taken out from first queue and arranges into the less second queue of polling cycle, it is seen then that The decay time of first task can be placed on when longer in the longer first queue of polling cycle, and it is first to avoid frequent poll Business, has saved system resource.It can arrange when the decay time of first task is shorter to the shorter second queue of polling cycle, By more frequent poll to improve the possibility that can be performed in time when the decay time of first task is zeroed.
In order to the task in accurately and effectively snoop queue, the embodiment of the present invention is additionally provided in a kind of snoop queue The concrete mode of task, by the task in the distributing order of task in queue successively snoop queue, and can ensure not as far as possible Occur that a task is polled multiple situation and occurs.
Optionally, on the basis of embodiment corresponding to Fig. 2, Fig. 3 is a kind of snoop queue provided in an embodiment of the present invention The method flow diagram of middle task, the described method includes:
S201:For the second task setting flag, second task is the poll in the polling cycle of the first queue First task arrived.
For example, the second task can be any one task in first queue, such as the second task can be One task.But due to the second task is first task being polled in a polling cycle, therefore under normal circumstances second Task is that the task of queue heads is in first queue.
For the second task setting flag effect primarily to determining when completion task poll, particular content exists Illustrated in S204.
S202:After complete second task of poll, by the tail of the queue of second task arrangement to the first queue.
S203:According to the task in queue distributing order successively first queue described in poll, and in the complete task of poll This task is arranged to the tail of the queue of the first queue afterwards.
For example, in a polling cycle, can be by this task due to a task in the complete first queue of poll Arrange to the tail of the queue of first queue.Other tasks being so polled to after the second task are after poll, in the arrangement of queue Sequentially, still it is arranged in after the second task.But it should be noted that in task polling procedure, under certain situation simultaneously It is not that each task is implemented all in accordance with the mode that S203 is limited in first queue, if be polled to a task (including Second task) decay time be in the time interval corresponding to other queues, this task will take from first queue Go out and arrange into other queues, the tail of the queue position without being arranged in first queue again.
S204:When being polled to second task with the mark, cancel the mark and knot of second task Beam poll.
Due to being provided with mark for the second task in step s 201, and in the complete task of poll, decay time is still Task in time interval in first queue team of the rearrangement in first queue in the way of S202 and S203 Tail.So in this polling cycle, if be polled to the second task with the mark, illustrate this polling cycle Middle whole tasks all polls started during polling tasks in first queue one time, it is believed that the task in this polling cycle Poll has been completed.Therefore, the mark of the second task can be cancelled and terminate this poll.
By the mark being arranged in the second task, to ensure a being not in task in a polling cycle as far as possible It is polled multiple situation to occur, improves polling efficiency.
Under normal circumstances, in polling procedure, complete that the time that the poll of task in a queue is consumed can be less than The polling cycle of this queue., i.e., after the task in a time queue of poll, and next polling cycle does not have started, therefore, It needs to be determined that go out the time of poll next time.Traditional being achieved in that can be by setting corresponding timing to a queue Device, such as timing can be started when starting a subtask poll, by the numerical value of timer to determine whether starting next time Task poll.But this mode needs to be respectively provided with corresponding timer to each queue, causes the waste of system resource.Therefore this Inventive embodiments additionally provide a kind of method for determining to begin a task with the poll moment, on the basis of the embodiment corresponding to Fig. 3, Referring to attached drawing 4, the described method includes:
S301:For the second task setting flag, second task is the poll in the polling cycle of the first queue First task arrived.
S302:Second moment was saved in second task, second moment is by the first moment and described The polling cycle of first queue determines, at the time of first moment is marks second task.
For example, the present invention does not limit the sequencing for performing S301 and S302, S302 can be performed prior to S301, The two steps can also perform at the same time.
First moment can be at the time of being polled to the second task for the first time in a polling cycle, such as:One wheel It is 12 points to ask specific time when being polled to the second task in the cycle for the first time, then the first moment can be 12 points.Second moment Determined jointly by the polling cycle of the first moment and first queue, such as the polling cycle of first queue is 10 seconds, the first moment For 12 when, the second moment can be 12: 10 seconds.
By preserving for the second moment in the second task, second can be polled to again in same polling cycle During business, determine to carry out the time of task poll next time by the second moment.
S303:After complete second task of poll, by the tail of the queue of second task arrangement to the first queue.
S304:According to the task in queue distributing order successively first queue described in poll, and in the complete task of poll This task is arranged to the tail of the queue of the first queue afterwards.
S305:When being polled to second task with the mark, and from second task described in acquisition Second moment.
S306:According to the 3rd moment and second moment determine next time to be polled the first queue when Carve, the 3rd moment is at the time of being polled to second task with the mark.
S307:Cancel the mark of second task and terminate poll.
The execution sequence between S306 and S307 is not limited in the present embodiment, S307 can be prior to being held before S306 OK, S306 can also be prior to being performed before S307, and S306 and S307 can also be performed at the same time.
For example, after the second moment was saved in the second task for being provided with and marking, when in same polling cycle When being polled to markd second task of setting, the second moment preserved in S302, example can be got from the second task Second moment described above is 12: 10 seconds.At the time of 3rd moment had tagged second task to be polled to, such as:3rd Moment is 12: 8 seconds at the time of being and be polled to tool tagged second task.Due to the first moment and the 3rd moment be It is complete from the first moment to the 3rd moment i.e. poll at the time of being successively polled to the second task twice in one polling cycle The time that task is consumed in a time first queue.Therefore by that can determine this poll week by the second moment and the 3rd moment Phase time still remaining.
For example, according to 12: 8 seconds the 3rd moment and 12: 10 seconds the second moment, determine next time to take turns the queue At the time of inquiry:1: 8 seconds=2 seconds 12: 10 seconds, that is, this polling cycle there remains 2 seconds terminate, can be right after 2 seconds First queue carries out next subtask poll.
As can be seen here, it is not necessary to timer is additionally set, by preserved in the second task of first queue second when Carve, when can be polled to the second task for the second time in same polling cycle, according to be polled to for the second time the second task when At the time of the second moment preserved in quarter and the second task voluntarily determines to begin a task with poll next time, thus it is responsible for first team Dormancy in the time of task poll can be not required in the processing module of row, and starts to work in time when needing task poll, Resource has been saved, has improved efficiency.
Next introduce when a task creation with decay time, how to be added into queue.Optionally, join See attached drawing 5, task, which is arranged to the specific method in multiple queues of setting, to be included:
S501:The 3rd task is obtained, the 3rd task is the task with decay time.
For example, the 3rd task can be a task with decay time being just created.
S502:By the 3rd task arrangement into the 3rd queue in the multiple queue, the 3rd task when It is between delay in the corresponding time interval of the 3rd queue.
That is, the corresponding time interval of queue can be as the arrangement foundation of newly creating for task, can be according to new The decay time selection of establishment task can arrange the queue of the task.Wherein, it is also necessary to illustrate, the 3rd queue can To be that the invention described above implements the first queue or second queue that refer to, other teams that can also be in set multiple queues Row.The present invention does not limit the specific location that the 3rd task is arranged in the 3rd queue yet.
For example, when the executive agent of task poll during a processing module is as multiple queues, user submits one After a task, processing module obtains the task first, next calculates this task distance and is performed the remaining time, immediately delay Between, task is put into corresponding queue according to decay time, such as:Assuming that when computer system includes 6 queues, 6 Queue is corresponding with respective time interval respectively:The time interval of queue d is greater than 3200 seconds, and the time interval of queue e is 800 Second~3200 seconds, the time interval of queue f is 200 seconds~800 seconds, and the time interval of queue g is 40 seconds~200 seconds, queue h's Time interval is 10 seconds~40 seconds, and the section of queue i is less than 10 seconds.When calculating is performed remaining to a certain task distance Between be 3405 seconds, due to 3405 seconds be more than 3200 seconds, then by the task arrangement into queue d.Likewise, when processing module calculates The time that the task distance submitted to user is performed needs was 520 seconds, due to 520 seconds time zones for being in 200 seconds~800 seconds Between, then by task arrangement into queue f.
Fig. 6 is a kind of structure drawing of device of task polling set-up provided in an embodiment of the present invention, applied to computer system, Multiple queues with corresponding time interval are provided with the computer system, each queue in the multiple queue is used for Arrangement decay time meets the task of corresponding time interval, and the multiple queue includes at least first queue and second queue, The polling cycle of the first queue is more than the polling cycle of the second queue, and described device includes poll units 601, calculates Unit 602, judging unit 603 and arrangement unit 604:
The poll units 601, for arranging in first queue described in the polling cycle poll according to the first queue Task.
The computing unit 602, for calculating the decay time for the task that is polled to.
The judging unit 603, for the time interval residing for the decay time for the judging to be polled to of the task;Wherein, When judging the time interval residing for the decay time of first task, the first task is arranged task by the first queue In a task;If the decay time of the first task is in the time interval corresponding to the second queue, triggering The arrangement unit 604.
The arrangement unit 604, for the first task to be taken out from the first queue, and arranges to described the In two queues.
The description of above-mentioned unit refers to the associated description in embodiment corresponding to Fig. 2, no longer repeats one by one here.
Optionally, the judging unit is additionally operable to when the decay time of the first task is less than or equal to 0, by described the One task is taken out from the first queue, and performs the first task.
Optionally, the corresponding time interval of first queue time interval corresponding with the second queue is not overlapping.
Optionally, it is described first that the poll units, which are additionally operable to as the second task setting flag, second task, First task being polled in the polling cycle of queue;After complete second task of poll, second task arrangement is arrived The tail of the queue of the first queue;According to the task in queue distributing order successively first queue described in poll, and in poll complete one This task is arranged to the tail of the queue of the first queue after a task;When being polled to second task with the mark When, cancel the mark of second task and terminate poll.
Optionally, the poll units are additionally operable to the second moment being saved in second task, second moment To be determined by the polling cycle at the first moment and the first queue, first moment for mark second task when Carve;Second moment is obtained from second task;It is next time right to be determined according to the 3rd moment and second moment At the time of the first queue is polled, the 3rd moment be second task with the mark that is polled to when Carve.
Optionally, the judging unit is additionally operable to judge whether be placed with task in the first queue;If do not arrange Task, then wait performing again after the polling cycle of a first queue and described judge whether arrange in the first queue There is task.
Optionally, the queue type of the multiple queue includes setting memory queue in memory, is arranged in disk Document queue, combination any one or more in the queue of list structure form in the database is set.
Optionally, memory queue of the shortest queue of polling cycle for setting in memory in the multiple queue.
Optionally, described device further includes acquiring unit:
The acquiring unit, for obtaining the 3rd task, the 3rd task is the task with decay time;
The arrangement unit is additionally operable to by the 3rd task arrangement into the 3rd queue in the multiple queue, described The decay time of 3rd task is in the corresponding time interval of the 3rd queue.
As it can be seen that multiple queues for task of arranging, the time delay for task of arranging in queue are set in computer systems Time meets the time interval corresponding to the queue, since decay time is in the task of different time intervals by scattered arrangement In different queue, therefore for queue institute poll only it is task in this queue, so once needing polling tasks Quantity obviously than in traditional approach it is once need in polling computer system whole tasks quantity it is few.For the plurality of team First queue in row, according to the task in the polling cycle poll first queue of first queue, and calculates and is polled to task Decay time, if the decay time for being polled to first task is in the plurality of queue in the corresponding time interval of second queue, Then first task is taken out from first queue and is arranged into the less second queue of polling cycle, it is seen then that first task Decay time can be placed on when longer in the longer first queue of polling cycle, avoid frequent poll first task, saved System resource.It can arrange when the decay time of first task is shorter to the shorter second queue of polling cycle, by more Frequent poll is to improve the possibility that can be performed in time during the decay time of first task zero.
Fig. 7 is a kind of method flow diagram of task arrangement method provided in an embodiment of the present invention, applied to computer system, Multiple queues with corresponding time interval are provided with the computer system, each queue in the multiple queue is used Meet the task of time interval corresponding to this queue in arrangement decay time, the described method includes:
S701:Acquisition task, the task are the task with decay time.
S702:If the decay time of the task is in the corresponding time interval of object queue, the task is arranged Into the object queue, the object queue is a queue in the multiple queue.
That is, the corresponding time interval of queue can be as the arrangement foundation of newly creating for task, and newly create Task can be being obtained in S701 for task.
Since each queue has corresponding time interval, therefore can be selected according to the new decay time for creating task Meet the queue for the mission requirements of arranging, in other words, if the decay time of the task falls into a queue in the plurality of queue Corresponding time interval, then this queue can be the object queue in S702, the task can be arranged and arrive this In queue.
Wherein, it is also necessary to illustrate, the present invention does not limit the specific location that the task is arranged in object queue.
Optionally, the multiple queue includes at least first queue and second queue, the polling cycle of the first queue More than the polling cycle of the second queue, the described method includes:
According to arranging in first queue described in the polling cycle poll of the first queue for task;
Calculate the decay time for the task that is polled to;
Time interval residing for the decay time for the task that judgement is polled to;Wherein, the time delay of first task is being judged During time interval residing for the time, the first task is a task in first queue institute arrangement task;
If the decay time of the first task is in the time interval corresponding to the second queue, by described first Task is taken out from the first queue, and arranges into the second queue.
Optionally, the queue type of the multiple queue includes setting memory queue in memory, is arranged in disk Document queue, combination any one or more in the queue of list structure form in the database is set.
Optionally, memory queue of the shortest queue of polling cycle for setting in memory in the multiple queue.
As it can be seen that task of different time intervals is in due to decay time is arranged in different queue by scattered, thus it is right What it is in queue institute poll is only task in this queue, so once needing the quantity of polling tasks obviously than tradition side The once quantity for needing whole tasks in polling computer system will be lacked in formula.Can effectively reduce in addition prevent due to and When be polled to the long-delayed problem of task that causes some decay times to be zeroed, should perform.
Fig. 8 is a kind of structure drawing of device of task arrangement apparatus provided in an embodiment of the present invention, applied to computer system, Multiple queues with corresponding time interval are provided with the computer system, each queue in the multiple queue is used Meet the task of time interval corresponding to this queue in arrangement decay time, described device includes acquiring unit 801 and arrangement Unit 802:
The acquiring unit 801, for obtaining task, the task is the task with decay time;
The arrangement unit 802, if the decay time for the task is in the corresponding time interval of object queue, By task arrangement into the object queue, the object queue is a queue in the multiple queue.
Optionally, the multiple queue includes at least first queue and second queue, the polling cycle of the first queue More than the polling cycle of the second queue, it is single that described device further includes poll units, computing unit, judging unit and arrangement Member:
The poll units, appoint for what is arranged in first queue described in the polling cycle poll according to the first queue Business;
The computing unit, for calculating the decay time for the task that is polled to;
The judging unit, for the time interval residing for the decay time for the judging to be polled to of the task;Wherein, sentencing During time interval residing for the decay time of disconnected first task, the first task is in first queue institute arrangement task One task;If the decay time of the first task is in the time interval corresponding to the second queue, described in triggering Arrangement unit;
The arrangement unit, for the first task to be taken out from the first queue, and arranges and arrives described second In queue.
Optionally, the queue type of the multiple queue includes setting memory queue in memory, is arranged in disk Document queue, combination any one or more in the queue of list structure form in the database is set.
Optionally, memory queue of the shortest queue of polling cycle for setting in memory in the multiple queue.
As it can be seen that task of different time intervals is in due to decay time is arranged in different queue by scattered, thus it is right What it is in queue institute poll is only task in this queue, so once needing the quantity of polling tasks obviously than tradition side The once quantity for needing whole tasks in polling computer system will be lacked in formula.Can effectively reduce in addition prevent due to and When be polled to the long-delayed problem of task that causes some decay times to be zeroed, should perform.
One of ordinary skill in the art will appreciate that:Realizing all or part of step of above method embodiment can pass through The relevant hardware of programmed instruction is completed, and foregoing routine can be stored in a computer read/write memory medium, which exists During execution, execution the step of including above method embodiment;And foregoing storage medium can be in following media at least one Kind:Read-only storage (English:Read-only memory, abbreviation:ROM), RAM, magnetic disc or CD etc. are various to store The medium of program code.
It should be noted that each embodiment in this specification is described by the way of progressive, each embodiment it Between identical similar part mutually referring to what each embodiment stressed is the difference with other embodiment. For equipment and system embodiment, since it is substantially similar to embodiment of the method, so describe fairly simple, The relevent part can refer to the partial explaination of embodiments of method.Equipment and system embodiment described above is only schematic , wherein may or may not be as the unit that separating component illustrates physically separate, shown as unit Component may or may not be physical location, you can with positioned at a place, or can also be distributed to multiple networks On unit.Some or all of module therein can be selected to realize the purpose of this embodiment scheme according to the actual needs. Those of ordinary skill in the art are without creative efforts, you can to understand and implement.
The foregoing is only a preferred embodiment of the present invention, but protection scope of the present invention be not limited thereto, Any one skilled in the art the invention discloses technical scope in, the change or replacement that can readily occur in, It should be covered by the protection scope of the present invention.Therefore, protection scope of the present invention should be with scope of the claims Subject to.

Claims (17)

1. a kind of task polling method, it is characterised in that being provided with applied to computer system, in the computer system has Multiple queues of corresponding time interval, each queue in the multiple queue meet the corresponding time for decay time of arranging The task in section, the multiple queue include at least first queue and second queue, and the polling cycle of the first queue is more than The polling cycle of the second queue, the described method includes:
According to arranging in first queue described in the polling cycle poll of the first queue for task;
Calculate the decay time for the task that is polled to;
Time interval residing for the decay time for the task that judgement is polled to;Wherein, the decay time of first task is being judged During residing time interval, the first task is a task in first queue institute arrangement task;
If the decay time of the first task is in the time interval corresponding to the second queue, by the first task Take out, and arranged into the second queue from the first queue.
2. according to the method described in claim 1, it is characterized in that, it is described judge first task decay time residing for time Section, further includes:
If the decay time of the first task is less than or equal to 0, the first task is taken out from the first queue, and holds The row first task.
3. the according to the method described in claim 1, it is characterized in that, corresponding time interval of the first queue and described second The corresponding time interval of queue is not overlapping.
4. the according to the method described in claim 1, it is characterized in that, polling cycle poll institute according to the first queue Arranging in first queue for task is stated, including:
For the second task setting flag, second task is first be polled in the polling cycle of the first queue Task;
After complete second task of poll, by the tail of the queue of second task arrangement to the first queue;
According to the task in queue distributing order successively first queue described in poll, and by this after the complete task of poll Tail of the queue of the business arrangement to the first queue;
When being polled to second task with the mark, cancel the mark of second task and terminate poll.
5. according to the method described in claim 4, it is characterized in that, described is the second task setting flag, further include:
Second moment was saved in second task, second moment is by the first moment and the first queue Polling cycle determines, at the time of first moment is marks second task;
It is described when being polled to second task with the mark, further include:
Second moment is obtained from second task;
At the time of determining to be polled the first queue according to the 3rd moment and second moment next time, described Three moment were at the time of being polled to second task with the mark.
6. according to the method described in claim 1 to 5 any one, it is characterised in that described according to the first queue Before arranging in first queue described in polling cycle poll for task, further include:
Judge whether be placed with task in the first queue;
If not arranging task, the judgement described first is performed again after waiting the polling cycle of a first queue Whether task is placed with queue.
7. according to the method described in claim 1 to 5 any one, it is characterised in that queue type's bag of the multiple queue Include and memory queue in memory, the document queue being arranged in disk are set, list structure form in the database is set Any one or more combination in queue.
8. according to the method described in claim 1 to 5 any one, it is characterised in that polling cycle is most in the multiple queue Memory queue of the short queue for setting in memory.
9. according to the method described in claim 1 to 5 any one, it is characterised in that the method further includes:
The 3rd task is obtained, the 3rd task is the task with decay time;
By the 3rd task arrangement into the 3rd queue in the multiple queue, the decay time of the 3rd task is in In the corresponding time interval of 3rd queue.
10. a kind of task polling set-up, it is characterised in that applied to computer system, tool is provided with the computer system There are multiple queues of corresponding time interval, when each queue in the multiple queue meets corresponding for decay time of arranging Between section task, the multiple queue includes at least first queue and second queue, and the polling cycle of the first queue is big In the polling cycle of the second queue, described device includes poll units, computing unit, judging unit and arrangement unit:
The poll units, for arranging in first queue described in the polling cycle poll according to the first queue for task;
The computing unit, for calculating the decay time for the task that is polled to;
The judging unit, for the time interval residing for the decay time for the judging to be polled to of the task;Wherein, is being judged During time interval residing for the decay time of one task, the first task is one in first queue institute arrangement task Task;If the decay time of the first task is in the time interval corresponding to the second queue, the arrangement is triggered Unit;
The arrangement unit, for the first task to be taken out from the first queue, and arranges and arrives the second queue In.
11. device according to claim 10, it is characterised in that the poll units are additionally operable to set for the second task and mark Note, second task are first task being polled in the polling cycle of the first queue;Poll complete described second After task, by the tail of the queue of second task arrangement to the first queue;According to described in queue distributing order successively poll the Task in one queue, and this task is arranged to the tail of the queue of the first queue after the complete task of poll;Work as poll During to second task with the mark, the mark for cancelling second task simultaneously terminates poll.
12. according to the devices described in claim 11, it is characterised in that the poll units are additionally operable to the second moment being saved in In second task, second moment to be determined by the polling cycle at the first moment and the first queue, described the At the time of one moment is marked second task;Second moment is obtained from second task;According to the 3rd moment At the time of determining to be polled the first queue with second moment next time, the 3rd moment is to be polled to tool At the time of having second task of the mark.
13. a kind of task arrangement method, it is characterised in that applied to computer system, tool is provided with the computer system There are multiple queues of corresponding time interval, each queue in the multiple queue meets this team for decay time of arranging The task of time interval corresponding to row, the described method includes:
Acquisition task, the task are the task with decay time;
If the decay time of the task is in the corresponding time interval of object queue, by task arrangement to the target In queue, the object queue is a queue in the multiple queue.
14. according to the method for claim 13, it is characterised in that the multiple queue includes at least first queue and second Queue, the polling cycle of the first queue are more than the polling cycle of the second queue, the described method includes:
According to arranging in first queue described in the polling cycle poll of the first queue for task;
Calculate the decay time for the task that is polled to;
Time interval residing for the decay time for the task that judgement is polled to;Wherein, the decay time of first task is being judged During residing time interval, the first task is a task in first queue institute arrangement task;
If the decay time of the first task is in the time interval corresponding to the second queue, by the first task Take out, and arranged into the second queue from the first queue.
15. the method according to claim 13 or 14, it is characterised in that the queue type of the multiple queue includes setting Memory queue in memory, the document queue being arranged in disk, set in the queue of list structure form in the database Any one or more combinations.
16. the method according to claim 13 or 14, it is characterised in that the shortest team of polling cycle in the multiple queue It is classified as the memory queue set in memory.
17. a kind of task arrangement apparatus, it is characterised in that applied to computer system, tool is provided with the computer system There are multiple queues of corresponding time interval, each queue in the multiple queue meets this team for decay time of arranging The task of time interval corresponding to row, described device include acquiring unit and arrangement unit:
The acquiring unit, for obtaining task, the task is the task with decay time;
The arrangement unit, if the decay time for the task is in the corresponding time interval of object queue, by described in Task is arranged into the object queue, and the object queue is a queue in the multiple queue.
CN201610942962.8A 2016-10-31 2016-10-31 Task polling method, task arrangement method and related device Active CN108021439B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610942962.8A CN108021439B (en) 2016-10-31 2016-10-31 Task polling method, task arrangement method and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610942962.8A CN108021439B (en) 2016-10-31 2016-10-31 Task polling method, task arrangement method and related device

Publications (2)

Publication Number Publication Date
CN108021439A true CN108021439A (en) 2018-05-11
CN108021439B CN108021439B (en) 2022-07-15

Family

ID=62070712

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610942962.8A Active CN108021439B (en) 2016-10-31 2016-10-31 Task polling method, task arrangement method and related device

Country Status (1)

Country Link
CN (1) CN108021439B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110139229A (en) * 2019-04-15 2019-08-16 平安科技(深圳)有限公司 Delay sends method, apparatus, computer equipment and the storage medium of short message
CN111343152A (en) * 2020-02-07 2020-06-26 北京达佳互联信息技术有限公司 Data processing method and device, electronic equipment and storage medium
CN112966876A (en) * 2021-03-19 2021-06-15 北京京东振世信息技术有限公司 Order production scheduling method and device, electronic equipment and readable medium
CN116647530A (en) * 2023-06-06 2023-08-25 深圳花儿绽放网络科技股份有限公司 Automatic execution system for instant messaging task

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1794855A (en) * 2005-06-27 2006-06-28 华为技术有限公司 Method and device synchronous operating time in equipment management
CN1870767A (en) * 2005-12-14 2006-11-29 华为技术有限公司 Method for managing timer task
CN101178713A (en) * 2006-11-29 2008-05-14 腾讯科技(深圳)有限公司 Method and system for collecting web page
CN101183316A (en) * 2007-11-28 2008-05-21 北京中星微电子有限公司 Tasks delayed time processing method and system in real-time operating system
CN101561767A (en) * 2008-04-16 2009-10-21 上海聚力传媒技术有限公司 Method and device for executing tasks based on operating system
US20110078352A1 (en) * 2009-09-30 2011-03-31 International Business Machines Corporation Administering The Polling Of A Number Of Devices For Device Status
CN103744730A (en) * 2014-01-27 2014-04-23 北京京东尚科信息技术有限公司 Task scheduling method and device
CN104951282A (en) * 2015-05-21 2015-09-30 中国人民解放军理工大学 Timer management system and method
CN105808329A (en) * 2016-02-25 2016-07-27 北京京东尚科信息技术有限公司 Distributed overtime task scheduling method and device
CN105915468A (en) * 2016-06-17 2016-08-31 北京邮电大学 Service scheduling method and device

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1794855A (en) * 2005-06-27 2006-06-28 华为技术有限公司 Method and device synchronous operating time in equipment management
CN1870767A (en) * 2005-12-14 2006-11-29 华为技术有限公司 Method for managing timer task
CN101178713A (en) * 2006-11-29 2008-05-14 腾讯科技(深圳)有限公司 Method and system for collecting web page
CN101183316A (en) * 2007-11-28 2008-05-21 北京中星微电子有限公司 Tasks delayed time processing method and system in real-time operating system
CN101561767A (en) * 2008-04-16 2009-10-21 上海聚力传媒技术有限公司 Method and device for executing tasks based on operating system
US20110078352A1 (en) * 2009-09-30 2011-03-31 International Business Machines Corporation Administering The Polling Of A Number Of Devices For Device Status
CN103744730A (en) * 2014-01-27 2014-04-23 北京京东尚科信息技术有限公司 Task scheduling method and device
CN104951282A (en) * 2015-05-21 2015-09-30 中国人民解放军理工大学 Timer management system and method
CN105808329A (en) * 2016-02-25 2016-07-27 北京京东尚科信息技术有限公司 Distributed overtime task scheduling method and device
CN105915468A (en) * 2016-06-17 2016-08-31 北京邮电大学 Service scheduling method and device

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
GEORGE VARGHESE等: "Hashed and Hierarchical Timing Wheels: Efficient Data Structures for Implementing a Timer Facility", 《IEEE/ACM TRANSACTIONS ON NETWORKING》 *
SUNFACE撩技术: "[Erlang]惊艳的时间轮定时器(遍历优化)", 《HTTPS://BLOG.CSDN.NET/ERLIB/ARTICLE/DETAILS/40743959》 *
ZQHXUYUAN: "Kafka技术内幕样章 层级时间轮", 《HTTPS://SEGMENTFAULT.COM/A/1190000005348993》 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110139229A (en) * 2019-04-15 2019-08-16 平安科技(深圳)有限公司 Delay sends method, apparatus, computer equipment and the storage medium of short message
CN110139229B (en) * 2019-04-15 2022-03-29 平安科技(深圳)有限公司 Method and device for sending short message in delayed mode, computer equipment and storage medium
CN111343152A (en) * 2020-02-07 2020-06-26 北京达佳互联信息技术有限公司 Data processing method and device, electronic equipment and storage medium
CN112966876A (en) * 2021-03-19 2021-06-15 北京京东振世信息技术有限公司 Order production scheduling method and device, electronic equipment and readable medium
CN112966876B (en) * 2021-03-19 2024-04-12 北京京东振世信息技术有限公司 Order production scheduling method and device, electronic equipment and readable medium
CN116647530A (en) * 2023-06-06 2023-08-25 深圳花儿绽放网络科技股份有限公司 Automatic execution system for instant messaging task

Also Published As

Publication number Publication date
CN108021439B (en) 2022-07-15

Similar Documents

Publication Publication Date Title
CN108021439A (en) A kind of task polling method, task arrangement method and relevant apparatus
He et al. Matchmaking: A new mapreduce scheduling technique
US8806498B2 (en) Method and system for resolving dependency among the enqueued works and/or finished works and scheduling the dependency-resolved works
CN101923490B (en) Job scheduling apparatus and job scheduling method
CN107579926A (en) The QoS methods to set up of Ceph cloud storage systems based on token bucket algorithm
CN101676890B (en) Bus arbitration method for dynamically adjusting bandwidth allocation and arbitrator thereof
CN107316167A (en) A kind of allocator and device based on shops position of distributors
CN106648461A (en) Memory management device and method
CN113138860B (en) Message queue management method and device
CN107613025A (en) A kind of implementation method replied based on message queue order and device
CN104346458B (en) Date storage method and storage device
CN109428912A (en) A kind of distributed system resource allocation methods, apparatus and system
CN106293918A (en) A kind of dispatch the method for process, system and computer
CN106257893A (en) Storage server task response method, client, server and system
CN107613529A (en) Message treatment method and base station
JP2020502647A5 (en)
CN107577539A (en) The shared drive structure communicated for kernel state and User space and its application
KR20200075883A (en) Techniques for pairing behavior in task assignment system
CN110297662A (en) Instruct method, processor and the electronic equipment of Out-of-order execution
CN104683486B (en) Method, apparatus, the distributed system of synchronization message are handled in distributed system
CN103577469B (en) Database connection multiplexing method and apparatus
CN110457251A (en) Data communications method and device between a kind of multiprocessor
CN108694078A (en) The interruption confirmed based on nearest interrupt requests indicator and work
Cao et al. A game-theoretic framework for revenue sharing in edge-cloud computing system
CN107277022A (en) Processes Tag method and device

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

Effective date of registration: 20230608

Address after: Room 1-2-A06, Yungu Park, No. 1008 Dengcai Street, Sandun Town, Xihu District, Hangzhou City, Zhejiang Province

Patentee after: Aliyun Computing Co.,Ltd.

Address before: Box 847, four, Grand Cayman capital, Cayman Islands, UK

Patentee before: ALIBABA GROUP HOLDING Ltd.