WO2020026010A2 - Task execution control method, device, equipment/terminal/server and storage medium - Google Patents

Task execution control method, device, equipment/terminal/server and storage medium Download PDF

Info

Publication number
WO2020026010A2
WO2020026010A2 PCT/IB2018/056492 IB2018056492W WO2020026010A2 WO 2020026010 A2 WO2020026010 A2 WO 2020026010A2 IB 2018056492 W IB2018056492 W IB 2018056492W WO 2020026010 A2 WO2020026010 A2 WO 2020026010A2
Authority
WO
WIPO (PCT)
Prior art keywords
work
worker
state
created
threads
Prior art date
Application number
PCT/IB2018/056492
Other languages
French (fr)
Chinese (zh)
Other versions
WO2020026010A3 (en
Inventor
张志毅
Original Assignee
优视科技新加坡有限公司
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 优视科技新加坡有限公司 filed Critical 优视科技新加坡有限公司
Publication of WO2020026010A2 publication Critical patent/WO2020026010A2/en
Publication of WO2020026010A3 publication Critical patent/WO2020026010A3/en

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/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4418Suspend and resume; Hibernate and awake

Definitions

  • the embodiments of the present application relate to the field of task regulation, and in particular, to a method, device, device / terminal / server, and computer-readable storage medium for regulating and controlling task execution.
  • Background technique
  • one of the technical problems solved by the embodiments of the present application is to provide a solution for task execution regulation to solve the frequent creation of additional tasks generated in the prior art when adjusting the number of concurrently executed work tasks. Problems with worker threads.
  • An embodiment of the present application provides a method for regulating task execution.
  • the method includes: obtaining the number of worker threads for concurrent execution of work tasks; based on the number of worker threads for concurrent execution of work tasks and a pre-created
  • the condition variable of the worker thread determines the worker thread used for concurrent execution of the work task.
  • An embodiment of the present application further provides a control device for task execution, where the device includes: a first obtaining A fetching module configured to obtain the number of worker threads used for concurrent execution of work tasks; a first determination module configured to be based on the number of the worker threads used for concurrent execution of work tasks and condition variables created in advance; Determine the worker threads used for concurrent execution of work tasks.
  • An embodiment of the present application further provides a device / terminal / server, including: one or more processors; a storage device configured to store one or more programs; when the one or more programs are stored by the one or more programs The execution of each processor causes the one or more processors to implement the method for controlling task execution as described above.
  • An embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the method for regulating and controlling task execution as described above is implemented.
  • the number of worker threads used for concurrent execution of work tasks is obtained, and based on the number of worker threads used for concurrent execution of work tasks and condition variables created in advance
  • To determine the worker threads used for concurrent execution of work tasks compared with other existing methods, use condition variables of pre-created worker threads to determine worker threads used for concurrent execution of work tasks, which can create additional work infrequently
  • the number of worker threads used for concurrent execution of work tasks is dynamically adjusted, and then the number of concurrently executed work tasks is dynamically adjusted, thereby improving the efficiency of concurrent execution of work tasks.
  • FIG. 1 is a flowchart of steps of a method for regulating task execution according to Embodiment 1 of the present application
  • FIG. 2 is a flowchart of steps of a method of regulating task execution according to Embodiment 2 of the present application
  • FIG. 3 is a flowchart according to this application Structure block diagram of a task execution regulating device according to the third embodiment
  • FIG. 4 is a structure block diagram of a task execution regulating device according to the fourth embodiment of the present application
  • FIG. 5 is a task execution according to the fifth embodiment of the present application
  • FIG. 6 is a schematic structural diagram of a device / terminal / server according to Embodiment 6 of the present application. detailed description
  • FIG. 1 there is shown a flowchart of steps of a method for adjusting task execution according to Embodiment 1 of the present application.
  • step S101 the number of worker threads used for concurrent execution of work tasks is obtained.
  • the user may first set the number of worker threads for concurrent execution of the work task in the worker thread number setter, and then obtain the number of worker threads for concurrent execution of the work task from the worker thread number setter. .
  • the number of worker threads used for concurrent execution of the work task may be automatically set by the electronic device according to the execution status of the work task.
  • the work task includes a download task. It can be understood that the above description is only exemplary, and this embodiment of the present application does not limit this in any way.
  • concurrent execution can be understood as that several work tasks are in a period of time between the start of execution and completion of execution, and these work tasks are all run on the same processor, but Only one work task runs on the processor at a time.
  • the system has only one CPU, it cannot really perform more than one worker thread at the same time. It can only divide the CPU runtime into several time periods, and then divide the time period. Allocate to each worker thread for execution, while the worker thread code in one period runs, other worker threads are in a suspended state.
  • a worker thread for concurrent execution of a work task is determined based on the number of the worker threads for concurrent execution of a work task and a condition variable of a previously created worker thread.
  • the number of pre-created worker threads is multiple, and each pre-created worker thread corresponds to a condition variable.
  • the conditional variable of the worker thread is used to implement the self-blocking logic of the worker thread. Specifically, for each worker thread in the pre-created worker thread, if the working state of the worker thread is adjusted from the awake state to the sleep state, a waiting function is called in a synchronization statement block through a condition variable of the worker thread, and the worker thread is changed. The working state of the worker is adjusted from the awake state to the dormant state.
  • the condition variable of the worker thread is used in the synchronization statement block.
  • the notification function is called during the adjustment of the working state of the worker thread from the sleep state to the awake state.
  • the working state of the worker thread created first includes the hibernation state and / or the awake state.
  • determining a worker thread used for concurrent execution of a work task based on the number of the worker threads used for concurrent execution of the work task and a condition variable created in advance if the The number of concurrently executed work threads of a work task is less than the number of pre-created worker threads, then detecting the work state of the pre-created worker thread, and adjusting the pre-created worker variable through the work variables of the pre-created worker thread.
  • the working state of the worker thread to determine the worker thread for concurrent execution of the work task. It can be understood that any implementation manner of determining a worker thread for concurrent execution of a work task based on the number of the worker threads used for concurrent execution of the work task and a condition variable created in advance may be applicable here. The application examples do not limit this in any way.
  • a working variable of the pre-created worker thread is adjusted through a working variable of the pre-created worker thread to determine a worker thread for concurrent execution of a work task, if the The number of the worker threads in the created worker threads whose working state is the awake state is less than the number of the worker threads for concurrent execution of work tasks, and the pre-created The working state of the worker thread whose working state is the dormant state is adjusted to the awake state, so that the number of worker threads whose working state in the pre-created worker thread is awake state is equal to the concurrent execution of the work task.
  • the number of worker threads in the pre-created worker thread if the number of worker threads in the pre-created worker thread is awake state is greater than the number of worker threads for concurrent execution of the work task, using the pre-created worker thread Condition variable, the pre-created work line
  • the working state of the worker thread whose working state is awake is adjusted to a sleep state, so that the number of worker threads whose working state in the pre-created worker thread is awake state is equal to the number of worker threads for concurrent execution of the work task.
  • the number of worker threads With this, it is possible to dynamically adjust the number of worker threads for concurrent execution of work tasks without creating additional worker threads frequently, thereby achieving dynamic adjustment of the number of concurrently executed work tasks.
  • any implementation manner of adjusting the working state of the pre-created worker thread to determine the working thread for concurrent execution of the work task may be applicable by using the working variables of the pre-created worker thread, This embodiment of the present application does not limit this in any way.
  • determining a worker thread used for concurrent execution of a work task based on the number of the worker threads used for concurrent execution of the work task and a condition variable created in advance if the The number of concurrently executed work threads of a work task is equal to the number of pre-created work threads, then the working state of the pre-created work thread is detected, and the pre-created And adjusting a working state of the pre-created worker thread to determine a worker thread for concurrent execution of a worker task. It can be understood that any implementation manner of determining a worker thread for concurrent execution of a work task based on the number of the worker threads used for concurrent execution of the work task and a condition variable created in advance may be applicable here. The application examples do not limit this in any way.
  • a working variable of the pre-created worker thread is adjusted through a working variable of the pre-created worker thread to determine a worker thread for concurrent execution of a work task, if the The number of the worker threads in the created worker threads whose working state is the awake state is less than the number of the worker threads for concurrent execution of work tasks, and the pre-created The working state of the worker thread whose working state is the sleep state is adjusted to the awake state, so that the working states of the pre-created worker threads are all awake states.
  • any implementation manner of adjusting the working state of the pre-created worker thread to determine the working thread for concurrent execution of the work task may be applicable by using the working variables of the pre-created worker thread, This embodiment of the present application does not limit this in any way.
  • the pre-created worker thread's condition variable when used to adjust the work status of the pre-created worker thread's working state to the sleep state to the awake state,
  • the condition variables of the pre-created worker thread whose working state is the dormant state call a notification function in a synchronization statement block, and adjusts the work state of the pre-created worker thread whose working state is the dormant state. Wake state. It can be understood that any implementation manner that adjusts the working state of the working thread in the pre-created working thread to the sleeping state to the awake state may be applicable to this, and this embodiment of the present application does not limit this. .
  • the pre-created worker thread's condition variable when used to adjust the work status of the pre-created worker thread's work state to the awake state to the sleep state,
  • the condition variable of the pre-created worker thread whose working state is the awake state calls a waiting function in a synchronization statement block, and adjusts the working state of the pre-created worker thread whose working state is the awake state.
  • Is dormant It can be understood that any implementation manner of adjusting the working state of the worker thread in which the working state in the pre-created worker thread is the awake state to the dormant state may be applicable to this, and this embodiment of the present application does not limit this. .
  • the number of worker threads used for concurrent execution of work tasks is obtained, and based on the number of worker threads used for concurrent execution of work tasks, and in advance
  • the condition variable of the created worker thread determines the worker thread for concurrent execution of the work task.
  • the condition variable of the worker thread created in advance is used to determine the worker thread for concurrent execution of the work task.
  • the number of worker threads used for concurrent execution of work tasks is dynamically adjusted, and then the number of concurrently executed work tasks is dynamically adjusted, thereby improving the efficiency of concurrent execution of work tasks.
  • the method for controlling task execution in this embodiment may be performed by any appropriate device having data processing capabilities, including but not limited to: a camera, a terminal, a mobile terminal, a PC, a server, a vehicle-mounted device, an entertainment device, an advertising device, and personal digital Assistant (PDA), tablet, laptop, handheld game console, smart glasses, smart watch, wearable device, virtual display device or display enhancement device (such as Google Glass ⁇ Oculus Rift, Hololens, Gear VR) Example two
  • FIG. 2 a flowchart of steps of a method for regulating task execution according to Embodiment 2 of the present application is shown.
  • step S201 the number of worker threads used for concurrent execution of work tasks is obtained.
  • step S201 is similar to step S101 described above, details are not described herein again.
  • step S202 if the number of the worker threads for concurrent execution of the work task is greater than the number of pre-created worker threads, a new worker thread is created, so that the number of the pre-created worker threads and the new The sum of the number of worker threads is equal to the number of worker threads for concurrent execution of the work task.
  • the pre-created worker thread and the condition variables of the new worker thread are used to adjust the working states of the pre-created worker thread and the new worker thread to the awake state.
  • a condition variable is set correspondingly.
  • the self-blocking logic of the new worker thread can be implemented through the condition variables of the new worker thread.
  • the specific implementation process is similar to the pre-created worker thread, and is not repeated here.
  • the method further includes: obtaining basic information of the work task; and storing the work task in a blocking queue based on the basic information of the work task.
  • the basic information includes a type and a size of a work task. Therefore, it is not necessary to monitor the completion status of the work task in real time, and it is possible to realize the scheduling and concurrent execution of multiple work tasks. Understandably, the above description The description is only exemplary, which is not limited in the embodiment of the present application.
  • the work task can be input from one end of the queue and output from the other end.
  • the blocking queue involved in the embodiment of the present application adopts a first-in-first-out principle, that is, a work task that is first inserted into the blocking queue is also the first to leave the queue, which is similar to the function of queuing.
  • the sharing of work tasks can be easily achieved by blocking queues. Assume that there are several work tasks that generate threads, and in addition there are several work task execution threads. If the work task spawns a thread and the prepared work task needs to be shared with the work task execution thread, using a queue to transfer the work task can easily solve the problem of sharing work tasks between them.
  • the work task generation thread Ideally, if the work task generation thread generates work tasks faster than the work task execution thread executes work tasks, and when the work tasks generated by the work task generation threads accumulate to a certain degree, then the work task generation threads must be suspended Wait for a while (blocking the work task spawning thread), in order to wait for the work task execution thread to finish processing the accumulated work tasks, and vice versa.
  • the work task generation threads must be suspended Wait for a while (blocking the work task spawning thread), in order to wait for the work task execution thread to finish processing the accumulated work tasks, and vice versa.
  • each programmer in the case of not using a blocking queue, in a multi-threaded environment, each programmer must control these details by himself, especially considering both efficiency and thread safety, which will bring considerable complexity to the program. .
  • the so-called blocking in some cases, will suspend the thread (that is, block), and once the condition is met, the suspended thread will be automatically awakened. It can be understood that the above description is only exemplary, and this embodiment does not limit it in any way.
  • the work threads for the concurrent execution of work tasks are sequentially obtained from the blocking queue, and the work tasks are concurrently executed. Specifically, each work thread used for concurrent execution of the work task obtains the corresponding work task from the blocking queue in turn, and executes the work task concurrently. It can be understood that the above description is only exemplary, and the embodiment of the present application does not limit this in any way.
  • the method for controlling task execution in this embodiment may be performed by any appropriate device having data processing capabilities, including but not limited to: a camera, a terminal, a mobile terminal, a PC, a server, a vehicle-mounted device, an entertainment device, an advertising device, and personal digital Assistant (PDA), tablet, laptop, handheld game console, smart glasses, smart watch, wearable device, virtual display device or display enhancement device (such as Google Glass, Oculus Rift, Hololens, Gear VR), etc.
  • PDA personal digital Assistant
  • FIG. 3 a structural block diagram of a control device for task execution according to Embodiment 3 of the present application is shown.
  • the task execution regulating device in this embodiment includes: a first acquisition module 301 configured to acquire the number of worker threads for concurrent execution of work tasks; a first determination module 302 configured to be based on the concurrent use of work tasks The number of worker threads to be executed and condition variables of the worker threads created in advance determine the worker threads for concurrent execution of work tasks.
  • the task execution control device in this embodiment is used to implement the corresponding task execution control method in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, and details are not described herein again.
  • FIG. 4 there is shown a structural block diagram of a control device for task execution according to Embodiment 4 of the present application.
  • the task execution regulating device in this embodiment includes: a first acquisition module 401 configured to acquire the number of worker threads for concurrent execution of work tasks; a first determination module 402 configured to be based on the concurrent use of work tasks The number of worker threads to be executed and condition variables of the worker threads created in advance determine the worker threads for concurrent execution of work tasks.
  • the first determining module 402 includes: a second determining module 4021 configured to detect the number of the worker threads for concurrent execution of the work task is less than the number of the worker threads created in advance, The working state of the pre-created worker thread, and the working state of the pre-created worker thread is adjusted through the working variables of the pre-created worker thread to determine a worker thread for concurrent execution of the worker task.
  • a second determining module 4021 configured to detect the number of the worker threads for concurrent execution of the work task is less than the number of the worker threads created in advance, The working state of the pre-created worker thread, and the working state of the pre-created worker thread is adjusted through the working variables of the pre-created worker thread to determine a worker thread for concurrent execution of the worker task.
  • the second determination module 4021 includes: a first adjustment module 4022, configured to, if the number of working threads in the pre-created working thread is awake, is smaller than the number of working threads for the working task For the number of concurrently executed worker threads, the condition of the pre-created worker thread is used to adjust the work state of the worker thread whose work status is the dormant state to the awake state, so that the The number of pre-created worker threads whose working state is awake state is equal to the number of the worker threads for concurrent execution of work tasks, wherein the working state includes awake state and / or hibernation state.
  • a first adjustment module 4022 configured to, if the number of working threads in the pre-created working thread is awake, is smaller than the number of working threads for the working task For the number of concurrently executed worker threads, the condition of the pre-created worker thread is used to adjust the work state of the worker thread whose work status is the dormant state to the awake state, so that the The number of pre-
  • the second determination module 4021 further includes: a second adjustment module 4023 configured to, if the number of working threads in the pre-created working threads is awake, is greater than the number of working threads
  • the number of worker threads executing tasks concurrently, through the pre-created work lines Condition variable of the process, adjust the working state of the worker thread whose working state is the awake state to the sleep state, so that the working state of the pre-created worker thread is the worker thread of the awake state
  • the number is equal to the number of the worker threads for concurrent execution of the work task, wherein the work state includes an awake state and / or a sleep state.
  • the first determining module 402 further includes: a third determining module 4024, configured to detect the number of the worker threads for concurrent execution of the work task equal to the number of the worker threads created in advance.
  • the work state of the pre-created worker thread is described, and the work state of the pre-created worker thread is adjusted through the work variable of the pre-created worker thread to determine the worker thread for concurrent execution of the work task.
  • the third determination module 4024 includes: a third adjustment module 4025, configured to, if the number of working threads in the pre-created working thread is awake, is smaller than the number of working threads for the working task For the number of concurrently executed worker threads, the condition of the pre-created worker thread is used to adjust the work state of the worker thread whose work status is the dormant state to the awake state, so that the The work states of the pre-created worker threads are all wake-up states, where the work states include a wake-up state and / or a sleep state.
  • the first determining module 402 further includes: a creating module 4026, configured to create a new job if the number of the worker threads used for concurrent execution of the work task is greater than the number of pre-created worker threads. Threads, so that the sum of the number of the pre-created worker threads and the number of the new worker threads is equal to the number of the worker threads for concurrent execution of the worker task.
  • a creating module 4026 configured to create a new job if the number of the worker threads used for concurrent execution of the work task is greater than the number of pre-created worker threads. Threads, so that the sum of the number of the pre-created worker threads and the number of the new worker threads is equal to the number of the worker threads for concurrent execution of the worker task.
  • the first determination module 402 further includes: a fourth adjustment module 4027, configured to pass the pre-created work thread and the condition variable of the new work thread to the pre-created work thread Both the working state of the thread and the new worker thread are adjusted to the awake state.
  • a fourth adjustment module 4027 configured to pass the pre-created work thread and the condition variable of the new work thread to the pre-created work thread Both the working state of the thread and the new worker thread are adjusted to the awake state.
  • the task execution control device in this embodiment is used to implement the corresponding task execution control method in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, and details are not described herein again.
  • Example 5
  • FIG. 5 there is shown a structural block diagram of a control device for task execution according to Embodiment 5 of the present application.
  • the task execution regulating device in this embodiment includes: a first acquisition module 504 configured to acquire the number of worker threads for concurrent execution of work tasks; a first determination module 505 configured to be based on the concurrent use of work tasks The number of worker threads to be executed and condition variables of the worker threads created in advance determine the worker threads for concurrent execution of work tasks.
  • the first adjustment module 5051 includes: a fifth adjustment module 5052, which is configured to be called in a synchronization statement block by using a condition variable of a working thread in which the working state in the pre-created working thread is a sleep state. The notification function adjusts the work state of the worker thread whose work state is the sleep state in the pre-created worker thread to the wake state.
  • the second adjustment module 5053 includes: a sixth adjustment module 5054, which is configured to be called in a synchronization statement block through a condition variable of a worker thread whose work status is awake in the pre-created worker thread.
  • the waiting function adjusts the work state of the worker thread whose work state is the awake state to the sleep state in the pre-created worker thread.
  • the apparatus further includes: a second obtaining module 501 configured to obtain basic information of the work task; a storage module 502 configured to store the work task based on the basic information of the work task In the blocking queue.
  • the apparatus further includes: a third obtaining module 503 configured to sequentially obtain the work tasks from the blocking queue through the worker threads for concurrent execution of the work tasks, and execute the work concurrently. work tasks.
  • a third obtaining module 503 configured to sequentially obtain the work tasks from the blocking queue through the worker threads for concurrent execution of the work tasks, and execute the work concurrently. work tasks.
  • the basic information includes a type and a size of a work task.
  • the work task includes a download task.
  • the task execution control device in this embodiment is used to implement the corresponding task execution control method in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, and details are not described herein again.
  • FIG. 6 a schematic structural diagram of a device / terminal / server according to Embodiment 6 of the present application is shown.
  • the specific embodiment of the present application does not limit the specific implementation of the device / terminal / server.
  • the device / terminal / server may include a processor 601 and a storage device 602.
  • the processor 601 is configured to execute a program 603, and may specifically perform relevant steps in an embodiment of a method for controlling execution of the foregoing tasks.
  • the program 603 may include program code, where the program code includes a computer operation instruction.
  • the processor 601 may be a central processing unit CPU, or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.
  • One or more processors included in the device / terminal / server may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs And one or more ASICs.
  • the storage device 602 is configured to store one or more programs 603.
  • the storage device 602 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), for example, at least one disk memory.
  • the program 603 may be specifically configured to cause the processor 601 to perform the following operations: obtaining the number of worker threads used for concurrent execution of work tasks; based on the number of worker threads used for concurrent execution of work tasks and condition variables created in advance To determine the worker threads for concurrent execution of work tasks.
  • the program 603 is further configured to cause the processor 601 to determine the concurrent use of the work tasks based on the number of the work threads for concurrent execution of the work tasks and the condition variables of the pre-created work threads.
  • the processor 601 determines the concurrent use of the work tasks based on the number of the work threads for concurrent execution of the work tasks and the condition variables of the pre-created work threads.
  • the number of the worker threads used for concurrent execution of the work task is less than the number of pre-created worker threads, detecting the work state of the pre-created worker threads and using the pre-created work A working variable of a thread, adjusting a working state of the pre-created working thread to determine a working thread for concurrent execution of a working task.
  • the program 603 is further configured to cause the processor 601 to adjust a working state of the pre-created worker thread through a working variable of the pre-created worker thread to determine a work task.
  • the pre-created worker threads are used.
  • a condition variable of a thread adjusting a working state of a working thread in which the working state in the pre-created worker thread is a sleep state to an awake state, so that a working thread in the pre-created worker thread is in a wake-up state.
  • the number is equal to the number of the worker threads for concurrent execution of the work task, wherein the work state includes an awake state and / or a sleep state.
  • the program 603 is further configured to cause the processor 601 to adjust a working state of the pre-created worker thread through a working variable of the pre-created worker thread to determine a work task.
  • the processor 601 When concurrently executing worker threads, if the number of worker threads in the pre-created worker threads whose working state is awake is greater than the number of worker threads for concurrent execution of work tasks, the pre-created workers are used.
  • a condition variable of the thread adjusting the working state of the worker thread whose working state is the awake state to a sleep state, so that the working state of the previously created worker thread is a working state of the awake state
  • the number is equal to the number of the worker threads for concurrent execution of the work task, wherein the work state includes an awake state and / or a sleep state.
  • the program 603 is further configured to cause the processor 601 to When determining the number of worker threads for concurrent execution of work tasks based on the number of worker threads concurrently executing work tasks and condition variables created in advance, if the number of worker threads used for concurrent execution of work tasks is equal to the previously created The number of worker threads, then detecting the work state of the pre-created worker thread, and adjusting the work state of the pre-created worker thread through the work variable of the pre-created worker thread to determine the concurrent use of the work task Executed worker thread.
  • the program 603 is further configured to cause the processor 601 to adjust a working state of the pre-created worker thread through a working variable of the pre-created worker thread to determine a work task.
  • the pre-created worker threads are used.
  • the condition variable of the thread adjusts the working state of the worker thread whose working state is the sleep state to the awake state, so that the working states of the pre-created worker thread are all awake states, where:
  • the working state includes an awake state and / or a hibernation state.
  • the program 603 is further configured to cause the processor 601 to determine the concurrent use of the work tasks based on the number of the work threads for concurrent execution of the work tasks and the condition variables of the pre-created work threads.
  • the processor 601 determines the concurrent use of the work tasks based on the number of the work threads for concurrent execution of the work tasks and the condition variables of the pre-created work threads.
  • the number of the worker threads used for concurrent execution of the work task is greater than the number of pre-created worker threads, a new worker thread is created, so that the number of the pre-created worker threads is the same as the number of the pre-created worker threads.
  • the sum of the number of new worker threads is equal to the number of worker threads for concurrent execution of the worker task.
  • the program 603 is further configured to cause the processor 601 to use the pre-created worker thread and the condition variable of the new worker thread to associate the pre-created worker thread with the new worker thread.
  • the working states of the worker threads are adjusted to the awake state.
  • the program 603 is further configured to cause the processor 601 to use the condition variables of the pre-created worker thread to change the working state of the pre-created worker thread to a dormant worker thread.
  • a notification function is called in a synchronization statement block through a condition variable of the worker thread whose working state is a sleep state in the pre-created worker thread, and the work in the pre-created worker thread is The working state of the worker thread in the sleep state is adjusted to the awake state.
  • the program 603 is further configured to cause the processor 601 to use the condition variables of the pre-created worker thread to change the working state in the pre-created worker thread to the worker thread in the awake state.
  • a waiting function is called in a synchronization statement block through a condition variable of the worker thread in which the working state in the pre-created worker thread is awake.
  • the working state of the worker thread whose working state is the awake state in the pre-created worker thread is adjusted to a sleep state.
  • the program 603 is further configured to cause the processor 601 to obtain basic information of the work task; and based on the basic information of the work task, store the work task in a blocking queue.
  • the program 603 is further configured to cause the processor 601 to sequentially obtain the work task from the blocking queue through the work thread for concurrent execution of the work task, and execute the work concurrently. work tasks.
  • the basic information includes a type and a size of a work task.
  • the work task includes a download task.
  • the number of worker threads used for concurrent execution of work tasks is obtained, and based on the number of worker threads used for concurrent execution of work tasks and condition variables created in advance, determine the Compared with other existing methods, the worker threads for concurrent execution of work tasks use condition variables of pre-created worker threads to determine the worker threads for concurrent execution of work tasks, which can create additional worker threads infrequently.
  • the number of working threads used for concurrent execution of work tasks is dynamically controlled, and the number of concurrently executed work tasks is dynamically adjusted, thereby improving the efficiency of concurrent execution of work tasks.
  • each component / step described in the embodiment of the present application may be split into more components / steps, or two or more components / steps or partial operations of components / steps may be combined into New components / steps to achieve the purpose of the embodiments of the present application.
  • the process described above with reference to the flowchart may be implemented as a computer software program.
  • the embodiment of the present application includes a computer program product including a computer program borne on a computer-readable medium, where the computer program includes program code for executing the methods shown in the foregoing multiple method embodiments.
  • the computer program may be downloaded and installed from a network through a communication section, and / or installed from a removable medium.
  • CPU central processing unit
  • the above-mentioned functions defined in the method shown in the embodiment of the present application are performed.
  • the computer-readable medium described in this application may be a computer-readable signal medium.
  • Computer-readable storage media it may be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access storage (RAM), read-only storage (ROM), erasable Type programmable read-only storage device (EPROM or flash memory), optical fiber, portable compact disk read-only storage device (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing.
  • RAM random access storage
  • ROM read-only storage
  • EPROM or flash memory erasable Type programmable read-only storage device
  • CD-ROM portable compact disk read-only storage device
  • magnetic storage device or any suitable combination of the foregoing.
  • a computer-readable storage medium may be any tangible medium containing or storing a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.
  • a computer-readable signal medium may include a data signal that is included in baseband or propagated as part of a carrier wave, and which carries computer-readable program code. Such a propagated data signal may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • the computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, and the computer-readable medium may send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device .
  • Program code embodied on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
  • Computer program code for performing the operations of the present application may be written in one or more programming languages, or a combination thereof, which includes an object-oriented programming language--such as
  • Java, Smalltalk, C ++ also includes regular procedural programming languages such as "C” or similar programming languages.
  • the program code can be executed entirely on the user's computer, partly on the user's computer, as an independent software package, partly on the user's computer, partly on a remote computer, or entirely on a remote computer or server.
  • the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (such as provided by an Internet service) (Commercially connected via the Internet).
  • LAN local area network
  • WAN wide area network
  • an Internet service Commercially connected via the Internet
  • each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, which contains one or more functions for implementing a specified logical function Executable instructions.
  • the functions marked in the blocks may also occur in a different order than those marked in the drawings. For example, two successively represented boxes may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved.
  • each block in the block diagram and / or flowchart, and a combination of blocks in the block diagram and / or flowchart It may be implemented by a dedicated hardware-based system that performs prescribed functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.
  • the units described in the embodiments of the present application may be implemented in a software manner, or may be implemented in a hardware manner.
  • the described unit may also be provided in a processor, for example, it may be described as:
  • a processor includes an acquisition unit, a processing unit, and a test unit.
  • the name of these units does not constitute a limitation on the unit itself in some cases.
  • the obtaining unit may also be described as "a unit for obtaining a business test file of a target object to be tested according to a test instruction".
  • the present application also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the method described in any one of the foregoing embodiments is implemented.
  • the present application further provides a computer-readable medium, which may be included in the device described in the foregoing embodiments; or may exist alone without being assembled into the device.
  • the computer-readable medium carries one or more programs, and when the one or more programs are executed by the device, the device where the device is located obtains a number of working threads for concurrent execution of work tasks; based on the The number of worker threads for concurrent execution of work tasks and condition variables of previously created worker threads determine the worker threads for concurrent execution of work tasks.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • General Factory Administration (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiments of the present application relate to the field of task control, and provided thereby are a task execution control method, device, equipment/terminal/server and computer-readable storage medium. The task execution control method comprises: obtaining the number of work threads used for concurrent execution of work tasks; and on the basis of the number of work threads used for concurrent execution of the work tasks and pre-created condition variables of the work threads, determining work threads for concurrent execution of the work tasks. By means of the embodiment of the present application, in the case of infrequent creation of additional work threads, the number of work threads used for concurrent execution of work tasks can be dynamically adjusted, and then the number of work tasks executed concurrently can be dynamically adjusted, so as to improve the efficiency of concurrent execution of work tasks.

Description

任务执行的调控方法、 装置、 设备 /终端 /服务器及存储介质 本申请要求在 2018 年 08 月 02 日提交中国专利局、 申请号为 201810869318.1、 发明名称为 “任务执行的调控方法、 装置、 设备 / 终端 /服务器及存储介质” 的中国专利申请的优先权, 其全部内容通 过引用结合在本申请中。  Method, device, device / terminal / server and storage medium for task executionThis application requires that the China Patent Office be filed on August 02, 2018, with application number 201810869318.1, and the invention name is "Method, Device, Device, Device for Controlling Task Execution / Terminal / Server and Storage Media ", the entirety of which is incorporated herein by reference in its entirety.
技术领域 Technical field
本申请实施例涉及任务调控领域, 尤其涉及一种任务执行的调控方法、 装 置、 设备 /终端 /服务器及计算机可读存储介质。 背景技术  The embodiments of the present application relate to the field of task regulation, and in particular, to a method, device, device / terminal / server, and computer-readable storage medium for regulating and controlling task execution. Background technique
现在市场上提供下载功能的客户端的都会有属于自己的下载任务管理功能, 而在实际的下载任务管理场景当中往往是需要做到下载任务的个数是可以动态 设置的, 这样就可以控制下载任务的并发下载数量。 了解到目前大多数控制下 载任务的并发下载数量的技术实现方案是需要监听下载任务是否完成的状态, 然后再去轮询下载任务存储队列确定是否还有待执行的下载任务。 如果下载任 务存储队列中还有待执行的下载任务,就再重新创建任务线程去执行下载任务。 这样, 目前的技术实现方案存在以下缺陷: 一个是需要实时地监听下载任务的 完成状态, 另一个是需要频繁地创建额外的工作线程去执行下载任务。 发明内容  At present, clients on the market that provide download functions have their own download task management functions. In actual download task management scenarios, it is often necessary to set the number of download tasks dynamically, so that download tasks can be controlled. Number of concurrent downloads. Knowing that most current technical implementations that control the number of concurrent downloads of download tasks require monitoring the completion status of the download task, and then polling the download task storage queue to determine whether there are any pending download tasks. If there are still download tasks in the download task storage queue, re-create the task thread to execute the download task. In this way, the current technical implementation solution has the following defects: one is to monitor the completion status of the download task in real time, and the other is to frequently create additional worker threads to execute the download task. Summary of the invention
有鉴于此, 本申请实施例所解决的技术问题之一在于提供一种任务执行的 调控的方案, 以解决现有技术中存在的在调整并发执行的工作任务的数量时产 生的频繁创建额外的工作线程的问题。  In view of this, one of the technical problems solved by the embodiments of the present application is to provide a solution for task execution regulation to solve the frequent creation of additional tasks generated in the prior art when adjusting the number of concurrently executed work tasks. Problems with worker threads.
本申请实施例提供了一种任务执行的调控方法, 所述方法包括: 获取用于 工作任务并发执行的工作线程的数量; 基于所述用于工作任务并发执行的工作 线程的数量和预先创建的工作线程的条件变量, 确定用于工作任务并发执行的 工作线程。  An embodiment of the present application provides a method for regulating task execution. The method includes: obtaining the number of worker threads for concurrent execution of work tasks; based on the number of worker threads for concurrent execution of work tasks and a pre-created The condition variable of the worker thread determines the worker thread used for concurrent execution of the work task.
本申请实施例还提供了一种任务执行的调控装置, 所述装置包括: 第一获 取模块, 被配置为获取用于工作任务并发执行的工作线程的数量; 第一确定模 块, 被配置为基于所述用于工作任务并发执行的工作线程的数量和预先创建的 工作线程的条件变量, 确定用于工作任务并发执行的工作线程。 An embodiment of the present application further provides a control device for task execution, where the device includes: a first obtaining A fetching module configured to obtain the number of worker threads used for concurrent execution of work tasks; a first determination module configured to be based on the number of the worker threads used for concurrent execution of work tasks and condition variables created in advance; Determine the worker threads used for concurrent execution of work tasks.
本申请实施例还提供了一种设备 /终端 /服务器,包括:一个或多个处理器; 存储装置, 配置为存储一个或多个程序; 当所述一个或多个程序被所述一个或 多个处理器执行, 使得所述一个或多个处理器实现如上所述的任务执行的调控 方法。  An embodiment of the present application further provides a device / terminal / server, including: one or more processors; a storage device configured to store one or more programs; when the one or more programs are stored by the one or more programs The execution of each processor causes the one or more processors to implement the method for controlling task execution as described above.
本申请实施例还提供了一种计算机可读存储介质,其上存储有计算机程序, 该程序被处理器执行时实现如上所述的任务执行的调控方法。  An embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the method for regulating and controlling task execution as described above is implemented.
通过本申请实施例提供的任务执行的调控的技术方案, 获取用于工作任务 并发执行的工作线程的数量, 并基于用于工作任务并发执行的工作线程的数量 和预先创建的工作线程的条件变量, 确定用于工作任务并发执行的工作线程, 与现有的其它方式相比, 利用预先创建的工作线程的条件变量确定用于工作任 务并发执行的工作线程, 能够在不频繁地创建额外的工作线程的情况下, 动态 调控用于工作任务并发执行的工作线程的数量, 进而实现并发执行的工作任务 的数量的动态调整, 从而提高工作任务并发执行的效率。 附图说明  Through the technical solution of task execution regulation provided in the embodiments of the present application, the number of worker threads used for concurrent execution of work tasks is obtained, and based on the number of worker threads used for concurrent execution of work tasks and condition variables created in advance To determine the worker threads used for concurrent execution of work tasks, compared with other existing methods, use condition variables of pre-created worker threads to determine worker threads used for concurrent execution of work tasks, which can create additional work infrequently In the case of threads, the number of worker threads used for concurrent execution of work tasks is dynamically adjusted, and then the number of concurrently executed work tasks is dynamically adjusted, thereby improving the efficiency of concurrent execution of work tasks. BRIEF DESCRIPTION OF THE DRAWINGS
后文将参照附图以示例性而非限制性的方式详细描述本申请实施例的一些 具体实施例。 附图中相同的附图标记标示了相同或类似的部件或部分。 本领域 技术人员应该理解, 这些附图未必是按比例绘制的。 附图中:  Hereinafter, some specific embodiments of the embodiments of the present application will be described in detail by way of example and not limitation with reference to the accompanying drawings. The same reference numbers in the drawings identify the same or similar components or parts. Those skilled in the art will appreciate that these drawings are not necessarily drawn to scale. In the drawings:
图 1是根据本申请实施例一的一种任务执行的调控方法的步骤流程图; 图 2是根据本申请实施例二的一种任务执行的调控方法的步骤流程图; 图 3是根据本申请实施例三的一种任务执行的调控装置的结构框图; 图 4是根据本申请实施例四的一种任务执行的调控装置的结构框图; 图 5是根据本申请实施例五的一种任务执行的调控装置的结构框图; 图 6是根据本申请实施例六的一种设备 /终端 /服务器的结构示意图。 具体实施方式  FIG. 1 is a flowchart of steps of a method for regulating task execution according to Embodiment 1 of the present application; FIG. 2 is a flowchart of steps of a method of regulating task execution according to Embodiment 2 of the present application; FIG. 3 is a flowchart according to this application Structure block diagram of a task execution regulating device according to the third embodiment; FIG. 4 is a structure block diagram of a task execution regulating device according to the fourth embodiment of the present application; FIG. 5 is a task execution according to the fifth embodiment of the present application FIG. 6 is a schematic structural diagram of a device / terminal / server according to Embodiment 6 of the present application. detailed description
为了使本领域的人员更好地理解本申请实施例中的技术方案, 下面将结合 本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述, 显然,所描述的实施例仅是本申请实施例一部分实施例,而不是全部的实施例。 基于本申请实施例中的实施例,本领域普通技术人员所获得的所有其他实施例, 都应当属于本申请实施例保护的范围。 实施例一 In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described The embodiments are only a part of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the embodiments of the present application, all other embodiments obtained by those skilled in the art should fall within the protection scope of the embodiments of the present application. Example one
参照图 1, 示出了根据本申请实施例一的一种任务执行的调控方法的步骤 流程图。  Referring to FIG. 1, there is shown a flowchart of steps of a method for adjusting task execution according to Embodiment 1 of the present application.
本实施例的任务执行的调控方法包括以下步骤:  The method for adjusting task execution in this embodiment includes the following steps:
在步骤 S101中, 获取用于工作任务并发执行的工作线程的数量。  In step S101, the number of worker threads used for concurrent execution of work tasks is obtained.
在本申请实施例中, 用户可先在工作线程数量设置器中设置用于工作任务 并发执行的工作线程的数量, 然后从工作线程数量设置器中获取用于工作任务 并发执行的工作线程的数量。 在一些可选实施例中, 可由电子设备根据工作任 务的执行情况自动设置用于工作任务并发执行的工作线程的数量。 其中, 所述 工作任务包括下载任务。 可以理解的是, 以上描述仅为示例性的, 本申请实施 例对此不做任何限定。  In the embodiment of the present application, the user may first set the number of worker threads for concurrent execution of the work task in the worker thread number setter, and then obtain the number of worker threads for concurrent execution of the work task from the worker thread number setter. . In some optional embodiments, the number of worker threads used for concurrent execution of the work task may be automatically set by the electronic device according to the execution status of the work task. The work task includes a download task. It can be understood that the above description is only exemplary, and this embodiment of the present application does not limit this in any way.
在本申请实施例中, 并发执行可理解为在一个时间段内有几个工作任务都 处于已启动执行到执行完毕之间, 且这几个工作任务都是在同一个处理机上运 行, 但任一个时刻点上只有一个工作任务在处理机上运行。 具体地, 当有多个 工作线程在操作时, 如果系统只有一个 CPU, 则它不可能真正同时进行一个以 上的工作线程,它只能把 CPU运行时间划分成若干个时间段,再将时间段分配 给各个工作线程执行, 在一个时间段的工作线程代码运行时, 其它工作线程处 于挂起状。 可以理解的是, 以上描述仅为示例性的, 本申请实施例对此不做任 何限定。  In the embodiment of the present application, concurrent execution can be understood as that several work tasks are in a period of time between the start of execution and completion of execution, and these work tasks are all run on the same processor, but Only one work task runs on the processor at a time. Specifically, when there are multiple worker threads operating, if the system has only one CPU, it cannot really perform more than one worker thread at the same time. It can only divide the CPU runtime into several time periods, and then divide the time period. Allocate to each worker thread for execution, while the worker thread code in one period runs, other worker threads are in a suspended state. It can be understood that the above description is only exemplary, and the embodiment of the present application does not limit this in any way.
在步骤 S102 中, 基于所述用于工作任务并发执行的工作线程的数量和预 先创建的工作线程的条件变量, 确定用于工作任务并发执行的工作线程。  In step S102, a worker thread for concurrent execution of a work task is determined based on the number of the worker threads for concurrent execution of a work task and a condition variable of a previously created worker thread.
在本申请实施例中, 预先创建的工作线程的数量为多个, 并且每个预先创 建的工作线程对应有一个条件变量。 通过工作线程的条件变量, 来实现工作线 程的自阻塞逻辑。 具体地, 针对预先创建的工作线程中的每个工作线程, 如果 将工作线程的工作状态由唤醒状态调整为休眠状态, 则通过工作线程的条件变 量在同步语句块中调用等待函数, 将工作线程的工作状态由唤醒状态调整为休 眠状态; 针对预先创建的工作线程中的每个工作线程, 如果将工作线程的工作 状态由休眠状态调整为唤醒状态, 则通过工作线程的条件变量在同步语句块中 调用通知函数, 将工作线程的工作状态由休眠状态调整为唤醒状态。 其中, 预 先创建的工作线程的工作状态包括休眠状态和 /或唤醒状态。 可以理解的是, 以 上描述仅为示例性的, 本申请实施例对此不做任何限定。 In the embodiment of the present application, the number of pre-created worker threads is multiple, and each pre-created worker thread corresponds to a condition variable. The conditional variable of the worker thread is used to implement the self-blocking logic of the worker thread. Specifically, for each worker thread in the pre-created worker thread, if the working state of the worker thread is adjusted from the awake state to the sleep state, a waiting function is called in a synchronization statement block through a condition variable of the worker thread, and the worker thread is changed. The working state of the worker is adjusted from the awake state to the dormant state. For each worker thread in the pre-created worker thread, if the working state of the worker thread is adjusted from the dormant state to the awake state, the condition variable of the worker thread is used in the synchronization statement block. The notification function is called during the adjustment of the working state of the worker thread from the sleep state to the awake state. Of which The working state of the worker thread created first includes the hibernation state and / or the awake state. It can be understood that the above description is only exemplary, and this embodiment of the present application does not limit this in any way.
在一些可选实施例中, 在基于所述用于工作任务并发执行的工作线程的数 量和预先创建的工作线程的条件变量, 确定用于工作任务并发执行的工作线程 时, 如果所述用于工作任务并发执行的工作线程的数量小于预先创建的工作线 程的数量, 则检测所述预先创建的工作线程的工作状态, 并通过所述预先创建 的工作线程的工作变量, 调整所述预先创建的工作线程的工作状态, 以确定用 于工作任务并发执行的工作线程。 可以理解的是, 任何基于所述用于工作任务 并发执行的工作线程的数量和预先创建的工作线程的条件变量, 确定用于工作 任务并发执行的工作线程的实施方式均可适用于此, 本申请实施例对此不做任 何限定。  In some optional embodiments, when determining a worker thread used for concurrent execution of a work task based on the number of the worker threads used for concurrent execution of the work task and a condition variable created in advance, if the The number of concurrently executed work threads of a work task is less than the number of pre-created worker threads, then detecting the work state of the pre-created worker thread, and adjusting the pre-created worker variable through the work variables of the pre-created worker thread. The working state of the worker thread to determine the worker thread for concurrent execution of the work task. It can be understood that any implementation manner of determining a worker thread for concurrent execution of a work task based on the number of the worker threads used for concurrent execution of the work task and a condition variable created in advance may be applicable here. The application examples do not limit this in any way.
在一些可选实施例中, 在通过所述预先创建的工作线程的工作变量, 调整 所述预先创建的工作线程的工作状态, 以确定用于工作任务并发执行的工作线 程时, 如果所述预先创建的工作线程中的工作状态为唤醒状态的工作线程的数 量小于所述用于工作任务并发执行的工作线程的数量, 则通过所述预先创建的 工作线程的条件变量, 将所述预先创建的工作线程中的工作状态为休眠状态的 工作线程的工作状态调整为唤醒状态, 以使得所述预先创建的工作线程中的工 作状态为唤醒状态的工作线程的数量等于所述用于工作任务并发执行的工作线 程的数量; 如果所述预先创建的工作线程中的工作状态为唤醒状态的工作线程 的数量大于所述用于工作任务并发执行的工作线程的数量, 则通过所述预先创 建的工作线程的条件变量, 将所述预先创建的工作线程中的工作状态为唤醒状 态的工作线程的工作状态调整为休眠状态, 以使得所述预先创建的工作线程中 的工作状态为唤醒状态的工作线程的数量等于所述用于工作任务并发执行的工 作线程的数量。 籍此, 能够在不频繁地创建额外的工作线程的情况下, 动态调 控用于工作任务并发执行的工作线程的数量, 进而实现并发执行的工作任务的 数量的动态调整。 可以理解的是, 任何通过所述预先创建的工作线程的工作变 量, 调整所述预先创建的工作线程的工作状态, 以确定用于工作任务并发执行 的工作线程的实施方式均可适用于此, 本申请实施例对此不做任何限定。  In some optional embodiments, when a working variable of the pre-created worker thread is adjusted through a working variable of the pre-created worker thread to determine a worker thread for concurrent execution of a work task, if the The number of the worker threads in the created worker threads whose working state is the awake state is less than the number of the worker threads for concurrent execution of work tasks, and the pre-created The working state of the worker thread whose working state is the dormant state is adjusted to the awake state, so that the number of worker threads whose working state in the pre-created worker thread is awake state is equal to the concurrent execution of the work task. The number of worker threads in the pre-created worker thread, if the number of worker threads in the pre-created worker thread is awake state is greater than the number of worker threads for concurrent execution of the work task, using the pre-created worker thread Condition variable, the pre-created work line The working state of the worker thread whose working state is awake is adjusted to a sleep state, so that the number of worker threads whose working state in the pre-created worker thread is awake state is equal to the number of worker threads for concurrent execution of the work task. The number of worker threads. With this, it is possible to dynamically adjust the number of worker threads for concurrent execution of work tasks without creating additional worker threads frequently, thereby achieving dynamic adjustment of the number of concurrently executed work tasks. It may be understood that any implementation manner of adjusting the working state of the pre-created worker thread to determine the working thread for concurrent execution of the work task may be applicable by using the working variables of the pre-created worker thread, This embodiment of the present application does not limit this in any way.
在一些可选实施例中, 在基于所述用于工作任务并发执行的工作线程的数 量和预先创建的工作线程的条件变量, 确定用于工作任务并发执行的工作线程 时, 如果所述用于工作任务并发执行的工作线程的数量等于预先创建的工作线 程的数量, 则检测所述预先创建的工作线程的工作状态, 并通过所述预先创建 的工作线程的工作变量, 调整所述预先创建的工作线程的工作状态, 以确定用 于工作任务并发执行的工作线程。 可以理解的是, 任何基于所述用于工作任务 并发执行的工作线程的数量和预先创建的工作线程的条件变量, 确定用于工作 任务并发执行的工作线程的实施方式均可适用于此, 本申请实施例对此不做任 何限定。 In some optional embodiments, when determining a worker thread used for concurrent execution of a work task based on the number of the worker threads used for concurrent execution of the work task and a condition variable created in advance, if the The number of concurrently executed work threads of a work task is equal to the number of pre-created work threads, then the working state of the pre-created work thread is detected, and the pre-created And adjusting a working state of the pre-created worker thread to determine a worker thread for concurrent execution of a worker task. It can be understood that any implementation manner of determining a worker thread for concurrent execution of a work task based on the number of the worker threads used for concurrent execution of the work task and a condition variable created in advance may be applicable here. The application examples do not limit this in any way.
在一些可选实施例中, 在通过所述预先创建的工作线程的工作变量, 调整 所述预先创建的工作线程的工作状态, 以确定用于工作任务并发执行的工作线 程时, 如果所述预先创建的工作线程中的工作状态为唤醒状态的工作线程的数 量小于所述用于工作任务并发执行的工作线程的数量, 则通过所述预先创建的 工作线程的条件变量, 将所述预先创建的工作线程中的工作状态为休眠状态的 工作线程的工作状态调整为唤醒状态, 以使得所述预先创建的工作线程的工作 状态均为唤醒状态。 籍此, 能够在不频繁地创建额外的工作线程的情况下, 动 态调控用于工作任务并发执行的工作线程的数量, 进而实现并发执行的工作任 务的数量的动态调整。 可以理解的是, 任何通过所述预先创建的工作线程的工 作变量, 调整所述预先创建的工作线程的工作状态, 以确定用于工作任务并发 执行的工作线程的实施方式均可适用于此, 本申请实施例对此不做任何限定。  In some optional embodiments, when a working variable of the pre-created worker thread is adjusted through a working variable of the pre-created worker thread to determine a worker thread for concurrent execution of a work task, if the The number of the worker threads in the created worker threads whose working state is the awake state is less than the number of the worker threads for concurrent execution of work tasks, and the pre-created The working state of the worker thread whose working state is the sleep state is adjusted to the awake state, so that the working states of the pre-created worker threads are all awake states. With this, it is possible to dynamically adjust the number of worker threads for concurrent execution of work tasks without creating additional worker threads frequently, thereby achieving dynamic adjustment of the number of concurrently executed work tasks. It may be understood that any implementation manner of adjusting the working state of the pre-created worker thread to determine the working thread for concurrent execution of the work task may be applicable by using the working variables of the pre-created worker thread, This embodiment of the present application does not limit this in any way.
在一些可选实施例中, 在通过所述预先创建的工作线程的条件变量, 将所 述预先创建的工作线程中的工作状态为休眠状态的工作线程的工作状态调整为 唤醒状态时, 通过所述预先创建的工作线程中的工作状态为休眠状态的工作线 程的条件变量在同步语句块中调用通知函数, 将所述预先创建的工作线程中的 工作状态为休眠状态的工作线程的工作状态调整为唤醒状态。 可以理解的是, 任何将所述预先创建的工作线程中的工作状态为休眠状态的工作线程的工作状 态调整为唤醒状态的实施方式均可适用于此,本申请实施例对此不做任何限定。  In some optional embodiments, when the pre-created worker thread's condition variable is used to adjust the work status of the pre-created worker thread's working state to the sleep state to the awake state, The condition variables of the pre-created worker thread whose working state is the dormant state call a notification function in a synchronization statement block, and adjusts the work state of the pre-created worker thread whose working state is the dormant state. Wake state. It can be understood that any implementation manner that adjusts the working state of the working thread in the pre-created working thread to the sleeping state to the awake state may be applicable to this, and this embodiment of the present application does not limit this. .
在一些可选实施例中, 在通过所述预先创建的工作线程的条件变量, 将所 述预先创建的工作线程中的工作状态为唤醒状态的工作线程的工作状态调整为 休眠状态时, 通过所述预先创建的工作线程中的工作状态为唤醒状态的工作线 程的条件变量在同步语句块中调用等待函数, 将所述预先创建的工作线程中的 工作状态为唤醒状态的工作线程的工作状态调整为休眠状态。 可以理解的是, 任何将所述预先创建的工作线程中的工作状态为唤醒状态的工作线程的工作状 态调整为休眠状态的实施方式均可适用于此,本申请实施例对此不做任何限定。  In some optional embodiments, when the pre-created worker thread's condition variable is used to adjust the work status of the pre-created worker thread's work state to the awake state to the sleep state, The condition variable of the pre-created worker thread whose working state is the awake state calls a waiting function in a synchronization statement block, and adjusts the working state of the pre-created worker thread whose working state is the awake state. Is dormant. It can be understood that any implementation manner of adjusting the working state of the worker thread in which the working state in the pre-created worker thread is the awake state to the dormant state may be applicable to this, and this embodiment of the present application does not limit this. .
通过本申请实施例提供的任务执行的调控方法, 获取用于工作任务并发执 行的工作线程的数量, 并基于用于工作任务并发执行的工作线程的数量和预先 创建的工作线程的条件变量, 确定用于工作任务并发执行的工作线程, 与现有 的其它方式相比, 利用预先创建的工作线程的条件变量确定用于工作任务并发 执行的工作线程, 能够在不频繁地创建额外的工作线程的情况下, 动态调控用 于工作任务并发执行的工作线程的数量, 进而实现并发执行的工作任务的数量 的动态调整, 从而提高工作任务并发执行的效率。 Through the method for controlling task execution provided in the embodiments of the present application, the number of worker threads used for concurrent execution of work tasks is obtained, and based on the number of worker threads used for concurrent execution of work tasks, and in advance The condition variable of the created worker thread determines the worker thread for concurrent execution of the work task. Compared with other existing methods, the condition variable of the worker thread created in advance is used to determine the worker thread for concurrent execution of the work task. In the case where additional worker threads are not frequently created, the number of worker threads used for concurrent execution of work tasks is dynamically adjusted, and then the number of concurrently executed work tasks is dynamically adjusted, thereby improving the efficiency of concurrent execution of work tasks.
本实施例的任务执行的调控方法可以由任意适当的具有数据处理能力的设 备执行, 包括但不限于:摄像头、终端、移动终端、 PC机、服务器、车载设备、 娱乐设备、 广告设备、 个人数码助理 (PDA) 、 平板电脑、 笔记本电脑、 掌上 游戏机、智能眼镜、智能手表、可穿戴设备、虚拟显示设备或显示增强设备 (如 Google Glass ^ Oculus Rift、 Hololens、 Gear VR)
Figure imgf000007_0001
实施例二
The method for controlling task execution in this embodiment may be performed by any appropriate device having data processing capabilities, including but not limited to: a camera, a terminal, a mobile terminal, a PC, a server, a vehicle-mounted device, an entertainment device, an advertising device, and personal digital Assistant (PDA), tablet, laptop, handheld game console, smart glasses, smart watch, wearable device, virtual display device or display enhancement device (such as Google Glass ^ Oculus Rift, Hololens, Gear VR)
Figure imgf000007_0001
Example two
参照图 2, 示出了根据本申请实施例二的一种任务执行的调控方法的步骤 流程图。  Referring to FIG. 2, a flowchart of steps of a method for regulating task execution according to Embodiment 2 of the present application is shown.
本实施例的任务执行的调控方法包括以下步骤:  The method for adjusting task execution in this embodiment includes the following steps:
在步骤 S201中, 获取用于工作任务并发执行的工作线程的数量。  In step S201, the number of worker threads used for concurrent execution of work tasks is obtained.
由于该步骤 S201与上述步骤 S101类似, 在此不再赘述。  Since step S201 is similar to step S101 described above, details are not described herein again.
在步骤 S202 中, 如果所述用于工作任务并发执行的工作线程的数量大于 预先创建的工作线程的数量, 则创建新的工作线程, 以使得所述预先创建的工 作线程的数量与所述新的工作线程的数量的和等于所述用于工作任务并发执行 的工作线程的数量。  In step S202, if the number of the worker threads for concurrent execution of the work task is greater than the number of pre-created worker threads, a new worker thread is created, so that the number of the pre-created worker threads and the new The sum of the number of worker threads is equal to the number of worker threads for concurrent execution of the work task.
在一些可选实施例中, 通过所述预先创建的工作线程和所述新的工作线程 的条件变量, 将所述预先创建的工作线程与所述新的工作线程的工作状态均调 整为唤醒状态。 可以理解的是, 以上描述仅为示例性的, 本申请实施例对此不 做任何限定。  In some optional embodiments, the pre-created worker thread and the condition variables of the new worker thread are used to adjust the working states of the pre-created worker thread and the new worker thread to the awake state. . It can be understood that the foregoing description is merely exemplary, and the embodiment of the present application does not limit this in any way.
在本申请实施例中, 针对创建得到的每个新的工作线程, 对应设置有条件 变量。 可通过新的工作线程的条件变量, 来实现新的工作线程的自阻塞逻辑。 具体的实现过程与预先创建的工作线程类似, 在此不再赘述。  In the embodiment of the present application, for each new worker thread created, a condition variable is set correspondingly. The self-blocking logic of the new worker thread can be implemented through the condition variables of the new worker thread. The specific implementation process is similar to the pre-created worker thread, and is not repeated here.
在一些可选实施例中, 所述方法还包括: 获取所述工作任务的基础信息; 基于所述工作任务的基础信息, 将所述工作任务存储在阻塞队列中。 其中, 所 述基础信息包括工作任务的类型和大小。 籍此, 不需要实时地监听工作任务的 完成状态, 能够实现多个工作任务的调度和并发执行。 可以理解的是, 以上描 述仅为示例性的, 本申请实施例对此不做任何限定。 In some optional embodiments, the method further includes: obtaining basic information of the work task; and storing the work task in a blocking queue based on the basic information of the work task. The basic information includes a type and a size of a work task. Therefore, it is not necessary to monitor the completion status of the work task in real time, and it is possible to realize the scheduling and concurrent execution of multiple work tasks. Understandably, the above description The description is only exemplary, which is not limited in the embodiment of the present application.
在本申请实施例中,通过阻塞队列,可以使得工作任务由队列的一端输入, 从另外一端输出。具体地,本申请实施例涉及的阻塞队列采用先进先出的原则, 即先插入阻塞队列的工作任务也最先出队列, 类似于排队的功能。 在多工作线 程的环境中, 通过阻塞队列可以很容易实现工作任务的共享。 假设有若干个工 作任务产生线程, 另外又有若干个工作任务执行线程。 如果工作任务产生线程 需要把准备好的工作任务共享给工作任务执行线程, 利用队列的方式来传递工 作任务, 可以很方便地解决它们之间的工作任务共享问题。 理想情况下, 如果 工作任务产生线程产生工作任务的速度大于工作任务执行线程执行工作任务的 速度, 并且当工作任务产生线程产生出来的工作任务累积到一定程度的时, 那 么工作任务产生线程必须暂停等待一下 (阻塞工作任务产生线程) , 以便等待 工作任务执行线程把累积的工作任务处理完毕, 反之亦然。 然而, 在不使用阻 塞队列的情况下, 在多线程环境下, 每个程序员都必须去自己控制这些细节, 尤其还要兼顾效率和线程安全, 而这会给程序带来不小的复杂度。 其中, 在多 线程领域中, 所谓阻塞,在某些情况下会挂起线程(即阻塞), 一旦条件满足, 被挂起的线程又会自动被唤醒。 可以理解的是, 以上描述仅为示例性的, 本申 请实施例对此不做任何限定。  In the embodiment of the present application, by blocking the queue, the work task can be input from one end of the queue and output from the other end. Specifically, the blocking queue involved in the embodiment of the present application adopts a first-in-first-out principle, that is, a work task that is first inserted into the blocking queue is also the first to leave the queue, which is similar to the function of queuing. In a multi-working environment, the sharing of work tasks can be easily achieved by blocking queues. Assume that there are several work tasks that generate threads, and in addition there are several work task execution threads. If the work task spawns a thread and the prepared work task needs to be shared with the work task execution thread, using a queue to transfer the work task can easily solve the problem of sharing work tasks between them. Ideally, if the work task generation thread generates work tasks faster than the work task execution thread executes work tasks, and when the work tasks generated by the work task generation threads accumulate to a certain degree, then the work task generation threads must be suspended Wait for a while (blocking the work task spawning thread), in order to wait for the work task execution thread to finish processing the accumulated work tasks, and vice versa. However, in the case of not using a blocking queue, in a multi-threaded environment, each programmer must control these details by himself, especially considering both efficiency and thread safety, which will bring considerable complexity to the program. . Among them, in the multi-threaded field, the so-called blocking, in some cases, will suspend the thread (that is, block), and once the condition is met, the suspended thread will be automatically awakened. It can be understood that the above description is only exemplary, and this embodiment does not limit it in any way.
在一个具体的例子中, 通过所述用于工作任务并发执行的工作线程, 依次 从所述阻塞队列中获取所述工作任务, 并且并发执行所述工作任务。 具体地, 通过用于工作任务并发执行的每个工作线程, 依次从所述阻塞队列中获取相应 的工作任务,并且并发执行工作任务。可以理解的是,以上描述仅为示例性的, 本申请实施例对此不做任何限定。  In a specific example, the work threads for the concurrent execution of work tasks are sequentially obtained from the blocking queue, and the work tasks are concurrently executed. Specifically, each work thread used for concurrent execution of the work task obtains the corresponding work task from the blocking queue in turn, and executes the work task concurrently. It can be understood that the above description is only exemplary, and the embodiment of the present application does not limit this in any way.
通过本申请实施例提供的任务执行的调控方法,获取工作任务的基础信息, 并基于工作任务的基础信息, 将工作任务存储在阻塞队列中, 与现有的其它方 式相比, 将工作任务存储在阻塞队列中, 不需要实时地监听工作任务的完成状 态, 能够实现多个工作任务的调度和并发执行。  By using the method for controlling task execution provided in the embodiments of the present application, basic information of a work task is obtained, and based on the basic information of the work task, the work task is stored in a blocking queue. Compared with other existing methods, the work task is stored. In the blocking queue, there is no need to monitor the completion status of the work tasks in real time, and it is possible to realize the scheduling and concurrent execution of multiple work tasks.
本实施例的任务执行的调控方法可以由任意适当的具有数据处理能力的设 备执行, 包括但不限于:摄像头、终端、移动终端、 PC机、服务器、车载设备、 娱乐设备、 广告设备、 个人数码助理 (PDA) 、 平板电脑、 笔记本电脑、 掌上 游戏机、智能眼镜、智能手表、可穿戴设备、虚拟显示设备或显示增强设备(如 Google Glass、 Oculus Rift、 Hololens、 Gear VR) 等。 实施例三 The method for controlling task execution in this embodiment may be performed by any appropriate device having data processing capabilities, including but not limited to: a camera, a terminal, a mobile terminal, a PC, a server, a vehicle-mounted device, an entertainment device, an advertising device, and personal digital Assistant (PDA), tablet, laptop, handheld game console, smart glasses, smart watch, wearable device, virtual display device or display enhancement device (such as Google Glass, Oculus Rift, Hololens, Gear VR), etc. Example three
参照图 3 , 示出了根据本申请实施例三的一种任务执行的调控装置的结构 框图。  Referring to FIG. 3, a structural block diagram of a control device for task execution according to Embodiment 3 of the present application is shown.
本实施例的任务执行的调控装置包括: 第一获取模块 301, 被配置为获取 用于工作任务并发执行的工作线程的数量; 第一确定模块 302, 被配置为基于 所述用于工作任务并发执行的工作线程的数量和预先创建的工作线程的条件变 量, 确定用于工作任务并发执行的工作线程。  The task execution regulating device in this embodiment includes: a first acquisition module 301 configured to acquire the number of worker threads for concurrent execution of work tasks; a first determination module 302 configured to be based on the concurrent use of work tasks The number of worker threads to be executed and condition variables of the worker threads created in advance determine the worker threads for concurrent execution of work tasks.
本实施例的任务执行的调控装置用于实现前述多个方法实施例中相应的任 务执行的调控方法, 并具有相应的方法实施例的有益效果, 在此不再赘述。 实施例四  The task execution control device in this embodiment is used to implement the corresponding task execution control method in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, and details are not described herein again. Embodiment 4
参照图 4, 示出了根据本申请实施例四的一种任务执行的调控装置的结构 框图。  Referring to FIG. 4, there is shown a structural block diagram of a control device for task execution according to Embodiment 4 of the present application.
本实施例的任务执行的调控装置包括: 第一获取模块 401, 被配置为获取 用于工作任务并发执行的工作线程的数量; 第一确定模块 402, 被配置为基于 所述用于工作任务并发执行的工作线程的数量和预先创建的工作线程的条件变 量, 确定用于工作任务并发执行的工作线程。  The task execution regulating device in this embodiment includes: a first acquisition module 401 configured to acquire the number of worker threads for concurrent execution of work tasks; a first determination module 402 configured to be based on the concurrent use of work tasks The number of worker threads to be executed and condition variables of the worker threads created in advance determine the worker threads for concurrent execution of work tasks.
可选地, 所述第一确定模块 402, 包括: 第二确定模块 4021, 被配置为如 果所述用于工作任务并发执行的工作线程的数量小于预先创建的工作线程的数 量, 则检测所述预先创建的工作线程的工作状态, 并通过所述预先创建的工作 线程的工作变量, 调整所述预先创建的工作线程的工作状态, 以确定用于工作 任务并发执行的工作线程。  Optionally, the first determining module 402 includes: a second determining module 4021 configured to detect the number of the worker threads for concurrent execution of the work task is less than the number of the worker threads created in advance, The working state of the pre-created worker thread, and the working state of the pre-created worker thread is adjusted through the working variables of the pre-created worker thread to determine a worker thread for concurrent execution of the worker task.
可选地, 所述第二确定模块 4021, 包括: 第一调整模块 4022, 被配置为如 果所述预先创建的工作线程中的工作状态为唤醒状态的工作线程的数量小于所 述用于工作任务并发执行的工作线程的数量, 则通过所述预先创建的工作线程 的条件变量, 将所述预先创建的工作线程中的工作状态为休眠状态的工作线程 的工作状态调整为唤醒状态, 以使得所述预先创建的工作线程中的工作状态为 唤醒状态的工作线程的数量等于所述用于工作任务并发执行的工作线程的数量, 其中, 所述工作状态包括唤醒状态和 /或休眠状态。  Optionally, the second determination module 4021 includes: a first adjustment module 4022, configured to, if the number of working threads in the pre-created working thread is awake, is smaller than the number of working threads for the working task For the number of concurrently executed worker threads, the condition of the pre-created worker thread is used to adjust the work state of the worker thread whose work status is the dormant state to the awake state, so that the The number of pre-created worker threads whose working state is awake state is equal to the number of the worker threads for concurrent execution of work tasks, wherein the working state includes awake state and / or hibernation state.
可选地, 所述第二确定模块 4021, 还包括: 第二调整模块 4023 , 被配置为 如果所述预先创建的工作线程中的工作状态为唤醒状态的工作线程的数量大于 所述用于工作任务并发执行的工作线程的数量, 则通过所述预先创建的工作线 程的条件变量, 将所述预先创建的工作线程中的工作状态为唤醒状态的工作线 程的工作状态调整为休眠状态, 以使得所述预先创建的工作线程中的工作状态 为唤醒状态的工作线程的数量等于所述用于工作任务并发执行的工作线程的数 量, 其中, 所述工作状态包括唤醒状态和 /或休眠状态。 Optionally, the second determination module 4021 further includes: a second adjustment module 4023 configured to, if the number of working threads in the pre-created working threads is awake, is greater than the number of working threads The number of worker threads executing tasks concurrently, through the pre-created work lines Condition variable of the process, adjust the working state of the worker thread whose working state is the awake state to the sleep state, so that the working state of the pre-created worker thread is the worker thread of the awake state The number is equal to the number of the worker threads for concurrent execution of the work task, wherein the work state includes an awake state and / or a sleep state.
可选地, 所述第一确定模块 402, 还包括: 第三确定模块 4024, 被配置为 如果所述用于工作任务并发执行的工作线程的数量等于预先创建的工作线程的 数量, 则检测所述预先创建的工作线程的工作状态, 并通过所述预先创建的工 作线程的工作变量, 调整所述预先创建的工作线程的工作状态, 以确定用于工 作任务并发执行的工作线程。  Optionally, the first determining module 402 further includes: a third determining module 4024, configured to detect the number of the worker threads for concurrent execution of the work task equal to the number of the worker threads created in advance. The work state of the pre-created worker thread is described, and the work state of the pre-created worker thread is adjusted through the work variable of the pre-created worker thread to determine the worker thread for concurrent execution of the work task.
可选地, 所述第三确定模块 4024, 包括: 第三调整模块 4025, 被配置为如 果所述预先创建的工作线程中的工作状态为唤醒状态的工作线程的数量小于所 述用于工作任务并发执行的工作线程的数量, 则通过所述预先创建的工作线程 的条件变量, 将所述预先创建的工作线程中的工作状态为休眠状态的工作线程 的工作状态调整为唤醒状态, 以使得所述预先创建的工作线程的工作状态均为 唤醒状态, 其中, 所述工作状态包括唤醒状态和 /或休眠状态。  Optionally, the third determination module 4024 includes: a third adjustment module 4025, configured to, if the number of working threads in the pre-created working thread is awake, is smaller than the number of working threads for the working task For the number of concurrently executed worker threads, the condition of the pre-created worker thread is used to adjust the work state of the worker thread whose work status is the dormant state to the awake state, so that the The work states of the pre-created worker threads are all wake-up states, where the work states include a wake-up state and / or a sleep state.
可选地, 所述第一确定模块 402, 还包括: 创建模块 4026, 被配置为如果 所述用于工作任务并发执行的工作线程的数量大于预先创建的工作线程的数量, 则创建新的工作线程, 以使得所述预先创建的工作线程的数量与所述新的工作 线程的数量的和等于所述用于工作任务并发执行的工作线程的数量。  Optionally, the first determining module 402 further includes: a creating module 4026, configured to create a new job if the number of the worker threads used for concurrent execution of the work task is greater than the number of pre-created worker threads. Threads, so that the sum of the number of the pre-created worker threads and the number of the new worker threads is equal to the number of the worker threads for concurrent execution of the worker task.
可选地, 所述第一确定模块 402, 还包括: 第四调整模块 4027, 被配置为 通过所述预先创建的工作线程和所述新的工作线程的条件变量, 将所述预先创 建的工作线程与所述新的工作线程的工作状态均调整为唤醒状态。  Optionally, the first determination module 402 further includes: a fourth adjustment module 4027, configured to pass the pre-created work thread and the condition variable of the new work thread to the pre-created work thread Both the working state of the thread and the new worker thread are adjusted to the awake state.
本实施例的任务执行的调控装置用于实现前述多个方法实施例中相应的任 务执行的调控方法, 并具有相应的方法实施例的有益效果, 在此不再赘述。 实施例五  The task execution control device in this embodiment is used to implement the corresponding task execution control method in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, and details are not described herein again. Example 5
参照图 5, 示出了根据本申请实施例五的一种任务执行的调控装置的结构 框图。  Referring to FIG. 5, there is shown a structural block diagram of a control device for task execution according to Embodiment 5 of the present application.
本实施例的任务执行的调控装置包括: 第一获取模块 504, 被配置为获取 用于工作任务并发执行的工作线程的数量; 第一确定模块 505, 被配置为基于 所述用于工作任务并发执行的工作线程的数量和预先创建的工作线程的条件变 量, 确定用于工作任务并发执行的工作线程。 可选地, 所述第一调整模块 5051, 包括: 第五调整模块 5052, 被配置为通 过所述预先创建的工作线程中的工作状态为休眠状态的工作线程的条件变量在 同步语句块中调用通知函数, 将所述预先创建的工作线程中的工作状态为休眠 状态的工作线程的工作状态调整为唤醒状态。 The task execution regulating device in this embodiment includes: a first acquisition module 504 configured to acquire the number of worker threads for concurrent execution of work tasks; a first determination module 505 configured to be based on the concurrent use of work tasks The number of worker threads to be executed and condition variables of the worker threads created in advance determine the worker threads for concurrent execution of work tasks. Optionally, the first adjustment module 5051 includes: a fifth adjustment module 5052, which is configured to be called in a synchronization statement block by using a condition variable of a working thread in which the working state in the pre-created working thread is a sleep state. The notification function adjusts the work state of the worker thread whose work state is the sleep state in the pre-created worker thread to the wake state.
可选地, 所述第二调整模块 5053, 包括: 第六调整模块 5054, 被配置为通 过所述预先创建的工作线程中的工作状态为唤醒状态的工作线程的条件变量在 同步语句块中调用等待函数, 将所述预先创建的工作线程中的工作状态为唤醒 状态的工作线程的工作状态调整为休眠状态。  Optionally, the second adjustment module 5053 includes: a sixth adjustment module 5054, which is configured to be called in a synchronization statement block through a condition variable of a worker thread whose work status is awake in the pre-created worker thread. The waiting function adjusts the work state of the worker thread whose work state is the awake state to the sleep state in the pre-created worker thread.
可选地, 所述装置还包括: 第二获取模块 501, 被配置为获取所述工作任 务的基础信息; 存储模块 502, 被配置为基于所述工作任务的基础信息, 将所 述工作任务存储在阻塞队列中。  Optionally, the apparatus further includes: a second obtaining module 501 configured to obtain basic information of the work task; a storage module 502 configured to store the work task based on the basic information of the work task In the blocking queue.
可选地, 所述装置还包括: 第三获取模块 503 , 被配置为通过所述用于工 作任务并发执行的工作线程, 依次从所述阻塞队列中获取所述工作任务, 并且 并发执行所述工作任务。  Optionally, the apparatus further includes: a third obtaining module 503 configured to sequentially obtain the work tasks from the blocking queue through the worker threads for concurrent execution of the work tasks, and execute the work concurrently. work tasks.
可选地, 所述基础信息包括工作任务的类型和大小。  Optionally, the basic information includes a type and a size of a work task.
可选地, 所述工作任务包括下载任务。  Optionally, the work task includes a download task.
本实施例的任务执行的调控装置用于实现前述多个方法实施例中相应的任 务执行的调控方法, 并具有相应的方法实施例的有益效果, 在此不再赘述。 实施例六  The task execution control device in this embodiment is used to implement the corresponding task execution control method in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, and details are not described herein again. Example Six
参照图 6, 示出了根据本申请实施例六的一种设备 /终端 /服务器的结构示 意图, 本申请具体实施例并不对设备 /终端 /服务器的具体实现做限定。  Referring to FIG. 6, a schematic structural diagram of a device / terminal / server according to Embodiment 6 of the present application is shown. The specific embodiment of the present application does not limit the specific implementation of the device / terminal / server.
如图 6所示, 该设备 /终端 /服务器可以包括: 处理器 (processor)601、 存储 装置 602。  As shown in FIG. 6, the device / terminal / server may include a processor 601 and a storage device 602.
其中:  among them:
处理器 601,用于执行程序 603,具体可以执行上述任务执行的调控方法实 施例中的相关步骤。  The processor 601 is configured to execute a program 603, and may specifically perform relevant steps in an embodiment of a method for controlling execution of the foregoing tasks.
具体地, 程序 603可以包括程序代码, 该程序代码包括计算机操作指令。 处理器 601可能是中央处理器 CPU,或者是特定集成电路 ASIC( Application Specific Integrated Circuit) , 或者是被配置成实施本申请实施例的一个或多个 集成电路。 设备 /终端 /服务器包括的一个或多个处理器, 可以是同一类型的处 理器, 如一个或多个 CPU; 也可以是不同类型的处理器, 如一个或多个 CPU 以及一个或多个 ASIC。 Specifically, the program 603 may include program code, where the program code includes a computer operation instruction. The processor 601 may be a central processing unit CPU, or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application. One or more processors included in the device / terminal / server may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs And one or more ASICs.
存储装置 602,配置为存放一个或多个程序 603。存储装置 602可能包含高 速 RAM存储器, 也可能还包括非易失性存储器 (non-volatile memory) , 例如 至少一个磁盘存储器。  The storage device 602 is configured to store one or more programs 603. The storage device 602 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), for example, at least one disk memory.
程序 603具体可以用于使得处理器 601执行以下操作: 获取用于工作任务 并发执行的工作线程的数量; 基于所述用于工作任务并发执行的工作线程的数 量和预先创建的工作线程的条件变量,确定用于工作任务并发执行的工作线程。  The program 603 may be specifically configured to cause the processor 601 to perform the following operations: obtaining the number of worker threads used for concurrent execution of work tasks; based on the number of worker threads used for concurrent execution of work tasks and condition variables created in advance To determine the worker threads for concurrent execution of work tasks.
在一种可选的实施方式中, 程序 603还用于使得处理器 601在基于所述用 于工作任务并发执行的工作线程的数量和预先创建的工作线程的条件变量, 确 定用于工作任务并发执行的工作线程时, 如果所述用于工作任务并发执行的工 作线程的数量小于预先创建的工作线程的数量, 则检测所述预先创建的工作线 程的工作状态, 并通过所述预先创建的工作线程的工作变量, 调整所述预先创 建的工作线程的工作状态, 以确定用于工作任务并发执行的工作线程。  In an optional implementation manner, the program 603 is further configured to cause the processor 601 to determine the concurrent use of the work tasks based on the number of the work threads for concurrent execution of the work tasks and the condition variables of the pre-created work threads. During the execution of the worker threads, if the number of the worker threads used for concurrent execution of the work task is less than the number of pre-created worker threads, detecting the work state of the pre-created worker threads and using the pre-created work A working variable of a thread, adjusting a working state of the pre-created working thread to determine a working thread for concurrent execution of a working task.
在一种可选的实施方式中, 程序 603还用于使得处理器 601在通过所述预 先创建的工作线程的工作变量, 调整所述预先创建的工作线程的工作状态, 以 确定用于工作任务并发执行的工作线程时, 如果所述预先创建的工作线程中的 工作状态为唤醒状态的工作线程的数量小于所述用于工作任务并发执行的工作 线程的数量, 则通过所述预先创建的工作线程的条件变量, 将所述预先创建的 工作线程中的工作状态为休眠状态的工作线程的工作状态调整为唤醒状态, 以 使得所述预先创建的工作线程中的工作状态为唤醒状态的工作线程的数量等于 所述用于工作任务并发执行的工作线程的数量, 其中, 所述工作状态包括唤醒 状态和 /或休眠状态。  In an optional implementation manner, the program 603 is further configured to cause the processor 601 to adjust a working state of the pre-created worker thread through a working variable of the pre-created worker thread to determine a work task. When concurrently executing worker threads, if the number of worker threads in the pre-created worker thread whose working state is awake is less than the number of worker threads for concurrent execution of work tasks, the pre-created worker threads are used. A condition variable of a thread, adjusting a working state of a working thread in which the working state in the pre-created worker thread is a sleep state to an awake state, so that a working thread in the pre-created worker thread is in a wake-up state. The number is equal to the number of the worker threads for concurrent execution of the work task, wherein the work state includes an awake state and / or a sleep state.
在一种可选的实施方式中, 程序 603还用于使得处理器 601在通过所述预 先创建的工作线程的工作变量, 调整所述预先创建的工作线程的工作状态, 以 确定用于工作任务并发执行的工作线程时, 如果所述预先创建的工作线程中的 工作状态为唤醒状态的工作线程的数量大于所述用于工作任务并发执行的工作 线程的数量, 则通过所述预先创建的工作线程的条件变量, 将所述预先创建的 工作线程中的工作状态为唤醒状态的工作线程的工作状态调整为休眠状态, 以 使得所述预先创建的工作线程中的工作状态为唤醒状态的工作线程的数量等于 所述用于工作任务并发执行的工作线程的数量, 其中, 所述工作状态包括唤醒 状态和 /或休眠状态。  In an optional implementation manner, the program 603 is further configured to cause the processor 601 to adjust a working state of the pre-created worker thread through a working variable of the pre-created worker thread to determine a work task. When concurrently executing worker threads, if the number of worker threads in the pre-created worker threads whose working state is awake is greater than the number of worker threads for concurrent execution of work tasks, the pre-created workers are used. A condition variable of the thread, adjusting the working state of the worker thread whose working state is the awake state to a sleep state, so that the working state of the previously created worker thread is a working state of the awake state The number is equal to the number of the worker threads for concurrent execution of the work task, wherein the work state includes an awake state and / or a sleep state.
在一种可选的实施方式中, 程序 603还用于使得处理器 601在基于所述用 于工作任务并发执行的工作线程的数量和预先创建的工作线程的条件变量, 确 定用于工作任务并发执行的工作线程时, 如果所述用于工作任务并发执行的工 作线程的数量等于预先创建的工作线程的数量, 则检测所述预先创建的工作线 程的工作状态, 并通过所述预先创建的工作线程的工作变量, 调整所述预先创 建的工作线程的工作状态, 以确定用于工作任务并发执行的工作线程。 In an optional implementation manner, the program 603 is further configured to cause the processor 601 to When determining the number of worker threads for concurrent execution of work tasks based on the number of worker threads concurrently executing work tasks and condition variables created in advance, if the number of worker threads used for concurrent execution of work tasks is equal to the previously created The number of worker threads, then detecting the work state of the pre-created worker thread, and adjusting the work state of the pre-created worker thread through the work variable of the pre-created worker thread to determine the concurrent use of the work task Executed worker thread.
在一种可选的实施方式中, 程序 603还用于使得处理器 601在通过所述预 先创建的工作线程的工作变量, 调整所述预先创建的工作线程的工作状态, 以 确定用于工作任务并发执行的工作线程时, 如果所述预先创建的工作线程中的 工作状态为唤醒状态的工作线程的数量小于所述用于工作任务并发执行的工作 线程的数量, 则通过所述预先创建的工作线程的条件变量, 将所述预先创建的 工作线程中的工作状态为休眠状态的工作线程的工作状态调整为唤醒状态, 以 使得所述预先创建的工作线程的工作状态均为唤醒状态, 其中, 所述工作状态 包括唤醒状态和 /或休眠状态。  In an optional implementation manner, the program 603 is further configured to cause the processor 601 to adjust a working state of the pre-created worker thread through a working variable of the pre-created worker thread to determine a work task. When concurrently executing worker threads, if the number of worker threads in the pre-created worker thread whose working state is awake is less than the number of worker threads for concurrent execution of work tasks, the pre-created worker threads are used. The condition variable of the thread adjusts the working state of the worker thread whose working state is the sleep state to the awake state, so that the working states of the pre-created worker thread are all awake states, where: The working state includes an awake state and / or a hibernation state.
在一种可选的实施方式中, 程序 603还用于使得处理器 601在基于所述用 于工作任务并发执行的工作线程的数量和预先创建的工作线程的条件变量, 确 定用于工作任务并发执行的工作线程时, 如果所述用于工作任务并发执行的工 作线程的数量大于预先创建的工作线程的数量, 则创建新的工作线程, 以使得 所述预先创建的工作线程的数量与所述新的工作线程的数量的和等于所述用于 工作任务并发执行的工作线程的数量。  In an optional implementation manner, the program 603 is further configured to cause the processor 601 to determine the concurrent use of the work tasks based on the number of the work threads for concurrent execution of the work tasks and the condition variables of the pre-created work threads. During the execution of the worker threads, if the number of the worker threads used for concurrent execution of the work task is greater than the number of pre-created worker threads, a new worker thread is created, so that the number of the pre-created worker threads is the same as the number of the pre-created worker threads. The sum of the number of new worker threads is equal to the number of worker threads for concurrent execution of the worker task.
在一种可选的实施方式中, 程序 603还用于使得处理器 601通过所述预先 创建的工作线程和所述新的工作线程的条件变量, 将所述预先创建的工作线程 与所述新的工作线程的工作状态均调整为唤醒状态。  In an optional implementation manner, the program 603 is further configured to cause the processor 601 to use the pre-created worker thread and the condition variable of the new worker thread to associate the pre-created worker thread with the new worker thread. The working states of the worker threads are adjusted to the awake state.
在一种可选的实施方式中, 程序 603还用于使得处理器 601在通过所述预 先创建的工作线程的条件变量, 将所述预先创建的工作线程中的工作状态为休 眠状态的工作线程的工作状态调整为唤醒状态时, 通过所述预先创建的工作线 程中的工作状态为休眠状态的工作线程的条件变量在同步语句块中调用通知函 数, 将所述预先创建的工作线程中的工作状态为休眠状态的工作线程的工作状 态调整为唤醒状态。  In an optional implementation manner, the program 603 is further configured to cause the processor 601 to use the condition variables of the pre-created worker thread to change the working state of the pre-created worker thread to a dormant worker thread. When the working state of the worker is adjusted to the awake state, a notification function is called in a synchronization statement block through a condition variable of the worker thread whose working state is a sleep state in the pre-created worker thread, and the work in the pre-created worker thread is The working state of the worker thread in the sleep state is adjusted to the awake state.
在一种可选的实施方式中, 程序 603还用于使得处理器 601在通过所述预 先创建的工作线程的条件变量, 将所述预先创建的工作线程中的工作状态为唤 醒状态的工作线程的工作状态调整为休眠状态时, 通过所述预先创建的工作线 程中的工作状态为唤醒状态的工作线程的条件变量在同步语句块中调用等待函 数, 将所述预先创建的工作线程中的工作状态为唤醒状态的工作线程的工作状 态调整为休眠状态。 In an optional implementation manner, the program 603 is further configured to cause the processor 601 to use the condition variables of the pre-created worker thread to change the working state in the pre-created worker thread to the worker thread in the awake state. When the working state of the worker is adjusted to a sleep state, a waiting function is called in a synchronization statement block through a condition variable of the worker thread in which the working state in the pre-created worker thread is awake The working state of the worker thread whose working state is the awake state in the pre-created worker thread is adjusted to a sleep state.
在一种可选的实施方式中, 程序 603还用于使得处理器 601获取所述工作 任务的基础信息; 基于所述工作任务的基础信息, 将所述工作任务存储在阻塞 队列中。  In an optional implementation manner, the program 603 is further configured to cause the processor 601 to obtain basic information of the work task; and based on the basic information of the work task, store the work task in a blocking queue.
在一种可选的实施方式中, 程序 603还用于使得处理器 601通过所述用于 工作任务并发执行的工作线程, 依次从所述阻塞队列中获取所述工作任务, 并 且并发执行所述工作任务。  In an optional implementation manner, the program 603 is further configured to cause the processor 601 to sequentially obtain the work task from the blocking queue through the work thread for concurrent execution of the work task, and execute the work concurrently. work tasks.
在一种可选的实施方式中, 所述基础信息包括工作任务的类型和大小。 在一种可选的实施方式中, 所述工作任务包括下载任务。  In an optional implementation manner, the basic information includes a type and a size of a work task. In an optional implementation manner, the work task includes a download task.
程序 603中各步骤的具体实现可以参见上述任务执行的调控方法实施例中 的相应步骤和单元中对应的描述, 在此不赘述。 所属领域的技术人员可以清楚 地了解到, 为描述的方便和简洁, 上述描述的设备和模块的具体工作过程, 可 以参考前述方法实施例中的对应过程描述, 在此不再赘述。  For specific implementation of each step in the program 603, reference may be made to corresponding descriptions in the corresponding steps and units in the embodiment of the method for controlling execution of the foregoing task, and details are not described herein. Those skilled in the art can clearly understand that, for the convenience and brevity of the description, the specific working processes of the devices and modules described above can be referred to the corresponding process descriptions in the foregoing method embodiments, and are not repeated here.
通过本实施例的设备 /终端 /服务器, 获取用于工作任务并发执行的工作线 程的数量, 并基于用于工作任务并发执行的工作线程的数量和预先创建的工作 线程的条件变量, 确定用于工作任务并发执行的工作线程, 与现有的其它方式 相比, 利用预先创建的工作线程的条件变量确定用于工作任务并发执行的工作 线程, 能够在不频繁地创建额外的工作线程的情况下, 动态调控用于工作任务 并发执行的工作线程的数量,进而实现并发执行的工作任务的数量的动态调整, 从而提高工作任务并发执行的效率。  Through the device / terminal / server of this embodiment, the number of worker threads used for concurrent execution of work tasks is obtained, and based on the number of worker threads used for concurrent execution of work tasks and condition variables created in advance, determine the Compared with other existing methods, the worker threads for concurrent execution of work tasks use condition variables of pre-created worker threads to determine the worker threads for concurrent execution of work tasks, which can create additional worker threads infrequently. The number of working threads used for concurrent execution of work tasks is dynamically controlled, and the number of concurrently executed work tasks is dynamically adjusted, thereby improving the efficiency of concurrent execution of work tasks.
需要指出, 根据实施的需要, 可将本申请实施例中描述的各个部件 /步骤拆 分为更多部件 /步骤, 也可将两个或多个部件 /步骤或者部件 /步骤的部分操作组 合成新的部件 /步骤, 以实现本申请实施例的目的。  It should be noted that according to the needs of implementation, each component / step described in the embodiment of the present application may be split into more components / steps, or two or more components / steps or partial operations of components / steps may be combined into New components / steps to achieve the purpose of the embodiments of the present application.
特别地, 根据本申请实施例, 上文参考流程图描述的过程可以被实现为计 算机软件程序。 例如, 本申请实施例包括一种计算机程序产品, 其包括承载在 计算机可读介质上的计算机程序, 该计算机程序包含用于执行上文多个方法实 施例中所示的方法的程序代码。 在这样的实施例中, 该计算机程序可以通过通 信部分从网络上被下载和安装, 和 /或从可拆卸介质被安装。在该计算机程序被 中央处理单元 (CPU) 执行时, 执行本申请实施例示出的方法中限定的上述功 會 L 需要说明的是, 本申请所述的计算机可读介质可以是计算机可读信号介质 或者计算机可读存储介质或者是上述两者的任意组合。 计算机可读存储介质例 如可以是, 但不限于, 电、 磁、 光、 电磁、 红外线、 或半导体的系统、 装置或 器件, 或者任意以上的组合。 计算机可读存储介质的更具体的例子可以包括但 不限于: 具有一个或多个导线的电连接、 便携式计算机磁盘、 硬盘、 随机访问 存储装置( RAM)、只读存储装置( ROM)、可擦式可编程只读存储装置( EPROM 或闪存)、光纤、便携式紧凑磁盘只读存储装置(CD-ROM)、光存储装置件、 磁存储装置件、 或者上述的任意合适的组合。 在本申请中, 计算机可读存储介 质可以是任何包含或存储程序的有形介质, 该程序可以被指令执行系统、 装置 或者器件使用或者与其结合使用。 而在本申请中, 计算机可读的信号介质可以 包括在基带中或者作为载波一部分传播的数据信号, 其中承载了计算机可读的 程序代码。 这种传播的数据信号可以采用多种形式, 包括但不限于电磁信号、 光信号或上述的任意合适的组合。 计算机可读的信号介质还可以是计算机可读 存储介质以外的任何计算机可读介质, 该计算机可读介质可以发送、 传播或者 传输用于由指令执行系统、 装置或者器件使用或者与其结合使用的程序。 计算 机可读介质上包含的程序代码可以用任何适当的介质传输, 包括但不限于: 无 线、 电线、 光缆、 RF等等, 或者上述的任意合适的组合。 Particularly, according to the embodiment of the present application, the process described above with reference to the flowchart may be implemented as a computer software program. For example, the embodiment of the present application includes a computer program product including a computer program borne on a computer-readable medium, where the computer program includes program code for executing the methods shown in the foregoing multiple method embodiments. In such an embodiment, the computer program may be downloaded and installed from a network through a communication section, and / or installed from a removable medium. When the computer program is executed by a central processing unit (CPU), the above-mentioned functions defined in the method shown in the embodiment of the present application are performed. It should be noted that the computer-readable medium described in this application may be a computer-readable signal medium. Either a computer-readable storage medium or any combination of the two. Examples of computer-readable storage media For example, it may be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access storage (RAM), read-only storage (ROM), erasable Type programmable read-only storage device (EPROM or flash memory), optical fiber, portable compact disk read-only storage device (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing. In this application, a computer-readable storage medium may be any tangible medium containing or storing a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium may include a data signal that is included in baseband or propagated as part of a carrier wave, and which carries computer-readable program code. Such a propagated data signal may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. The computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, and the computer-readable medium may send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device . Program code embodied on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
可以以一种或多种程序设计语言或其组合来编写用于执行本申请的操作的 计算机程序代码, 所述程序设计语言包括面向对象的程序设计语言 ------诸如 Computer program code for performing the operations of the present application may be written in one or more programming languages, or a combination thereof, which includes an object-oriented programming language--such as
Java、 Smalltalk, C++, 还包括常规的过程式程序设计语言 诸如” C”语言 或类似的程序设计语言。 程序代码可以完全地在用户计算机上执行、 部分地在 用户计算机上执行、 作为一个独立的软件包执行、 部分在用户计算机上部分在 远程计算机上执行、 或者完全在远程计算机或服务器上执行。 在涉及远程计算 机的情形中, 远程计算机可以通过任意种类的网络 ------包括局域网(LAN)或广 域网(WAN) 连接到用户计算机, 或者, 可以连接到外部计算机(例如利用 因特网服务提供商来通过因特网连接) 。 Java, Smalltalk, C ++, also includes regular procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partly on the user's computer, as an independent software package, partly on the user's computer, partly on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (such as provided by an Internet service) (Commercially connected via the Internet).
附图中的流程图和框图, 图示了按照本申请各种实施例的系统、 方法和计 算机程序产品的可能实现的体系架构、 功能和操作。 在这点上, 流程图或框图 中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、 或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。 也应 当注意, 在有些作为替换的实现中, 方框中所标注的功能也可以以不同于附图 中所标注的顺序发生。 例如, 两个接连地表示的方框实际上可以基本并行地执 行, 它们有时也可以按相反的顺序执行, 这依所涉及的功能而定。 也要注意的 是, 框图和 /或流程图中的每个方框、 以及框图和 /或流程图中的方框的组合, 可以用执行规定的功能或操作的专用的基于硬件的系统来实现, 或者可以用专 用硬件与计算机指令的组合来实现。 The flowchart and block diagrams in the accompanying drawings illustrate the architecture, functions, and operations of possible implementations of systems, methods, and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, which contains one or more functions for implementing a specified logical function Executable instructions. It should also be noted that in some alternative implementations, the functions marked in the blocks may also occur in a different order than those marked in the drawings. For example, two successively represented boxes may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and a combination of blocks in the block diagram and / or flowchart, It may be implemented by a dedicated hardware-based system that performs prescribed functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.
描述于本申请实施例中所涉及到的单元可以通过软件的方式实现, 也可以 通过硬件的方式来实现。 所描述的单元也可以设置在处理器中, 例如, 可以描 述为: 一种处理器包括获取单元、 处理单元、 和测试单元。 其中, 这些单元的 名称在某种情况下并不构成对该单元本身的限定, 例如, 获取单元还可以被描 述为“根据测试指令获取待测试目标对象的业务测试文件的单元” 。  The units described in the embodiments of the present application may be implemented in a software manner, or may be implemented in a hardware manner. The described unit may also be provided in a processor, for example, it may be described as: A processor includes an acquisition unit, a processing unit, and a test unit. The name of these units does not constitute a limitation on the unit itself in some cases. For example, the obtaining unit may also be described as "a unit for obtaining a business test file of a target object to be tested according to a test instruction".
作为另一方面, 本申请还提供了一种计算机可读存储介质, 其上存储有计 算机程序, 该程序被处理器执行时实现如上述任一实施例所描述的方法。  As another aspect, the present application also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the method described in any one of the foregoing embodiments is implemented.
作为另一方面, 本申请还提供了一种计算机可读介质, 该计算机可读介质 可以是上述实施例中描述的装置中所包含的; 也可以是单独存在, 而未装配入 该装置中。 上述计算机可读介质承载有一个或者多个程序, 当上述一个或者多 个程序被该装置执行时, 使得该装置所在的设备获取用于工作任务并发执行的 工作线程的数量; 基于所述用于工作任务并发执行的工作线程的数量和预先创 建的工作线程的条件变量, 确定用于工作任务并发执行的工作线程。  As another aspect, the present application further provides a computer-readable medium, which may be included in the device described in the foregoing embodiments; or may exist alone without being assembled into the device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by the device, the device where the device is located obtains a number of working threads for concurrent execution of work tasks; based on the The number of worker threads for concurrent execution of work tasks and condition variables of previously created worker threads determine the worker threads for concurrent execution of work tasks.
以上描述仅为本申请的较佳实施例以及对所运用技术原理的说明。 本领域 技术人员应当理解, 本申请中所涉及的发明范围, 并不限于上述技术特征的特 定组合而成的技术方案, 同时也应涵盖在不脱离上述发明构思的情况下, 由上 述技术特征或其等同特征进行任意组合而形成的其它技术方案。 例如上述特征 与本申请中公开的 (但不限于) 具有类似功能的技术特征进行互相替换而形成 的技术方案。  The above description is only a preferred embodiment of the present application and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to the technical solution of the specific combination of the above technical features, but also covers the above technical features or Other technical solutions formed by arbitrarily combining their equivalent features. For example, a technical solution formed by replacing the foregoing features with technical features disclosed in the present application (but not limited to) with similar functions.

Claims

权 利 要 求 书 Claim
1、 一种任务执行的调控方法, 其特征在于, 所述方法包括: 1. A method for regulating task execution, characterized in that the method includes:
获取用于工作任务并发执行的工作线程的数量;  Get the number of worker threads used for concurrent execution of work tasks;
基于所述用于工作任务并发执行的工作线程的数量和预先创建的工作线程 的条件变量, 确定用于工作任务并发执行的工作线程。  Based on the number of the worker threads for concurrent execution of the work task and condition variables of the worker threads created in advance, a worker thread for the concurrent execution of the work task is determined.
2、根据权利要求 1所述的方法, 其特征在于, 所述基于所述用于工作任务 并发执行的工作线程的数量和预先创建的工作线程的条件变量, 确定用于工作 任务并发执行的工作线程, 包括:  2. The method according to claim 1, wherein, based on the number of the worker threads for concurrent execution of the work task and condition variables of the worker threads created in advance, determining the work for concurrent execution of the work task Threads, including:
如果所述用于工作任务并发执行的工作线程的数量小于预先创建的工作线 程的数量, 则检测所述预先创建的工作线程的工作状态, 并通过所述预先创建 的工作线程的工作变量, 调整所述预先创建的工作线程的工作状态, 以确定用 于工作任务并发执行的工作线程。  If the number of the worker threads used for concurrent execution of the work task is less than the number of pre-created worker threads, detecting the work state of the pre-created worker thread, and adjusting it through the work variables of the pre-created worker thread A working state of the pre-created worker thread to determine a worker thread for concurrent execution of a worker task.
3、根据权利要求 2所述的方法, 其特征在于, 所述通过所述预先创建的工 作线程的工作变量, 调整所述预先创建的工作线程的工作状态, 以确定用于工 作任务并发执行的工作线程, 包括:  3. The method according to claim 2, characterized in that, by using a working variable of the pre-created worker thread, adjusting a work state of the pre-created worker thread to determine a concurrent execution of a work task. Worker threads, including:
如果所述预先创建的工作线程中的工作状态为唤醒状态的工作线程的数量 小于所述用于工作任务并发执行的工作线程的数量, 则通过所述预先创建的工 作线程的条件变量, 将所述预先创建的工作线程中的工作状态为休眠状态的工 作线程的工作状态调整为唤醒状态, 以使得所述预先创建的工作线程中的工作 状态为唤醒状态的工作线程的数量等于所述用于工作任务并发执行的工作线程 的数量, 其中, 所述工作状态包括唤醒状态和 /或休眠状态。  If the number of the worker threads in the pre-created worker thread whose working state is the awake state is less than the number of the worker threads for concurrent execution of the work task, using the condition variables of the pre-created worker thread, The work state of the pre-created worker thread whose working state is the dormant state is adjusted to the awake state, so that the number of the worker threads of the pre-created worker thread whose work state is the awake state is equal to the number of The number of worker threads concurrently executing work tasks, where the work state includes an awake state and / or a sleep state.
4、根据权利要求 2所述的方法, 其特征在于, 所述通过所述预先创建的工 作线程的工作变量, 调整所述预先创建的工作线程的工作状态, 以确定用于工 作任务并发执行的工作线程, 包括:  4. The method according to claim 2, characterized in that, by using a working variable of the pre-created worker thread, adjusting a working state of the pre-created worker thread to determine a concurrent execution of a work task. Worker threads, including:
如果所述预先创建的工作线程中的工作状态为唤醒状态的工作线程的数量 大于所述用于工作任务并发执行的工作线程的数量, 则通过所述预先创建的工 作线程的条件变量, 将所述预先创建的工作线程中的工作状态为唤醒状态的工 作线程的工作状态调整为休眠状态, 以使得所述预先创建的工作线程中的工作 状态为唤醒状态的工作线程的数量等于所述用于工作任务并发执行的工作线程 的数量, 其中, 所述工作状态包括唤醒状态和 /或休眠状态。  If the number of worker threads in which the working state in the pre-created worker thread is the awake state is greater than the number of worker threads for concurrent execution of the work task, using the condition variables of the pre-created worker thread, The work state of the pre-created worker thread whose work state is the awake state is adjusted to the sleep state, so that the number of the worker threads of the pre-created worker thread whose work state is the awake state is equal to the The number of worker threads concurrently executing work tasks, where the work state includes an awake state and / or a sleep state.
5、根据权利要求 1所述的方法, 其特征在于, 所述基于所述用于工作任务 并发执行的工作线程的数量和预先创建的工作线程的条件变量, 确定用于工作 任务并发执行的工作线程, 包括: 5. The method according to claim 1, characterized in that, based on said for the work task The number of concurrently executed worker threads and condition variables of the previously created worker threads to determine the worker threads for concurrent execution of work tasks include:
如果所述用于工作任务并发执行的工作线程的数量等于预先创建的工作线 程的数量, 则检测所述预先创建的工作线程的工作状态, 并通过所述预先创建 的工作线程的工作变量, 调整所述预先创建的工作线程的工作状态, 以确定用 于工作任务并发执行的工作线程。  If the number of the worker threads used for concurrent execution of the work task is equal to the number of the pre-created worker threads, detecting the work state of the pre-created worker threads, and adjusting through the work variables of the pre-created worker threads A working state of the pre-created worker thread to determine a worker thread for concurrent execution of a worker task.
6、根据权利要求 5所述的方法, 其特征在于, 所述通过所述预先创建的工 作线程的工作变量, 调整所述预先创建的工作线程的工作状态, 以确定用于工 作任务并发执行的工作线程, 包括:  6. The method according to claim 5, characterized in that, by using a working variable of the pre-created worker thread, adjusting a working state of the pre-created worker thread to determine a concurrent execution of a work task. Worker threads, including:
如果所述预先创建的工作线程中的工作状态为唤醒状态的工作线程的数量 小于所述用于工作任务并发执行的工作线程的数量, 则通过所述预先创建的工 作线程的条件变量, 将所述预先创建的工作线程中的工作状态为休眠状态的工 作线程的工作状态调整为唤醒状态, 以使得所述预先创建的工作线程的工作状 态均为唤醒状态, 其中, 所述工作状态包括唤醒状态和 /或休眠状态。  If the number of the worker threads in the pre-created worker thread whose working state is the awake state is less than the number of the worker threads for concurrent execution of the work task, using the condition variables of the pre-created worker thread, The work state of the pre-created worker thread whose working state is the dormant state is adjusted to the awake state, so that the work states of the pre-created worker thread are all awake states, wherein the work state includes the awake state. And / or hibernation.
7、根据权利要求 1所述的方法, 其特征在于, 所述基于所述用于工作任务 并发执行的工作线程的数量和预先创建的工作线程的条件变量, 确定用于工作 任务并发执行的工作线程, 包括:  7. The method according to claim 1, wherein, based on the number of the worker threads for concurrent execution of the work task and condition variables of the worker threads created in advance, determining the work for concurrent execution of the work task Threads, including:
如果所述用于工作任务并发执行的工作线程的数量大于预先创建的工作线 程的数量, 则创建新的工作线程, 以使得所述预先创建的工作线程的数量与所 述新的工作线程的数量的和等于所述用于工作任务并发执行的工作线程的数量。  If the number of the worker threads for concurrent execution of the work task is greater than the number of pre-created worker threads, creating a new worker thread so that the number of the pre-created worker threads and the number of the new worker threads The sum is equal to the number of the worker threads for concurrent execution of the work task.
8、 根据权利要求 7所述的方法, 其特征在于, 所述方法还包括:  8. The method according to claim 7, further comprising:
通过所述预先创建的工作线程和所述新的工作线程的条件变量, 将所述预 先创建的工作线程与所述新的工作线程的工作状态均调整为唤醒状态。  By using the pre-created worker thread and the condition variables of the new worker thread, the work states of the pre-created worker thread and the new worker thread are adjusted to the awake state.
9、根据权利要求 3所述的方法, 其特征在于, 所述通过所述预先创建的工 作线程的条件变量, 将所述预先创建的工作线程中的工作状态为休眠状态的工 作线程的工作状态调整为唤醒状态, 包括:  9. The method according to claim 3, wherein the working state of the pre-created worker thread is the working state of the worker thread through the condition variables of the pre-created worker thread. Adjusted to awake state, including:
通过所述预先创建的工作线程中的工作状态为休眠状态的工作线程的条件 变量在同步语句块中调用通知函数, 将所述预先创建的工作线程中的工作状态 为休眠状态的工作线程的工作状态调整为唤醒状态。  A notification function is called in a synchronization statement block by using a condition variable of a worker thread whose working state is in a sleep state in the pre-created worker thread, and the work of the worker thread in which the working state in the pre-created worker thread is in a sleep state The state is adjusted to the awake state.
10、 根据权利要求 4所述的方法, 其特征在于, 所述通过所述预先创建的 工作线程的条件变量, 将所述预先创建的工作线程中的工作状态为唤醒状态的 工作线程的工作状态调整为休眠状态, 包括: 通过所述预先创建的工作线程中的工作状态为唤醒状态的工作线程的条件 变量在同步语句块中调用等待函数, 将所述预先创建的工作线程中的工作状态 为唤醒状态的工作线程的工作状态调整为休眠状态。 10. The method according to claim 4, characterized in that, by using the condition variables of the pre-created worker thread, the work state of the pre-created worker thread is the work state of the worker thread in the awake state. Adjusted to sleep, including: Calling a waiting function in a synchronization statement block by using a condition variable of the worker thread whose working state is the awake state in the pre-created worker thread, and The state is adjusted to the hibernation state.
11、 根据权利要求 1-10中任意一项权利要求所述的方法, 其特征在于, 所 述方法还包括:  11. The method according to any one of claims 1-10, wherein the method further comprises:
获取所述工作任务的基础信息;  Obtaining basic information of the work task;
基于所述工作任务的基础信息, 将所述工作任务存储在阻塞队列中。  Based on the basic information of the work task, the work task is stored in a blocking queue.
12、 根据权利要求 11所述的方法, 其特征在于, 所述方法还包括: 通过所述用于工作任务并发执行的工作线程, 依次从所述阻塞队列中获取 所述工作任务, 并且并发执行所述工作任务。  12. The method according to claim 11, further comprising: using the worker threads for concurrent execution of work tasks, sequentially obtaining the work tasks from the blocking queue, and executing the work tasks concurrently. The work task.
13、根据权利要求 11所述的方法, 其特征在于, 所述基础信息包括工作任 务的类型和大小。  13. The method according to claim 11, wherein the basic information includes a type and a size of a work task.
14、 根据权利要求 1-13中任意一项权利要求所述的方法, 其特征在于, 所 述工作任务包括下载任务。  14. The method according to any one of claims 1-13, wherein the work task comprises a download task.
15、 一种任务执行的调控装置, 其特征在于, 所述装置包括:  15. A control device for task execution, characterized in that the device includes:
第一获取模块, 被配置为获取用于工作任务并发执行的工作线程的数量; 第一确定模块, 被配置为基于所述用于工作任务并发执行的工作线程的数 量和预先创建的工作线程的条件变量,确定用于工作任务并发执行的工作线程。  A first acquisition module configured to acquire the number of worker threads for concurrent execution of work tasks; a first determination module configured to be based on the number of worker threads for concurrent execution of work tasks and a pre-created number of worker threads Condition variable, which determines the worker thread used for concurrent execution of the work task.
16、根据权利要求 15所述的装置,其特征在于,所述第一确定模块,包括: 第二确定模块, 被配置为如果所述用于工作任务并发执行的工作线程的数 量小于预先创建的工作线程的数量, 则检测所述预先创建的工作线程的工作状 态, 并通过所述预先创建的工作线程的工作变量, 调整所述预先创建的工作线 程的工作状态, 以确定用于工作任务并发执行的工作线程。  16. The apparatus according to claim 15, wherein the first determining module comprises: a second determining module configured to, if the number of the worker threads for concurrent execution of the work task is less than a pre-created The number of worker threads, then detecting the work state of the pre-created worker thread, and adjusting the work state of the pre-created worker thread through the work variable of the pre-created worker thread to determine the concurrent use of the work task Executed worker thread.
17、根据权利要求 16所述的装置,其特征在于,所述第二确定模块,包括: 第一调整模块, 被配置为如果所述预先创建的工作线程中的工作状态为唤 醒状态的工作线程的数量小于所述用于工作任务并发执行的工作线程的数量, 则通过所述预先创建的工作线程的条件变量, 将所述预先创建的工作线程中的 工作状态为休眠状态的工作线程的工作状态调整为唤醒状态, 以使得所述预先 创建的工作线程中的工作状态为唤醒状态的工作线程的数量等于所述用于工作 任务并发执行的工作线程的数量, 其中, 所述工作状态包括唤醒状态和 /或休眠 状态。  17. The apparatus according to claim 16, wherein the second determination module comprises: a first adjustment module configured to work threads that are in a wake-up state if a work state in the pre-created worker thread is an awake state. If the number of worker threads is smaller than the number of worker threads used for concurrent execution of work tasks, the condition of the pre-created worker thread is used to change the work status of the pre-created worker thread to the sleep state of the worker thread. The state is adjusted to the awake state, so that the number of the worker threads whose work state is the awake state in the pre-created worker threads is equal to the number of the worker threads for concurrent execution of the work task, where the work state includes awake Status and / or hibernation.
18、 根据权利要求 16所述的装置, 其特征在于, 所述第二确定模块, 还包 括: 18. The device according to claim 16, wherein the second determining module further comprises: Include:
第二调整模块, 被配置为如果所述预先创建的工作线程中的工作状态为唤 醒状态的工作线程的数量大于所述用于工作任务并发执行的工作线程的数量, 则通过所述预先创建的工作线程的条件变量, 将所述预先创建的工作线程中的 工作状态为唤醒状态的工作线程的工作状态调整为休眠状态, 以使得所述预先 创建的工作线程中的工作状态为唤醒状态的工作线程的数量等于所述用于工作 任务并发执行的工作线程的数量, 其中, 所述工作状态包括唤醒状态和 /或休眠 状态。  The second adjustment module is configured to pass the pre-created worker thread if the number of the worker threads whose working state is awake state is greater than the number of the worker threads for concurrent execution of the work task. A condition variable of the worker thread, adjusting the work state of the worker thread in which the work state in the pre-created worker thread is awake state to a sleep state, so that the work state in the pre-created worker thread is a work in awake state The number of threads is equal to the number of the worker threads for concurrent execution of the work task, wherein the work state includes an awake state and / or a sleep state.
19、 根据权利要求 15所述的装置, 其特征在于, 所述第一确定模块, 还包 括:  19. The apparatus according to claim 15, wherein the first determining module further comprises:
第三确定模块, 被配置为如果所述用于工作任务并发执行的工作线程的数 量等于预先创建的工作线程的数量, 则检测所述预先创建的工作线程的工作状 态, 并通过所述预先创建的工作线程的工作变量, 调整所述预先创建的工作线 程的工作状态, 以确定用于工作任务并发执行的工作线程。  A third determining module is configured to detect the working state of the pre-created worker thread if the number of the worker threads for concurrent execution of the work task is equal to the number of the pre-created worker thread, and pass the pre-created And adjusting a working state of the pre-created worker thread to determine a worker thread for concurrent execution of a worker task.
20、根据权利要求 19所述的装置,其特征在于,所述第三确定模块,包括: 第三调整模块, 被配置为如果所述预先创建的工作线程中的工作状态为唤 醒状态的工作线程的数量小于所述用于工作任务并发执行的工作线程的数量, 则通过所述预先创建的工作线程的条件变量, 将所述预先创建的工作线程中的 工作状态为休眠状态的工作线程的工作状态调整为唤醒状态, 以使得所述预先 创建的工作线程的工作状态均为唤醒状态, 其中, 所述工作状态包括唤醒状态 和 /或休眠状态。  20. The apparatus according to claim 19, wherein the third determining module comprises: a third adjusting module configured to work threads that are in a wake-up state if a working state in the pre-created working thread is a wake-up state. If the number of worker threads is smaller than the number of worker threads used for concurrent execution of work tasks, the condition of the pre-created worker thread is used to change the work status of the pre-created worker thread to the sleep state of the worker thread. The state is adjusted to the awake state, so that the working states of the pre-created worker threads are all awake states, where the work states include the awake state and / or the hibernation state.
21、 根据权利要求 15所述的装置, 其特征在于, 所述第一确定模块, 还包 括:  21. The device according to claim 15, wherein the first determining module further comprises:
创建模块, 被配置为如果所述用于工作任务并发执行的工作线程的数量大 于预先创建的工作线程的数量, 则创建新的工作线程, 以使得所述预先创建的 工作线程的数量与所述新的工作线程的数量的和等于所述用于工作任务并发执 行的工作线程的数量。  A creation module configured to create a new worker thread if the number of worker threads for concurrent execution of a work task is greater than the number of previously created worker threads, so that the number of the previously created worker threads is equal to the number of the previously created worker threads The sum of the number of new worker threads is equal to the number of worker threads for concurrent execution of the worker task.
22、 根据权利要求 21所述的装置, 其特征在于, 所述第一确定模块, 还包 括:  22. The apparatus according to claim 21, wherein the first determining module further comprises:
第四调整模块, 被配置为通过所述预先创建的工作线程和所述新的工作线 程的条件变量, 将所述预先创建的工作线程与所述新的工作线程的工作状态均 调整为唤醒状态。 A fourth adjustment module is configured to adjust the working states of the pre-created worker thread and the new worker thread to a wake-up state through the pre-created worker thread and condition variables of the new worker thread. .
23、根据权利要求 17所述的装置,其特征在于,所述第一调整模块,包括: 第五调整模块, 被配置为通过所述预先创建的工作线程中的工作状态为休 眠状态的工作线程的条件变量在同步语句块中调用通知函数, 将所述预先创建 的工作线程中的工作状态为休眠状态的工作线程的工作状态调整为唤醒状态。 23. The apparatus according to claim 17, wherein the first adjustment module comprises: a fifth adjustment module configured to pass a work thread in a pre-created work thread into a sleep state through a worker thread The notification function is called in the synchronization statement block to adjust the work state of the worker thread in the pre-created worker thread to the sleep state to the awake state.
24、根据权利要求 18所述的装置,其特征在于,所述第二调整模块,包括: 第六调整模块, 被配置为通过所述预先创建的工作线程中的工作状态为唤 醒状态的工作线程的条件变量在同步语句块中调用等待函数, 将所述预先创建 的工作线程中的工作状态为唤醒状态的工作线程的工作状态调整为休眠状态。  24. The device according to claim 18, wherein the second adjustment module comprises: a sixth adjustment module configured to pass a worker thread whose work state is awake state through the pre-created worker thread. The condition variable of the call the waiting function in the synchronization statement block, and adjusts the work state of the worker thread whose work state is the awake state to the sleep state.
25、 根据权利要求 15-24中任意一项权利要求所述的装置, 其特征在于, 所述装置还包括:  25. The device according to any one of claims 15-24, wherein the device further comprises:
第二获取模块, 被配置为获取所述工作任务的基础信息;  A second acquisition module configured to acquire basic information of the work task;
存储模块, 被配置为基于所述工作任务的基础信息, 将所述工作任务存储 在阻塞队列中。  The storage module is configured to store the work task in a blocking queue based on the basic information of the work task.
26、 根据权利要求 25所述的装置, 其特征在于, 所述装置还包括: 第三获取模块, 被配置为通过所述用于工作任务并发执行的工作线程, 依 次从所述阻塞队列中获取所述工作任务, 并且并发执行所述工作任务。  26. The device according to claim 25, further comprising: a third obtaining module configured to obtain sequentially from the blocking queue through the worker threads for concurrent execution of work tasks. The work tasks, and the work tasks are performed concurrently.
27、根据权利要求 25所述的装置, 其特征在于, 所述基础信息包括工作任 务的类型和大小。  27. The apparatus according to claim 25, wherein the basic information includes a type and a size of a work task.
28、 根据权利要求 15-27中任意一项权利要求所述的装置, 其特征在于, 所述工作任务包括下载任务。  28. The device according to any one of claims 15-27, wherein the work task comprises a download task.
29、 一种设备 /终端 /服务器, 包括:  29. A device / terminal / server including:
一个或多个处理器;  One or more processors;
存储装置, 配置为存储一个或多个程序;  A storage device configured to store one or more programs;
当所述一个或多个程序被所述一个或多个处理器执行, 使得所述一个或多 个处理器实现如权利要求 1-14 中任意一项权利要求所述的任务执行的调控方 法。  When the one or more programs are executed by the one or more processors, the one or more processors enable the one or more processors to implement the method for controlling task execution according to any one of claims 1-14.
30、 一种计算机可读存储介质, 其上存储有计算机程序, 该程序被处 理器执行时实现如权利要求 1 - 14 中任意一项权利要求所述的任务执行的 调控方法。  30. A computer-readable storage medium having stored thereon a computer program that, when executed by a processor, implements a method for controlling the execution of a task according to any one of claims 1-14.
PCT/IB2018/056492 2018-08-02 2018-08-27 Task execution control method, device, equipment/terminal/server and storage medium WO2020026010A2 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810869318.1 2018-08-02
CN201810869318.1A CN109189483A (en) 2018-08-02 2018-08-02 Regulation method, apparatus, equipment/terminal/server and the storage medium of task execution

Publications (2)

Publication Number Publication Date
WO2020026010A2 true WO2020026010A2 (en) 2020-02-06
WO2020026010A3 WO2020026010A3 (en) 2020-03-05

Family

ID=64920505

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/IB2018/056492 WO2020026010A2 (en) 2018-08-02 2018-08-27 Task execution control method, device, equipment/terminal/server and storage medium

Country Status (2)

Country Link
CN (1) CN109189483A (en)
WO (1) WO2020026010A2 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024051270A1 (en) * 2023-05-08 2024-03-14 之江实验室 Task execution method, apparatus, storage medium, and electronic device

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111611066A (en) * 2020-06-30 2020-09-01 平安银行股份有限公司 Task execution method, task execution server, and storage medium
CN112559160B (en) * 2021-02-19 2021-06-04 智道网联科技(北京)有限公司 Map engine multithread control method and device

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8209701B1 (en) * 2007-09-27 2012-06-26 Emc Corporation Task management using multiple processing threads
US9563474B2 (en) * 2013-06-13 2017-02-07 Wipro Limited Methods for managing threads within an application and devices thereof
CN104156261A (en) * 2014-08-11 2014-11-19 浪潮(北京)电子信息产业有限公司 Method and device for processing tasks among multiple controllers
CN106257425B (en) * 2016-07-20 2019-04-09 东南大学 A kind of Java concurrent program path method for decomposing based on con current control flow graph
CN106547612B (en) * 2016-10-18 2020-10-20 深圳怡化电脑股份有限公司 Multitasking method and device
CN106790525A (en) * 2016-12-20 2017-05-31 广东小天才科技有限公司 A kind of document down loading method and device
CN107463439A (en) * 2017-08-21 2017-12-12 山东浪潮通软信息科技有限公司 A kind of thread pool implementation method and device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024051270A1 (en) * 2023-05-08 2024-03-14 之江实验室 Task execution method, apparatus, storage medium, and electronic device

Also Published As

Publication number Publication date
CN109189483A (en) 2019-01-11
WO2020026010A3 (en) 2020-03-05

Similar Documents

Publication Publication Date Title
US20190155656A1 (en) Method and system for scheduling threads for execution
US9135080B2 (en) Dynamically assigning a portion of physical computing resource to logical partitions based on characteristics of executing logical partitions
US9396028B2 (en) Scheduling workloads and making provision decisions of computer resources in a computing environment
US10552213B2 (en) Thread pool and task queuing method and system
US10402223B1 (en) Scheduling hardware resources for offloading functions in a heterogeneous computing system
US20160350245A1 (en) Workload batch submission mechanism for graphics processing unit
US20140259018A1 (en) Backoff Job Queue Polling Mechanism
WO2020026010A2 (en) Task execution control method, device, equipment/terminal/server and storage medium
US9372725B2 (en) Dynamically adjusting wait periods according to system performance
US9942272B2 (en) Handling out of order events
US9983907B2 (en) Resource-aware backfill job scheduling
US9471387B2 (en) Scheduling in job execution
US9513661B2 (en) Calibrated timeout interval on a configuration value, shared timer value, and shared calibration factor
US9229716B2 (en) Time-based task priority boost management using boost register values
US11061730B2 (en) Efficient scheduling for hyper-threaded CPUs using memory monitoring
US20170161114A1 (en) Method and apparatus for time-based scheduling of tasks
US11941722B2 (en) Kernel optimization and delayed execution
TW201421420A (en) Graphic processing unit virtual apparatus, graphic processing unit host apparatus, and graphic processing unit program processing methods thereof
US20240233066A1 (en) Kernel optimization and delayed execution
US11922533B2 (en) Dynamically reducing latency in processing pipelines
US8484235B2 (en) Dynamically switching the serialization method of a data structure
CN118132001A (en) Data processing method, data processing system, chip, device and medium
CN115705245A (en) Resource allocation method, device, electronic equipment and storage medium
CN117539598A (en) Task processing method and device, electronic equipment and storage medium
CN115826857A (en) NVMe instruction processing method, device, equipment and medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18928282

Country of ref document: EP

Kind code of ref document: A2

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18928282

Country of ref document: EP

Kind code of ref document: A2