CN111935309B - Method and device for managing circular tasks - Google Patents

Method and device for managing circular tasks Download PDF

Info

Publication number
CN111935309B
CN111935309B CN202010978109.8A CN202010978109A CN111935309B CN 111935309 B CN111935309 B CN 111935309B CN 202010978109 A CN202010978109 A CN 202010978109A CN 111935309 B CN111935309 B CN 111935309B
Authority
CN
China
Prior art keywords
task
time
execution time
execution
absolute
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010978109.8A
Other languages
Chinese (zh)
Other versions
CN111935309A (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.)
Wuhan Zhongke Tongda High New Technology Co Ltd
Original Assignee
Wuhan Zhongke Tongda High New Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Zhongke Tongda High New Technology Co Ltd filed Critical Wuhan Zhongke Tongda High New Technology Co Ltd
Priority to CN202010978109.8A priority Critical patent/CN111935309B/en
Publication of CN111935309A publication Critical patent/CN111935309A/en
Application granted granted Critical
Publication of CN111935309B publication Critical patent/CN111935309B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • 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
    • G06F9/4887Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues involving deadlines, e.g. rate based, periodic

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the application provides a method and a device for managing a circular task, the method for managing the circular task is applied to a traffic police system, the traffic police system comprises a data server and a terminal, the loop task management method detects the execution state of the loop task to obtain the actual execution ending time of the ith loop task, and determining the theoretical execution time of the (i + 1) th cycle task according to the actual execution ending time and the cycle task execution period, comparing the theoretical execution time of the (i + 1) th cycle task with the absolute execution time set, the actual execution time of the (i + 1) th round task may be corrected when the theoretical execution time of the (i + 1) th round task does not belong to the absolute execution time set, therefore, the (i + 1) th cycle task can eliminate time errors, and the subsequent cycle tasks can be normally executed according to the cycle task execution period.

Description

