A message task scheduling method, device and electronic device

By creating a message task queue and resource pool management in the software, the task is executed after determining that the device resources are sufficient, which solves the device freeze problem caused by silent tasks and improves user experience and memory usage efficiency.

CN111782362BActive Publication Date: 2024-09-03ZHUHAI BAOQU TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010608882.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-29
Publication Date
2024-09-03
Estimated Expiration
2040-06-29

AI Technical Summary

Technical Problem

When the software is running for a long time, silent tasks may cause excessive use of device resources, causing device freezes and affecting user experience.

Method used

By placing the tasks to be executed into the message task queue, receiving task execution instructions, and executing the tasks only when it is determined that the device resources are sufficient, the thread pool and memory pool are used to manage resources to avoid overuse of resources.

Benefits of technology

It effectively avoids overuse of device resources, reduces memory fragmentation, and improves user experience and long-term stable operation of the software.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111782362B
    Figure CN111782362B
Patent Text Reader

Abstract

The embodiments of the present invention disclose a message task scheduling method, device and electronic device, which relate to the field of computer application technology and can prevent device resources (such as memory and CPU) from being overused by software tasks, causing the device to freeze. The message task scheduling method includes: placing the task to be executed into a created message task queue; receiving a task execution instruction; obtaining the task specified by the task execution instruction from the message task queue; judging whether the current device resources are sufficient; if the current device resources are sufficient, executing the specified task. The present invention is applicable to when the device executes software tasks, which can not only prevent the device resources from being overused, but also effectively reduce the generation of memory fragmentation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer application technology, and in particular to a message task scheduling method, device and electronic equipment. Background Art

[0002] To ensure stable operation of the device, some software installed on it needs to run for a long time, especially security software, such as Kingsoft Antivirus, 360 Security Guard, etc. During the long-term operation of these software, there may be various silent tasks, such as when the user installs a rogue software, the user needs to be reminded to interrupt the software installation; when the user clicks on the garbage cleaning task, the garbage cleaning will be executed. The execution of software tasks will consume device resources (such as memory and CPU). When these resources are consumed to a certain extent, it will affect the user's functional experience, especially the silent tasks, which will make the user feel that the device is inexplicably slow.

[0003] Therefore, there is an urgent need for a software task scheduling method to avoid excessive use of device resources and cause device freezes when device software tasks are executed. Summary of the invention

[0004] In view of this, an embodiment of the present invention provides a message task scheduling method, device and electronic device, which can prevent the device from being overused and causing the device to freeze.

[0005] In a first aspect, an embodiment of the present invention provides a message task scheduling method, comprising:

[0006] Put the tasks to be executed into the created message task queue;

[0007] Receive task execution instructions;

[0008] Obtaining the task specified by the task execution instruction from the message task queue;

[0009] Determine whether the current device resources are sufficient;

[0010] If the current device resources are sufficient, the specified task is executed.

[0011] In combination with the first aspect, in a first possible implementation manner of the first aspect, determining whether the current device has sufficient resources includes:

[0012] Determine whether the current device resource usage information exceeds a preset threshold;

[0013] If the current device resource usage information does not exceed the preset threshold, it is determined that the current device resources are sufficient; or

[0014] If the current device resource usage information exceeds the preset threshold, then after waiting for a preset period of time, it is determined again whether the current device resource usage information exceeds the preset threshold.

[0015] In combination with the first aspect or the first implementable mode of the first aspect, in a second implementable mode of the first aspect, the performing of the specified task includes:

[0016] Allocate thread resources for the specified task from a pre-set thread pool as the execution thread for this task;

[0017] In a preset memory pool, a first memory is allocated for the designated task from the memory marked as being in an unoccupied state, and the first memory is marked as being in an occupied state;

[0018] Substituting the execution parameters in the task execution instruction into the specified task through the current task execution thread, and using the first memory to execute the specified task;

[0019] After the specified task is executed, the first memory is marked as unoccupied.

[0020] In combination with the second implementable embodiment of the first aspect, in a third implementable embodiment of the first aspect, before the first memory is divided from the memory marked as unoccupied in the pre-set memory pool for the specified task and the first memory is marked as occupied, the method further includes:

