WO2024160136A1 - Task scheduling method and apparatus, and electronic device - Google Patents

Task scheduling method and apparatus, and electronic device Download PDF

Info

Publication number
WO2024160136A1
WO2024160136A1 PCT/CN2024/074173 CN2024074173W WO2024160136A1 WO 2024160136 A1 WO2024160136 A1 WO 2024160136A1 CN 2024074173 W CN2024074173 W CN 2024074173W WO 2024160136 A1 WO2024160136 A1 WO 2024160136A1
Authority
WO
WIPO (PCT)
Prior art keywords
task
parameter information
target identification
identification information
information
Prior art date
Application number
PCT/CN2024/074173
Other languages
French (fr)
Chinese (zh)
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 WO2024160136A1 publication Critical patent/WO2024160136A1/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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]

Definitions

  • the present application belongs to the field of communication technology, and more specifically, relates to a task scheduling method, device and electronic equipment.
  • the current system's resource scheduling strategy will give priority to the operation of the foreground application, that is, the foreground application can obtain resources first, such as giving priority to running WeChat in the foreground on the large core of the CPU and increasing its scheduling priority, while the background application will limit the acquisition of resources, such as limiting the background QQ or Thunder to run on the small core of the CPU and lowering its scheduling priority.
  • the purpose of the embodiments of the present application is to provide a task scheduling method, device and electronic device, which can solve the problem of system freeze caused by priority inversion in the related art.
  • an embodiment of the present application provides a task scheduling method, the method comprising: when a first task obtains a critical lock, obtaining parameter information of the first task; when the parameter information satisfies a preset condition, running the first task, wherein the parameter information satisfies the preset condition including: the parameter information includes target identification information.
  • an embodiment of the present application provides a task scheduling device, comprising: an acquisition module, used to acquire parameter information of the first task when the first task acquires a key lock; a control module, used to run the first task when the parameter information meets a preset condition, wherein the parameter information meets the preset condition including: the parameter information includes target identification information.
  • an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.
  • an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
  • an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.
  • an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.
  • FIG1 is a flow chart of a task scheduling method provided in an embodiment of the present application.
  • FIG2 is a schematic flow chart of an example of the present application.
  • FIG3 is a schematic flow chart of another example of the present application.
  • FIG4 is a schematic flow chart of another example of the present application.
  • FIG5 is a schematic diagram of a task scheduling device according to an embodiment of the present application.
  • FIG6 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
  • FIG. 7 is a schematic diagram of the hardware structure of an electronic device provided in another embodiment of the present application.
  • first, second, etc. in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first”, “second”, etc. are generally of one type, and the number of objects is not limited.
  • the first object can be one or more.
  • “and/or” in the specification and claims represents at least one of the connected objects, and the character “/" generally indicates that the objects associated with each other are in an "or” relationship.
  • a task scheduling method is provided in an embodiment of the present application.
  • the method includes the following steps 101 to 102 , which are described in detail below.
  • Step 101 When a first task obtains a key lock, obtain parameter information of the first task.
  • Step 102 When the parameter information meets a preset condition, execute the first task.
  • the multiple tasks are sequentially obtained in chronological order. Moreover, after any of the multiple tasks obtains the key lock, it indicates that the task enters the critical area of waiting to run or running, and the system resources corresponding to the task are occupied. Usually, the task that obtains the key lock earlier will run before the task that obtains the key lock later, so that the multiple tasks can run in the order of the time of obtaining the key lock.
  • the task can be marked by the target identification information, and the target identification information is used as one of the parameter information of the task.
  • the target identification information can be used to indicate that the corresponding task is a special task.
  • the target identification information can be a special character, and the special task that needs to be run in priority is marked by the special character.
  • the target identification information is not specifically limited here.
  • parameter information of the first task is obtained. If the target identification information is included in the parameter information, it is determined that the first task is a special task that meets the preset condition. If the target identification information is not included in the parameter information, it is determined that the first task does not meet the preset condition.
  • the first task is any one of the multiple tasks.
  • the first task is executed on the CPU, and other high-priority tasks are prohibited from executing.
  • Task 1 and Task 2 obtain the key lock in chronological order, and if neither Task 1 nor Task 2 is marked with identification information, Task 1 and Task 2 will be run in the order of the time of obtaining the key lock. If Task 2 is a special task marked with special characters, when Task 2 obtains the key lock with identification information, Task 2 will be run before Task 1.
  • the embodiment of the present application by setting a key lock, it can be ensured that only one task obtains the key lock at the same time, so that when multiple tasks are running at the same time, the multiple tasks can be run in order of the time of obtaining the key lock, thereby avoiding the problem of system congestion.
  • the first task with the target identification information can be run first, thereby shortening the waiting time for the first task to run, and avoiding the problem of system jams caused by priority inversion in the related art.
  • the embodiment of the present application also provides a method for controlling task scheduling based on the identification duration of target identification information. That is, when the parameter information includes the target identification information, the parameter information also satisfies the preset condition that: the identification duration of the target identification information is less than or equal to the preset duration.
  • a special task among them can be marked with target identification information, and the identification time of the special task marked with the target identification information can be recorded.
  • the identification time can be associated with the corresponding target identification information.
  • the parameter information of the first task is obtained, and it is first determined whether the parameter information of the first task includes the target identification information. If the parameter information of the task includes target identification information, it is determined whether the identification duration of the target identification information is less than or equal to the preset duration. If the identification duration of the target identification information is less than or equal to the preset duration, it is determined that the parameter information meets the preset condition, and other high-priority tasks are prohibited from running, and the first task is run.
  • the parameter information satisfies the preset condition and also includes: the identification duration of the target identification information is less than or equal to the preset duration, thereby avoiding the impact of long-term running of a special task on the running of other tasks, thereby affecting the running speed of the system and reducing the user experience.
  • the method further includes:
  • Step 201 if the parameter information does not satisfy the preset condition and there is a second task with a higher priority than the first task, run the second task; wherein the parameter information not satisfying the preset condition includes one of the following: the parameter information does not include the target identification information, the parameter information includes the target identification information but the identification duration of the target identification information is greater than the preset duration;
  • Step 202 After the second task exits execution, the first task is executed.
  • the target identification information when the target identification information is not included in the parameter information of the first task, or when the target identification information is included in the parameter information but the identification duration of the target identification information is greater than the preset duration, it is determined that the parameter information of the first task does not meet the preset conditions.
  • the second task is run.
  • the first task is in a waiting state. After the second task exits the run, the first task is run.
  • the time when task 2 acquires the key lock is earlier than the time when task 1 acquires the key lock, that is, the priority of task 2 is higher than the priority of task 1.
  • the parameter information of task 1 does not include the target identification information, or the parameter information of task 1 includes the target identification information but the target identification information is not specified.
  • the duration of the task is longer than the preset duration. In this case, the parameter information of task 1 does not meet the set conditions. According to the priority order, task 2 is run first, and task 1 is run after task 2 is completed and exits.
  • the second task when the parameter information of the first task does not meet the set conditions and there is a second task with a higher priority than the first task, the second task is run, and after the second task exits, the first task is run, which can avoid the problem of system freeze caused by multi-task running conflicts.
  • the embodiment of the present application also sets a condition for triggering the acquisition of the parameter information of the first task. That is, when the first task acquires the key lock, the parameter information of the first task is acquired, including:
  • Step 301 When the first task obtains a key lock and the first task occupies system resources, obtain parameter information of the first task;
  • Step 302 When the first task obtains the critical lock and the third task occupies the system resources, wait for the first task to be awakened, and when the first task is awakened, obtain parameter information of the first task; wherein the first task is awakened when the third task releases the system resources.
  • two conditions are set to trigger the acquisition of parameter information of the first task:
  • Condition 1 When the first task obtains the critical lock and the first task occupies system resources, parameter information of the first task is obtained.
  • the first task When the first task obtains the critical lock and the first task does not occupy system resources, it indicates that the first task may be blocked. At this time, whether the parameter information of the first task meets the preset conditions is not detected.
  • the first task obtains the critical lock and occupies system resources, it is necessary to determine whether the first task is a special task that meets the preset conditions, and then determine the priority order of the first task and other tasks that need to be run. That is, the parameter information of the first task is obtained to detect whether the parameter information of the first task meets the preset conditions.
  • Condition 2 The first task acquires the critical lock and the third task occupies the system resources In the case where the first task is awakened, wait for the first task to be awakened, and when the first task is awakened, obtain parameter information of the first task; wherein the first task is awakened when the third task releases the system resources.
  • the second condition is for the case where the first task obtains the critical lock and the third task occupies system resources.
  • the operation of the first task may be blocked.
  • the first task is a lock nested structure. Before running the first task, it is necessary not only to obtain the critical lock as an outer lock, but also to obtain the inner lock used to lock the system resources it allocates. After the first task obtains the critical lock, the inner lock is occupied by the third task and cannot be obtained. In this case, the operation of the first task is blocked.
  • the other tasks are run first according to the priority order, and the first task is in a sleep state waiting to be awakened.
  • the other tasks include the third task. After the third task is completed and exits the running, the internal lock is released. At this time, the first task is awakened, and the first task can obtain the internal lock, and then occupy the system resources.
  • the parameter information of the first task is obtained to detect whether the parameter information of the first task meets the preset condition.
  • the system operation speed can be improved and the system power consumption can be reduced.
  • the first task is blocked, other tasks are run first, and when the third task releases the system resources, the first task is awakened to obtain the parameter information of the first task, which can also avoid the problem that other low-priority tasks cannot be run due to the blocking of high-priority tasks, thereby improving the system operation speed.
  • the method further includes:
  • the first task releases the key lock and clears the parameter information of the first task.
  • clearing the parameter information of the first task is clearing the target identification information in the parameter information of the first task.
  • the clearing of the parameter information of the first task is to clear the target identification information and the identification duration of the target identification information in the parameter information of the first task.
  • the parameter information of the first task is cleared, thereby preventing the target identification information from affecting the normal operation of other tasks after the task with the target identification information is run.
  • the method further includes:
  • Step 401 When a setting event occurs and the parameter information of the first task includes the target identification information, obtain the identification duration of the target identification information.
  • the setting event may be an event that occurs periodically.
  • the setting event may be a Tick interrupt event.
  • the Tick interrupt is a periodic clock interrupt. In a mobile phone system, the Tick interrupt is generally 4 milliseconds each time. The Tick interrupt can periodically update the time information of the task running in the system, and then determine whether the currently running task needs to be scheduled based on the time information of the task running.
  • a timeout judgment can be made on the identification duration of a special task in the system including target identification information.
  • Step 402 When the identification duration of the target identification information is greater than the preset duration, clear the target identification information in the parameter information of the first task.
  • the identification time of the target identification information is greater than the preset time, that is, the time for running the first task is too long, the running of the first task is abnormal, and it may fall into an infinite loop.
  • the target identification information in the parameter information of the first task is cleared, and the first task is reordered according to the time when it obtains the key lock to avoid it running all the time.
  • the identification time of the target identification information is obtained; when the identification time of the target identification information is greater than the preset time, the first task is cleared.
  • the target identification information in the parameter information of the task can avoid the problem that other tasks cannot be run due to abnormal task operation, thereby improving the speed of system operation.
  • FIG. 2 is a schematic diagram of a task scheduling method according to an example of the present invention, in which a special task that cannot be preempted exists among the tasks and the special task is executed.
  • the specific steps of the task scheduling method may include:
  • Step 21 Before the first task obtains system resources, a key lock is obtained. When obtaining the key lock, the target identification information is marked for the first task, and the identification time of the first task being marked with the target identification information is recorded, and then the target identification information and the identification time of the target identification information are used as one of the parameter information of the first task.
  • Step 22 When the first task obtains the critical lock and the first task occupies system resources, obtain parameter information of the first task.
  • the first task obtains the key lock, which indicates that the first task enters the critical section of the waiting or running state, and the first task occupies the CPU. If there is a high-priority second task that needs to be run, since the first task preempts the CPU, step 23 is executed to determine the order in which the first task and the second task are run.
  • Step 23 Determine whether the parameter information of the first task includes target identification information, and whether the identification duration of the target identification information of the first task exceeds a preset duration t.
  • Step 24 If it is detected that the parameter information of the first task includes target identification information, and the identification duration of the target identification information is less than or equal to the preset duration t, the CPU is prohibited from switching to the second task, and the CPU runs the first task.
  • Step 25 If it is detected that the parameter information of the first task does not include the target identification information, or the parameter information of the first task includes the target identification information but the identification duration has exceeded the preset duration t, the second task with a higher priority is executed first.
  • Step 26 When the second task is completed, the CPU switches back to running the first task.
  • Step 27 The first task releases the key lock.
  • the first task releasing the critical lock indicates that the first task exits the critical section.
  • Step 28 Clear the target identification information in the parameter information of the first task.
  • step 24 if it is detected that the parameter information of the first task includes target identification information, and the identification duration of the target identification information is less than or equal to the preset duration t, the CPU is prohibited from switching to the second task, and the CPU runs the first task, which can shorten the critical section time of the first task.
  • steps 25 and 26 if it is detected that the parameter information of the first task does not include the target identification information, or the parameter information of the first task includes the target identification information but the identification duration has exceeded the preset duration t, the high-priority second task will be run first, and when the second task is completed, the CPU will switch back to run the first task, which can avoid the problem of system freeze caused by priority inversion.
  • FIG3 is a schematic diagram of a task scheduling method according to another example of the present invention, in which the first task is blocked, actively gives up the CPU, and then quickly switches back to run on the CPU.
  • the specific steps of the task scheduling method may include:
  • Step 31 Before the first task obtains system resources, a key lock is obtained. When obtaining the key lock, target identification information is marked for the first task, and the identification time of the first task being marked with the target identification information is recorded, and the target identification information and the identification time of the target identification information are used as one of the parameter information of the first task.
  • Step 32 When the first task acquires the critical lock and the third task occupies the system resources, wait for the first task to be awakened.
  • the first task acquires the critical lock, which indicates that the first task enters the critical section.
  • the third task occupies the system resources that the first task needs to allocate, and the first task is blocked.
  • the first task is in a state of waiting to be awakened.
  • the CPU will run other tasks, including the third task.
  • Step 33 When the first task is awakened, obtain parameter information of the first task; wherein the first task is awakened when the third task releases the system resources.
  • the first task when the third task exits and releases the system resources, the first task is awakened.
  • parameter information of the first task is obtained to determine whether the parameter information of the first task meets a preset condition.
  • Step 34 Determine whether the parameter information of the first task includes target identification information, and whether the identification duration of the target identification information of the first task exceeds the preset duration t?
  • Step 35 If the parameter information of the first task includes the target identification information and there is no timeout, the CPU is immediately switched back to the first task.
  • Step 36 If the parameter information of the first task does not include the target identification information, or the parameter information of the first task includes the target identification information but the identification duration has timed out, determine whether to switch to other tasks based on whether there are other high-priority tasks that need to be run.
  • Step 37 After other high-priority tasks exit execution, the CPU switches back to the first task.
  • Step 38 The first task releases the critical lock, indicating that the first task exits the critical section.
  • Step 39 Clear the target identification information of the first task.
  • the CPU when the first task is blocked, the CPU is actively released, and the current CPU will run the third task.
  • the third task exits the first task is awakened.
  • the first task is awakened, it is determined whether the parameter information of the first task meets the preset conditions. If the parameter information of the first task includes the target identification information and there is no timeout, the current CPU is immediately switched back to run the first task, thereby avoiding the problem that other tasks cannot be run due to the blocking of high-priority tasks, and the system operation speed can also be improved.
  • FIG. 4 is a schematic diagram of a task scheduling method according to another example of the present invention, in which the example is aimed at periodic timeout detection of the system to determine whether there is an abnormality in the operation of the task.
  • the specific steps of the task scheduling method may include:
  • Step 41 Tick interrupt occurs.
  • Step 42 When the Tick is interrupted, check whether the first task is a special task including target identification information, and whether the identification duration of the target identification information exceeds a preset duration t.
  • Step 43 If the first task is a special task including target identification information, and its identification duration exceeds the preset duration t, then the target identification information of the first task is cleared, that is, the CPU is allowed to run other tasks.
  • Step 44 If the first task is not a special task, or the first task includes a target identification signal If the special task of the message exceeds the preset time t, the Tick timeout judgment is exited.
  • the Tick interrupt can be used to perform timeout detection on the task with target identification information in the system. If it is detected that the identification duration of the target identification information exceeds the preset duration, it means that the task has occupied the CPU for a long time, and there may be an operation abnormality, and it has fallen into an infinite loop. In this case, the target identification information of the task is cleared to allow the task to be queued again. Because the priority of the task after requeuing is lower, it will be ranked later, and the system can run other tasks. In this way, the problem of other tasks being unable to run due to abnormal task operation can be avoided, and the speed of system operation is improved.
  • the task scheduling method provided in the embodiment of the present application can be performed by a task scheduling device.
  • the task scheduling device provided in the embodiment of the present application is described by taking the method for performing task scheduling by the task scheduling device as an example.
  • a task scheduling device 500 is provided in an embodiment of the present application.
  • the device 500 includes:
  • An acquisition module 501 is used to acquire parameter information of the first task when the first task acquires the key lock;
  • the control module 502 is used to execute the first task when the parameter information meets a preset condition, wherein the parameter information meets the preset condition includes: the parameter information includes target identification information.
  • the embodiment of the present application by setting a key lock, it can be ensured that only one task obtains the key lock at the same time, so that when multiple tasks are running at the same time, the multiple tasks can be run in order of the time of obtaining the key lock, thereby avoiding the problem of system congestion.
  • the first task with the target identification information can be run first, thereby shortening the waiting time for the first task to run, and avoiding the problem of system jams caused by priority inversion in the related art.
  • the parameter information satisfying the preset condition further includes: the identification duration of the target identification information is less than or equal to the preset duration.
  • the parameter information satisfies the preset condition and also includes: the identification duration of the target identification information is less than or equal to the preset duration, thereby avoiding the impact of long-term running of a special task on the running of other tasks, thereby affecting the running speed of the system and reducing the user experience.
  • control module 502 is further configured to run the second task if the parameter information does not meet the preset condition and there is a second task with a higher priority than the first task; wherein the parameter information does not meet the preset condition includes one of the following: the parameter information does not include the target identification information, the parameter information includes the target identification information but the identification duration of the target identification information is greater than the preset duration;
  • the first task is executed.
  • the second task when the parameter information of the first task does not meet the set conditions and there is a second task with a higher priority than the first task, the second task is run, and after the second task exits, the first task is run, which can avoid the problem of system freeze caused by multi-task running conflicts.
  • the device further includes: a clearing module 503,
  • the clearing module 503 is used to clear the parameter information of the first task after the first task releases the critical lock.
  • the parameter information of the first task is cleared, thereby preventing the target identification information from affecting the normal operation of other tasks after the task with the target identification information is run.
  • the acquisition module 501 is specifically used to acquire parameter information of the first task when the first task acquires a critical lock and the first task occupies system resources;
  • the acquisition module 501 is specifically used to wait for the first task to be awakened when the first task acquires the critical lock and the third task occupies the system resources, and to obtain parameter information of the first task when the first task is awakened; wherein the first task is awakened when the third task releases the system resources.
  • the system operation speed can be improved and the system power consumption can be reduced.
  • the first task is blocked, other tasks are run first, and when the third task releases the system resources, the first task is awakened to obtain the parameter information of the first task, which can also avoid the problem that other low-priority tasks cannot be run due to the blocking of high-priority tasks, thereby improving the system operation speed.
  • the acquisition module 501 is used to acquire the identification duration of the target identification information when a setting event occurs and the parameter information of the first task includes the target identification information;
  • the clearing module 503 is used to clear the target identification information in the parameter information of the first task when the identification duration of the target identification information is greater than the preset duration.
  • the identification duration of the target identification information is obtained; when the identification duration of the target identification information is greater than the preset duration, the target identification information in the parameter information of the first task is cleared, thereby avoiding the problem of other tasks being unable to run due to abnormal task operation, thereby improving the speed of system operation.
  • the task scheduling device in the embodiment of the present application can be an electronic device or a component in the electronic device, such as an integrated circuit or a chip.
  • the electronic device can be a terminal or other devices other than a terminal.
  • the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR)/virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc.
  • It can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present application is not specifically limited.
  • Network Attached Storage NAS
  • PC personal computer
  • TV television
  • teller machine a self-service machine
  • the task scheduling device in the embodiment of the present application may be a device having an operating system.
  • the operating system may be an Android operating system, an iOS operating system, or other operating systems.
  • the operating system capable of the present invention is not specifically limited in the embodiments of the present application.
  • the task scheduling device provided in the embodiment of the present application can implement each process implemented by the method embodiments of Figures 1 to 4. To avoid repetition, they will not be described here.
  • an embodiment of the present application also provides an electronic device 600, including a processor 601 and a memory 602, and the memory 602 stores a program or instruction that can be executed on the processor 601.
  • the program or instruction is executed by the processor 601
  • the various steps of the above-mentioned task scheduling method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
  • the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
  • FIG. 7 is a schematic diagram of the hardware structure of an electronic device implementing an embodiment of the present application.
  • the electronic device 1000 includes but is not limited to: a radio frequency unit 1001, a network module 1002, an audio output unit 1003, an input unit 1004, a sensor 1005, a display unit 1006, a user input unit 1007, an interface unit 1008, a memory 1009, and a processor 1010 and other components.
  • the electronic device 1000 can also include a power source (such as a battery) for supplying power to each component, and the power source can be logically connected to the processor 1010 through a power management system, so that the power management system can manage charging, discharging, and power consumption.
  • a power source such as a battery
  • the electronic device structure shown in FIG7 does not constitute a limitation on the electronic device, and the electronic device can include more or fewer components than shown in the figure, or combine certain components, or arrange components differently, which will not be described in detail here.
  • the processor 1010 is used to obtain parameter information of the first task when the first task obtains the key lock; and run the first task when the parameter information meets the preset conditions, wherein the parameter information meets the preset conditions including: the parameter information includes target identification information.
  • the embodiment of the present application by setting a key lock, it can be ensured that only one task obtains the key lock at the same time, so that when multiple tasks are running at the same time, the multiple tasks can be run in order of the time of obtaining the key lock, thereby avoiding the problem of system congestion.
  • the first task with the target identification information can be run first, thereby avoiding the problem of system congestion. This shortens the waiting time for the first task to run and avoids the problem of system freeze caused by priority inversion in related technologies.
  • the parameter information satisfying a preset condition further includes: an identification duration of the target identification information being less than or equal to a preset duration.
  • the parameter information satisfies the preset condition and also includes: the identification duration of the target identification information is less than or equal to the preset duration, which can avoid the long-term running of a special task affecting the running of other tasks, thereby affecting the running speed of the system and reducing the user experience.
  • the processor 1010 is also used to run the second task if the parameter information does not meet the preset condition and there is a second task with a higher priority than the first task; wherein the parameter information does not meet the preset condition includes one of the following: the parameter information does not include the target identification information, the parameter information includes the target identification information but the identification duration of the target identification information is greater than the preset duration; after the second task exits running, the first task is run.
  • the second task when the parameter information of the first task does not meet the set conditions and there is a second task with a higher priority than the first task, the second task is run, and after the second task exits, the first task is run, which can avoid the problem of system freeze caused by multi-task running conflicts.
  • the processor 1010 is configured to clear the parameter information of the first task after the first task releases the critical lock.
  • the parameter information of the first task is cleared, thereby preventing the target identification information from affecting the normal operation of other tasks after the task with the target identification information is run.
  • the processor 1010 is configured to, when the first task acquires the critical lock and the first task occupies system resources, acquire parameter information of the first task; or, when the first task acquires the critical lock and the third task occupies the system resources, wait for the first task to be awakened, and when the first task is awakened, acquire parameter information of the first task. wherein, the first task is awakened when the third task releases the system resources.
  • the system operation speed can be improved and the system power consumption can be reduced.
  • the first task is blocked, other tasks are run first, and when the third task releases the system resources, the first task is awakened to obtain the parameter information of the first task, which can also avoid the problem that other low-priority tasks cannot be run due to the blocking of high-priority tasks, thereby improving the system operation speed.
  • the processor 1010 is used to obtain the identification duration of the target identification information when a set event occurs and the parameter information of the first task includes the target identification information; and to clear the target identification information in the parameter information of the first task when the identification duration of the target identification information is greater than the preset duration.
  • the identification duration of the target identification information is obtained; when the identification duration of the target identification information is greater than the preset duration, the target identification information in the parameter information of the first task is cleared, thereby avoiding the problem of other tasks being unable to run due to abnormal task operation, thereby improving the speed of system operation.
  • the input unit 1004 may include a graphics processing unit (GPU) 10041 and a microphone 10042, and the graphics processor 10041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode.
  • the display unit 1006 may include a display panel 10061, and the display panel 10061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc.
  • the user input unit 1007 includes a touch panel 10071 and at least one of other input devices 10072.
  • the touch panel 10071 is also called a touch screen.
  • the touch panel 10071 may include two parts: a touch detection device and a touch controller.
  • Other input devices 10072 may include, but are not limited to, a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
  • the memory 1009 can be used to store software programs and various data.
  • the memory 1009 can mainly include
  • the memory 1009 includes a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc.
  • the memory 1009 may include a volatile memory or a non-volatile memory, or the memory 1009 may include both volatile and non-volatile memories.
  • the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory.
  • the volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM).
  • the memory 1009 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
  • the processor 1010 may include one or more processing units; optionally, the processor 1010 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 1010.
  • An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored.
  • a program or instruction is stored.
  • the various processes of the above-mentioned task scheduling method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
  • the processor is the processor in the electronic device described in the above embodiment.
  • the readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
  • the present application embodiment further provides a chip, the chip comprising a processor and a communication interface.
  • the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned task scheduling method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
  • the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
  • An embodiment of the present application provides a computer program product, which is stored in a storage medium.
  • the program product is executed by at least one processor to implement the various processes of the above-mentioned task scheduling method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
  • the technical solution of the present application can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM/RAM, a disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
  • a storage medium such as ROM/RAM, a disk, or an optical disk