Method and device for managing circular tasks
Technical Field
The application relates to the technical field of intelligent traffic, in particular to a method and a device for managing a circulation task.
Background
In the interaction process of the server and the terminal, in order to ensure stable data transmission, whether the connection between the terminal and the server is stable or not needs to be determined, so that the server can be adopted to send heartbeat packets to the terminal at a specific time interval, and a certain number of responses of the heartbeat packets are needed in a preset time interval to realize the detection function of the heartbeat packets.
Therefore, the technical problem that the detection function of the heartbeat packet cannot be realized due to the time error in the existing heartbeat packet sending process is solved.
Disclosure of Invention
The embodiment of the application provides a method and a device for managing a cyclic task, which are used for solving the technical problem that the detection function of a heartbeat packet cannot be realized due to the existence of a time error in the existing heartbeat packet sending process.
The embodiment of the application provides a cyclic task management method, which is applied to a traffic police system, wherein the traffic police system comprises a data server and a terminal, and the cyclic task management method comprises the following steps:
the data server receives a task execution request which is sent by the terminal and carries a cycle task execution period;
determining an absolute execution time set of the cyclic task according to the execution period of the cyclic task and the local time;
detecting the execution state of the cycle task to obtain the actual execution ending time of the ith cycle task; the actual execution ending time is the time added into the queue after the cyclic task is generated;
determining the theoretical execution time of the (i + 1) th cycle task according to the actual execution ending time and the cycle task execution period;
and correcting the actual execution time of the (i + 1) th cycle task according to the comparison result of the theoretical execution time and the absolute execution time set, so that the actual execution time of the (i + 1) th cycle task belongs to the absolute execution time set.
Meanwhile, the embodiment of the present application provides a circulation task management device, and this circulation task management device is applied to the traffic police system, the traffic police system includes data server and terminal, the circulation task management device includes:
the receiving module is used for receiving a task execution request which is sent by the terminal and carries a cycle task execution period;
the first determining module is used for determining an absolute execution time set of the cyclic task according to the execution period of the cyclic task and the local time;
the detection module is used for detecting the execution state of the cycle task to obtain the actual execution ending time of the ith cycle task; the actual execution ending time is the time added into the queue after the cyclic task is generated;
the second determining module is used for determining the theoretical execution time of the (i + 1) th cycle task according to the actual execution ending time and the cycle task execution period;
and the correction module is used for correcting the actual execution time of the (i + 1) th cycle task according to the comparison result of the theoretical execution time and the absolute execution time set, so that the actual execution time of the (i + 1) th cycle task belongs to the absolute execution time set.
Meanwhile, the embodiment of the application provides a data server for a traffic alarm system, the data server comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor implements the steps in the above circular task management method when executing the program.
Meanwhile, the embodiment of the application provides a computer-readable storage medium for a traffic alarm system, wherein a plurality of instructions are stored in the computer-readable storage medium, and the instructions are suitable for being loaded by a processor to execute the steps in the cyclic task management method.
Has the advantages that: the embodiment of the application provides a method and a device for managing a circulating task, wherein the method for managing the circulating task is applied to a traffic police system, the traffic police system comprises a data server and a terminal, and the method for managing the circulating task comprises the steps of firstly adopting the data server to receive a task execution request which is sent by the terminal and carries a circulating task execution period; then determining an absolute execution time set of the cyclic task according to the execution period of the cyclic task and the local time; then detecting the execution state of the cycle task to obtain the actual execution ending time of the ith cycle task; then, according to the actual execution ending time and the cycle task execution period, determining the theoretical execution time of the (i + 1) th cycle task; then correcting the actual execution time of the (i + 1) th cycle task according to the comparison result of the theoretical execution time and the absolute execution time set, so that the actual execution time of the (i + 1) th cycle task belongs to the absolute execution time set; according to the embodiment of the application, the execution state of the cycle task is detected to obtain the actual execution ending time of the ith cycle task, the theoretical execution time of the (i + 1) th cycle task is determined according to the actual execution ending time and the cycle task execution period, the theoretical execution time of the (i + 1) th cycle task is compared with the absolute execution time set, the actual execution time of the (i + 1) th cycle task can be corrected when the theoretical execution time of the (i + 1) th cycle task does not belong to the absolute execution time set, so that the (i + 1) th cycle task can eliminate time errors, and the subsequent cycle tasks can be normally executed according to the cycle task execution period.
Drawings
The technical solution and other advantages of the present application will become apparent from the detailed description of the embodiments of the present application with reference to the accompanying drawings.
Fig. 1 is a schematic view of a scene of an intelligent transportation system according to an embodiment of the present application.
Fig. 2 is a flowchart illustrating a method for managing a loop task according to an embodiment of the present application.
Fig. 3 is a first schematic diagram of each time of a loop task in a loop task management method according to an embodiment of the present application.
Fig. 4 is a second schematic diagram of each time of a loop task in the loop task management method according to the embodiment of the present application.
Fig. 5 is a third schematic diagram of each time of a loop task in the loop task management method according to the embodiment of the present application.
Fig. 6 is a schematic diagram of a wait queue in a round-robin task management method according to an embodiment of the present application.
Fig. 7 is a schematic diagram of a change process of a wait queue along with a current time change in a round-robin task management method according to an embodiment of the present application.
Fig. 8 is a schematic structural diagram of a loop task management device according to an embodiment of the present application.
Fig. 9 is a schematic structural diagram of a data server according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. It is to be understood that the embodiments described are only a few embodiments of the present application and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, fig. 1 is a schematic view of a scene of an intelligent traffic system according to an embodiment of the present application, where the system may include a device and a server that are connected and communicated through an SIP (session initiation Protocol) gateway, which is not described again, where the device includes a front-end device 11 and the like, the server includes a data server 12 and a communication server, and fig. 1 does not show the communication server and the like, where:
the front-end device 11 includes, but is not limited to, an embedded high-definition camera, an industrial personal computer, a high-definition camera, and the like, and is configured to perform data acquisition on a vehicle and a pedestrian passing through the front-end device, where the data acquisition includes, but is not limited to, a license plate number of the vehicle (the number may be a fake plate or a fake plate), a license plate type (a blue-bottom license plate of a private car, a yellow-bottom license plate of a truck, and the like), and illegal behaviors of the pedestrian.
The server includes a local server and/or a remote server, etc. The data server 12 and the communication server may be deployed on local servers, or may be partially or wholly deployed on remote servers.
The data server 12 may receive a task execution request carrying a cycle task execution period sent by the terminal; determining an absolute execution time set of the cyclic task according to the execution period of the cyclic task and the local time; detecting the execution state of the cycle task to obtain the time execution ending time of the ith cycle task; determining the theoretical execution time of the (i + 1) th cycle task according to the actual execution ending time and the cycle task execution period; and correcting the actual execution time of the (i + 1) th cycle task according to the comparison result of the theoretical execution time and the absolute execution time set, so that the actual execution time of the (i + 1) th cycle task is the absolute execution time set.
It should be noted that the local time refers to the time of a place set by the server, for example, if the server is set in a place using the beijing time, the local time is the beijing time, and the server can periodically update the local time through the beijing system to ensure the time accuracy.
It should be noted that the system scenario diagram shown in fig. 1 is an example, and the server and the scenario described in the embodiment of the present application are for more clearly illustrating the technical solution of the embodiment of the present application, and do not form a limitation on the technical solution provided in the embodiment of the present application, and as a person having ordinary skill in the art knows, with the evolution of the system and the occurrence of a new service scenario, the technical solution provided in the embodiment of the present application is also applicable to similar technical problems. The following are detailed below. It should be noted that the following description of the embodiments is not intended to limit the preferred order of the embodiments.
Fig. 2 is a schematic flowchart of a loop task management method according to an embodiment of the present application, please refer to fig. 2, where the loop task management method includes the following steps:
201: and the data server receives a task execution request which is sent by the terminal and carries a cycle task execution period.
In one embodiment, when the data server interacts with the terminal, for example, when the data server receives a real-time monitoring video stream sent by the front-end device, in order to ensure that the real-time monitoring video stream is successfully transmitted, it is necessary to ensure that the connection between the data server and the front-end device is stable, so that the front-end device sends a task execution request, so that the data server can monitor whether the connection between the data server and the front-end device is stable by executing a circular task, and perform corresponding operations, for example, alarming, when the data server is disconnected from the front-end device, so that the connection between the data server and the front-end device can be re-established, and meanwhile, the interaction between the data server and the terminal also includes the interaction between the data server and the user terminal, for example, when the data server and the traffic police terminal perform illegal data transmission, in order to ensure that the, the connection between the data server and the traffic police terminal needs to be ensured to be stable, so that the task execution request sent by the traffic police terminal can be received, whether the connection between the data server and the traffic police terminal is stable or not is monitored according to the cyclic task, and when the disconnection between the data server and the traffic police terminal is monitored, corresponding operation is performed, for example, the connection between the traffic police terminal and the data server is reestablished.
In one embodiment, the real-time monitoring video stream includes videos shot by front-end devices, such as high-definition cameras, and includes real-time monitoring of vehicles passing through the front-end devices and real-time monitoring of pedestrians passing through the front-end devices, and meanwhile, in the real-time monitoring video stream, information of corresponding time and addresses of the front-end devices can be recorded, so that when illegal behaviors occur in the real-time monitoring video stream, corresponding recording can be performed on the time and the addresses of the illegal behaviors, and the illegal behaviors can be processed according to the corresponding records.
In an embodiment, the illegal data refers to illegal related data content obtained by monitoring the video stream in real time, and the illegal data may be video data or picture data, and the illegal time point, the illegal time and place, specific illegal behaviors, and the like can be obtained according to the illegal data.
In an embodiment, the cyclic task refers to a task with the same task content executed according to a cyclic task execution period, for example, a data server sends a heartbeat packet to detect whether a terminal is disconnected; the cycle task execution period refers to a specific time interval at which the cycle task is executed according to the execution requirement of the cycle task, namely the cycle task refers to a task in which the same task is executed for a plurality of times at the same time interval.
202: and determining an absolute execution time set of the cyclic task according to the execution period of the cyclic task and the local time.
In an embodiment, after obtaining the execution period of the loop task and the local time, an absolute execution time set of the loop task may be determined according to the execution period of the loop task and the local time, where for example, the execution period of the loop task is 3 seconds, and the local time is 9: 00:00, the absolute execution time set of the loop task can be obtained as 9: 00:00 followed by 3 seconds, 6 seconds, 9 seconds, 12 seconds, …, and then when executing the loop task, execution may proceed according to the set of absolute execution times for the loop task.
It should be noted that, the specific time used in the embodiment of the present application is to describe an implementation process of the scheme of the present application, and the setting manner is not limited to the specific implementation manner of the present application, and in the execution process of the actual cyclic task, the absolute execution time set of the cyclic task is obtained according to the actual cyclic task execution period of the cyclic task and the local time.
203: and detecting the execution state of the loop task to obtain the actual execution ending time of the ith loop task.
In one embodiment, the actual execution end time refers to a time corresponding to the absolute execution time of the loop task, and does not refer to a time after the loop task is completely executed, but refers to a time added to the queue after the loop task is generated, for example, after the absolute execution time of the loop task is 6 seconds, the actual execution end time may be 6 seconds later or 7 seconds later.
In an embodiment, during the execution of the loop task, the execution state of the loop task may be detected, so as to obtain the actual execution end time of the loop task, for example, when a certain execution time of the loop task is set to be 6 seconds and then executed, but when the actual execution end time is 7 seconds, the actual execution end time may be recorded as 7 seconds.
In the embodiment of the present application, i and i +1 refer to one of the loop tasks, and do not refer to the loop task at a specific time point in the loop task, and i refers to a positive integer greater than or equal to one.
In one embodiment, when the execution state of the loop task is detected, the execution state of the loop task can be detected in real time, so that the actual execution end time of each loop task is obtained.
In an embodiment, when detecting the execution state of the loop task, the loop task may be detected according to a detection period, and when detecting the loop task according to the detection period, if the loop task execution is not detected, the detection period is shortened, so that the actual execution end time of the loop task can be detected, which includes: setting a detection period according to the execution period of the circular task; judging whether the circulating task is triggered or not according to the detection period; when the cyclic task is not triggered, shortening the detection period to obtain an updated detection period; judging whether the cyclic task is triggered or not according to the updating detection period; when the cycle task is triggered, recording the triggering time of the cycle task, and modifying the updating detection period into a detection period; obtaining the actual execution ending time of the ith cycle task according to the cycle task triggering time; specifically, for example, if the execution period of the loop task is 3 seconds, the detection period may be set to 3 seconds, if the loop task is executed according to the execution period, the trigger of the loop task may be detected according to the detection period, if the trigger of the loop task is not detected when the detection period arrives when the detection period is detected according to the detection period, the detection period needs to be shortened, and the update detection period is used to detect whether the loop task is triggered, for example, the detection period of 3 seconds is shortened to the update detection period of 0.5 seconds, so that the trigger time of the loop task may be accurately detected, and the actual execution end time of the loop task may be obtained, and after the trigger time of the loop task is detected, considering that the present application may correct the time error, so that the update detection period of the loop task may be modified into the detection period, where modifying the update detection period into the detection period means after the time error of the loop task is, and detecting the detection period according to the cycle task execution period of the cycle task, namely after the updated detection period is modified into the detection period, for example, after the absolute execution time of the (i + 1) th cycle task is 6 seconds, detecting once after 6 seconds according to the detection period, and then sequentially detecting according to the detection period until the cycle task trigger is not detected on the detection period again.
204: and determining the theoretical execution time of the (i + 1) th cycle task according to the actual execution ending time and the cycle task execution period.
In one embodiment, the theoretical execution time refers to an execution time of a next loop task (i +1 th loop task) obtained according to an actual execution end time of a previous loop task (i-th loop task) and an execution period of the loop task, for example, after the actual execution end time of the previous loop task is 7 seconds, the execution period of the loop task is 3 seconds, and then the theoretical execution time of the next loop task is 10 seconds.
205: and correcting the actual execution time of the (i + 1) th cycle task according to the comparison result of the theoretical execution time and the absolute execution time set, so that the actual execution time of the (i + 1) th cycle task belongs to the absolute execution time set.
In one embodiment, in order to execute a loop task according to an absolute execution time set when executing the loop task, when a theoretical execution time of the loop task belongs to the absolute execution time set, the loop task is executed according to the theoretical execution time, and when the theoretical execution time of the loop task does not belong to the absolute execution time set, the theoretical execution time of the loop task is corrected to an actual execution time, so that the loop task is executed according to the absolute execution time in the absolute execution time set, so that a time error can be corrected when the time error occurs, and the loop task is normally executed, the step includes: judging whether the theoretical execution time is equal to the absolute execution time in the absolute execution time set or not; when the theoretical execution time is equal to the absolute execution time in the absolute execution time set, taking the theoretical execution time as the actual execution time of the (i + 1) th cycle task; when the theoretical execution time is not equal to the absolute execution time in the absolute execution time set, correcting the actual execution time of the (i + 1) th cycle task; specifically, as shown in fig. 3, taking a time axis T as an example, assuming that the absolute execution time set of the loop tasks includes the loop tasks executed sequentially after 3 seconds, after 6 seconds, after 9 seconds, and after 12 seconds, and assuming that the absolute execution time of the ith loop task is 3 seconds, and the actual execution end time of the ith loop task is 3 seconds, the theoretical execution time of the (i + 1) th loop task is 6 seconds later, that is, the theoretical execution time of the (i + 1) th loop task belongs to the loop task execution time set, and it indicates that no time error occurs in the absolute execution time of the loop task at this time, the theoretical execution time of the (i + 1) th loop task is directly taken as the actual execution time of the (i + 1) th loop task, and the (i + 1) th loop task is executed; assuming that the actual execution end time of the i-th loop task is 4 seconds later, the theoretical execution time of the i + 1-th loop task is 7 seconds later, but the i + 1-th loop task does not belong to the loop task absolute execution time set after 7 seconds later, and therefore the theoretical execution time of the i + 1-th loop task needs to be corrected to the actual execution time, for example, after 7 seconds, the theoretical execution time needs to be corrected to 6 seconds later, so that the loop task is executed according to the absolute execution time set.
In an embodiment, when the theoretical execution time is not equal to the absolute execution time in the absolute execution time set, the actual execution time of the (i + 1) th round task may be corrected by the theoretical execution time and the absolute execution time set, and the actual execution time of the (i + 1) th round task may be determined by obtaining the absolute execution time closest to the theoretical execution time and according to the absolute execution time and the theoretical execution time, where the step includes: acquiring the absolute execution time which is closest to the theoretical execution time in the absolute execution time set; judging whether the absolute execution time is larger than the theoretical execution time or not; when the absolute execution time is larger than the theoretical execution time, taking the last absolute execution time of the absolute execution time set in the absolute execution time set as the actual execution time of the (i + 1) th cycle task; when the absolute execution time is smaller than the theoretical execution time, taking the absolute execution time as the actual execution time of the (i + 1) th cycle task; specifically, as shown in fig. 4, assuming that the actual execution end time of the i-th loop task is 4 seconds later, the theoretical execution time of the i + 1-th loop task is 7 seconds later, at this time, the absolute execution time closest to the theoretical execution time is 6 seconds later in the set of absolute execution times, and is less than 7 seconds later after 6 seconds, at this time, the actual execution time of the i + 1-th loop task after 6 seconds can be taken as the actual execution time of the i + 1-th loop task, so as to correct the time error of the execution time of the loop task; assuming that the actual execution completion time of the i-th loop task is 8 seconds later, the theoretical execution time of the i + 1-th loop task is 11 seconds later, in which case the absolute execution time is 12 seconds later when the theoretical execution time is closest to the absolute execution time, and is greater than 11 seconds later when 12 seconds later, the actual execution time of the i + 1-th loop task may be corrected by correcting the actual execution time of the i + 1-th loop task such that the i + 1-th loop task is executed at the absolute execution time of the absolute execution time set, after 9 seconds later than the last absolute execution time of the 12 seconds later when the absolute execution time is set.
In an embodiment, when the theoretical execution time is not equal to the absolute execution time in the absolute execution time set, the actual execution time of the (i + 1) th round task may be corrected according to the actual execution end time and the absolute execution time in the absolute execution time set, and the actual execution time of the (i + 1) th round task may be corrected according to the absolute execution time and the actual execution end time by obtaining the absolute execution time in the absolute execution time set that is closest to the actual execution end time, where the step includes: acquiring the absolute execution time which is closest to the actual execution ending time in the absolute execution time set; judging whether the absolute execution time is larger than the actual execution ending time or not; when the absolute execution time is larger than the actual execution ending time, taking the absolute execution time as the actual execution time of the (i + 1) th cycle task; when the absolute execution time is less than the actual execution ending time, taking the next absolute execution time of the absolute execution time as the actual execution time of the (i + 1) th cycle task; specifically, as shown in fig. 4, assuming that the actual execution end time of the i-th loop task is 4 seconds later, the absolute execution time closest to the actual execution end time is 3 seconds later and is less than 4 seconds later after 3 seconds, and therefore the actual execution time of the i + 1-th loop task can be corrected by taking 6 seconds later, which is the next absolute execution time after 3 seconds, as the actual execution time of the i + 1-th loop task; assuming that the actual execution completion time of the i-th loop task is 8 seconds later, the absolute execution time closest to the actual execution completion time is 9 seconds later, and after 9 seconds later, the absolute execution time is more than 8 seconds later, so that the actual execution time of the i + 1-th loop task can be corrected by setting 9 seconds later as the actual execution time of the i + 1-th loop task, so that the loop tasks can be executed according to the absolute execution time with the absolute execution time set.
In an embodiment, when the actual execution time of the (i + 1) th loop task is corrected, the actual execution time of the (i + 1) th loop task may be corrected by obtaining the delay time of the loop task and then according to the delay time, and the step includes: according to the theoretical execution time, determining the absolute execution time which is smaller than the theoretical execution time in the absolute execution time set and is closest to the theoretical execution time; determining the delay time of the cyclic task according to the theoretical execution time and the absolute execution time; correcting the actual execution time of the (i + 1) th cycle task according to the delay time of the cycle task; specifically, as shown in fig. 4, assuming that the actual execution end time of the i-th loop task is 4 seconds later, after the theoretical execution time of the i + 1-th loop task is 7 seconds, the absolute execution times are collectively less than 7 seconds later and the closest absolute execution time to 7 seconds later is 6 seconds later, therefore, the delay time may be determined to be 1 second after 6 seconds and 7 seconds later, and then the actual execution time of the i + 1-th loop task is corrected according to the delay time, that is, by setting the delay time to 1 second, the actual execution time of the i + 1-th loop task may be obtained after the delay time is eliminated and is 6 seconds later, so that the actual execution time of the i + 1-th loop task is corrected; assuming that the actual execution completion time of the i-th loop task is 8 seconds later, the theoretical execution time of the i + 1-th loop task is 11 seconds later, the absolute execution times are less than 11 seconds later and the absolute execution time closest to the 11 seconds later is 9 seconds later, so that the delay time of the loop task can be determined to be 2 seconds after 9 seconds and 11 seconds later, and then the actual execution time of the i + 1-th loop task can be obtained to be 9 seconds after the 2 seconds, which is the delay time, is eliminated according to the delay time and the theoretical execution time, so that the actual execution time of the loop task can be corrected by the delay time of the loop task.
In an embodiment, as shown in fig. 4, when a time error occurs in the prior art, for example, after the actual execution end time of the ith loop task is 8 seconds, according to the prior art, after the theoretical execution time of the (i + 1) th loop task is 11 seconds, and after the theoretical execution time of the (i + 2) th loop task is 14 seconds, it can be seen that the loop task is executed only twice after 3 seconds to 12 seconds, while after the (i + 1) th loop task is corrected to 9 seconds in the embodiment of the present application, the loop task is executed three times after 3 seconds to 12 seconds, while in the connection between the server and the terminal, the fewer the number of the loop task is executed, the problem that the loop task cannot realize the function thereof is caused, for example, the detection function of the heartbeat packet cannot be realized when the heartbeat packet is sent, while after the embodiment of the present application corrects the (i + 1) th loop task, the number of the loop task execution can be avoided from being reduced, thereby realizing the detection function of the heartbeat packet.
In an embodiment, an execution queue of the loop tasks may be set, then the loop task is selected from the execution queue of the loop tasks as the (i + 1) th loop task, and the theoretical execution time of the (i + 1) th loop task is corrected to the actual execution time, and the step includes: according to the execution time set of the cyclic task; acquiring an execution queue of a circular task; judging whether the difference value between the actual execution ending time of the ith cyclic task and the absolute execution time of the ith cyclic task is greater than the execution period of the cyclic task or not according to the absolute execution time of the ith cyclic task and the actual execution ending time of the ith cyclic task; when the difference value between the actual execution ending time of the ith cyclic task and the absolute execution time of the ith cyclic task is greater than the execution period of the cyclic task, taking the cyclic task with the absolute execution time greater than the actual execution ending time and closest to the actual execution ending time in the execution queue of the cyclic task as the (i + 1) th cyclic task; acquiring the theoretical execution time of the (i + 1) th cycle task; correcting the actual execution time of the (i + 1) th cycle task according to the absolute execution time of the (i + 1) th cycle task and the theoretical execution time of the (i + 1) th cycle task; specifically, as shown in fig. 5, based on the execution time set of the loop tasks, for example, after 3 seconds, after 6 seconds, after 9 seconds, after 12 seconds, the loop task execution period is 3 seconds, and an execution list of the loop tasks is obtained, including the loop task of the number 1, the loop task of the number 2, the loop task of the number 3, and the loop task of the number 4, assuming that the loop task of the number 1 is the ith loop task, and the absolute execution time of the ith loop task is 3 seconds, the actual execution end time of the ith loop task, and assuming that 8 seconds later, the difference between the actual execution end time of the ith loop task, that is, 8 seconds later, and the absolute execution time of the ith loop task, that is, 3 seconds later, is 5 seconds later, and 5 seconds later than the loop task execution period is 3 seconds later, the loop task whose absolute execution time is 8 seconds later than the actual execution end time and closest to the actual execution end time is taken as the i +1 st loop task The loop task, namely the loop task with the absolute execution time of 3 after 9 seconds, is taken as the (i + 1) th loop task, the theoretical execution time of the (i + 1) th loop task is obtained, namely 11 seconds later, and then the actual execution time of the (i + 1) th loop task is corrected according to the absolute execution time of the (i + 1) th loop task, namely 9 seconds later, and the theoretical execution time of the (i + 1) th loop task, namely 11 seconds later, namely the actual execution time of the (i + 1) th loop task is obtained after the 11 seconds later is corrected to 9 seconds later.
In one embodiment, when there is an unexecuted loop task in the execution queue of the loop task, such as the loop task with sequence number 2 in fig. 5, the loop task with sequence number 2 may be deleted.
In an embodiment, when determining whether the difference between the actual execution end time of the ith round task and the absolute execution time of the ith round task is greater than the round task execution period, there is also a case that the difference between the actual execution end time of the ith round task and the absolute execution time of the ith round task is less than the round task execution period, at this time, the round task located next to the ith round task in the execution queue of the round task may be regarded as the (i + 1) th round task, and then the time execution time of the (i + 1) th round task is corrected, this step includes: when the difference value between the actual execution ending time of the ith cyclic task and the absolute execution time of the ith cyclic task is smaller than the execution period of the cyclic task, taking the cyclic task positioned at the next position of the ith cyclic task in the execution queue of the cyclic task as the (i + 1) th cyclic task; determining the absolute execution time of the (i + 1) th cycle task according to the absolute execution time of the ith cycle task and the cycle task execution period; acquiring the theoretical execution time of the (i + 1) th cycle task; correcting the actual execution time of the (i + 1) th cycle task according to the absolute execution time of the (i + 1) th cycle task and the theoretical execution time of the (i + 1) th cycle task; specifically, as shown in fig. 5, assuming that the loop task with the number 1 is the i-th loop task, the actual execution end time of the i-th loop task is 4 seconds later, the absolute execution time of the i-th loop task is 3 seconds later, and the difference between the time after 4 seconds and the time after 3 seconds is less than the loop task execution period, i.e., 3 seconds, the loop task at the position next to the i-th loop task in the loop task execution queue is the i + 1-th loop task, i.e., the loop task with the number 2 at the position next to the number 1 is the i + 1-th loop task, and meanwhile, according to the absolute execution time of the i-th loop task, i.e., 3 seconds later, and the loop task execution period, i.e., 3 seconds, the absolute execution time of the i + 1-th loop task can be determined to be 6 seconds later, then the theoretical execution time of the i + 1-th loop task, i.e., 7 seconds later, and then, according to the absolute execution time of the (i + 1) th cycle task and the theoretical execution time of the (i + 1) th cycle task, correcting the actual execution time of the (i + 1) th cycle task, namely correcting the actual execution time to be 6 seconds after 7 seconds, so that the cycle tasks can be executed according to the absolute execution time with the absolute execution time set.
In one embodiment, when the actual execution ending time of the i-th loop task is detected and then the theoretical execution time of the i + 1-th loop task is obtained to be not equal to the absolute execution time in the absolute execution time set, in order to verify that no detection error occurs, whether the actual execution ending time of the i + 1-th loop task is equal to the absolute execution time in the absolute execution time set may be used to determine that the detection is correct and the time error of the loop task needs to be corrected when the actual execution ending time of the i + 1-th loop task is not equal to the absolute execution time in the absolute execution time set, so that the actual execution time of the i + 2-th loop task is corrected, and when the actual execution ending time of the i + 1-th loop task is equal to the absolute execution time in the absolute execution time set, the detection error occurs, the actual execution time of the (i + 2) th round task may not be modified, which includes: when the theoretical execution time is not equal to the absolute execution time in the absolute execution time set, acquiring the actual execution ending time of the (i + 1) th cycle task; judging whether the actual execution ending time of the (i + 1) th cycle task is equal to the absolute execution time in the absolute execution time set or not; when the actual execution ending time of the (i + 1) th cycle task is not equal to the absolute execution time in the absolute execution time set, modifying the actual execution time of the (i + 2) th cycle task; when the actual execution end time of the (i + 1) th cycle task is equal to the absolute execution time in the absolute execution time set, not modifying the actual execution time of the (i + 2) th cycle task.
In an embodiment, after obtaining the actual execution time of each loop task, the loop tasks need to be added into the wait queue, and each loop task can be added into the wait queue according to the time sequence of the absolute execution time of the loop task, considering that when the loop tasks are executed, if absolute time sequencing is adopted, the absolute time of each loop task needs to be continuously updated, therefore, in the embodiment of the present application, when the loop tasks are added into the wait queue, the wait time of the loop task at the head position of the wait queue is made to be absolute time, and the wait time of the loop task at the non-head position is made to be relative time, at this time, after the actual execution time of each loop task is determined, the execution time of the loop task needs to be determined according to the actual execution time of the loop task and the current time, and then the execution time of each loop task needs to be determined according to the current, determining the waiting time of the cyclic task at the head position as absolute time, and the waiting time of the cyclic task at the non-head position as relative time, wherein the steps comprise: setting the waiting time of the circular task at the head position of the waiting queue as absolute time according to the current time and the execution time of the circular task; the absolute time is a time difference of the execution time of the loop task of the head position with respect to the current time.
In an embodiment, as shown in fig. 6, assuming that the execution time of the loop task is obtained according to the current time and the actual execution time of the loop task, the waiting time of the loop task may be obtained according to the execution time of the loop task, as shown in fig. 6, where the current time 61 is 12:59: 57, then according to the current time and the execution time of the circular task at the head position of the waiting queue, in fig. 6, a task one 621 is taken as the circular task at the head position of the waiting queue, and at the same time, the execution time 622 of the task one 621 is obtained, that is, 13:00: 00, after the current time 61 and the execution time 622 of the task one 621 are obtained, the absolute time 623 of the loop task at the head position is obtained to be 3 seconds, that is, the task one is added to the execution queue after 3 seconds.
In fig. 6, the waiting time column indicates the waiting time of each loop task, the waiting time of the loop task at the head position is absolute time, the waiting time of the loop task at the non-head position is relative time, the updated waiting time column indicates the updated waiting time of each loop task, the loop task at the head position is absolute time, and the waiting time of the loop task at the non-head position is relative time.
It should be noted that the time axis T in fig. 6 includes each time along the range from 00:00:00 to 24:00:00, and the time axis T in fig. 6 shows two times "12: 59: 00" and "13: 00: 06", and the corresponding tasks are sorted according to the time corresponding to the time axis T.
In one embodiment, after obtaining the waiting time of the head position round robin task, the waiting time of the head position round robin task in the waiting queue needs to be obtained, and the step includes: setting the waiting time of the cyclic task at the non-head position of the waiting queue as relative time according to the execution time of each cyclic task; the relative time is a time difference between the execution time of the loop task at the non-head position and the execution time of the previous loop task.
In one embodiment, when the waiting time of the loop task at the non-head position in the waiting queue is set as the relative time, the execution time of the loop task and the execution time of the previous loop task of the loop task need to be known, so that the relative time of the loop task can be determined, the step includes: searching the previous cycle task corresponding to the cycle task according to the position of each cycle task in the non-head position in the waiting queue; determining the relative time of the cyclic task and the last cyclic task according to the execution time of the cyclic task and the execution time corresponding to the last cyclic task; specifically, as shown in fig. 6, when it is required to determine the relative time from task two 631 to task N, where the task N is denoted by 651, the position of each loop task is obtained, and then the last loop task of the loop task and the execution time of the last loop task are obtained, for example, the last loop task of task two 631 is task one 621, and the execution time 632 of task two 631 is 13:00: 03, execution time 622 of task one 621 is 13:00: 00, after the relative time 633 of the second task 631 is 3 seconds after the first task is executed, the last cycle task of the third task 641 is the second task 631, and the execution time 642 of the third task 641 is 13:00:06, the execution time of task two 631 is 13:00: 03, after the relative time of task three 641 is 3 seconds after task two is executed, …, the execution time 652 of task N with reference numeral 651 is ab: cd: ef (the time is later than the time of the task three), assuming that the difference between the execution time of the task N and the execution time of the task N-1 is 3k seconds, the relative time of the task N, which is labeled 651, is 3k seconds after the task N-1 is executed, and accordingly, the relative time of each non-head-position cyclic task is obtained according to the execution time of each cyclic task and the previous cyclic task.
It should be noted that the current time is the local time of the server, for example, if the server is set in a place where the beijing time is adopted, the current time is the beijing time, and the server can periodically update the local time through the beijing system to ensure the time accuracy.
It should be noted that, the time used in the embodiment of the present application is used to describe the implementation process of the scheme of the present application, and the setting manner is not limited to the specific implementation manner of the present application, and in the processing process of the actual cyclic task, the setting is performed according to the execution time and the actual time interval of each cyclic task, for example, two execution periods are separated between two adjacent cyclic tasks, and the actual time interval of two cyclic tasks is two execution periods instead of one execution period.
In fig. 6 and 7, task N indicates the nth task, and since the task contents of the loop task are the same, task N indicates the nth task to be executed, and the execution time of task N is different from that of task one, and does not indicate that task N is different from that of task one, and since the execution cycle of the loop task is set to 3 seconds in fig. 6 and 7, the value of 3k in fig. 6 and 7 is the difference between the execution time of task N and the execution time of task N-1, and k is a positive integer.
In one embodiment, the latency of the round-robin task that dynamically updates the head position is required as the current time changes, this step includes: and dynamically updating the waiting time of the cyclic task of the head position according to the current time.
In one embodiment, when the current time changes, the absolute time of the cyclic task at the head position is updated, so that the cyclic task at the head position can be added to the execution queue when the execution time of the cyclic task at the head position reaches, and in the updating process, when the current time passes 1 second, the absolute time is reduced by 1 second, for example, when the current time is from 57 th to 58 th, the absolute time is updated from 3 seconds to 2 seconds, so that the absolute time of the cyclic task at the head position is continuously updated, and the cyclic task at the head position can be added to the execution queue according to the execution time and executed.
In one embodiment, after the step of dynamically updating the waiting time of the cyclic task at the head position according to the current time, the method further includes adding the cyclic task at the head position as the task to be executed to an execution queue when the absolute time of the cyclic task at the head position arrives.
In one embodiment, when the execution time of the loop task at the head position reaches, that is, when the absolute time is zero, the loop task at the head position is added to the execution queue as the task to be executed, so that the loop task is executed.
In one embodiment, after the step of adding the round-robin task at the head position as the to-be-executed task to the execution queue when the absolute time of the round-robin task at the head position is reached, the method further includes determining a next round-robin task of the to-be-executed task in the waiting queue as the round-robin task at the head position in the waiting queue, and setting the waiting time of the round-robin task at the head position as the absolute time.
In one embodiment, after adding the task to be executed to the execution queue, the next round task of the task to be executed is updated to the round task at the head position in the waiting queue, and the waiting time of the round task at the head position is set to an absolute time, as shown in fig. 6, after the task one 621 at the head position in the waiting queue is added to the execution queue as the task to be executed, the absolute time of the task one 621 at the head position does not need to be updated, at this time, the next round task at the head position in the waiting queue, i.e., task two 631, is determined to be the round task at the head position in the waiting queue, then the waiting time of task two 631 is updated to an absolute time 634, i.e., after 3 seconds, while the execution time is reserved at the relative time of the round task following task two, without being updated, e., the relative time 643 of task three 641 is reserved, i.e., after task two executes, the relative time 653 for task N, designated 651, remains, i.e., 3k seconds after task N-1 has been performed.
The embodiment of the application provides a method for managing circular tasks, which performs relative time sequencing on the waiting time of the circular tasks in a waiting queue, so that when the circular tasks in the waiting queue are added into an execution queue, only the waiting time of the circular tasks at the head position of the waiting queue needs to be updated, and the relative time of the circular tasks at the non-head position in the waiting queue does not need to be updated, thereby reducing the amount of changed data.
Fig. 7 is a schematic diagram of a change process of a wait queue along with a current time change in a round robin task management method according to an embodiment of the present application, please refer to fig. 7:
after setting waiting time for each circular task in the waiting queue according to the current time and the execution time of each circular task, obtaining a waiting queue I71, wherein the waiting queue I71 comprises each circular task and the waiting time of each circular task, the waiting queue I71 comprises the waiting time of a task I711 and a task I711 which are positioned at head positions, namely after the absolute time is 3 seconds, the waiting time of a task II 712 and a task II 712 which are positioned at non-head positions, namely after the relative time is 3 seconds for executing the task I, the waiting time of a task III 713 and a task III 713, namely after the relative time is 3 seconds for executing the task II, …, the waiting time of a task N which is marked 714 and the waiting time of a task N which is marked 714 are 3k seconds for executing the task N-1;
taking the time axis T as an example, assuming that after the current time changes by 0.5 second, the waiting queue one 71 is changed into the waiting queue two 72, and meanwhile, the waiting queue two 72 only needs to change the waiting time of the task one 721 at the head position, that is, the absolute time of the task one 721 is updated to 2.5 seconds from 3 seconds later, and the waiting time from the task two 712 at the non-head position to the task N with the reference numeral 714 does not need to be updated;
with the change of the current time, when the execution time of the task one 721 at the head position of the wait queue two 72 arrives, that is, the wait time is 0, the wait queue two 72 is updated to the wait queue three 73, the task one 721 at the head position in the wait queue two 72 is added to the execution queue, the wait time of the loop task update at the head position of the wait queue three 73 to the task two 731, the wait time of the task two 731 is set to the absolute time, that is, after 3 seconds, and the wait time of the task three 713 after the task two 731 to the task N with the reference number 714 does not need to be updated.
The embodiment of the application provides a change process of a waiting queue along with the change of the current time, and as can be seen from the change process of the waiting queue, when the waiting time of a circular task is updated, only the waiting time of the circular task at the head position in the waiting queue needs to be updated, and the waiting time of the circular task at the non-head position in the waiting queue does not need to be updated, so that the change data volume is reduced.
The embodiment of the application obtains the actual execution ending time of the ith cycle task, namely any cycle task, by detecting the execution state of the cycle task, so as to obtain the theoretical execution time of the next cycle task, compare the theoretical execution time with the absolute execution time set, judge whether a time error occurs, correct the actual execution time of the next cycle task when the time error occurs, thereby correcting the time error when the time error occurs in the cyclic task, and avoiding the problem of the execution of the cyclic task caused by the detection error by verifying whether the detection error occurs, meanwhile, the actual execution time of the (i + 1) th cycle task can be corrected through the actual execution time of the (i) th cycle task, the theoretical execution time of the (i + 1) th cycle task and the delay time of the cycle task, so that the time error is eliminated.
Correspondingly, fig. 8 is a schematic structural diagram of a loop task management device according to an embodiment of the present application; referring to fig. 8, the loop task management apparatus includes the following modules:
a receiving module 801, configured to receive a task execution request carrying a cycle task execution period sent by the terminal;
a first determining module 802, configured to determine an absolute execution time set of the cyclic task according to the execution period of the cyclic task and the local time;
a detecting module 803, configured to detect an execution state of the loop task, and obtain an actual execution end time of an ith loop task;
a second determining module 804, configured to determine a theoretical execution time of the (i + 1) th cyclic task according to the actual execution end time and the cyclic task execution period;
a correcting module 805, configured to correct the actual execution time of the (i + 1) th round task according to a comparison result between the theoretical execution time and the absolute execution time set, so that the actual execution time of the (i + 1) th round task belongs to the absolute execution time set.
In one embodiment, the modification module 805 is configured to determine whether the theoretical execution time is equal to an absolute execution time in the absolute execution time set; when the theoretical execution time is equal to the absolute execution time in the absolute execution time set, taking the theoretical execution time as the actual execution time of the (i + 1) th cycle task; and when the theoretical execution time is not equal to the absolute execution time in the absolute execution time set, correcting the actual execution time of the (i + 1) th cycle task.
In one embodiment, the modification module 805 is configured to obtain an absolute execution time closest to the theoretical execution time in an absolute execution time set; judging whether the absolute execution time is larger than the theoretical execution time or not; when the absolute execution time is larger than the theoretical execution time, taking the last absolute execution time of the absolute execution time set in the absolute execution time set as the actual execution time of the (i + 1) th cycle task; and when the absolute execution time is less than the theoretical execution time, taking the absolute execution time as the actual execution time of the (i + 1) th cycle task.
In one embodiment, the modification module 805 is configured to obtain an absolute execution time closest to the actual execution ending time in the absolute execution time set; judging whether the absolute execution time is larger than the actual execution ending time or not; when the absolute execution time is larger than the actual execution ending time, taking the absolute execution time as the actual execution time of the (i + 1) th cycle task; and when the absolute execution time is less than the actual execution ending time, taking the next absolute execution time of the absolute execution time as the actual execution time of the (i + 1) th cycle task.
In one embodiment, the modification module 805 is configured to determine, according to the theoretical execution time, an absolute execution time in the absolute execution time set that is smaller than the theoretical execution time and closest to the theoretical execution time; determining the delay time of the cyclic task according to the theoretical execution time and the absolute execution time; and correcting the actual execution time of the (i + 1) th cycle task according to the delay time of the cycle task.
In an embodiment, the modification module 805 is configured to obtain an execution queue of the loop task according to an absolute execution time set of the loop task; judging whether the difference value between the actual execution ending time of the ith cyclic task and the absolute execution time of the ith cyclic task is greater than the execution period of the cyclic task or not according to the absolute execution time of the ith cyclic task and the actual execution ending time of the ith cyclic task; when the difference value between the actual execution ending time of the ith cyclic task and the absolute execution time of the ith cyclic task is greater than the execution period of the cyclic task, taking the cyclic task with the absolute execution time greater than the actual execution ending time and closest to the actual execution ending time in the execution queue of the cyclic task as the (i + 1) th cyclic task; acquiring the theoretical execution time of the (i + 1) th cycle task; and correcting the actual execution time of the (i + 1) th cycle task according to the absolute execution time of the (i + 1) th cycle task and the theoretical execution time of the (i + 1) th cycle task.
In one embodiment, the modification module 805 is configured to, when a difference between an actual execution end time of the ith round task and an absolute execution time of the ith round task is less than a round task execution period, regard a round task located next to the ith round task in an execution queue of the round task as the (i + 1) th round task; determining the absolute execution time of the (i + 1) th cycle task according to the absolute execution time of the ith cycle task and the cycle task execution period; acquiring the theoretical execution time of the (i + 1) th cycle task; and correcting the actual execution time of the (i + 1) th cycle task according to the absolute execution time of the (i + 1) th cycle task and the theoretical execution time of the (i + 1) th cycle task.
In an embodiment, the modification module 805 is configured to obtain an actual execution end time of the (i + 1) th round task when the theoretical execution time is not equal to the absolute execution time in the absolute execution time set; judging whether the actual execution ending time of the (i + 1) th cycle task is equal to the absolute execution time in the absolute execution time set or not; when the actual execution ending time of the (i + 1) th cycle task is not equal to the absolute execution time in the absolute execution time set, correcting the actual execution time of the (i + 2) th cycle task; when the actual execution end time of the (i + 1) th cycle task is equal to the absolute execution time in the absolute execution time set, not modifying the actual execution time of the (i + 2) th cycle task.
In one embodiment, the detection module 803 is configured to set a detection period according to the execution period of the loop task; judging whether the circulating task is triggered or not according to the detection period; when the cyclic task is not triggered, shortening the detection period to obtain an updated detection period; judging whether the cyclic task is triggered or not according to the updating detection period; when the cycle task is triggered, recording the triggering time of the cycle task, and modifying the updating detection period into a detection period; and obtaining the actual execution ending time of the ith cycle task according to the cycle task triggering time.
Accordingly, embodiments of the present application also provide a data server, as shown in fig. 9, the data server may include Radio Frequency (RF) circuit 901, memory 902 including one or more computer-readable storage media, input unit 903, display unit 904, sensor 905, audio circuit 906, Wireless Fidelity (WiFi) module 907, processor 908 including one or more processing cores, and power supply 909. Those skilled in the art will appreciate that the data server architecture shown in FIG. 9 does not constitute a limitation of data servers and may include more or fewer components than shown, or some combination of components, or a different arrangement of components. Wherein:
RF circuit 901 may be used for receiving and transmitting signals during a message transmission or communication process, and in particular, for receiving downlink information from a base station and then processing the received downlink information by one or more processors 908; in addition, data relating to uplink is transmitted to the base station. The memory 902 may be used to store software programs and modules, and the processor 908 executes various functional applications and data processing by operating the software programs and modules stored in the memory 902. The input unit 903 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
The display unit 904 may be used to display information input by or provided to the user and various graphical user interfaces of the server, which may be made up of graphics, text, icons, video, and any combination thereof.
The data server may also include at least one sensor 905, such as light sensors, motion sensors, and other sensors. The audio circuitry 906 includes speakers that can provide an audio interface between the user and the data server.
WiFi belongs to short distance wireless transmission technology, and the data server can help the user send and receive e-mail, browse web page and access streaming media etc. through WiFi module 907, which provides wireless broadband internet access for the user. Although fig. 9 shows the WiFi module 907, it is understood that it does not belong to the essential constitution of the data server, and may be omitted entirely as needed within the scope of not changing the essence of the application.
The processor 908 is the control center of the data server, connects various parts of the entire handset using various interfaces and lines, and performs various functions of the data server and processes data by running or executing software programs and/or modules stored in the memory 902 and calling data stored in the memory 902, thereby performing overall monitoring of the handset.
The data server also includes a power supply 909 (such as a battery) that provides power to the various components, which may preferably be logically connected to the processor 908 via a power management system, such that the functions of managing charging, discharging, and power consumption are performed via the power management system.
Although not shown, the data server may further include a camera, a bluetooth module, and the like, which are not described in detail herein. Specifically, in this embodiment, the processor 908 in the data server loads the executable file corresponding to the process of one or more application programs into the memory 902 according to the following instructions, and the processor 908 runs the application program stored in the memory 902, so as to implement the following functions:
receiving a task execution request which is sent by the terminal and carries a cycle task execution period; determining an absolute execution time set of the cyclic task according to the execution period of the cyclic task and the local time; detecting the execution state of the cycle task to obtain the actual execution ending time of the ith cycle task; determining the theoretical execution time of the (i + 1) th cycle task according to the actual execution ending time and the cycle task execution period; and correcting the actual execution time of the (i + 1) th cycle task according to the comparison result of the theoretical execution time and the absolute execution time set, so that the actual execution time of the (i + 1) th cycle task belongs to the absolute execution time set.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by instructions or by associated hardware controlled by the instructions, which may be stored in a computer readable storage medium and loaded and executed by a processor.
To this end, an embodiment of the present application provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to implement the following functions:
receiving a task execution request which is sent by the terminal and carries a cycle task execution period; determining an absolute execution time set of the cyclic task according to the execution period of the cyclic task and the local time; detecting the execution state of the cycle task to obtain the actual execution ending time of the ith cycle task; determining the theoretical execution time of the (i + 1) th cycle task according to the actual execution ending time and the cycle task execution period; and correcting the actual execution time of the (i + 1) th cycle task according to the comparison result of the theoretical execution time and the absolute execution time set, so that the actual execution time of the (i + 1) th cycle task belongs to the absolute execution time set.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
Wherein the storage medium may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like.
Since the instructions stored in the storage medium can execute the steps in any method provided in the embodiments of the present application, the beneficial effects that can be achieved by any method provided in the embodiments of the present application can be achieved, for details, see the foregoing embodiments, and are not described herein again.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
The above detailed description is given to a method and an apparatus for managing a loop task, a data server, and a computer-readable storage medium according to an embodiment of the present application, and a specific example is applied to explain the principle and the implementation of the present application, and the description of the above embodiment is only used to help understand the technical solution and the core idea of the present application; those of ordinary skill in the art will understand that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications or substitutions do not depart from the spirit and scope of the present disclosure as defined by the appended claims.