[0021] Determine whether the size of the memory marked as unoccupied in the preset memory pool is not less than the memory size required by the specified task;

[0022] If the size of the memory marked as unoccupied is not less than the size of the memory required by the specified task, executing the step of allocating a first memory for the specified task from the memory marked as unoccupied;

[0023] If the memory size marked as unoccupied is smaller than the memory size required for the specified task, apply for memory of a preset size and put it into the preset memory pool, and return to execute the step of determining whether the memory size marked as unoccupied in the preset memory pool is not smaller than the memory required for the specified task.

[0024] In combination with the first possible implementation of the first aspect, in a fourth possible implementation of the first aspect, determining whether the current device resource usage information exceeds a preset threshold includes:

[0025] Get the CPU and / or memory usage of the current device through the pre-set SDK;

[0026] The SDK determines whether the acquired CPU and / or memory usage exceeds a preset threshold.

[0027] In combination with the first aspect, in a fifth possible implementation manner of the first aspect, the task execution instruction includes a task identifier and an execution parameter thereof;

[0028] The step of placing the task to be executed into the created message task queue includes:

[0029] Obtaining task information of the task to be executed; wherein the task information includes a task identifier and an interface for receiving execution parameters;

[0030] Write the acquired task information into the pre-created message task queue.

[0031] In combination with the fifth possible implementation manner of the first aspect, in a sixth possible implementation manner of the first aspect, the acquiring task information of the task to be executed includes:

[0032] The task information of the task to be executed is obtained by externally importing the task to be executed and / or reading a configuration file of the task to be executed.

[0033] In combination with the first aspect, in a seventh possible implementation manner of the first aspect, the receiving the task execution instruction includes:

[0034] Receive messages through the global message receiving interface in the pre-created hidden window;

[0035] Get the task execution instructions from the received message.

[0036] In a second aspect, an embodiment of the present invention provides a message task scheduling device, including:

[0037] The queue management module is used to put the tasks to be executed into the created message task queue;

[0038] A receiving module, used for receiving a task execution instruction;

[0039] An instruction acquisition module, used for acquiring the task specified by the task execution instruction from the message task queue;

[0040] A judgment module is used to judge whether the current device resources are sufficient;

[0041] The execution module is used to execute the specified task when the judgment result of the judgment module is yes.

[0042] In combination with the second aspect, in a first implementable manner of the second aspect, the determination module includes:

[0043] The first judgment submodule is used to judge whether the current device resource usage information exceeds a preset threshold;

[0044] The determination submodule is used to determine whether the current device resources are sufficient when the judgment result of the first judgment submodule is no; the determination submodule is also used to trigger the first judgment submodule to determine again whether the current device resource usage information exceeds the preset threshold after waiting for a preset period of time when the judgment result of the first judgment submodule is yes.

[0045] In combination with the second aspect or the first implementable embodiment of the second aspect, in a second implementable embodiment of the second aspect, the execution module includes:

[0046] The thread allocation submodule is used to allocate thread resources from a preset thread pool to the specified task as the execution thread of this task;

[0047] A memory application submodule, configured to allocate a first memory for the specified task from the memory marked as unoccupied in a preset memory pool, and mark the first memory as occupied;

[0048] An execution submodule, used for substituting the execution parameters in the task execution instruction into the specified task through the current task execution thread, and using the first memory to execute the specified task;

[0049] The identification submodule is used to mark the first memory as unoccupied after executing the specified task.

[0050] In combination with the second possible implementation of the second aspect, in a third possible implementation of the second aspect, the execution module further includes: a second judgment submodule and a capacity expansion submodule;

[0051] The second judgment submodule is used to judge whether the size of the memory marked as unoccupied in the preset memory pool is not less than the memory size required by the specified task before the memory application submodule applies for the first memory;

[0052] The memory application submodule is specifically configured to allocate a first memory for the specified task from the memory marked as unoccupied in a preset memory pool when the judgment result of the second judgment submodule is yes, and mark the first memory as occupied;