Landscapes

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

Abstract

Disclosed in the present application are a task scheduling method and apparatus, and an electronic device, which are applied in the technical field of communications. The method comprises: when a first task acquires a key lock, acquiring parameter information of the first task; and when the parameter information satisfies a preset condition, running the first task, wherein the parameter information satisfying the preset condition comprises: the parameter information comprising target identification information.

Description

任务调度方法、装置和电子设备Task scheduling method, device and electronic equipment
相关申请的交叉引用CROSS-REFERENCE TO RELATED APPLICATIONS
本申请要求在2023年01月30日提交中国专利局、申请号为202310067875.2、发明名称为“任务调度方法、装置和电子设备”的中国专利申请的优先权,该中国专利申请的全部内容通过引用包含于此。This application claims the priority of the Chinese patent application filed with the China Patent Office on January 30, 2023, with application number 202310067875.2 and invention name “Task Scheduling Method, Device and Electronic Device”. The entire contents of the Chinese patent application are incorporated herein by reference.
技术领域Technical Field
本申请属于通信技术领域,更具体地,涉及一种任务调度方法、装置和电子设备。The present application belongs to the field of communication technology, and more specifically, relates to a task scheduling method, device and electronic equipment.
背景技术Background Art
随着科学技术的不断发展,电子设备的功能越来越多,常驻在电子设备后台的应用也越来越多。通常情况下,在同一时间运行的程序较多时,系统可以根据资源调度策略中的调度优先级高低调动资源。例如,当用户在前台使用手机刷微信朋友圈时,手机的后台还有很多应用在后台运行,比如QQ在后台接收消息,迅雷在后台下载电影等等。当前系统的资源调度策略会优先保障前台应用的运行,也就是前台应用可以优先获得资源,比如将前台的微信优先运行在CPU大核并且提高其调度优先级,而后台应用则限制资源的获得,比如将后台的QQ或者迅雷限制在CPU小核上运行并且降低其调度优先级等。With the continuous development of science and technology, electronic devices have more and more functions, and more and more applications are resident in the background of electronic devices. Usually, when there are many programs running at the same time, the system can adjust resources according to the scheduling priority in the resource scheduling strategy. For example, when a user uses a mobile phone to browse WeChat Moments in the foreground, there are still many applications running in the background of the mobile phone, such as QQ receiving messages in the background, Thunder downloading movies in the background, etc. The current system's resource scheduling strategy will give priority to the operation of the foreground application, that is, the foreground application can obtain resources first, such as giving priority to running WeChat in the foreground on the large core of the CPU and increasing its scheduling priority, while the background application will limit the acquisition of resources, such as limiting the background QQ or Thunder to run on the small core of the CPU and lowering its scheduling priority.
但是,采用此种资源调度策略会大大加剧优先级反转问题的发生,即,优先极高的任务因被优先级低的任务堵塞而不能运行,需要先运行优先级低的任务释放系统锁后,才能运行优先级高的任务的现象,从而导致系统卡顿的问题。However, adopting this resource scheduling strategy will greatly aggravate the occurrence of priority inversion problem, that is, extremely high priority tasks cannot run because they are blocked by low priority tasks. The low priority tasks need to be run first to release the system lock before high priority tasks can run, thus causing system lag problems.
发明内容 Summary of the invention
本申请实施例的目的是提供一种任务调度方法、装置和电子设备,能够解决相关技术中因优先级反转而导致的系统卡顿的问题。The purpose of the embodiments of the present application is to provide a task scheduling method, device and electronic device, which can solve the problem of system freeze caused by priority inversion in the related art.
第一方面,本申请实施例提供了一种任务调度方法,所述方法包括:在第一任务获取到关键锁的情况下,获取所述第一任务的参数信息;在所述参数信息满足预设条件的情况下,运行所述第一任务,其中,所述参数信息满足预设条件包括:所述参数信息中包括目标标识信息。In a first aspect, an embodiment of the present application provides a task scheduling method, the method comprising: when a first task obtains a critical lock, obtaining parameter information of the first task; when the parameter information satisfies a preset condition, running the first task, wherein the parameter information satisfies the preset condition including: the parameter information includes target identification information.
第二方面,本申请实施例提供一种任务调度装置,所述装置包括:获取模块,用于在第一任务获取到关键锁的情况下,获取所述第一任务的参数信息;控制模块,用于在所述参数信息满足预设条件的情况下,运行所述第一任务,其中,所述参数信息满足预设条件包括:所述参数信息中包括目标标识信息。In a second aspect, an embodiment of the present application provides a task scheduling device, comprising: an acquisition module, used to acquire parameter information of the first task when the first task acquires a key lock; a control module, used to run the first task when the parameter information meets a preset condition, wherein the parameter information meets the preset condition including: the parameter information includes target identification information.
第三方面,本申请实施例提供了一种电子设备,该电子设备包括处理器和存储器,所述存储器存储可在所述处理器上运行的程序或指令,所述程序或指令被所述处理器执行时实现如第一方面所述的方法的步骤。In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.
第四方面,本申请实施例提供了一种可读存储介质,所述可读存储介质上存储程序或指令,所述程序或指令被处理器执行时实现如第一方面所述的方法的步骤。In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
第五方面,本申请实施例提供了一种芯片,所述芯片包括处理器和通信接口,所述通信接口和所述处理器耦合,所述处理器用于运行程序或指令,实现如第一方面所述的方法。In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.
第六方面,本申请实施例提供一种计算机程序产品,该程序产品被存储在存储介质中,该程序产品被至少一个处理器执行以实现如第一方面所述的方法。In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.
在本申请实施例中,通过设置关键锁,可以保证同一时间只存在一个任务获取关键锁,从而可以在多个任务同时运行时,通过获取关键锁的时间排序运行该多个任务,避免系统拥堵的问题。通过在第一任务获取到关键锁的情况下,获取所述第一任务的参数信息,在所述参数信息满足预设条件的情 况下,运行所述第一任务,可以优先运行带有目标标识信息的第一任务,从而缩短第一任务等待运行的时间,避免相关技术中优先级反转造成系统卡顿的问题。In the embodiment of the present application, by setting a key lock, it can be ensured that only one task obtains the key lock at the same time, so that when multiple tasks are running at the same time, the multiple tasks can be run in order of the time of obtaining the key lock, thereby avoiding the problem of system congestion. By obtaining the parameter information of the first task when the first task obtains the key lock, and when the parameter information meets the preset conditions, In this case, when the first task is run, the first task with the target identification information can be run first, thereby shortening the waiting time for the first task to run and avoiding the problem of system freeze caused by priority inversion in the related art.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1为本申请实施例提供的任务调度方法的流程图;FIG1 is a flow chart of a task scheduling method provided in an embodiment of the present application;
图2为本申请一个例子的示意性流程图;FIG2 is a schematic flow chart of an example of the present application;
图3为本申请另一个例子的示意性流程图;FIG3 is a schematic flow chart of another example of the present application;
图4为本申请又一个例子的示意性流程图;FIG4 is a schematic flow chart of another example of the present application;
图5为本申请实施例的任务调度装置的示意图;FIG5 is a schematic diagram of a task scheduling device according to an embodiment of the present application;
图6为本申请实施例提供的电子设备的结构示意图;FIG6 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
图7为本申请另一实施例提供的电子设备的硬件结构示意图。FIG. 7 is a schematic diagram of the hardware structure of an electronic device provided in another embodiment of the present application.
具体实施方式DETAILED DESCRIPTION
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清除地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员获得的所有其他实施例,都属于本申请保护的范围。The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field belong to the scope of protection of this application.
本申请的说明书和权利要求书中的术语“第一”、“第二”等是用于区别类似的对象,而不用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施,且“第一”、“第二”等所区分的对象通常为一类,并不限定对象的个数,例如第一对象可以是一个,也可以是多个。此外,说明书以及权利要求中“和/或”表示所连接对象的至少其中之一,字符“/”,一般表示前后关联对象是一种“或”的关系。The terms "first", "second", etc. in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and/or" in the specification and claims represents at least one of the connected objects, and the character "/" generally indicates that the objects associated with each other are in an "or" relationship.
下面结合附图,通过具体的实施例及其应用场景对本申请实施例提供的任务调度方法进行详细地说明。 The task scheduling method provided in the embodiment of the present application is described in detail below through specific embodiments and their application scenarios in conjunction with the accompanying drawings.
如图1所示,其是本申请实施例提供的一种任务调度方法,该方法包括如下步骤101~步骤102,以下予以详细说明。As shown in FIG. 1 , a task scheduling method is provided in an embodiment of the present application. The method includes the following steps 101 to 102 , which are described in detail below.
步骤101,在第一任务获取到关键锁的情况下,获取所述第一任务的参数信息。Step 101: When a first task obtains a key lock, obtain parameter information of the first task.
步骤102、在所述参数信息满足预设条件的情况下,运行所述第一任务。Step 102: When the parameter information meets a preset condition, execute the first task.
本实施例中,在电子设备的系统中,常会存在同一时间多任务运行的情况。例如,在使用手机玩游戏的过程中,前台运行游戏应用,与此同时,还可能存在后台运行“设置”应用、“音乐”应用、“文件管理”等应用。但是,由于电子设备的一些硬件资源的限制,比如,存储数据的UFS存储器在手机中只有一个,导致在多个任务调用系统资源的时候,同一时间只能有一个任务在调用。其中,关键锁可以是被设置在调用数据的入口处,以保证同一时间只有一个任务读取系统资源。也就是说,同一时间只存在一个任务获取关键锁。In this embodiment, in the system of the electronic device, there are often situations where multiple tasks are running at the same time. For example, in the process of playing games with a mobile phone, the game application is running in the foreground, and at the same time, there may also be "settings" applications, "music" applications, "file management" and other applications running in the background. However, due to the limitations of some hardware resources of the electronic device, for example, there is only one UFS memory for storing data in the mobile phone, resulting in that when multiple tasks call system resources, only one task can call at the same time. Among them, the key lock can be set at the entrance of the call data to ensure that only one task reads the system resources at the same time. In other words, there is only one task that obtains the key lock at the same time.
在调用数据的入口处设置好关键锁后,在多个任务需要获取系统资源的情况下,由于同一时间只存在一个任务获取关键锁,因此,该多个任务被按照时间顺序依次获取关键锁。并且,在该多个任务中其中任一任务获取到关键锁后,标志着该任务进入等待运行或者运行的临界区,该任务对应的系统资源被占用。通常情况下,获取关键锁的时间靠前的任务会优先于获取关键锁的时间靠后的任务运行,从而,该多个任务可以按照获取关键锁的时间顺序运行。After the key lock is set at the entrance of the call data, when multiple tasks need to obtain system resources, since only one task obtains the key lock at the same time, the multiple tasks are sequentially obtained in chronological order. Moreover, after any of the multiple tasks obtains the key lock, it indicates that the task enters the critical area of waiting to run or running, and the system resources corresponding to the task are occupied. Usually, the task that obtains the key lock earlier will run before the task that obtains the key lock later, so that the multiple tasks can run in the order of the time of obtaining the key lock.
若需要优先运行该多个任务中某个任务,则在该任务获取关键锁时,可以通过目标标识信息对该任务进行标记,并将所述目标标识信息作为该任务的参数信息的其中一项。其中,目标标识信息可以用于指示其对应的任务为特殊任务。例如,目标标识信息可以是特殊字符,通过特殊字符标记需要优先运行的特殊任务。本领域技术人员应当理解,这里对目标标识信息不做具体限定。If it is necessary to run a task among the multiple tasks in priority, when the task obtains the key lock, the task can be marked by the target identification information, and the target identification information is used as one of the parameter information of the task. Among them, the target identification information can be used to indicate that the corresponding task is a special task. For example, the target identification information can be a special character, and the special task that needs to be run in priority is marked by the special character. Those skilled in the art should understand that the target identification information is not specifically limited here.
在第一任务获取到关键锁的情况下,获取所述第一任务的参数信息。在 所述参数信息中包括所述目标标识信息的情况下,则确定所述第一任务为满足预设条件的特殊任务。在所述参数信息中不包括所述目标标识信息的情况下,则确定所述第一任务不满足预设条件。其中,第一任务为所述多个任务中任意一个任务。When the first task obtains the key lock, parameter information of the first task is obtained. If the target identification information is included in the parameter information, it is determined that the first task is a special task that meets the preset condition. If the target identification information is not included in the parameter information, it is determined that the first task does not meet the preset condition. The first task is any one of the multiple tasks.
在确定所述第一任务为满足预设条件的特殊任务的情况下,在CPU运行所述第一任务,并禁止其他高优先级的任务运行。When it is determined that the first task is a special task that meets the preset condition, the first task is executed on the CPU, and other high-priority tasks are prohibited from executing.
例如,任务1和任务2按照时间先后获取关键锁,若任务1和任务2均未标记有标识信息,则按照获取关键锁的时间先后顺序运行任务1和任务2。若任务2为通过特殊字符标记的特殊任务,在任务2获取到带有标识信息的关键锁的情况下,任务2先于任务1运行。For example, if Task 1 and Task 2 obtain the key lock in chronological order, and if neither Task 1 nor Task 2 is marked with identification information, Task 1 and Task 2 will be run in the order of the time of obtaining the key lock. If Task 2 is a special task marked with special characters, when Task 2 obtains the key lock with identification information, Task 2 will be run before Task 1.
根据本申请实施例,通过设置关键锁,可以保证同一时间只存在一个任务获取关键锁,从而可以在多个任务同时运行时,通过获取关键锁的时间排序运行该多个任务,避免系统拥堵的问题。通过在第一任务获取到关键锁的情况下,获取所述第一任务的参数信息,在所述参数信息满足预设条件的情况下,运行所述第一任务,可以优先运行带有目标标识信息的第一任务,从而缩短第一任务等待运行的时间,避免相关技术中优先级反转造成系统卡顿的问题。According to the embodiment of the present application, by setting a key lock, it can be ensured that only one task obtains the key lock at the same time, so that when multiple tasks are running at the same time, the multiple tasks can be run in order of the time of obtaining the key lock, thereby avoiding the problem of system congestion. By obtaining the parameter information of the first task when the first task obtains the key lock, and running the first task when the parameter information meets the preset conditions, the first task with the target identification information can be run first, thereby shortening the waiting time for the first task to run, and avoiding the problem of system jams caused by priority inversion in the related art.
在一个实施例中,为了避免特殊任务长时间在运行而导致其他任务无法正常运行的问题,进而降低用户体验,本申请实施例还提供了一种基于目标标识信息的标识时长控制任务调度的方法。即,在所述参数信息中包括目标标识信息的情况下,所述参数信息满足预设条件还包括:所述目标标识信息的标识时长小于或者等于预设时长。In one embodiment, in order to avoid the problem that a special task runs for a long time and causes other tasks to fail to run normally, thereby reducing the user experience, the embodiment of the present application also provides a method for controlling task scheduling based on the identification duration of target identification information. That is, when the parameter information includes the target identification information, the parameter information also satisfies the preset condition that: the identification duration of the target identification information is less than or equal to the preset duration.
本实施例中,在多个任务获取关键锁时,可以在通过目标标识信息标记其中的特殊任务的同时,记录该特殊任务被标记有所述目标标识信息的标识时长。并且,将该标识时长与对应的目标标识信息相关联。In this embodiment, when multiple tasks acquire a key lock, a special task among them can be marked with target identification information, and the identification time of the special task marked with the target identification information can be recorded. In addition, the identification time can be associated with the corresponding target identification information.
在第一任务获取到关键锁的情况下,获取所述第一任务的参数信息,并先确定所述第一任务的参数信息中是否包括目标标识信息。在确定所述第一 任务的参数信息中包括目标标识信息的情况下,再确定所述目标标识信息的标识时长是否小于或者等于预设时长。在所述目标标识信息的标识时长小于或者等于预设时长的情况下,确定所述参数信息满足预设条件,进而禁止其他高优先级的任务运行,运行所述第一任务。When the first task obtains the key lock, the parameter information of the first task is obtained, and it is first determined whether the parameter information of the first task includes the target identification information. If the parameter information of the task includes target identification information, it is determined whether the identification duration of the target identification information is less than or equal to the preset duration. If the identification duration of the target identification information is less than or equal to the preset duration, it is determined that the parameter information meets the preset condition, and other high-priority tasks are prohibited from running, and the first task is run.
根据本申请实施例,通过在所述参数信息中包括目标标识信息的情况下,所述参数信息满足预设条件还包括:所述目标标识信息的标识时长小于或者等于预设时长,可以避免因特殊任务长时间运行而影响其他任务的运行,进而影响系统的运行速度,降低用户体验。According to an embodiment of the present application, by including target identification information in the parameter information, the parameter information satisfies the preset condition and also includes: the identification duration of the target identification information is less than or equal to the preset duration, thereby avoiding the impact of long-term running of a special task on the running of other tasks, thereby affecting the running speed of the system and reducing the user experience.
在一个实施例中,所述获取所述第一任务的参数信息之后,所述方法还包括:In one embodiment, after obtaining the parameter information of the first task, the method further includes:
步骤201、在所述参数信息不满足所述预设条件,且存在优先级高于所述第一任务的第二任务的情况下,运行所述第二任务;其中,所述参数信息不满足所述预设条件包括以下其中一项:所述参数信息中不包括所述目标标识信息、所述参数信息中包括所述目标标识信息但所述目标标识信息的标识时长大于所述预设时长;Step 201: if the parameter information does not satisfy the preset condition and there is a second task with a higher priority than the first task, run the second task; wherein the parameter information not satisfying the preset condition includes one of the following: the parameter information does not include the target identification information, the parameter information includes the target identification information but the identification duration of the target identification information is greater than the preset duration;
步骤202、在所述第二任务退出运行之后,运行所述第一任务。Step 202: After the second task exits execution, the first task is executed.
本实施例中,在所述第一任务的参数信息中不包括所述目标标识信息,或者,所述参数信息中包括所述目标标识信息但所述目标标识信息的标识时长大于所述预设时长的情况下,确定所述第一任务的参数信息不满足预设条件。In this embodiment, when the target identification information is not included in the parameter information of the first task, or when the target identification information is included in the parameter information but the identification duration of the target identification information is greater than the preset duration, it is determined that the parameter information of the first task does not meet the preset conditions.
在所述第一任务的参数信息不满足所述预设条件,且存在优先级高于所述第一任务的第二任务的情况下,运行所述第二任务。并且,在运行所述第二任务时,所述第一任务处于等待运行状态。在所述第二任务退出运行之后,运行所述第一任务。When the parameter information of the first task does not meet the preset condition and there is a second task with a higher priority than the first task, the second task is run. When the second task is run, the first task is in a waiting state. After the second task exits the run, the first task is run.
例如,任务2获取关键锁的时间先于任务1获取关键锁的时间,即,任务2的优先级高于任务1的优先级。并且,任务1的参数信息不包括目标标识信息,或者,任务1的参数信息包括目标标识信息但是目标标识信息的标 识时长大于预设时长。此种情况下,任务1的参数信息不满足设定条件,根据优先级顺序,先运行任务2,待任务2运行完成且退出运行之后,再运行任务1。For example, the time when task 2 acquires the key lock is earlier than the time when task 1 acquires the key lock, that is, the priority of task 2 is higher than the priority of task 1. In addition, the parameter information of task 1 does not include the target identification information, or the parameter information of task 1 includes the target identification information but the target identification information is not specified. The duration of the task is longer than the preset duration. In this case, the parameter information of task 1 does not meet the set conditions. According to the priority order, task 2 is run first, and task 1 is run after task 2 is completed and exits.
根据本申请实施例,在所述第一任务的参数信息不满足所述设定条件,且存在优先级高于所述第一任务的第二任务的情况下,运行所述第二任务,在所述第二任务退出运行之后,运行所述第一任务,可以避免多任务运行冲突导致系统卡顿的问题。According to an embodiment of the present application, when the parameter information of the first task does not meet the set conditions and there is a second task with a higher priority than the first task, the second task is run, and after the second task exits, the first task is run, which can avoid the problem of system freeze caused by multi-task running conflicts.
在一个实施例中,为了提高系统的运行速度,降低系统功耗,本申请实施例还设置了触发获取第一任务的参数信息的条件。也就是说,所述在第一任务获取到关键锁的情况下,获取所述第一任务的参数信息,包括:In one embodiment, in order to improve the operating speed of the system and reduce the power consumption of the system, the embodiment of the present application also sets a condition for triggering the acquisition of the parameter information of the first task. That is, when the first task acquires the key lock, the parameter information of the first task is acquired, including:
步骤301、在所述第一任务获取到关键锁,且所述第一任务占用系统资源的情况下,获取所述第一任务的参数信息;Step 301: When the first task obtains a key lock and the first task occupies system resources, obtain parameter information of the first task;
步骤302、在所述第一任务获取到关键锁,且第三任务占用所述系统资源的情况下,等待所述第一任务被唤醒,并在所述第一任务被唤醒的情况下,获取所述第一任务的参数信息;其中,所述第一任务在所述第三任务释放所述系统资源的情况下被唤醒。Step 302: When the first task obtains the critical lock and the third task occupies the system resources, wait for the first task to be awakened, and when the first task is awakened, obtain parameter information of the first task; wherein the first task is awakened when the third task releases the system resources.
本实施例中,设置触发获取第一任务的参数信息的两种条件:In this embodiment, two conditions are set to trigger the acquisition of parameter information of the first task:
条件一:在所述第一任务获取到关键锁,且所述第一任务占用系统资源的情况下,获取所述第一任务的参数信息。Condition 1: When the first task obtains the critical lock and the first task occupies system resources, parameter information of the first task is obtained.
在第一任务获取到关键锁,且所述第一任务未占用系统资源的情况下,说明所述第一任务可能被堵塞,此时,不进行对于所述第一任务的参数信息是否满足预设条件的检测。When the first task obtains the critical lock and the first task does not occupy system resources, it indicates that the first task may be blocked. At this time, whether the parameter information of the first task meets the preset conditions is not detected.
在第一任务获取到关键锁,且所述第一任务占用系统资源的情况下,需要判断所述第一任务是否为满足预设条件的特殊任务,进而确定所述第一任务和需要运行的其他任务的优先级顺序。即,获取所述第一任务的参数信息,以检测所述第一任务的参数信息是否满足预设条件。When the first task obtains the critical lock and occupies system resources, it is necessary to determine whether the first task is a special task that meets the preset conditions, and then determine the priority order of the first task and other tasks that need to be run. That is, the parameter information of the first task is obtained to detect whether the parameter information of the first task meets the preset conditions.
条件二:在所述第一任务获取到关键锁,且第三任务占用所述系统资源 的情况下,等待所述第一任务被唤醒,并在所述第一任务被唤醒的情况下,获取所述第一任务的参数信息;其中,所述第一任务在所述第三任务释放所述系统资源的情况下被唤醒。Condition 2: The first task acquires the critical lock and the third task occupies the system resources In the case where the first task is awakened, wait for the first task to be awakened, and when the first task is awakened, obtain parameter information of the first task; wherein the first task is awakened when the third task releases the system resources.
所述条件二针对的是在第一任务获取到关键锁,且第三任务占用系统资源的情况,此种情况下,所述第一任务的运行可能被堵塞。例如,第一任务为锁嵌套结构,在运行第一任务前,不仅要获取关键锁作为外锁,还需要获取用于锁定其调佣的系统资源的内锁。在第一任务获取到关键锁后,所述内锁被第三任务占用,无法获取所述内锁。此种情况下,第一任务的运行被堵塞。The second condition is for the case where the first task obtains the critical lock and the third task occupies system resources. In this case, the operation of the first task may be blocked. For example, the first task is a lock nested structure. Before running the first task, it is necessary not only to obtain the critical lock as an outer lock, but also to obtain the inner lock used to lock the system resources it allocates. After the first task obtains the critical lock, the inner lock is occupied by the third task and cannot be obtained. In this case, the operation of the first task is blocked.
在第一任务的运行被堵塞的情况下,按照优先级顺序先运行其他任务,所述第一任务处于等待被唤醒的睡眠状态。其中,所述其他任务中包括所述第三任务。在所述第三任务运行完成且退出运行之后,释放所述内锁。此时,所述第一任务被唤醒,所述第一任务可以获取所述内锁,进而占用所述系统资源。在所述第一任务占用所述系统资源的情况下,获取所述第一任务的参数信息,以检测所述第一任务的参数信息是否满足所述预设条件。In the case where the running of the first task is blocked, other tasks are run first according to the priority order, and the first task is in a sleep state waiting to be awakened. Among them, the other tasks include the third task. After the third task is completed and exits the running, the internal lock is released. At this time, the first task is awakened, and the first task can obtain the internal lock, and then occupy the system resources. In the case where the first task occupies the system resources, the parameter information of the first task is obtained to detect whether the parameter information of the first task meets the preset condition.
根据本申请实施例,通过进一步设置触发获取所述第一任务的参数信息的条件,可以提高系统运行速度,降低系统功耗。并且在第一任务被堵塞的情况下,先运行其他任务,在所述第三任务释放所述系统资源的情况下唤醒所述第一任务,获取所述第一任务的参数信息,还可避免因优先级高的任务被堵塞而无法运行其他优先级低的任务的问题,提高系统运行速度。According to the embodiment of the present application, by further setting the conditions for triggering the acquisition of the parameter information of the first task, the system operation speed can be improved and the system power consumption can be reduced. In addition, when the first task is blocked, other tasks are run first, and when the third task releases the system resources, the first task is awakened to obtain the parameter information of the first task, which can also avoid the problem that other low-priority tasks cannot be run due to the blocking of high-priority tasks, thereby improving the system operation speed.
在一个实施例中,所述运行所述第一任务之后,所述方法还包括:In one embodiment, after executing the first task, the method further includes:
在所述第一任务释放所述关键锁之后,清除所述第一任务的所述参数信息。After the first task releases the critical lock, the parameter information of the first task is cleared.
本实施例中,在运行完所述第一任务之后,所述第一任务释放所述关键锁,并清除所述第一任务的所述参数信息。其中,在所述参数信息中包括目标标识信息的情况下,所述清除所述第一任务的所述参数信息为清除所述第一任务的所述参数信息中的所述目标标识信息。在所述参数信息中包括目标 标识信息和所述目标标识信息的标识时长的情况下,所述清除所述第一任务的所述参数信息为清除所述第一任务的所述参数信息中的所述目标标识信息和所述目标标识信息的标识时长。In this embodiment, after the first task is executed, the first task releases the key lock and clears the parameter information of the first task. Wherein, in the case where the parameter information includes target identification information, clearing the parameter information of the first task is clearing the target identification information in the parameter information of the first task. In the case of the identification information and the identification duration of the target identification information, the clearing of the parameter information of the first task is to clear the target identification information and the identification duration of the target identification information in the parameter information of the first task.
根据本申请实施例,在所述第一任务释放所述关键锁之后,清除所述第一任务的所述参数信息,从而可以避免在运行完带有目标标识信息的任务后,该目标标识信息影响其他任务的正常运行。According to an embodiment of the present application, after the first task releases the critical lock, the parameter information of the first task is cleared, thereby preventing the target identification information from affecting the normal operation of other tasks after the task with the target identification information is run.
在一个实施例中,所述获取所述第一任务的参数信息之后,所述方法还包括:In one embodiment, after obtaining the parameter information of the first task, the method further includes:
步骤401、在发生设定事件,且所述第一任务的所述参数信息中包括所述目标标识信息的情况下,获取所述目标标识信息的标识时长。Step 401: When a setting event occurs and the parameter information of the first task includes the target identification information, obtain the identification duration of the target identification information.
本实施例中,设定事件可以是周期性发生的事件。例如,设定事件可以是Tick中断事件,可以理解的,Tick中断是周期性的时钟中断,在手机系统内,Tick中断一般为4毫秒每次。Tick中断可以实现周期性地更新系统中任务运行的时间信息,进而基于该任务运行的时间信息确定当前运行的任务是否需要调度。In this embodiment, the setting event may be an event that occurs periodically. For example, the setting event may be a Tick interrupt event. It is understandable that the Tick interrupt is a periodic clock interrupt. In a mobile phone system, the Tick interrupt is generally 4 milliseconds each time. The Tick interrupt can periodically update the time information of the task running in the system, and then determine whether the currently running task needs to be scheduled based on the time information of the task running.
在系统运行的过程中,可以在发生设定事件的情况下,对系统中包括目标标识信息的特殊任务,进行标识时长的超时判断。During the operation of the system, when a set event occurs, a timeout judgment can be made on the identification duration of a special task in the system including target identification information.
步骤402、在所述目标标识信息的标识时长大于所述预设时长的情况下,清除所述第一任务的所述参数信息中的所述目标标识信息。Step 402: When the identification duration of the target identification information is greater than the preset duration, clear the target identification information in the parameter information of the first task.
本实施例中,在所述目标标识信息的标识时长大于所述预设时长的情况下,也就是说,运行所述第一任务的时间过长,所述第一任务的运行出现异常,可能陷入了死循环。此种情况下,清除所述第一任务的参数信息中的所述目标标识信息,所述第一任务按照其获取关键锁的时间重新排序,以避免其一直运行。In this embodiment, when the identification time of the target identification information is greater than the preset time, that is, the time for running the first task is too long, the running of the first task is abnormal, and it may fall into an infinite loop. In this case, the target identification information in the parameter information of the first task is cleared, and the first task is reordered according to the time when it obtains the key lock to avoid it running all the time.
根据本申请实施例,通过在发生设定事件,且所述第一任务的所述参数信息中包括所述目标标识信息的情况下,获取所述目标标识信息的标识时长;在所述目标标识信息的标识时长大于所述预设时长的情况下,清除所述第一 任务的所述参数信息中的所述目标标识信息,可以避免因任务运行异常而导致其他任务无法运行的问题,提高了系统运行的速度。According to an embodiment of the present application, when a setting event occurs and the parameter information of the first task includes the target identification information, the identification time of the target identification information is obtained; when the identification time of the target identification information is greater than the preset time, the first task is cleared. The target identification information in the parameter information of the task can avoid the problem that other tasks cannot be run due to abnormal task operation, thereby improving the speed of system operation.
<例子1><Example 1>
图2为根据本发明一个例子的任务调度方法的示意图,该例子针对任务中存在不能抢占的特殊任务,执行该特殊任务的情况。FIG. 2 is a schematic diagram of a task scheduling method according to an example of the present invention, in which a special task that cannot be preempted exists among the tasks and the special task is executed.
根据图2所示,该例子中,任务调度方法的具体步骤可以包括:As shown in FIG. 2 , in this example, the specific steps of the task scheduling method may include:
步骤21:在第一任务获取系统资源前,获取关键锁。在获取关键锁时,为第一任务标记目标标识信息,并记录第一任务被标记所述目标标识信息的标识时长,再将目标标识信息和该目标标识信息的标识时长作为第一任务的参数信息的其中一项。Step 21: Before the first task obtains system resources, a key lock is obtained. When obtaining the key lock, the target identification information is marked for the first task, and the identification time of the first task being marked with the target identification information is recorded, and then the target identification information and the identification time of the target identification information are used as one of the parameter information of the first task.
步骤22:在所述第一任务获取到关键锁,且所述第一任务占用系统资源的情况下,获取所述第一任务的参数信息。Step 22: When the first task obtains the critical lock and the first task occupies system resources, obtain parameter information of the first task.
本实施例中,第一任务获取到关键锁,标志着第一任务进入等待运行或者运行状态的临界区,第一任务占用CPU。若存在高优先级的第二任务需要运行,由于第一任务抢占CPU,则执行步骤23,以确定所述第一任务和第二任务运行的先后顺序。In this embodiment, the first task obtains the key lock, which indicates that the first task enters the critical section of the waiting or running state, and the first task occupies the CPU. If there is a high-priority second task that needs to be run, since the first task preempts the CPU, step 23 is executed to determine the order in which the first task and the second task are run.
步骤23:判断第一任务的参数信息中是否包括目标标识信息,并且第一任务的目标标识信息的标识时长有没有超过预设时长t。Step 23: Determine whether the parameter information of the first task includes target identification information, and whether the identification duration of the target identification information of the first task exceeds a preset duration t.
步骤24.若检测到第一任务的参数信息中包括目标标识信息,且目标标识信息的标识时长小于或者等于预设时长t,则禁止CPU切换到第二任务,CPU运行第一任务。Step 24: If it is detected that the parameter information of the first task includes target identification information, and the identification duration of the target identification information is less than or equal to the preset duration t, the CPU is prohibited from switching to the second task, and the CPU runs the first task.
步骤25:若检测到第一任务的参数信息中不包括目标标识信息,或者第一任务的参数信息中包括目标标识信息但是标识时长已经超过预设时长t,则先运行高优先级的第二任务。Step 25: If it is detected that the parameter information of the first task does not include the target identification information, or the parameter information of the first task includes the target identification information but the identification duration has exceeded the preset duration t, the second task with a higher priority is executed first.
步骤26:当第二任务运行完成,CPU会切换回运行第一任务。Step 26: When the second task is completed, the CPU switches back to running the first task.
步骤27:第一任务释放关键锁。Step 27: The first task releases the key lock.
本实施例中,第一任务释放关键锁标志着所述第一任务退出临界区。 In this embodiment, the first task releasing the critical lock indicates that the first task exits the critical section.
步骤28:清除第一任务的所述参数信息中的目标标识信息。Step 28: Clear the target identification information in the parameter information of the first task.
在该实施例中,步骤24中若检测到第一任务的参数信息中包括目标标识信息,且目标标识信息的标识时长小于或者等于预设时长t,则禁止CPU切换到第二任务,CPU运行第一任务,可以缩短第一任务的临界区时间。步骤25和步骤26中,若检测到第一任务的参数信息中不包括目标标识信息,或者第一任务的参数信息中包括目标标识信息但是标识时长已经超过预设时长t,则先运行高优先级的第二任务,当第二任务运行完成,CPU会切换回运行第一任务,可以避免优先级反转导致系统卡顿的问题。In this embodiment, in step 24, if it is detected that the parameter information of the first task includes target identification information, and the identification duration of the target identification information is less than or equal to the preset duration t, the CPU is prohibited from switching to the second task, and the CPU runs the first task, which can shorten the critical section time of the first task. In steps 25 and 26, if it is detected that the parameter information of the first task does not include the target identification information, or the parameter information of the first task includes the target identification information but the identification duration has exceeded the preset duration t, the high-priority second task will be run first, and when the second task is completed, the CPU will switch back to run the first task, which can avoid the problem of system freeze caused by priority inversion.
<例子2><Example 2>
图3为根据本发明另一个例子的任务调度方法的示意图,该例子针对第一任务被堵塞,主动让出CPU,然后快速切换回来在CPU运行的情况。FIG3 is a schematic diagram of a task scheduling method according to another example of the present invention, in which the first task is blocked, actively gives up the CPU, and then quickly switches back to run on the CPU.
根据图3所示,该例子中,任务调度方法的具体步骤可以包括:As shown in FIG3 , in this example, the specific steps of the task scheduling method may include:
步骤31:在第一任务获取系统资源前,获取关键锁。在获取关键锁时,为第一任务标记目标标识信息,并记录第一任务被标记所述目标标识信息的标识时长,再将目标标识信息和该目标标识信息的标识时长作为第一任务的参数信息的其中一项。Step 31: Before the first task obtains system resources, a key lock is obtained. When obtaining the key lock, target identification information is marked for the first task, and the identification time of the first task being marked with the target identification information is recorded, and the target identification information and the identification time of the target identification information are used as one of the parameter information of the first task.
步骤32:在所述第一任务获取到关键锁,且第三任务占用所述系统资源的情况下,等待所述第一任务被唤醒。Step 32: When the first task acquires the critical lock and the third task occupies the system resources, wait for the first task to be awakened.
本实施例中,第一任务获取到关键锁,标志着所述第一任务进入临界区。此时,第三任务占用所述第一任务需要调佣的系统资源,第一任务被堵塞,此时,第一任务处于等待被唤醒的状态。CPU将运行其他任务,其中,其他任务中包含第三任务。In this embodiment, the first task acquires the critical lock, which indicates that the first task enters the critical section. At this time, the third task occupies the system resources that the first task needs to allocate, and the first task is blocked. At this time, the first task is in a state of waiting to be awakened. The CPU will run other tasks, including the third task.
步骤33:在所述第一任务被唤醒的情况下,获取所述第一任务的参数信息;其中,所述第一任务在所述第三任务释放所述系统资源的情况下被唤醒。Step 33: When the first task is awakened, obtain parameter information of the first task; wherein the first task is awakened when the third task releases the system resources.
本实施例中,在第三任务退出运行,释放该系统资源的情况下,第一任务被唤醒。在所述第一任务被唤醒的情况下,获取所述第一任务的参数信息,以判断所述第一任务的参数信息是否满足预设条件。 In this embodiment, when the third task exits and releases the system resources, the first task is awakened. When the first task is awakened, parameter information of the first task is obtained to determine whether the parameter information of the first task meets a preset condition.
步骤34:判断第一任务的参数信息中是否包括目标标识信息,并且第一任务的目标标识信息的标识时长有没有超过预设时长t?Step 34: Determine whether the parameter information of the first task includes target identification information, and whether the identification duration of the target identification information of the first task exceeds the preset duration t?
步骤35:若第一任务的参数信息中包括目标标识信息,并且没有超时,则马上让CPU切换回第一任务运行。Step 35: If the parameter information of the first task includes the target identification information and there is no timeout, the CPU is immediately switched back to the first task.
步骤36:若第一任务的参数信息中不包括目标标识信息,或者第一任务的参数信息中包括目标标识信息,但是标识时长已经超时,则根据当前是否有其他高优先级的任务需要运行,判断是否切换到其他任务运行。Step 36: If the parameter information of the first task does not include the target identification information, or the parameter information of the first task includes the target identification information but the identification duration has timed out, determine whether to switch to other tasks based on whether there are other high-priority tasks that need to be run.
步骤37:在其他高优先级的任务退出运行后,CPU切换回第一任务运行。Step 37: After other high-priority tasks exit execution, the CPU switches back to the first task.
步骤38:第一任务释放关键锁,标志着第一任务退出临界区。Step 38: The first task releases the critical lock, indicating that the first task exits the critical section.
步骤39:清除第一任务的目标标识信息。Step 39: Clear the target identification information of the first task.
本实施例中,在第一任务被阻塞的情况下,主动让出CPU,当前CPU将运行第三任务。在第三任务退出运行,第一任务被唤醒。在第一任务被唤醒的情况下,判断所述第一任务的参数信息是否满足预设条件。若第一任务的参数信息中包括目标标识信息,且没有超时的情况下,马上让当前CPU切换回运行第一任务,从而避免因高优先级的任务被堵塞而无法运行其他任务的问题,还可提高系统运行速度。In this embodiment, when the first task is blocked, the CPU is actively released, and the current CPU will run the third task. When the third task exits, the first task is awakened. When the first task is awakened, it is determined whether the parameter information of the first task meets the preset conditions. If the parameter information of the first task includes the target identification information and there is no timeout, the current CPU is immediately switched back to run the first task, thereby avoiding the problem that other tasks cannot be run due to the blocking of high-priority tasks, and the system operation speed can also be improved.
<例子3><Example 3>
图4为根据本发明又一个例子的任务调度方法的示意图,该例子针对系统的周期性超时检测,以判断任务是否存在运行异常的情况。FIG. 4 is a schematic diagram of a task scheduling method according to another example of the present invention, in which the example is aimed at periodic timeout detection of the system to determine whether there is an abnormality in the operation of the task.
根据图4所示,该例子中,任务调度方法的具体步骤可以包括:As shown in FIG4 , in this example, the specific steps of the task scheduling method may include:
步骤41:发生Tick中断。Step 41: Tick interrupt occurs.
步骤42:Tick中断时,检查第一任务是否为包括目标标识信息的特殊任务,而且目标标识信息的标识时长是否超过预设时长t。Step 42: When the Tick is interrupted, check whether the first task is a special task including target identification information, and whether the identification duration of the target identification information exceeds a preset duration t.
步骤43:若第一任务为包括目标标识信息的特殊任务,而且其标识时长超过预设时长t,则清除第一任务的目标标识信息,也就是允许CPU运行其他任务。Step 43: If the first task is a special task including target identification information, and its identification duration exceeds the preset duration t, then the target identification information of the first task is cleared, that is, the CPU is allowed to run other tasks.
步骤44:若第一任务不是特殊任务,或者,第一任务是包括目标标识信 息的特殊任务,但是其标识时长超过预设时长t,则退出Tick超时判断。Step 44: If the first task is not a special task, or the first task includes a target identification signal If the special task of the message exceeds the preset time t, the Tick timeout judgment is exited.
本实施例中,可以利用Tick中断对系统中带有目标标识信息的任务进行超时检测,如果检查到目标标识信息的标识时长超过预设时长,说明该任务长时间抢占CPU,可能出现运行异常,陷入了死循环,此种情况下,清除该任务的目标标识信息,以使该任务重新开始排队。因该任务重新排队后的优先级较低,会排在比较后面,系统可以运行其他任务。如此,可以避免因任务运行出现异常而导致其他任务无法运行的问题,提高了系统运行的速度。In this embodiment, the Tick interrupt can be used to perform timeout detection on the task with target identification information in the system. If it is detected that the identification duration of the target identification information exceeds the preset duration, it means that the task has occupied the CPU for a long time, and there may be an operation abnormality, and it has fallen into an infinite loop. In this case, the target identification information of the task is cleared to allow the task to be queued again. Because the priority of the task after requeuing is lower, it will be ranked later, and the system can run other tasks. In this way, the problem of other tasks being unable to run due to abnormal task operation can be avoided, and the speed of system operation is improved.
本申请实施例提供的任务调度方法,执行主体可以为任务调度装置。本申请实施例中以任务调度装置执行任务调度的方法为例,说明本申请实施例提供的任务调度装置。The task scheduling method provided in the embodiment of the present application can be performed by a task scheduling device. In the embodiment of the present application, the task scheduling device provided in the embodiment of the present application is described by taking the method for performing task scheduling by the task scheduling device as an example.
如图5所示,为本申请实施例提供的一种任务调度装置500,该装置500包括:As shown in FIG5 , a task scheduling device 500 is provided in an embodiment of the present application. The device 500 includes:
获取模块501,用于在第一任务获取到关键锁的情况下,获取所述第一任务的参数信息;An acquisition module 501 is used to acquire parameter information of the first task when the first task acquires the key lock;
控制模块502,用于在所述参数信息满足预设条件的情况下,运行所述第一任务,其中,所述参数信息满足预设条件包括:所述参数信息中包括目标标识信息。The control module 502 is used to execute the first task when the parameter information meets a preset condition, wherein the parameter information meets the preset condition includes: the parameter information includes target identification information.
根据本申请实施例,通过设置关键锁,可以保证同一时间只存在一个任务获取关键锁,从而可以在多个任务同时运行时,通过获取关键锁的时间排序运行该多个任务,避免系统拥堵的问题。通过在第一任务获取到关键锁的情况下,获取所述第一任务的参数信息,在所述参数信息满足预设条件的情况下,运行所述第一任务,可以优先运行带有目标标识信息的第一任务,从而缩短第一任务等待运行的时间,避免相关技术中优先级反转造成系统卡顿的问题。According to the embodiment of the present application, by setting a key lock, it can be ensured that only one task obtains the key lock at the same time, so that when multiple tasks are running at the same time, the multiple tasks can be run in order of the time of obtaining the key lock, thereby avoiding the problem of system congestion. By obtaining the parameter information of the first task when the first task obtains the key lock, and running the first task when the parameter information meets the preset conditions, the first task with the target identification information can be run first, thereby shortening the waiting time for the first task to run, and avoiding the problem of system jams caused by priority inversion in the related art.
在一个实施例中,在所述参数信息中包括目标标识信息的情况下,所述参数信息满足预设条件还包括:所述目标标识信息的标识时长小于或者等于预设时长。 In an embodiment, when the parameter information includes target identification information, the parameter information satisfying the preset condition further includes: the identification duration of the target identification information is less than or equal to the preset duration.
根据本申请实施例,通过在所述参数信息中包括目标标识信息的情况下,所述参数信息满足预设条件还包括:所述目标标识信息的标识时长小于或者等于预设时长,可以避免因特殊任务长时间运行而影响其他任务的运行,进而影响系统的运行速度,降低用户体验。According to an embodiment of the present application, by including target identification information in the parameter information, the parameter information satisfies the preset condition and also includes: the identification duration of the target identification information is less than or equal to the preset duration, thereby avoiding the impact of long-term running of a special task on the running of other tasks, thereby affecting the running speed of the system and reducing the user experience.
在一个实施例中,所述控制模块502还用于在所述参数信息不满足所述预设条件,且存在优先级高于所述第一任务的第二任务的情况下,运行所述第二任务;其中,所述参数信息不满足所述预设条件包括以下其中一项:所述参数信息中不包括所述目标标识信息、所述参数信息中包括所述目标标识信息但所述目标标识信息的标识时长大于所述预设时长;In one embodiment, the control module 502 is further configured to run the second task if the parameter information does not meet the preset condition and there is a second task with a higher priority than the first task; wherein the parameter information does not meet the preset condition includes one of the following: the parameter information does not include the target identification information, the parameter information includes the target identification information but the identification duration of the target identification information is greater than the preset duration;
在所述第二任务退出运行之后,运行所述第一任务。After the second task exits execution, the first task is executed.
根据本申请实施例,在所述第一任务的参数信息不满足所述设定条件,且存在优先级高于所述第一任务的第二任务的情况下,运行所述第二任务,在所述第二任务退出运行之后,运行所述第一任务,可以避免多任务运行冲突导致系统卡顿的问题。According to an embodiment of the present application, when the parameter information of the first task does not meet the set conditions and there is a second task with a higher priority than the first task, the second task is run, and after the second task exits, the first task is run, which can avoid the problem of system freeze caused by multi-task running conflicts.
在一个实施例中,所述装置还包括:清除模块503,In one embodiment, the device further includes: a clearing module 503,
所述清除模块503用于在所述第一任务释放所述关键锁之后,清除所述第一任务的所述参数信息。The clearing module 503 is used to clear the parameter information of the first task after the first task releases the critical lock.
根据本申请实施例,在所述第一任务释放所述关键锁之后,清除所述第一任务的所述参数信息,从而可以避免在运行完带有目标标识信息的任务后,该目标标识信息影响其他任务的正常运行。According to an embodiment of the present application, after the first task releases the critical lock, the parameter information of the first task is cleared, thereby preventing the target identification information from affecting the normal operation of other tasks after the task with the target identification information is run.
在一个实施例中,所述获取模块501具体用于在所述第一任务获取到关键锁,且所述第一任务占用系统资源的情况下,获取所述第一任务的参数信息;In one embodiment, the acquisition module 501 is specifically used to acquire parameter information of the first task when the first task acquires a critical lock and the first task occupies system resources;
或者,所述获取模块501具体用于在所述第一任务获取到关键锁,且第三任务占用所述系统资源的情况下,等待所述第一任务被唤醒,并在所述第一任务被唤醒的情况下,获取所述第一任务的参数信息;其中,所述第一任务在所述第三任务释放所述系统资源的情况下被唤醒。 Alternatively, the acquisition module 501 is specifically used to wait for the first task to be awakened when the first task acquires the critical lock and the third task occupies the system resources, and to obtain parameter information of the first task when the first task is awakened; wherein the first task is awakened when the third task releases the system resources.
根据本申请实施例,通过设置触发获取所述第一任务的参数信息的条件,可以提高系统运行速度,降低系统功耗。并且在第一任务被堵塞的情况下,先运行其他任务,在所述第三任务释放所述系统资源的情况下唤醒所述第一任务,获取所述第一任务的参数信息,还可避免因优先级高的任务被堵塞而无法运行其他优先级低的任务的问题,提高系统运行速度。According to the embodiment of the present application, by setting the conditions for triggering the acquisition of the parameter information of the first task, the system operation speed can be improved and the system power consumption can be reduced. In addition, when the first task is blocked, other tasks are run first, and when the third task releases the system resources, the first task is awakened to obtain the parameter information of the first task, which can also avoid the problem that other low-priority tasks cannot be run due to the blocking of high-priority tasks, thereby improving the system operation speed.
在一个实施例中,所述获取模块501用于在发生设定事件,且所述第一任务的所述参数信息中包括所述目标标识信息的情况下,获取所述目标标识信息的标识时长;In one embodiment, the acquisition module 501 is used to acquire the identification duration of the target identification information when a setting event occurs and the parameter information of the first task includes the target identification information;
所述清除模块503用于在所述目标标识信息的标识时长大于所述预设时长的情况下,清除所述第一任务的所述参数信息中的所述目标标识信息。The clearing module 503 is used to clear the target identification information in the parameter information of the first task when the identification duration of the target identification information is greater than the preset duration.
根据本申请实施例,通过在发生设定事件,且所述第一任务的所述参数信息中包括所述目标标识信息的情况下,获取所述目标标识信息的标识时长;在所述目标标识信息的标识时长大于所述预设时长的情况下,清除所述第一任务的所述参数信息中的所述目标标识信息,可以避免因任务运行异常而导致其他任务无法运行的问题,提高了系统运行的速度。According to an embodiment of the present application, when a set event occurs and the parameter information of the first task includes the target identification information, the identification duration of the target identification information is obtained; when the identification duration of the target identification information is greater than the preset duration, the target identification information in the parameter information of the first task is cleared, thereby avoiding the problem of other tasks being unable to run due to abnormal task operation, thereby improving the speed of system operation.
本申请实施例中的任务调度装置可以是电子设备,也可以是电子设备中的部件,例如集成电路或芯片。该电子设备可以是终端,也可以为除终端之外的其他设备。示例性的,电子设备可以为手机、平板电脑、笔记本电脑、掌上电脑、车载电子设备、移动上网装置(Mobile Internet Device,MID)、增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR)设备、机器人、可穿戴设备、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本或者个人数字助理(personal digital assistant,PDA)等,还可以为服务器、网络附属存储器(Network Attached Storage,NAS)、个人计算机(personal computer,PC)、电视机(television,TV)、柜员机或者自助机等,本申请实施例不作具体限定。The task scheduling device in the embodiment of the present application can be an electronic device or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR)/virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc. It can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present application is not specifically limited.
本申请实施例中的任务调度装置可以为具有操作系统的装置。该操作系统可以为安卓(Android)操作系统,可以为ios操作系统,还可以为其他可 能的操作系统,本申请实施例不作具体限定。The task scheduling device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other operating systems. The operating system capable of the present invention is not specifically limited in the embodiments of the present application.
本申请实施例提供的任务调度装置能够实现图1至图4的方法实施例实现的各个过程,为避免重复,这里不再赘述。The task scheduling device provided in the embodiment of the present application can implement each process implemented by the method embodiments of Figures 1 to 4. To avoid repetition, they will not be described here.
可选地,如图6所示,本申请实施例还提供一种电子设备600,包括处理器601和存储器602,存储器602上存储有可在所述处理器601上运行的程序或指令,该程序或指令被处理器601执行时实现上述任务调度方法实施例的各个步骤,且能达到相同的技术效果,为避免重复,这里不再赘述。Optionally, as shown in Figure 6, an embodiment of the present application also provides an electronic device 600, including a processor 601 and a memory 602, and the memory 602 stores a program or instruction that can be executed on the processor 601. When the program or instruction is executed by the processor 601, the various steps of the above-mentioned task scheduling method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
需要说明的是,本申请实施例中的电子设备包括上述所述的移动电子设备和非移动电子设备。It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
图7为实现本申请实施例的一种电子设备的硬件结构示意图。FIG. 7 is a schematic diagram of the hardware structure of an electronic device implementing an embodiment of the present application.
该电子设备1000包括但不限于:射频单元1001、网络模块1002、音频输出单元1003、输入单元1004、传感器1005、显示单元1006、用户输入单元1007、接口单元1008、存储器1009、以及处理器1010等部件。The electronic device 1000 includes but is not limited to: a radio frequency unit 1001, a network module 1002, an audio output unit 1003, an input unit 1004, a sensor 1005, a display unit 1006, a user input unit 1007, an interface unit 1008, a memory 1009, and a processor 1010 and other components.
本领域技术人员可以理解,电子设备1000还可以包括给各个部件供电的电源(比如电池),电源可以通过电源管理系统与处理器1010逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。图7中示出的电子设备结构并不构成对电子设备的限定,电子设备可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置,在此不再赘述。Those skilled in the art can understand that the electronic device 1000 can also include a power source (such as a battery) for supplying power to each component, and the power source can be logically connected to the processor 1010 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The electronic device structure shown in FIG7 does not constitute a limitation on the electronic device, and the electronic device can include more or fewer components than shown in the figure, or combine certain components, or arrange components differently, which will not be described in detail here.
其中,处理器1010,用于在第一任务获取到关键锁的情况下,获取所述第一任务的参数信息;在所述参数信息满足预设条件的情况下,运行所述第一任务,其中,所述参数信息满足预设条件包括:所述参数信息中包括目标标识信息。Among them, the processor 1010 is used to obtain parameter information of the first task when the first task obtains the key lock; and run the first task when the parameter information meets the preset conditions, wherein the parameter information meets the preset conditions including: the parameter information includes target identification information.
根据本申请实施例,通过设置关键锁,可以保证同一时间只存在一个任务获取关键锁,从而可以在多个任务同时运行时,通过获取关键锁的时间排序运行该多个任务,避免系统拥堵的问题。通过在第一任务获取到关键锁的情况下,获取所述第一任务的参数信息,在所述参数信息满足预设条件的情况下,运行所述第一任务,可以优先运行带有目标标识信息的第一任务,从 而缩短第一任务等待运行的时间,避免相关技术中优先级反转造成系统卡顿的问题。According to the embodiment of the present application, by setting a key lock, it can be ensured that only one task obtains the key lock at the same time, so that when multiple tasks are running at the same time, the multiple tasks can be run in order of the time of obtaining the key lock, thereby avoiding the problem of system congestion. By obtaining the parameter information of the first task when the first task obtains the key lock, and running the first task when the parameter information meets the preset conditions, the first task with the target identification information can be run first, thereby avoiding the problem of system congestion. This shortens the waiting time for the first task to run and avoids the problem of system freeze caused by priority inversion in related technologies.
可选地,在所述参数信息中包括目标标识信息的情况下,所述参数信息满足预设条件还包括:所述目标标识信息的标识时长小于或者等于预设时长。Optionally, in a case where the parameter information includes target identification information, the parameter information satisfying a preset condition further includes: an identification duration of the target identification information being less than or equal to a preset duration.
根据本申请实施例,通过在所述参数信息中包括目标标识信息的情况下,所述参数信息满足预设条件还包括:所述目标标识信息的标识时长小于或者等于预设时长,可以避免因特殊任务长时间运行而影响其他任务的运行,进而影响系统的运行速度,降低用户体验。According to an embodiment of the present application, by including target identification information in the parameter information, the parameter information satisfies the preset condition and also includes: the identification duration of the target identification information is less than or equal to the preset duration, which can avoid the long-term running of a special task affecting the running of other tasks, thereby affecting the running speed of the system and reducing the user experience.
可选地,处理器1010还用于在所述参数信息不满足所述预设条件,且存在优先级高于所述第一任务的第二任务的情况下,运行所述第二任务;其中,所述参数信息不满足所述预设条件包括以下其中一项:所述参数信息中不包括所述目标标识信息、所述参数信息中包括所述目标标识信息但所述目标标识信息的标识时长大于所述预设时长;在所述第二任务退出运行之后,运行所述第一任务。Optionally, the processor 1010 is also used to run the second task if the parameter information does not meet the preset condition and there is a second task with a higher priority than the first task; wherein the parameter information does not meet the preset condition includes one of the following: the parameter information does not include the target identification information, the parameter information includes the target identification information but the identification duration of the target identification information is greater than the preset duration; after the second task exits running, the first task is run.
根据本申请实施例,在所述第一任务的参数信息不满足所述设定条件,且存在优先级高于所述第一任务的第二任务的情况下,运行所述第二任务,在所述第二任务退出运行之后,运行所述第一任务,可以避免多任务运行冲突导致系统卡顿的问题。According to an embodiment of the present application, when the parameter information of the first task does not meet the set conditions and there is a second task with a higher priority than the first task, the second task is run, and after the second task exits, the first task is run, which can avoid the problem of system freeze caused by multi-task running conflicts.
可选地,处理器1010用于在所述第一任务释放所述关键锁之后,清除所述第一任务的所述参数信息。Optionally, the processor 1010 is configured to clear the parameter information of the first task after the first task releases the critical lock.
根据本申请实施例,在所述第一任务释放所述关键锁之后,清除所述第一任务的所述参数信息,从而可以避免在运行完带有目标标识信息的任务后,该目标标识信息影响其他任务的正常运行。According to an embodiment of the present application, after the first task releases the critical lock, the parameter information of the first task is cleared, thereby preventing the target identification information from affecting the normal operation of other tasks after the task with the target identification information is run.
可选地,处理器1010用于在所述第一任务获取到关键锁,且所述第一任务占用系统资源的情况下,获取所述第一任务的参数信息;或者,在所述第一任务获取到关键锁,且第三任务占用所述系统资源的情况下,等待所述第一任务被唤醒,并在所述第一任务被唤醒的情况下,获取所述第一任务的参 数信息;其中,所述第一任务在所述第三任务释放所述系统资源的情况下被唤醒。Optionally, the processor 1010 is configured to, when the first task acquires the critical lock and the first task occupies system resources, acquire parameter information of the first task; or, when the first task acquires the critical lock and the third task occupies the system resources, wait for the first task to be awakened, and when the first task is awakened, acquire parameter information of the first task. wherein, the first task is awakened when the third task releases the system resources.
根据本申请实施例,通过设置触发获取所述第一任务的参数信息的条件,可以提高系统运行速度,降低系统功耗。并且在第一任务被堵塞的情况下,先运行其他任务,在所述第三任务释放所述系统资源的情况下唤醒所述第一任务,获取所述第一任务的参数信息,还可避免因优先级高的任务被堵塞而无法运行其他优先级低的任务的问题,提高系统运行速度。According to the embodiment of the present application, by setting the conditions for triggering the acquisition of the parameter information of the first task, the system operation speed can be improved and the system power consumption can be reduced. In addition, when the first task is blocked, other tasks are run first, and when the third task releases the system resources, the first task is awakened to obtain the parameter information of the first task, which can also avoid the problem that other low-priority tasks cannot be run due to the blocking of high-priority tasks, thereby improving the system operation speed.
可选地,处理器1010用于在发生设定事件,且所述第一任务的所述参数信息中包括所述目标标识信息的情况下,获取所述目标标识信息的标识时长;在所述目标标识信息的标识时长大于所述预设时长的情况下,清除所述第一任务的所述参数信息中的所述目标标识信息。Optionally, the processor 1010 is used to obtain the identification duration of the target identification information when a set event occurs and the parameter information of the first task includes the target identification information; and to clear the target identification information in the parameter information of the first task when the identification duration of the target identification information is greater than the preset duration.
根据本申请实施例,通过在发生设定事件,且所述第一任务的所述参数信息中包括所述目标标识信息的情况下,获取所述目标标识信息的标识时长;在所述目标标识信息的标识时长大于所述预设时长的情况下,清除所述第一任务的所述参数信息中的所述目标标识信息,可以避免因任务运行异常而导致其他任务无法运行的问题,提高了系统运行的速度。According to an embodiment of the present application, when a set event occurs and the parameter information of the first task includes the target identification information, the identification duration of the target identification information is obtained; when the identification duration of the target identification information is greater than the preset duration, the target identification information in the parameter information of the first task is cleared, thereby avoiding the problem of other tasks being unable to run due to abnormal task operation, thereby improving the speed of system operation.
应理解的是,本申请实施例中,输入单元1004可以包括图形处理器(Graphics Processing Unit,GPU)10041和麦克风10042,图形处理器10041对在视频捕获模式或图像捕获模式中由图像捕获装置(如摄像头)获得的静态图片或视频的图像数据进行处理。显示单元1006可包括显示面板10061,可以采用液晶显示器、有机发光二极管等形式来配置显示面板10061。用户输入单元1007包括触控面板10071以及其他输入设备10072中的至少一种。触控面板10071,也称为触摸屏。触控面板10071可包括触摸检测装置和触摸控制器两个部分。其他输入设备10072可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆,在此不再赘述。It should be understood that in the embodiment of the present application, the input unit 1004 may include a graphics processing unit (GPU) 10041 and a microphone 10042, and the graphics processor 10041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 1006 may include a display panel 10061, and the display panel 10061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1007 includes a touch panel 10071 and at least one of other input devices 10072. The touch panel 10071 is also called a touch screen. The touch panel 10071 may include two parts: a touch detection device and a touch controller. Other input devices 10072 may include, but are not limited to, a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
存储器1009可用于存储软件程序以及各种数据。存储器1009可主要包 括存储程序或指令的第一存储区和存储数据的第二存储区,其中,第一存储区可存储操作系统、至少一个功能所需的应用程序或指令(比如声音播放功能、图像播放功能等)等。此外,存储器1009可以包括易失性存储器或非易失性存储器,或者,存储器1009可以包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(Read-Only Memory,ROM)、可编程只读存储器(Programmable ROM,PROM)、可擦除可编程只读存储器(Erasable PROM,EPROM)、电可擦除可编程只读存储器(Electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(Random Access Memory,RAM),静态随机存取存储器(Static RAM,SRAM)、动态随机存取存储器(Dynamic RAM,DRAM)、同步动态随机存取存储器(Synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(Double Data Rate SDRAM,DDRSDRAM)、增强型同步动态随机存取存储器(Enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(Synch link DRAM,SLDRAM)和直接内存总线随机存取存储器(Direct Rambus RAM,DRRAM)。本申请实施例中的存储器1009包括但不限于这些和任意其它适合类型的存储器。The memory 1009 can be used to store software programs and various data. The memory 1009 can mainly include The memory 1009 includes a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 1009 may include a volatile memory or a non-volatile memory, or the memory 1009 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 1009 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
处理器1010可包括一个或多个处理单元;可选的,处理器1010集成应用处理器和调制解调处理器,其中,应用处理器主要处理涉及操作系统、用户界面和应用程序等的操作,调制解调处理器主要处理无线通信信号,如基带处理器。可以理解的是,上述调制解调处理器也可以不集成到处理器1010中。The processor 1010 may include one or more processing units; optionally, the processor 1010 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 1010.
本申请实施例还提供一种可读存储介质,所述可读存储介质上存储有程序或指令,该程序或指令被处理器执行时实现上述任务调度方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned task scheduling method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
其中,所述处理器为上述实施例中所述的电子设备中的处理器。所述可读存储介质,包括计算机可读存储介质,如计算机只读存储器ROM、随机存取存储器RAM、磁碟或者光盘等。The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
本申请实施例另提供了一种芯片,所述芯片包括处理器和通信接口,所 述通信接口和所述处理器耦合,所述处理器用于运行程序或指令,实现上述任务调度方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。The present application embodiment further provides a chip, the chip comprising a processor and a communication interface. The communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned task scheduling method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
应理解,本申请实施例提到的芯片还可以称为系统级芯片、系统芯片、芯片系统或片上系统芯片等。It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
本申请实施例提供一种计算机程序产品,该程序产品被存储在存储介质中,该程序产品被至少一个处理器执行以实现如上述任务调度方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned task scheduling method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。此外,需要指出的是,本申请实施方式中的方法和装置的范围不限按示出或讨论的顺序来执行功能,还可包括根据所涉及的功能按基本同时的方式或按相反的顺序来执行功能,例如,可以按不同于所描述的次序来执行所描述的方法,并且还可以添加、省去、或组合各种步骤。另外,参照某些示例所描述的特征可在其他示例中被组合。It should be noted that, in this article, the terms "comprise", "include" 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, an element defined by the sentence "comprises one..." does not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be noted that the scope of the method and device in the embodiment of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
通过以上的实施方式的描述,本领域的技术人员可以清除地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以计算机软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端(可以是手机,计算机,服务器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM/RAM, a disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
上面结合附图对本申请的实施例进行了描述,但是本申请并不局限于上述的具体实施方式,上述的具体实施方式仅仅是示意性的,而不是限制性的, 本领域的普通技术人员在本申请的启示下,在不脱离本申请宗旨和权利要求所保护的范围情况下,还可做出很多形式,均属于本申请的保护之内。 The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above specific implementations, which are merely illustrative and not restrictive. Under the enlightenment of this application, ordinary technicians in this field can make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.

Claims (16)

  1. 一种任务调度方法,其中,所述方法包括:A task scheduling method, wherein the method comprises:
    在第一任务获取到关键锁的情况下,获取所述第一任务的参数信息;When the first task obtains the key lock, obtaining parameter information of the first task;
    在所述参数信息满足预设条件的情况下,运行所述第一任务,其中,所述参数信息满足预设条件包括:所述参数信息中包括目标标识信息。In a case where the parameter information meets a preset condition, the first task is executed, wherein the parameter information meeting the preset condition includes: the parameter information includes target identification information.
  2. 根据权利要求1所述的方法,其中,在所述参数信息中包括目标标识信息的情况下,所述参数信息满足预设条件还包括:所述目标标识信息的标识时长小于或者等于预设时长。According to the method according to claim 1, wherein, in the case where the parameter information includes target identification information, the parameter information satisfies the preset condition and further comprises: the identification duration of the target identification information is less than or equal to the preset duration.
  3. 根据权利要求2所述的方法,其中,所述获取所述第一任务的参数信息之后,所述方法还包括:The method according to claim 2, wherein after obtaining the parameter information of the first task, the method further comprises:
    在所述参数信息不满足所述预设条件,且存在优先级高于所述第一任务的第二任务的情况下,运行所述第二任务;其中,所述参数信息不满足所述预设条件包括以下其中一项:所述参数信息中不包括所述目标标识信息、所述参数信息中包括所述目标标识信息但所述目标标识信息的标识时长大于所述预设时长;If the parameter information does not satisfy the preset condition and there is a second task with a higher priority than the first task, run the second task; wherein the parameter information does not satisfy the preset condition includes one of the following: the parameter information does not include the target identification information, the parameter information includes the target identification information but the identification duration of the target identification information is greater than the preset duration;
    在所述第二任务退出运行之后,运行所述第一任务。After the second task exits execution, the first task is executed.
  4. 根据权利要求1至3中任一项所述的方法,其中,所述运行所述第一任务之后,所述方法还包括:The method according to any one of claims 1 to 3, wherein after executing the first task, the method further comprises:
    在所述第一任务释放所述关键锁之后,清除所述第一任务的所述参数信息。After the first task releases the critical lock, the parameter information of the first task is cleared.
  5. 根据权利要求1至3中任一项所述的方法,其中,所述在第一任务获取到关键锁的情况下,获取所述第一任务的参数信息,包括:The method according to any one of claims 1 to 3, wherein, when the first task obtains the critical lock, obtaining parameter information of the first task comprises:
    在所述第一任务获取到关键锁,且所述第一任务占用系统资源的情况下, 获取所述第一任务的参数信息;When the first task acquires the critical lock and the first task occupies system resources, Obtaining parameter information of the first task;
    或者,在所述第一任务获取到关键锁,且第三任务占用所述系统资源的情况下,等待所述第一任务被唤醒,并在所述第一任务被唤醒的情况下,获取所述第一任务的参数信息;其中,所述第一任务在所述第三任务释放所述系统资源的情况下被唤醒。Alternatively, when the first task obtains the critical lock and the third task occupies the system resources, wait for the first task to be awakened, and when the first task is awakened, obtain parameter information of the first task; wherein the first task is awakened when the third task releases the system resources.
  6. 根据权利要求1所述的方法,其中,所述获取所述第一任务的参数信息之后,所述方法还包括:The method according to claim 1, wherein after obtaining the parameter information of the first task, the method further comprises:
    在发生设定事件,且所述第一任务的所述参数信息中包括所述目标标识信息的情况下,获取所述目标标识信息的标识时长;When a setting event occurs and the parameter information of the first task includes the target identification information, obtaining the identification duration of the target identification information;
    在所述目标标识信息的标识时长大于所述预设时长的情况下,清除所述第一任务的所述参数信息中的所述目标标识信息。When the identification duration of the target identification information is greater than the preset duration, the target identification information in the parameter information of the first task is cleared.
  7. 一种任务调度装置,其中,所述装置包括:A task scheduling device, wherein the device comprises:
    获取模块,用于在第一任务获取到关键锁的情况下,获取所述第一任务的参数信息;An acquisition module, configured to acquire parameter information of the first task when the first task acquires the key lock;
    控制模块,用于在所述参数信息满足预设条件的情况下,运行所述第一任务,其中,所述参数信息满足预设条件包括:所述参数信息中包括目标标识信息。A control module is used to run the first task when the parameter information meets a preset condition, wherein the parameter information meets the preset condition includes: the parameter information includes target identification information.
  8. 根据权利要求7所述的装置,其中,在所述参数信息中包括目标标识信息的情况下,所述参数信息满足预设条件还包括:所述目标标识信息的标识时长小于或者等于预设时长。The device according to claim 7, wherein, in a case where the parameter information includes target identification information, the parameter information satisfying the preset condition further comprises: an identification duration of the target identification information is less than or equal to a preset duration.
  9. 根据权利要求8所述的装置,其中,所述控制模块还用于在所述参数信息不满足所述预设条件,且存在优先级高于所述第一任务的第二任务的情况下,运行所述第二任务;其中,所述参数信息不满足所述预设条件包括以 下其中一项:所述参数信息中不包括所述目标标识信息、所述参数信息中包括所述目标标识信息但所述目标标识信息的标识时长大于所述预设时长;The device according to claim 8, wherein the control module is further configured to run the second task if the parameter information does not meet the preset condition and there is a second task with a higher priority than the first task; wherein the parameter information does not meet the preset condition includes: One of the following: the parameter information does not include the target identification information, the parameter information includes the target identification information but the identification duration of the target identification information is greater than the preset duration;
    在所述第二任务退出运行之后,运行所述第一任务。After the second task exits execution, the first task is executed.
  10. 根据权利要求7至9任一项所述的装置,其中,所述装置还包括:清除模块,The device according to any one of claims 7 to 9, wherein the device further comprises: a clearing module,
    所述清除模块用于在所述第一任务释放所述关键锁之后,清除所述第一任务的所述参数信息。The clearing module is used to clear the parameter information of the first task after the first task releases the critical lock.
  11. 根据权利要求7至9任一项所述的装置,其中,所述获取模块具体用于在所述第一任务获取到关键锁,且所述第一任务占用系统资源的情况下,获取所述第一任务的参数信息;The device according to any one of claims 7 to 9, wherein the acquisition module is specifically configured to acquire parameter information of the first task when the first task acquires a critical lock and the first task occupies system resources;
    或者,所述获取模块具体用于在所述第一任务获取到关键锁,且第三任务占用所述系统资源的情况下,等待所述第一任务被唤醒,并在所述第一任务被唤醒的情况下,获取所述第一任务的参数信息;其中,所述第一任务在所述第三任务释放所述系统资源的情况下被唤醒。Alternatively, the acquisition module is specifically used to wait for the first task to be awakened when the first task acquires the critical lock and the third task occupies the system resources, and to obtain parameter information of the first task when the first task is awakened; wherein the first task is awakened when the third task releases the system resources.
  12. 根据权利要求7所述的装置,其中,所述获取模块用于在发生设定事件,且所述第一任务的所述参数信息中包括所述目标标识信息的情况下,获取所述目标标识信息的标识时长;The device according to claim 7, wherein the acquisition module is used to acquire the identification duration of the target identification information when a set event occurs and the parameter information of the first task includes the target identification information;
    所述装置还包括:清除模块,所述清除模块用于在所述目标标识信息的标识时长大于所述预设时长的情况下,清除所述第一任务的所述参数信息中的所述目标标识信息。The device further includes: a clearing module, configured to clear the target identification information in the parameter information of the first task when the identification duration of the target identification information is greater than the preset duration.
  13. 一种电子设备,其中,包括处理器和存储器,所述存储器存储可在所述处理器上运行的程序或指令,所述程序或指令被所述处理器执行时实现如权利要求1-6任一项所述的任务调度方法的步骤。 An electronic device, comprising a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the task scheduling method according to any one of claims 1 to 6 are implemented.
  14. 一种可读存储介质,其中,所述可读存储介质上存储程序或指令,所述程序或指令被处理器执行时实现如权利要求1-6任一项所述的任务调度方法的步骤。A readable storage medium, wherein the readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the task scheduling method according to any one of claims 1 to 6 are implemented.
  15. 一种芯片,其中,所述芯片包括处理器和通信接口,所述通信接口和所述处理器耦合,所述处理器用于运行程序或指令,实现如权利要求1-6任一项所述的任务调度方法的步骤。A chip, wherein the chip includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the steps of the task scheduling method according to any one of claims 1 to 6.
  16. 一种计算机程序产品,其中,所述计算机程序产品被存储在存储介质中,所述计算机程序产品被至少一个处理器执行以实现如权利要求1-6任一项所述的任务调度方法的步骤。 A computer program product, wherein the computer program product is stored in a storage medium, and the computer program product is executed by at least one processor to implement the steps of the task scheduling method according to any one of claims 1 to 6.
PCT/CN2024/074173 2023-01-30 2024-01-26 Task scheduling method and apparatus, and electronic device WO2024160136A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202310067875.2A CN115964180A (en) 2023-01-30 2023-01-30 Task scheduling method and device and electronic equipment
CN202310067875.2 2023-01-30

Publications (1)

Publication Number Publication Date
WO2024160136A1 true WO2024160136A1 (en) 2024-08-08

Family

ID=87359964

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2024/074173 WO2024160136A1 (en) 2023-01-30 2024-01-26 Task scheduling method and apparatus, and electronic device

Country Status (2)

Country Link
CN (1) CN115964180A (en)
WO (1) WO2024160136A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115964180A (en) * 2023-01-30 2023-04-14 维沃移动通信有限公司 Task scheduling method and device and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110046034A (en) * 2018-01-15 2019-07-23 北京国双科技有限公司 Task acquisition methods and device
CN110275766A (en) * 2019-06-25 2019-09-24 深圳前海微众银行股份有限公司 A kind of task processing method and device
CN114327894A (en) * 2021-12-29 2022-04-12 中国光大银行股份有限公司 Resource allocation method, device, electronic equipment and storage medium
CN115061800A (en) * 2022-06-30 2022-09-16 中国联合网络通信集团有限公司 Edge computing task processing method, edge server and storage medium
CN115964180A (en) * 2023-01-30 2023-04-14 维沃移动通信有限公司 Task scheduling method and device and electronic equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110046034A (en) * 2018-01-15 2019-07-23 北京国双科技有限公司 Task acquisition methods and device
CN110275766A (en) * 2019-06-25 2019-09-24 深圳前海微众银行股份有限公司 A kind of task processing method and device
CN114327894A (en) * 2021-12-29 2022-04-12 中国光大银行股份有限公司 Resource allocation method, device, electronic equipment and storage medium
CN115061800A (en) * 2022-06-30 2022-09-16 中国联合网络通信集团有限公司 Edge computing task processing method, edge server and storage medium
CN115964180A (en) * 2023-01-30 2023-04-14 维沃移动通信有限公司 Task scheduling method and device and electronic equipment

Also Published As

Publication number Publication date
CN115964180A (en) 2023-04-14

Similar Documents

Publication Publication Date Title
US10628216B2 (en) I/O request scheduling method and apparatus by adjusting queue depth associated with storage device based on hige or low priority status
CA2795489C (en) Opportunistic multitasking
US11283724B2 (en) Broadcast message management method and apparatus
WO2024160136A1 (en) Task scheduling method and apparatus, and electronic device
TWI512619B (en) Method and system for thread scheduling
CN107615250B (en) Application-oriented processing method and device and intelligent terminal
WO2024160154A1 (en) Cpu scheduling method and apparatus, electronic device, and readable storage medium
CN112231077B (en) Application scheduling method and electronic equipment
WO2023130866A1 (en) Method and apparatus for switching operating system, and electronic device and storage medium
JP5299869B2 (en) Computer micro job
CN106484536B (en) IO scheduling method, device and equipment
EP3614633B1 (en) Scheduling method and terminal
CN114546910A (en) Access control method, device, storage medium and electronic device
CN115033306B (en) Application exit method and device
WO2024055708A1 (en) Task scheduling method and apparatus, and device and medium
US9443109B2 (en) Computing device and method of processing secure services for computing device
CN117971250A (en) Application installation method, device, electronic equipment and readable storage medium
CN118093109A (en) Thread execution method, thread execution device, electronic equipment and medium
CN116737338A (en) Processing method, processing device, processing equipment and storage medium
CN117149391A (en) Thread management method and device and electronic equipment
CN116860412A (en) Thread scheduling method and device and electronic equipment
CN115994032A (en) Cache management method, device, electronic equipment and medium
CN116820747A (en) Resource management and control method and device, electronic equipment and readable storage medium
AU2013205570A1 (en) Opportunistic multitasking

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: 24749617

Country of ref document: EP

Kind code of ref document: A1