Claims (10)

1. A cyclic task management method is characterized by being applied to a traffic police system, wherein the traffic police system comprises a data server and a terminal, and the cyclic task management method comprises the following steps:
the data server receives a task execution request which is sent by the terminal and carries a cycle task execution period;
determining an absolute execution time set of the cyclic task according to the execution period of the cyclic task and the local time;
detecting the execution state of the cycle task to obtain the actual execution ending time of the ith cycle task; the actual execution ending time is the time added into the queue after the cyclic task is generated;
determining the theoretical execution time of the (i + 1) th cycle task according to the actual execution ending time and the cycle task execution period;
and correcting the actual execution time of the (i + 1) th cycle task according to the comparison result of the theoretical execution time and the absolute execution time set, so that the actual execution time of the (i + 1) th cycle task belongs to the absolute execution time set.
2. The round robin task management method of claim 1 wherein the step of correcting the actual execution time of the (i + 1) th round robin task based on the comparison of the theoretical execution time and the set of absolute execution times such that the actual execution time of the (i + 1) th round robin task belongs to the set of absolute execution times comprises:
judging whether the theoretical execution time is equal to the absolute execution time in the absolute execution time set or not;
when the theoretical execution time is equal to the absolute execution time in the absolute execution time set, taking the theoretical execution time as the actual execution time of the (i + 1) th cycle task;
and when the theoretical execution time is not equal to the absolute execution time in the absolute execution time set, correcting the actual execution time of the (i + 1) th cycle task.
3. The round robin task management method of claim 2 wherein said step of correcting the actual execution time of the (i + 1) th round robin task when the theoretical execution time is not equal to the absolute execution time in the set of absolute execution times comprises:
acquiring the absolute execution time which is closest to the theoretical execution time in the absolute execution time set;
judging whether the absolute execution time is larger than the theoretical execution time or not;
when the absolute execution time is larger than the theoretical execution time, taking the last absolute execution time of the absolute execution time set in the absolute execution time set as the actual execution time of the (i + 1) th cycle task;
and when the absolute execution time is less than the theoretical execution time, taking the absolute execution time as the actual execution time of the (i + 1) th cycle task.
4. The round robin task management method of claim 2 wherein said step of correcting the actual execution time of the (i + 1) th round robin task when the theoretical execution time is not equal to the absolute execution time in the set of absolute execution times comprises:
acquiring the absolute execution time which is closest to the actual execution ending time in the absolute execution time set;
judging whether the absolute execution time is larger than the actual execution ending time or not;
when the absolute execution time is larger than the actual execution ending time, taking the absolute execution time as the actual execution time of the (i + 1) th cycle task;
and when the absolute execution time is less than the actual execution ending time, taking the next absolute execution time of the absolute execution time as the actual execution time of the (i + 1) th cycle task.
5. The round robin task management method of claim 2 wherein said step of correcting the actual execution time of the (i + 1) th round robin task when the theoretical execution time is not equal to the absolute execution time in the set of absolute execution times comprises:
according to the theoretical execution time, determining the absolute execution time which is smaller than the theoretical execution time in the absolute execution time set and is closest to the theoretical execution time;
determining the delay time of the cyclic task according to the theoretical execution time and the absolute execution time;
and correcting the actual execution time of the (i + 1) th cycle task according to the delay time of the cycle task.
6. The round robin task management method of claim 2 wherein said step of correcting the actual execution time of the (i + 1) th round robin task when the theoretical execution time is not equal to the absolute execution time in the set of absolute execution times comprises:
acquiring an execution queue of the cyclic task according to the absolute execution time set of the cyclic task;
judging whether the difference value between the actual execution ending time of the ith cyclic task and the absolute execution time of the ith cyclic task is greater than the execution period of the cyclic task or not according to the absolute execution time of the ith cyclic task and the actual execution ending time of the ith cyclic task;
when the difference value between the actual execution ending time of the ith cyclic task and the absolute execution time of the ith cyclic task is greater than the execution period of the cyclic task, taking the cyclic task with the absolute execution time greater than the actual execution ending time and closest to the actual execution ending time in the execution queue of the cyclic task as the (i + 1) th cyclic task;
acquiring the theoretical execution time of the (i + 1) th cycle task;
and correcting the actual execution time of the (i + 1) th cycle task according to the absolute execution time of the (i + 1) th cycle task and the theoretical execution time of the (i + 1) th cycle task.
7. The loop task management method according to claim 6, wherein the step of determining whether a difference between an actual execution end time of the i-th loop task and the absolute execution time of the i-th loop task is greater than a loop task execution period based on the absolute execution time of the i-th loop task and the actual execution end time of the i-th loop task further comprises:
when the difference value between the actual execution ending time of the ith cyclic task and the absolute execution time of the ith cyclic task is smaller than the execution period of the cyclic task, taking the cyclic task positioned at the next position of the ith cyclic task in the execution queue of the cyclic task as the (i + 1) th cyclic task;
determining the absolute execution time of the (i + 1) th cycle task according to the absolute execution time of the ith cycle task and the cycle task execution period;
acquiring the theoretical execution time of the (i + 1) th cycle task;
and correcting the actual execution time of the (i + 1) th cycle task according to the absolute execution time of the (i + 1) th cycle task and the theoretical execution time of the (i + 1) th cycle task.
8. The round robin task management method of claim 1 wherein the step of correcting the actual execution time of the (i + 1) th round robin task based on the comparison of the theoretical execution time and the set of absolute execution times such that the actual execution time of the (i + 1) th round robin task belongs to the set of absolute execution times comprises:
when the theoretical execution time is not equal to the absolute execution time in the absolute execution time set, acquiring the actual execution ending time of the (i + 1) th cycle task;
judging whether the actual execution ending time of the (i + 1) th cycle task is equal to the absolute execution time in the absolute execution time set or not;
when the actual execution ending time of the (i + 1) th cycle task is not equal to the absolute execution time in the absolute execution time set, correcting the actual execution time of the (i + 2) th cycle task;
when the actual execution end time of the (i + 1) th cycle task is equal to the absolute execution time in the absolute execution time set, not modifying the actual execution time of the (i + 2) th cycle task.
9. The loop task management method according to claim 1, wherein the step of detecting the execution state of the loop task and obtaining the actual execution end time of the ith loop task includes:
setting a detection period according to the execution period of the circular task;
judging whether the circulating task is triggered or not according to the detection period;
when the cyclic task is not triggered, shortening the detection period to obtain an updated detection period;
judging whether the cyclic task is triggered or not according to the updating detection period;
when the cycle task is triggered, recording the triggering time of the cycle task, and modifying the updating detection period into a detection period;
and obtaining the actual execution ending time of the ith cycle task according to the cycle task triggering time.
10. A cyclic task management device is applied to a traffic police system, the traffic police system comprises a data server and a terminal, and the cyclic task management device comprises:
the receiving module is used for receiving a task execution request which is sent by the terminal and carries a cycle task execution period;
the first determining module is used for determining an absolute execution time set of the cyclic task according to the execution period of the cyclic task and the local time;
the detection module is used for detecting the execution state of the cycle task to obtain the actual execution ending time of the ith cycle task; the actual execution ending time is the time added into the queue after the cyclic task is generated;
the second determining module is used for determining the theoretical execution time of the (i + 1) th cycle task according to the actual execution ending time and the cycle task execution period;
and the correction module is used for correcting the actual execution time of the (i + 1) th cycle task according to the comparison result of the theoretical execution time and the absolute execution time set, so that the actual execution time of the (i + 1) th cycle task belongs to the absolute execution time set.
CN202010978109.8A 2020-09-17 2020-09-17 Method and device for managing circular tasks Active CN111935309B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010978109.8A CN111935309B (en) 2020-09-17 2020-09-17 Method and device for managing circular tasks

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010978109.8A CN111935309B (en) 2020-09-17 2020-09-17 Method and device for managing circular tasks