[0053] The expansion submodule is used to apply for a preset size of memory to be placed in the preset memory pool when the judgment result of the second judgment submodule is no, and trigger the second judgment module to again judge whether the size of the memory marked as unoccupied in the preset memory pool is not less than the memory required by the specified task.

[0054] In combination with the first feasible implementation of the second aspect, in a fourth feasible implementation of the second aspect, the first judgment submodule is specifically used to obtain the CPU and / or memory usage of the current device through a pre-set SDK, and to determine through the SDK whether the obtained CPU and / or memory usage exceeds a preset threshold.

[0055] In combination with the second aspect, in a fifth implementable embodiment of the second aspect, the queue management module includes:

[0056] The task information acquisition submodule is used to acquire the task information of the task to be executed; wherein the task information includes a task identifier and an interface for receiving execution parameters;

[0057] The writing submodule is used to write the acquired task information into the pre-created message task queue;

[0058] The task execution instruction received by the receiving module includes a task identifier and execution parameters thereof.

[0059] In combination with the fifth possible implementation of the second aspect, in a sixth possible implementation of the second aspect, the task information acquisition submodule obtains the task information of the task to be executed by externally importing the task to be executed and / or reading a configuration file of the task to be executed.

[0060] In combination with the second aspect, in a seventh possible implementation of the second aspect, the receiving module is specifically used to receive messages through a global message receiving interface in a pre-created hidden window, and obtain the task execution instruction from the received message.

[0061] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: a shell, a processor, a memory, a circuit board and a power supply circuit, wherein the circuit board is placed inside the space enclosed by the shell, and the processor and the memory are arranged on the circuit board; the power supply circuit is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory is used to store executable program code; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the message task scheduling method described in any of the aforementioned embodiments.

[0062] The message task scheduling method, device and electronic device provided by the embodiments of the present invention perform unified management of software tasks, especially silent tasks. Before executing a task, the device resource usage, such as CPU and memory usage, is obtained, and the task is executed only when resources are sufficient, thereby avoiding excessive use of resources and causing device freezes, thereby improving the user experience. In addition, by establishing a memory pool, software tasks apply for memory resources in the memory pool, reducing the generation of memory fragmentation, thereby improving memory utilization, and allowing the software to run stably for a long time. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0064] Figure 1 This is a flow chart of a first embodiment of a message task scheduling method of the present invention;

[0065] Figure 2 This is a flow chart of Embodiment 2 of the message task scheduling method of the present invention;

[0066] Figure 3 This is a flow chart of Embodiment 3 of the message task scheduling method of the present invention;

[0067] Figure 4 This is a structural diagram of a message task scheduling device embodiment 1 of the present invention;

[0068] Figure 5 This is a structural diagram of Embodiment 2 of the message task scheduling device of the present invention;

[0069] Figure 6 This is a structural diagram of Embodiment 3 of the message task scheduling device of the present invention;

[0070] Figure 7 This is a structural diagram of Embodiment 4 of the message task scheduling device of the present invention;

[0071] Figure 8 This is a structural diagram of Embodiment 5 of the message task scheduling device of the present invention;

[0072] Fig. 9 The figure is a schematic structural diagram of an embodiment of an electronic device of the present invention. DETAILED DESCRIPTION

[0073] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0074] It should be clear that the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0075] Figure 1 This is a flow chart of the first embodiment of the message task scheduling method of the present invention. Figure 1 The message task scheduling method embodiment of the present invention comprises the following steps:

[0076] S101, putting the task to be executed into the created message task queue.

[0077] In this embodiment, the task information of the task to be executed can be obtained by externally importing the task to be executed and / or reading the configuration file of the task to be executed, and then the task information can be written into the message task queue. The implementation method is simple and easy.

[0078] S102: Receive a task execution instruction.

[0079] In this embodiment, as an optional manner, this step includes: receiving a message through a global message receiving interface in a pre-created hidden window; and obtaining a task execution instruction from the received message.

[0080] Windows is the most widely used operating system at present. It is a message-driven system. Windows messages provide a means for applications to communicate with each other and with the Windows system. The functions implemented by the application are triggered by messages and completed by the response and processing of messages. For example, when the user clicks the Kingsoft Internet Security junk cleaning scan, Windows will send a user click message to Kingsoft Internet Security. After receiving the message, the program can process the task.

