CN106886450A - Method for scheduling task and system - Google Patents

Method for scheduling task and system Download PDF

Info

Publication number
CN106886450A
CN106886450A CN201510946243.9A CN201510946243A CN106886450A CN 106886450 A CN106886450 A CN 106886450A CN 201510946243 A CN201510946243 A CN 201510946243A CN 106886450 A CN106886450 A CN 106886450A
Authority
CN
China
Prior art keywords
task
timed
task group
group
timing
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.)
Pending
Application number
CN201510946243.9A
Other languages
Chinese (zh)
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 Group Holding 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 CN201510946243.9A priority Critical patent/CN106886450A/en
Publication of CN106886450A publication Critical patent/CN106886450A/en
Pending legal-status Critical Current

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mobile Radio Communication Systems (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The disclosure is directed to a kind of method for scheduling task and system, wherein method includes:Start timing of the timer to first task group, the first task group includes:The timed task of timed interval identical at least one;When the corresponding timed interval of first task group is reached, notify that each timed task in the first task group is performed.The disclosure reduces excessive consumption of the more timed task to system resource.

Description

Method for scheduling task and system
Technical field
This disclosure relates to computer technology, more particularly to a kind of method for scheduling task and system.
Background technology
In software development, be frequently encountered some scenes, it is necessary to using to timer timer, such as, Data timing refreshes, regularly inquires about certain state-event etc., and it is fixed that the task that these timings are performed is properly termed as When task.In the related art, it usually needs for each timed task is respectively provided with a corresponding timer, Also, timer can notify that corresponding task goes to perform when reaching the time, such as, timed task needs every Performed once every 2 minutes, then timer will timing, and tasks carrying is notified when at intervals of two minutes. This timer starts as the timing of task is referred to as task scheduling.But above-mentioned task scheduling side Formula, the resource consumption to system is larger, may cause that system operation is slower.
The content of the invention
To overcome problem present in correlation technique, the disclosure to provide a kind of method for scheduling task and system, To reduce excessive consumption of the more timed task to system resource.
According to the first aspect of the embodiment of the present disclosure, there is provided a kind of method for scheduling task, including:
Start timing of the timer to first task group, the first task group includes:Timed interval The timed task of identical at least one;
When the corresponding timed interval of the first task group is reached, in notifying the first task group Each timed task perform.
According to the second aspect of the embodiment of the present disclosure, there is provided a kind of task scheduling system, including:
Timing module, for starting timing of the timer to first task group, the first task group includes: The timed task of timed interval identical at least one;
Notification module, for when the corresponding timed interval of the first task group is reached, notifying institute Each timed task stated in first task group is performed.
The technical scheme provided by this disclosed embodiment can include the following benefits:Appoint by by timing Business is divided into timed task group, and starts the timing to the timed task group by timer, relative to respectively To the mode of each timed task timing, excessive consumption of the more timed task to system resource will be reduced.
It should be appreciated that the general description of the above and detailed description hereinafter are only exemplary and explanatory , the disclosure can not be limited.
Brief description of the drawings
Accompanying drawing herein is merged in specification and constitutes the part of this specification, shows and meets the present invention Embodiment, and together with specification be used for explain principle of the invention.
Fig. 1 is the timed task packet schematic diagram according to an exemplary embodiment;
Fig. 2 is a kind of flow chart of the method for scheduling task according to an exemplary embodiment;
Fig. 3 is the associated task group schematic diagram according to an exemplary embodiment;
Fig. 4 is a kind of structure chart of the task scheduling system according to an exemplary embodiment;
Fig. 5 is the structure chart of another task scheduling system according to an exemplary embodiment.
Specific embodiment
Here exemplary embodiment will be illustrated in detail, its example is illustrated in the accompanying drawings.Following When description is related to accompanying drawing, unless otherwise indicated, the same numbers in different accompanying drawings represent same or analogous Key element.Implementation method described in following exemplary embodiment does not represent the institute consistent with the present invention There is implementation method.Conversely, they be only with it is being described in detail in such as appended claims, of the invention one The example of the consistent apparatus and method of a little aspects.
In order to when timed task is more, it is to avoid the excessive consumption to system resource, the operation of system is improved Speed, the embodiment of the present application provides a kind of method for scheduling task, and the method employs one to timed task Plant the scheduling mode of centralization.
Referring to the example of Fig. 1, it is assumed that there is four timed tasks, timed task is to need at regular intervals The task of execution.For example, timed task -1 can be Refresh Data task, perform at intervals of two minutes once, Just obtain a latest data from data server at intervals of two minutes;Timed task -2 can inquire about certain The task of individual state-event, performed once every 1 minute, i.e., just inquired about an event shape every 1 minute Whether state changes;Similarly, timed task -3 and timed task -4 can also be included, the present embodiment is false If timed task -3 is also to perform at intervals of two minutes once, timed task -4 was performed once every 1 minute.
If above-mentioned " 2 minutes ", " 1 minute " are referred to as into timed interval, then it can be seen that, Timed task -3 is identical with the timed interval of timed task -1, timed task -4 and timed task -2 Timed interval is identical.As shown in figure 1, timed task -3 and timed task -1 can be classified as one group, Referred to as " task groups A ", one group is classified as by timed task -4 and timed task -2, referred to as " task groups B ", And task groups A and task groups B can be referred to as first task group.
Each above-mentioned first task group (task groups A and task groups B) is required for timer timer to enter Row timing, the signal in such as Fig. 1, task groups A and task groups B can share a timer (Fig. 1 In timer be a signal for principle), the timer can carry out timing, in the process of timing In, when being reached every 1 minute, can notify that each timed task in task groups B is performed;When every When reaching within 2 minutes, note that each timed task in task groups A is performed.
Be can see by above-mentioned, the method for scheduling task of the application is to perform the flow shown in Fig. 2:
In step 201, timing of the timer to first task group is started, the first task group includes: The timed task of timed interval identical at least one.
For example, first task group can be the task groups A in Fig. 1, including two timed tasks, That is timed task -1 and timed task -3.Divide the timed task in same task groups, can have identical Timed interval, such as, be all to perform at intervals of two minutes once.
Optionally, it is necessary to the quantity for starting the first task group of timer timing can be multiple, such as, In Fig. 1 examples, including two first task groups, task groups A and task groups B, it is, of course, also possible to Other task groups such as including task groups C or task groups D.
In step 202., when the corresponding timed interval of the first task group is reached, institute is notified Each timed task stated in first task group is performed.
For example, timer carries out timing for first task group, when at intervals of two minutes, first task is noted that Each timed task in group starts execution.
When the quantity of first task group is for multiple, such as, and two first task groups exemplified by Fig. 1, Task groups A and task groups B, the timed interval of the two task groups is different, the timing of task groups A Time interval is 2 minutes, and the timed interval of task groups B is 1 minute, then, timer is in meter When during, when reach each first task group distinguish corresponding timed interval when, notify respectively Corresponding first task group.Such as, timing was reached when 1 minute, noted that task groups B, was reached When at intervals of two minutes, task groups A is noted that.
Optionally, timer, can be according to first task group in each timed task of time arrival notice In each timed task priority tag, it is determined that to the notification sequence of each timed task.Such as, Some tasks may comparatively laborious obstruction thread, cause task below to be performed in time, that The priority that this generic task can be set is relatively low, and timer just can be according to the priority of task, to appointing The execution of business is ranked up, and allows the task of high priority to first carry out, it is ensured that the smooth execution of critical function, Then timer can in advance notify the timed task of high priority.
It can be seen that, in the method for scheduling task of the present embodiment, centralization is employed to multiple timed tasks Scheduling mode, i.e., being grouped as multiple timed tasks by a timer carries out timing, compared to tradition side Each timed task in formula is respectively provided with a corresponding timer, and the setting quantity of timer is reduced, The consumption to system resource can be reduced, therefore, even if run multiple timed tasks, also will not be big The speed of service of width reduction system.
Additionally, this scheduling that centralization is carried out to timed task, appointing when being also prevented from timer-triggered scheduler Business repeats to add.When system design is more complicated, multiple person cooperational occurs the various mistakes of code unavoidably, May result in same task and repeatedly open execution, by the management of centralization, each task has only One mark, repetition addition identical task can set and only carry out a task.
In another example, timer can also simultaneously start the one group timed task higher to the degree of association Timing, and stop simultaneously to this group of timing of timed task.Such as, when user opens certain page, The page includes multiple timed tasks that start to start timing, that is to say, that this multiple timed task In the same page, the page starts then these tasks and to start simultaneously, and when page close, the task also will Simultaneously close off.The present embodiment is directed to such case, can be by above-mentioned multiple tasks point in " associated task In group ", associated task group includes at least two timed tasks.
Exemplary, when above-mentioned page startup is detected, timer timer can start to closing simultaneously The timing of all timed tasks in connection task groups;When page close, timer can stop to closing simultaneously The timing of all timed tasks in connection task groups.It should be noted that above-mentioned page open, simply Individual example, while the timed task for starting or stopping might not be, according to same task, also may be used simultaneously Being other relation factors so that these timed tasks are needed while starting or stoping regularly.And the present embodiment By by these timed tasks point in associated task group, and by timer to associated task group in appoint Business carries out United Dispatching, is also more convenient for the management to multiple timed tasks.
Additionally, timer is when starting to the timing of each timed task in associated task group, can be with By each timed task in associated task group, according to the timed interval of timed task, it is right to be subdivided into Answer the first task group of the timed interval.Referring to the example of Fig. 3, it is assumed that wrapped in associated task group Include timed task -5 and timed task -6, and assume that the timed interval of timed task -5 is 2 minutes, The timed interval of timed task -6 is 1 minute, then, timed task -5 can be subdivided into task Group A, task groups B is subdivided into by timed task -6, and timer timer remains unchanged and arrived in timed interval Up to when notify task groups A and task groups B respectively, simply the task in the two task groups increased.
Additionally, in above-mentioned centralized task scheduling system, can also carry out some centralized tasks Management work.For example, can cut by all task suspensions in scheduling system the moment on backstage, switch to Recover again during foreground.Again for example, disk can be stored to current performing for task when program is exited In, state during last time closing can be reduced next time when starting, need to recover last state for some Demand has very important effect.Again for example, it is also possible to carry out the unified management of task status, receiving During to task status query request, the current status information of unique mark query task according to task, than Such as, also how long to be performed next time apart from task.
In the embodiment of the present application, it is possible to use CFRunLoopTimerRef correlation functions encapsulate Timer Call, runloop bottom functions, this packaged type can preferably reduce the consumption of resource.Additionally, This mode to the unified management of multiple timed tasks, is conducive to the timely release of internal memory, can prevent new Hand programmer writes and causes the internal memory cannot to discharge by mistake.
In order to realize above-mentioned method for scheduling task, present invention also provides a kind of task scheduling system, such as Shown in Fig. 4, the system can include:Timing module 41 and notification module 42.
Timing module 41, for starting timing of the timer to first task group, the first task group bag Include:The timed task of timed interval identical at least one;
Notification module 42, for when the corresponding timed interval of the first task group is reached, notifying Each timed task in the first task group is performed.
Further, the quantity of the first task group is at least one;First task described at least one Timed interval between group is different.Notification module 42, in timer timing course, when arriving When distinguishing corresponding timed interval up to each first task group, corresponding first task group is notified respectively.
Further, timing module 41, all timings being additionally operable to start to associated task group simultaneously in are appointed The timing of business, the associated task group includes:At least two timed tasks;Or, while stopping is right The timing of all timed tasks in the associated task group.
As shown in figure 5, the system can also include:Grouping module 43, for by the associated task group In each timed task, according to the timed interval of the timed task, be subdivided into correspondence it is described fixed When time interval first task group.
Additionally, notification module 42, each timed task being additionally operable in the first task group is notified is held During row, the priority tag of each timed task in the first task group, it is determined that fixed to each When task notification sequence.
Multiple timed tasks are employed the scheduling mode of centralization by the task scheduling apparatus of the present embodiment, Being grouped as multiple timed tasks by a timer carries out timing, determines compared to each in traditional approach When task be respectively provided with a corresponding timer, the setting quantity of timer is reduced, it is possible to reduce to being The consumption of resource of uniting, therefore, even if run multiple timed tasks, system will not be also greatly reduced The speed of service.
Those skilled in the art will readily occur to this after considering specification and putting into practice invention disclosed herein Other embodiments of invention.The application is intended to any modification of the invention, purposes or adaptability Change, these modifications, purposes or adaptations follow general principle of the invention and including this public affairs Open undocumented common knowledge or conventional techniques in the art.Description and embodiments only by It is considered as exemplary, true scope and spirit of the invention are pointed out by following claim.
It should be appreciated that the invention is not limited in be described above and be shown in the drawings it is accurate Structure, and can without departing from the scope carry out various modifications and changes.The scope of the present invention is only by institute Attached claim is limited.

Claims (10)

1. a kind of method for scheduling task, it is characterised in that including:
Start timing of the timer to first task group, the first task group includes:Timed interval The timed task of identical at least one;
When the corresponding timed interval of the first task group is reached, in notifying the first task group Each timed task perform.
2. method according to claim 1, it is characterised in that the quantity of the first task group is At least one;Timed interval between first task group described at least one is different;
It is described when the corresponding timed interval of first task group is reached, in notifying the first task group Each timed task perform, including:
The timer during timing, when reach each first task group distinguish corresponding timing when Between when being spaced, corresponding first task group is notified respectively.
3. method according to claim 1, it is characterised in that methods described also includes:
The timing of all timed tasks start to associated task group simultaneously in, wraps in the associated task group Include:At least two timed tasks;
Stop the timing to all timed tasks in the associated task group simultaneously.
4. method according to claim 3, it is characterised in that also include:
By each timed task in the associated task group, between the timing according to the timed task Every being subdivided into the first task group of the correspondence timed interval.
5. method according to claim 1, it is characterised in that described to notify the first task group In each timed task perform, including:
The priority tag of each timed task in the first task group, it is determined that to each regularly The notification sequence of task.
6. a kind of task scheduling system, it is characterised in that including:
Timing module, for starting timing of the timer to first task group, the first task group includes: The timed task of timed interval identical at least one;
Notification module, for when the corresponding timed interval of the first task group is reached, notifying institute Each timed task stated in first task group is performed.
7. system according to claim 6, it is characterised in that the quantity of the first task group is At least one;Timed interval between first task group described at least one is different;
The notification module, in timer timing course, distinguishing when each first task group is reached During corresponding timed interval, corresponding first task group is notified respectively.
8. system according to claim 6, it is characterised in that
The timing module, the timing of all timed tasks being additionally operable to start to associated task group simultaneously in, The associated task group includes:At least two timed tasks;Or, while stopping appointing the association The timing of all timed tasks in business group.
9. system according to claim 8, it is characterised in that also include:
Grouping module, for by each timed task in the associated task group, being appointed according to the timing The timed interval of business, is subdivided into the first task group of the correspondence timed interval.
10. system according to claim 6, it is characterised in that
The notification module, is additionally operable to when each timed task in notifying the first task group is performed, The priority tag of each timed task in the first task group, it is determined that to each timed task Notification sequence.
CN201510946243.9A 2015-12-16 2015-12-16 Method for scheduling task and system Pending CN106886450A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510946243.9A CN106886450A (en) 2015-12-16 2015-12-16 Method for scheduling task and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510946243.9A CN106886450A (en) 2015-12-16 2015-12-16 Method for scheduling task and system

Publications (1)

Publication Number Publication Date
CN106886450A true CN106886450A (en) 2017-06-23

Family

ID=59176060

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510946243.9A Pending CN106886450A (en) 2015-12-16 2015-12-16 Method for scheduling task and system

Country Status (1)

Country Link
CN (1) CN106886450A (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108509264A (en) * 2018-03-30 2018-09-07 浙江口碑网络技术有限公司 Overtime task dispatches system and method
CN108848150A (en) * 2018-06-06 2018-11-20 郑州云海信息技术有限公司 A kind of plan target method and system in cloud management platform
CN109298924A (en) * 2018-09-26 2019-02-01 中国平安人寿保险股份有限公司 Management method, computer readable storage medium and the terminal device of timed task
CN109831520A (en) * 2019-03-07 2019-05-31 网宿科技股份有限公司 A kind of timed task dispatching method and relevant apparatus
CN109981888A (en) * 2019-02-25 2019-07-05 努比亚技术有限公司 A kind of wake-up timer control method, terminal and computer readable storage medium
CN110413332A (en) * 2018-04-26 2019-11-05 武汉斗鱼网络科技有限公司 Timed task executes method, apparatus, terminal and computer-readable medium
CN112817723A (en) * 2021-02-04 2021-05-18 歌尔股份有限公司 Timer calling method, device, equipment and computer readable storage medium
CN112988359A (en) * 2021-04-26 2021-06-18 成都淞幸科技有限责任公司 Intelligent collection task allocation method and system based on timing scheduling

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101320337A (en) * 2008-07-16 2008-12-10 北京中星微电子有限公司 Timer and its implementing method
CN103368761A (en) * 2012-04-01 2013-10-23 腾讯科技(深圳)有限公司 Method and device for processing timing services
CN104765639A (en) * 2015-04-30 2015-07-08 北京奇虎科技有限公司 Timed task scheduling system and method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101320337A (en) * 2008-07-16 2008-12-10 北京中星微电子有限公司 Timer and its implementing method
CN103368761A (en) * 2012-04-01 2013-10-23 腾讯科技(深圳)有限公司 Method and device for processing timing services
CN104765639A (en) * 2015-04-30 2015-07-08 北京奇虎科技有限公司 Timed task scheduling system and method

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108509264A (en) * 2018-03-30 2018-09-07 浙江口碑网络技术有限公司 Overtime task dispatches system and method
CN110413332A (en) * 2018-04-26 2019-11-05 武汉斗鱼网络科技有限公司 Timed task executes method, apparatus, terminal and computer-readable medium
CN108848150A (en) * 2018-06-06 2018-11-20 郑州云海信息技术有限公司 A kind of plan target method and system in cloud management platform
CN109298924A (en) * 2018-09-26 2019-02-01 中国平安人寿保险股份有限公司 Management method, computer readable storage medium and the terminal device of timed task
CN109298924B (en) * 2018-09-26 2024-04-02 中国平安人寿保险股份有限公司 Timing task management method, computer readable storage medium and terminal device
CN109981888A (en) * 2019-02-25 2019-07-05 努比亚技术有限公司 A kind of wake-up timer control method, terminal and computer readable storage medium
CN109981888B (en) * 2019-02-25 2020-12-29 努比亚技术有限公司 Wake-up timer control method, terminal and computer readable storage medium
CN109831520A (en) * 2019-03-07 2019-05-31 网宿科技股份有限公司 A kind of timed task dispatching method and relevant apparatus
CN112817723A (en) * 2021-02-04 2021-05-18 歌尔股份有限公司 Timer calling method, device, equipment and computer readable storage medium
CN112988359A (en) * 2021-04-26 2021-06-18 成都淞幸科技有限责任公司 Intelligent collection task allocation method and system based on timing scheduling

Similar Documents

Publication Publication Date Title
CN106886450A (en) Method for scheduling task and system
CN109586947B (en) Distributed equipment information acquisition system and method
CN104360878B (en) A kind of method and device of application software deployment
US8639364B2 (en) Uniform synchronizing robot control and deadlock detection in uniform synchronization
WO2015139164A1 (en) Task scheduling method, apparatus and device
US9407573B2 (en) Bandwidth control in a controller area network (CAN)
CN108108463B (en) Synchronous task processing method and device based on time slice scheduling
US20170329632A1 (en) Device scheduling method, task manager and storage medium
CN104035786B (en) The optimization method and system of a kind of software timer
CN102270156A (en) Method for managing real-time embedded system timers
CN107491346A (en) A kind of task processing method of application, apparatus and system
CN109298924A (en) Management method, computer readable storage medium and the terminal device of timed task
CN113672240A (en) Container-based multi-machine-room batch automatic deployment application method and system
US20060048147A1 (en) Distributed counter and centralized sensor in barrier wait synchronization
EP3662368B1 (en) Method and apparatus for managing scheduling of services during boot-up
CN103778005A (en) Automatic task allocation method and device
CN106775620A (en) A kind of timing method and device
CN102929770A (en) Monitoring and positioning method of task monopolizing of user state of embedded Linux system
CN105227648B (en) A kind of subway comprehensive monitoring system time sequence triggering method based on time bucket
CN101833585A (en) Database server operation control system, method and device
CN106775964A (en) The operating system framework and method for scheduling task of time/event mixing triggering
CN103593606B (en) Context information management method and system
CN110161893A (en) The communication means and storage medium of slave device, control system, response data
Yan et al. Mixed time-triggered and event-triggered industrial controller in IoT environment
CN103870313B (en) Virtual machine task scheduling method and 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
RJ01 Rejection of invention patent application after publication

Application publication date: 20170623

RJ01 Rejection of invention patent application after publication