Publications (2)

Publication Number Publication Date
CN111935309A CN111935309A (en) 2020-11-13
CN111935309B true CN111935309B (en) 2020-12-29

Family

ID=73335052

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010978109.8A Active CN111935309B (en) 2020-09-17 2020-09-17 Method and device for managing circular tasks

Country Status (1)

Country Link
CN (1) CN111935309B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103365710A (en) * 2012-03-31 2013-10-23 索尼公司 Real-time task scheduling device and method and computer system

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100511155C (en) * 2006-12-18 2009-07-08 上海未来宽带技术及应用工程研究中心有限公司 Method for implementing non accumulation inaccuracy and self-adaption timer
KR101468624B1 (en) * 2013-05-30 2014-12-04 삼성에스디에스 주식회사 Terminal, system and method for measuring network state using the same
CN106254198B (en) * 2016-09-13 2019-06-18 北京控制工程研究所 Distributed System-Level task synchronization method based on time trigger
GB2554638B (en) * 2016-09-28 2019-12-04 Advanced Risc Mach Ltd Error detection in communication networks
US11086704B2 (en) * 2017-04-28 2021-08-10 Honeywell International Inc. Inferred detection of data replication errors of source applications by enterprise applications
CN109639751B (en) * 2018-10-16 2021-12-21 平安科技(深圳)有限公司 Block chain link point monitoring method, device and system and computer storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103365710A (en) * 2012-03-31 2013-10-23 索尼公司 Real-time task scheduling device and method and computer system