[0081] In this step, you can use the API CreateWindow provided by the operating system to create a hidden window. After the window is created, use the system API RegisterWindowMessage to register the message and add the message response logic. This allows external calls to only require sending a broadcast message and passing the task ID and execution parameters.

[0082] S103: Acquire the task specified by the task execution instruction from the message task queue.

[0083] In this embodiment, a task execution instruction is received through a hidden window. The instruction must include a task identifier and its execution parameters. According to the task identifier, the task to be executed can be obtained from the message task queue.

[0084] S104: Determine whether the current device resources are sufficient, if yes, execute step S105.

[0085] In this embodiment, before executing the specified task, it is determined whether the current device resources are sufficient, such as whether there is enough remaining device memory resources and CPU computing resources. If so, the specified task is executed. This avoids the problem of device lag due to excessive use of resources and prevents the user experience from being affected.

[0086] S105: Execute the specified task.

[0087] The message task scheduling method provided in the embodiment of the present invention uniformly manages software tasks, especially silent tasks. Before executing a task, it obtains the device resource usage, such as CPU and memory usage, and executes the task only when resources are sufficient, thereby avoiding excessive use of resources and causing device freezes, thereby improving the user experience.

[0088] Figure 2 This is a flow chart of the second embodiment of the message task scheduling method of the present invention. Figure 2 The message task scheduling method embodiment of the present invention comprises the following steps:

[0089] S201, putting the task to be executed into the created message task queue.

[0090] In this embodiment, this step is similar to step S101 in the above method embodiment and will not be described again here.

[0091] S202: Receive a task execution instruction.

[0092] In this embodiment, this step is similar to step S102 in the above method embodiment and will not be described again here.

[0093] S203: Acquire the task specified by the task execution instruction from the message task queue.

[0094] In this embodiment, this step is similar to step S103 in the above method embodiment and will not be described again here.

[0095] S204: Determine whether the current device resource usage information exceeds a preset threshold, if yes, execute step S206, otherwise execute step S205.

[0096] In this embodiment, whether the current device resources are sufficient only needs to be determined by judging whether the current device resource usage information exceeds the preset threshold value, and this method is relatively simple to implement. For example, if the CPU usage rate of the current device is 70%, and the memory usage rate is 70%, if the preset threshold CPU is 65%, and the memory usage rate is 80%, then although the current device memory usage rate is less than the preset threshold value of 80%, because the current CPU usage rate exceeds the preset threshold value of 65%, it is judged that the current device resource usage information exceeds the preset threshold value, and the specified task cannot be executed.

[0097] In this embodiment, as an optional method, this step S204 includes: obtaining the CPU and / or memory usage of the current device through a preset SDK; judging whether the obtained CPU and / or memory usage exceeds a preset threshold through the SDK. The CPU and / or memory usage of the device is the best indicator of the device's operating status. The logic for obtaining the CPU and / or memory usage and the judgment can be encapsulated into an SDK for easy calling, which can effectively save development time.

[0098] S205: Determine whether the current device resources are sufficient, and execute step S207.

[0099] S206: Wait for a preset time period and return to execute step S204.

[0100] In this embodiment, since the current device is executing other tasks, a large amount of resources are occupied. However, tasks are generally temporary. Once the execution is completed, the occupied resources will be released. At this time, it is necessary to wait for a preset time, such as 5 seconds, and return to continue to judge the device resource usage, thereby ensuring that the task is executed.

[0101] S207: Execute the specified task.

[0102] The message task scheduling method provided in the embodiment of the present invention, on the one hand, ensures that tasks are executed only when resources are sufficient, thereby avoiding excessive use of resources and causing device freezes; at the same time, by continuously obtaining device resource usage information, it ensures that all tasks can be executed when device resources are sufficient.

[0103] Figure 3 This is a flow chart of the third embodiment of the message task scheduling method of the present invention. Figure 3 The message task scheduling method embodiment of the present invention comprises the following steps:

[0104] S301, putting the task to be executed into the created message task queue.

[0105] In this embodiment, this step is similar to step S201 in the above method embodiment and will not be described again here.

[0106] S302: Receive a task execution instruction.

[0107] In this embodiment, this step is similar to step S202 in the above method embodiment and will not be described again here.

[0108] S303: Acquire the task specified by the task execution instruction from the message task queue.

[0109] In this embodiment, this step is similar to step S203 in the above method embodiment and will not be described again here.

[0110] S304: Determine whether the current device resource usage information exceeds a preset threshold, if yes, execute step S306, otherwise execute step S305.

[0111] In this embodiment, this step is similar to step S204 in the above method embodiment and will not be described again here.

[0112] S305: Determine whether the current device resources are sufficient, and execute step S307.

[0113] In this embodiment, this step is similar to step S205 in the above method embodiment and will not be described again here.

[0114] S306: Wait for a preset time period and return to execute S304.

[0115] In this embodiment, this step is similar to step S206 in the above method embodiment and will not be described again here.

[0116] S307: Allocate thread resources from a preset thread pool to the designated task as the execution thread for this task.

[0117] In this embodiment, the software may have multiple tasks to execute at the same time. For example, Kingsoft Antivirus may need to execute multiple tasks such as full disk scanning, garbage cleaning, and interruption of rogue software installation at the same time. To ensure that multiple tasks can be executed at the same time, the present invention proposes to establish a thread pool. When a task needs to be executed, thread resources can be allocated from the thread pool as the execution thread of this task, so that tasks can be executed asynchronously, ensuring that multiple tasks can be executed at the same time.

[0118] S308: In a preset memory pool, allocate a first memory for the designated task from the memory marked as being in an unoccupied state, and mark the first memory as being in an occupied state.

[0119] In this embodiment, in order to reduce the memory fragmentation caused by the application and release of memory during the task execution process, a memory pool resource is established. Among them, the reason for the generation of this memory fragmentation is that the frequent allocation and recovery of physical pages will cause a large number of continuous and small page blocks to be mixed in the middle of the allocated pages, which will generate memory fragmentation. Suppose there is a continuous free memory space with a total of 100 units, ranging from 0-99. If you apply for a piece of memory from it, such as 10 units, then the memory block applied for is in the range of 0-9. At this time, continue to apply for a piece of memory, for example, 5 units large, and the second memory block obtained should be in the range of 10-14. If you release the first memory block, and then apply for a memory block larger than 10 units, for example, 20 units. Because the memory block that has just been released cannot meet the new request, only 20 units of memory blocks can be allocated starting from 15. Now the status of the entire memory space is 0-9 free, 10-14 and 15-34 are occupied, and 35-99 free. Among them, 0-9 is a memory fragment. If 10-14 is always occupied, and the space requested in the future is larger than 10 units, then 0-9 will never be used and memory will become fragmented.

[0120] After adopting memory pool to manage memory, suppose there is a continuous free memory space with a total of 100 units as the memory pool, ranging from 0 to 99. If you apply for a piece of memory from it, such as 10 units, then the memory block applied for will be in the range of 0 to 9. At this time, if you continue to apply for memory resources, for example, 5 units in size, the second memory block obtained should be in the range of 10 to 14. If you release the first memory block, and then apply for a memory block larger than 10 units, such as 20 units, because the memory in the range of 0 to 9 is not occupied, you can allocate the ranges of 0 to 9 and 15 to 24, thus avoiding the generation of memory fragmentation.

[0121] In this embodiment, as an optional method, before step S308, it also includes: judging whether the memory size marked as unoccupied in the pre-set memory pool is not less than the memory size required for the specified task; if the memory size marked as unoccupied is not less than the memory size required for the specified task, executing step S308; otherwise, applying for memory of a preset size to be placed in the pre-set memory pool, and returning to execute the step of judging whether the memory size marked as unoccupied in the pre-set memory pool is not less than the memory required for the specified task.

[0122] After the program is started, you can apply for the default size of memory (this size needs to be determined according to the actual situation, and it can be expanded if it is not enough, but it cannot be infinite). For example, the default size is 1M. When Kingsoft Antivirus starts to clean up the garbage, it needs to read the rule base. The memory size is 400K, then 400K of 1M can be used directly, and the memory pool will mark the used 400K as occupied (marked in the code); then the user checks and kills again, and needs 2M. If it is found that the remaining is not enough, the memory pool can be expanded and used. After the garbage cleaning is completed, the used 400K is marked as unoccupied by the memory, and can be directly used by other tasks and logic next time.