Also Published As

Publication number Publication date
CN111935309A (en) 2020-11-13

Similar Documents

Publication Publication Date Title
CN107566786B (en) Method and device for acquiring monitoring video and terminal equipment
CN107273263B (en) Abnormal operation analysis method, application terminal and monitoring server
CN111694674B (en) Message distribution processing method, device, equipment and storage medium
WO2014166265A1 (en) Method, terminal, cache server and system for updating webpage data
CN111970215B (en) Data packet management method and device
CN112148493A (en) Streaming media task management method and device and data server
CN111340587B (en) Virtual commodity management method and related device
WO2022156586A1 (en) Network access method and device
CN111314181A (en) Network connectivity diagnosis method, device, terminal and storage medium
CN112188227A (en) Streaming media data distribution method and device
CN105429799A (en) Server backup method and device
US20230088033A1 (en) Wi-fi control method and apparatus and electronic device
CN111935497B (en) Video stream management method and data server for traffic police system
CN111935309B (en) Method and device for managing circular tasks
US11206191B2 (en) Method and system for providing seamless data transfer between communication devices
CN113791792A (en) Application calling information acquisition method and device and storage medium
CN115720193B (en) Multicast-based software deployment method and device
CN112188245B (en) Front-end camera real-time video-on-demand method and device and electronic equipment
WO2023061347A1 (en) Call processing method and apparatus, electronic device, and storage medium
CN113766630B (en) IMS network registration method and device and electronic equipment
EP2928105A2 (en) Content delivery architecture
CN111930490B (en) Streaming media task management method and device
CN111935313B (en) Connection pool management method and device
CN113839828A (en) Network quality detection method, device, terminal equipment and medium
CN111767131A (en) Streaming media task management 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