[0123] S309: Substitute the execution parameters in the task execution instruction into the specified task through the current task execution thread, and use the first memory to execute the specified task.

[0124] S310: After executing the specified task, mark the first memory as unoccupied.

[0125] In this embodiment, after the task is executed, the first memory is marked as unoccupied, so that subsequent tasks can apply for memory resources, thereby improving the efficiency of memory use.

[0126] The message task scheduling method provided by the embodiment of the present invention ensures that each task can be executed asynchronously by establishing a thread pool resource; in addition, by establishing a memory pool resource, the generation of memory fragments is reduced, the memory utilization efficiency is improved, and the consumption of device memory resources is reduced.

[0127] Figure 4 This is a structural diagram of a message task scheduling device embodiment 1 of the present invention. Figure 4 , an embodiment of a message task scheduling device of the present invention comprises:

[0128] The queue management module 11 is used to put the tasks to be executed into the created message task queue;

[0129] The receiving module 12 is used to receive the task execution instruction; specifically, it is used to receive the message through the global message receiving interface in the pre-created hidden window, and obtain the task execution instruction from the received message.

[0130] An instruction acquisition module 13, used for acquiring the task specified by the task execution instruction from the message task queue;

[0131] The judging module 14 is used to judge whether the current device resources are sufficient;

[0132] The execution module 15 is used to execute the specified task when the judgment result of the judgment module 14 is yes.

[0133] Figure 5 This is a structural diagram of Embodiment 2 of the message task scheduling device of the present invention. Figure 5 This embodiment is based on the structure of the first embodiment of the message task scheduling device, and the judgment module 14 includes:

[0134] The first judgment submodule 141 is used to judge whether the current device resource usage information exceeds a preset threshold; specifically, it is used to obtain the CPU and / or memory usage of the current device through a preset SDK, and judge through the SDK whether the obtained CPU and / or memory usage exceeds the preset threshold.

[0135] The determination submodule 142 is used to determine whether the current device resources are sufficient when the judgment result of the first judgment submodule is no; the determination submodule 142 is also used to trigger the first judgment submodule 141 to determine again whether the current device resource usage information exceeds the preset threshold after waiting for a preset period of time when the judgment result of the first judgment submodule 141 is yes.

[0136] Figure 6 This is a structural diagram of Embodiment 3 of the message task scheduling device of the present invention. Figure 6 This embodiment is based on the structure of the second embodiment of the message task scheduling device, and the execution module 15 includes:

[0137] The thread allocation submodule 151 is used to allocate thread resources from a preset thread pool to the specified task as the execution thread of this task;

[0138] The memory application submodule 152 is used to allocate a first memory for the specified task from the memory marked as unoccupied in a preset memory pool, and mark the first memory as occupied;

[0139] An execution submodule 153, configured to substitute the execution parameters in the task execution instruction into the specified task through the current task execution thread, and use the first memory to execute the specified task;

[0140] The identification submodule 154 is used to identify the first memory as being unoccupied after the specified task is executed.

[0141] Figure 7 This is a structural diagram of a fourth embodiment of a message task scheduling device of the present invention. Figure 7 , this embodiment is based on the structure of the aforementioned message task scheduling device embodiment 3, the execution module 15 also includes: a second judgment submodule 155 and an expansion submodule 156;

[0142] The second judgment submodule 155 is used to judge whether the size of the memory marked as unoccupied in the preset memory pool is not less than the memory size required by the specified task before the memory application submodule 152 applies for the first memory;

[0143] The memory application submodule 152 is specifically configured to allocate a first memory for the specified task from the memory marked as unoccupied in a preset memory pool when the judgment result of the second judgment submodule 155 is yes, and mark the first memory as occupied;

[0144] The expansion submodule 156 is used to apply for a preset size of memory to be placed in the preset memory pool when the judgment result of the second judgment submodule 155 is no, and trigger the second judgment module 155 to again judge whether the size of the memory marked as unoccupied in the preset memory pool is not less than the memory required for the specified task.

[0145] Figure 8 This is a structural diagram of a fourth embodiment of a message task scheduling device of the present invention. Figure 8 This embodiment is based on the structure of the above-mentioned message task scheduling device embodiment 1, and the queue management module 11 includes:

[0146] The task information acquisition submodule 111 is used to acquire the task information of the task to be executed; wherein the task information includes a task identifier and an interface for receiving execution parameters; specifically, the task information of the task to be executed is acquired by externally importing the task to be executed and / or reading a configuration file of the task to be executed;

[0147] The writing submodule 112 is used to write the acquired task information into a pre-created message task queue;

[0148] The task execution instruction received by the receiving module includes a task identifier and execution parameters thereof.

[0149] An embodiment of the present invention further provides an electronic device. Fig. 9 This is a schematic diagram of the structure of an embodiment of the electronic device of the present invention, which can implement the present invention Figure 1 , Figure 2 or Figure 3 The process of the embodiment shown is as follows: Fig. 9As shown, the above-mentioned electronic device may include: a shell 41, a processor 42, a memory 43, a circuit board 44 and a power supply circuit 45, wherein the circuit board 44 is arranged inside the space enclosed by the shell 41, and the processor 42 and the memory 43 are arranged on the circuit board 44; the power supply circuit 45 is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory 43 is used to store executable program codes; the processor 42 runs the program corresponding to the executable program code by reading the executable program code stored in the memory 43, so as to execute the message task scheduling method described in any of the above-mentioned embodiments.

[0150] This electronic device exists in many forms, including but not limited to:

[0151] (1) Mobile communication devices: These devices are characterized by having mobile communication functions and their main purpose is to provide voice and data communications. These terminals include: smart phones (such as iPhone), multimedia phones, functional phones, and low-end phones.

[0152] (2) Ultra-mobile personal computer devices: These devices fall into the category of personal computers, have computing and processing capabilities, and generally also have mobile Internet access features. These terminals include: PDA, MID and UMPC devices, such as iPad.

[0153] (3) Portable entertainment devices: These devices can display and play multimedia content. They include audio and video playback modules (such as iPods), handheld game consoles, e-books, smart toys, and portable car navigation devices.

[0154] (4) Server: A device that provides computing services. The server consists of a processor, hard disk, memory, system bus, etc. The server is similar to a general computer architecture, but because it needs to provide highly reliable services, it has higher requirements in terms of processing power, stability, reliability, security, scalability, and manageability.

[0155] (5) Other electronic devices with data interaction functions.

[0156] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0157] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0158] For the convenience of description, the above device is described by being divided into various units / modules according to their functions. Of course, when implementing the present invention, the functions of each unit / module can be realized in the same or multiple software and / or hardware.

[0159] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0160] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A message task scheduling method, characterized in that: include: Put the tasks to be executed into the created message task queue; Receive task execution instructions; Obtaining the task specified by the task execution instruction from the message task queue; Determine whether the current device resources are sufficient; If the current device resources are sufficient, the specified task is executed; The determining whether the current device has sufficient resources includes: determining whether the current device resource usage information exceeds a preset threshold; if the current device resource usage information does not exceed the preset threshold, determining that the current device resources are sufficient; or if the current device resource usage information exceeds the preset threshold, waiting for a preset time and determining again whether the current device resource usage information exceeds the preset threshold; The execution of the specified task includes: allocating thread resources for the specified task from a preset thread pool as a thread for executing this task; in a preset memory pool, allocating a first memory for the specified task from a memory marked as being in an unoccupied state, and marking the first memory as being in an occupied state; substituting the execution parameters in the task execution instruction into the specified task through the thread for executing this task, and using the first memory to execute the specified task; after executing the specified task, marking the first memory as being in an unoccupied state; The method further comprises: determining whether the size of the memory marked as unoccupied in the pre-set memory pool is not less than the size of the memory required for the specified task; if the size of the memory marked as unoccupied is not less than the size of the memory required for the specified task, executing the step of allocating the first memory from the memory marked as unoccupied for the specified task; if the size of the memory marked as unoccupied is less than the size of the memory required for the specified task, applying for a memory of a preset size to be put into the pre-set memory pool, and returning to execute the step of determining whether the size of the memory marked as unoccupied in the pre-set memory pool is not less than the size of the memory required for the specified task; The determining whether the current device resource usage information exceeds a preset threshold comprises: obtaining the CPU and / or memory usage of the current device through a preset SDK; determining through the SDK whether the obtained CPU and / or memory usage exceeds a preset threshold; The task execution instruction includes a task identifier and its execution parameters; the step of placing the task to be executed into the created message task queue includes: obtaining task information of the task to be executed; wherein the task information includes a receiving interface of the task identifier and the execution parameters; and writing the obtained task information into the pre-created message task queue; The obtaining of the task information of the task to be executed includes: obtaining the task information of the task to be executed by externally importing the task to be executed and / or reading a configuration file of the task to be executed; The receiving of the task execution instruction includes: receiving a message through a global message receiving interface in a pre-created hidden window; and acquiring the task execution instruction from the received message.

2. A message task scheduling device, characterized in that: include: The queue management module is used to put the tasks to be executed into the created message task queue; A receiving module, used for receiving a task execution instruction; An instruction acquisition module, used for acquiring the task specified by the task execution instruction from the message task queue; A judgment module is used to judge whether the current device resources are sufficient; An execution module, used for executing the specified task when the judgment result of the judgment module is yes; The judgment module includes: a first judgment submodule, used to judge whether the current device resource usage information exceeds a preset threshold; a determination submodule, used to determine that the current device resources are sufficient when the judgment result of the first judgment submodule is no; the determination submodule is also used to trigger the first judgment submodule to judge again whether the current device resource usage information exceeds the preset threshold after waiting for a preset time when the judgment result of the first judgment submodule is yes; The execution module includes: a thread allocation submodule, which is used to allocate thread resources for the specified task from a preset thread pool as the execution thread of this task; a memory application submodule, which is used to allocate a first memory for the specified task from the memory marked as unoccupied in the preset memory pool, and mark the first memory as occupied; an execution submodule, which is used to substitute the execution parameters in the task execution instruction into the specified task through the current task execution thread, and use the first memory to execute the specified task; an identification submodule, which is used to mark the first memory as unoccupied after executing the specified task; The execution module further includes: a second judgment submodule and an expansion submodule; the second judgment submodule is used to judge whether the size of the memory marked as unoccupied in the pre-set memory pool is not less than the memory size required by the specified task before the memory application submodule applies for the first memory; the memory application submodule is specifically used to, when the judgment result of the second judgment submodule is yes, in the pre-set memory pool, divide the first memory for the specified task from the memory marked as unoccupied, and mark the first memory as occupied; the expansion submodule is used to apply for a preset size of memory to be put into the pre-set memory pool when the judgment result of the second judgment submodule is no, and trigger the second judgment module to judge again whether the size of the memory marked as unoccupied in the pre-set memory pool is not less than the memory required by the specified task; The first judgment submodule is specifically used to obtain the CPU and / or memory usage of the current device through a preset SDK, and to determine through the SDK whether the obtained CPU and / or memory usage exceeds a preset threshold; The queue management module includes: a task information acquisition submodule, which is used to acquire task information of the task to be executed; wherein the task information includes a task identifier and an interface for receiving execution parameters; a writing submodule, which is used to write the acquired task information into a pre-created message task queue; wherein the task execution instruction received by the receiving module includes a task identifier and its execution parameters; The task information acquisition submodule specifically acquires the task information of the task to be executed by externally importing the task to be executed and / or reading the configuration file of the task to be executed; The receiving module is specifically used to receive messages through a global message receiving interface in a pre-created hidden window, and obtain a task execution instruction from the received message.

3. An electronic device, characterized in that: The electronic device comprises: a shell, a processor, a memory, a circuit board and a power supply circuit, wherein the circuit board is placed inside the space enclosed by the shell, and the processor and the memory are arranged on the circuit board; the power supply circuit is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory is used to store executable program code; the processor runs the program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the message task scheduling method described in claim 1 above.