[go: up one dir, main page]

WO2024188228A1 - Task processing method and apparatus, and readable storage medium - Google Patents

Task processing method and apparatus, and readable storage medium Download PDF

Info

Publication number
WO2024188228A1
WO2024188228A1 PCT/CN2024/081123 CN2024081123W WO2024188228A1 WO 2024188228 A1 WO2024188228 A1 WO 2024188228A1 CN 2024081123 W CN2024081123 W CN 2024081123W WO 2024188228 A1 WO2024188228 A1 WO 2024188228A1
Authority
WO
WIPO (PCT)
Prior art keywords
task
subtask
executed
processing
indication parameter
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
PCT/CN2024/081123
Other languages
French (fr)
Chinese (zh)
Inventor
薛建成
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Publication of WO2024188228A1 publication Critical patent/WO2024188228A1/en
Anticipated expiration legal-status Critical
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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]
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/48Indexing scheme relating to G06F9/48
    • G06F2209/482Application
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/48Indexing scheme relating to G06F9/48
    • G06F2209/483Multiproc
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/48Indexing scheme relating to G06F9/48
    • G06F2209/485Resource constraint
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5012Processor sets
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5021Priority

Definitions

  • the present application relates to the field of terminal technology, and in particular to a task processing method, device and readable storage medium.
  • Microcontroller Unit also known as single-chip microcomputer, has the advantages of small size, low power consumption and high reliability. It is widely used in industrial control, traffic management and daily life.
  • task processing including task execution and task switching
  • OS operating system
  • task is the basic unit of OS scheduling. Each task will occupy the CPU exclusively during execution.
  • the CPU needs to save the CPU context of the currently executing task to the stack space corresponding to the current task, and then load the CPU context of the new task into the CPU register to run the new task and realize task switching.
  • this method needs to provide corresponding storage resources for each task stack to store the CPU context of the executing task when the task is switched, which increases the storage resource and CPU performance overhead of task processing.
  • the present application provides a task processing method, device and readable storage medium, which to a certain extent solve the problem that the existing task processing methods consume a lot of storage resources and CPU.
  • the present application provides a task processing method, the method comprising:
  • the progress indication information including a first indication parameter corresponding to a first subtask, the first task including a plurality of subtasks, the first subtask being a subtask that has not been executed among the plurality of subtasks;
  • the first indication parameter in the progress indication information is updated to a second indication parameter corresponding to a second subtask, and the second subtask is a next subtask of the first subtask among the multiple subtasks.
  • the above method since after the processing of the first subtask is completed, the above method also updates the first indication parameter in the progress indication information to the second indication parameter corresponding to the second subtask, thus avoiding the need to allocate a separate storage space to the currently executed first task to save the CPU context of the currently executed first task when switching tasks, effectively reducing the dependence of task processing on storage resources, and greatly reducing the consumption of storage resources and CPU.
  • the second task is executed after the first indication parameter is updated.
  • the above task processing method makes the complete processing process of the first subtask include both the process of processing the first subtask using the processing function corresponding to the first subtask and the process of updating the progress indication information according to the execution order of multiple subtasks in the first task after the first subtask is processed by the processing function.
  • Such a design avoids the interruption of the execution of the first subtask due to the influence of other tasks during the execution of the first subtask. By dividing the first task into multiple subtasks, the occurrence rate of exceptions or interruptions during the execution of the first task is reduced.
  • the second subtask is the first subtask among the multiple subtasks.
  • the method before obtaining the progress indication information of the first task, the method further includes:
  • the multiple tasks in the task set are scheduled based on a preset task scheduling strategy.
  • the task scheduling strategy may include: any one of a first-in-first-out scheduling strategy, a priority-based scheduling strategy, and a polling scheduling strategy.
  • the first task is determined from the task set through scheduling strategies such as customization, first-in-first-out scheduling strategy, priority-based scheduling strategy and polling scheduling strategy.
  • scheduling strategies such as customization, first-in-first-out scheduling strategy, priority-based scheduling strategy and polling scheduling strategy. This not only meets the actual application needs or business scenarios, but also the diverse selection of scheduling strategies effectively ensures the flexibility of selecting task scheduling strategies between different tasks.
  • the plurality of subtasks in the first task are implemented by way of a state machine or an iterator.
  • a modular approach (such as state machine or iterator methods) can be used to develop and design the first task, thereby increasing programming flexibility and reducing the difficulty of task programming; when the actual business scenario changes, the established program framework of the first task can be used to implement functions corresponding to the new business scenario, thereby improving the reusability of the program and achieving the purpose of improving development and maintenance efficiency.
  • an embodiment of the present application provides a task processing device, the task processing device comprising:
  • an acquiring unit configured to acquire progress indication information of a first task, the progress indication information comprising a first indication parameter corresponding to a first subtask, the first task comprising a plurality of subtasks, the first subtask being a subtask that has not been executed among the plurality of subtasks;
  • a processing unit configured to execute a processing function corresponding to the first subtask according to the first indication parameter
  • An updating unit is used to update the first indication parameter in the progress indication information to a second indication parameter corresponding to a second subtask after the processing function is executed, and the second subtask is a next subtask of the first subtask among the multiple subtasks.
  • the second task is executed after the first indication parameter is updated.
  • the second subtask is the first subtask among the multiple subtasks.
  • the method before obtaining the progress indication information of the first task, the method further includes:
  • the multiple tasks in the task set are scheduled based on a preset task scheduling strategy.
  • the plurality of subtasks in the first task are implemented by way of a state machine or an iterator.
  • the task scheduling strategy includes: any one of a first-in-first-out scheduling strategy, a priority-based scheduling strategy, and a polling scheduling strategy.
  • an embodiment of the present application provides an electronic device, comprising: a processor, wherein the processor is used to run a computer program stored in a memory to implement the method in the first aspect or any possible implementation manner of the first aspect.
  • the present application provides a task processing system, which includes the electronic device described in the third aspect.
  • the present application provides a chip, comprising a processor, wherein the processor is used to read and execute a computer program stored in a memory to execute the method in the first aspect or any possible implementation of the first aspect.
  • the chip also includes a memory, and the memory is connected to the processor via a circuit or wire.
  • the present application provides a computer-readable storage medium, which stores a computer program.
  • the computer program is executed by a processor, the method in the first aspect or any possible implementation manner of the first aspect is implemented.
  • the present application provides a computer program product.
  • the computer program product runs on an electronic device, the electronic device executes the method in the first aspect or any possible implementation manner of the first aspect.
  • FIG1 is a schematic diagram of the structure of an existing task processing method provided in an embodiment of the present application.
  • FIG. 2 is a schematic diagram of the structure of another existing task processing method provided in an embodiment of the present application.
  • FIG3 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
  • FIG4 is a structural block diagram of an MCU embedded system provided in an embodiment of the present application.
  • FIG5 is a flowchart of processing multiple tasks provided in an embodiment of the present application.
  • FIG6 is a flowchart of a task processing method provided in an embodiment of the present application.
  • FIG. 7 is a flow chart of an implementation method corresponding to the task processing method provided in an embodiment of the present application.
  • FIG8 is a schematic diagram of an array structure created in another implementation method corresponding to the task processing method provided in an embodiment of the present application.
  • FIG. 9 is a flow chart of another implementation method corresponding to the task processing method provided in an embodiment of the present application.
  • FIG10 is a structural block diagram of a task processing device corresponding to the task processing method provided in an embodiment of the present application.
  • MCU also known as single-chip microcomputer
  • MCU-based embedded systems are no longer limited to realizing a single function, but need to be able to handle multiple operation flows at the same time.
  • motor-type MCUs need to control motor parameters and maintain communication connection with the host computer in actual use.
  • the processing of multiple workflows by the MCU embedded system may include the execution (or running) of each workflow and the switching between multiple workflows.
  • the scheduling management of multiple tasks can be implemented through the OS.
  • the task is used as the minimum scheduling and running unit of the application, and one task corresponds to an independent task processing function. Referring to Figure 1, it is assumed that multiple tasks include Task 1, Task 2...Task n, each task has a corresponding task control block and attributes, wherein the attributes include number, priority, entry function, stack space, and current stack pointer, etc.
  • the OS is responsible for managing the switching of the central processing unit (CPU) between multiple tasks. If Task 1 is the currently executing task, Task 1 will monopolize the CPU during execution. In some cases (for example, the priority of Task 2 is higher than the priority of Task 1), regardless of whether Task 1 is completed or not, the OS will control the CPU to switch from Task 1 to Task 2 to use the CPU to process Task 2. In the process of CPU switching from Task 1 to Task 2, the CPU context of Task 1 will first be saved in the stack space corresponding to Task 1, so that Task 1 can continue to execute Task 1 when it obtains the CPU again. After the CPU context of Task 1 is saved in the stack space of Task 1, the CPU context of Task 2 is loaded into the CPU register to run Task 2.
  • CPU central processing unit
  • the OS can be used to complete the scheduling and management of multiple tasks, a certain amount of storage space needs to be provided for the task control block and stack of each task during the task switching process, which greatly increases the reliance of task scheduling on storage resources and increases the overhead of storage resources and CPU performance.
  • this method is only applicable to MCUs with a certain amount of storage space or computing frequency capabilities to meet the minimum operating requirements of the OS for scheduling and management. If the MCU does not have a certain amount of storage space or computing frequency capabilities, or cannot meet the practical requirements of the minimum storage space or computing frequency for the OS to schedule and process tasks, the above method cannot be used to achieve the scheduling and management of multiple tasks.
  • the software framework of the super loop system can usually be used to implement task scheduling management through hard coding.
  • the super loop system is a foreground/background system.
  • the super loop system includes a background system and a foreground system.
  • the background system is also called the background system, which processes multiple functions of one or more tasks in an infinite loop through a background program; for example, task 1 may include multiple functions such as function A, function B, function C, and function D; or task 1, task 2, and task 3 include multiple functions such as function A, function B, function C, and function D.
  • the foreground system is also called the foreground system.
  • the foreground system is composed of multiple interrupt service programs.
  • the foreground system may include interrupt service program 1 and interrupt service program 2.
  • the background system will execute task 1 in an infinite loop; if the foreground system triggers interrupt service program 1, at this time, the background system is executing function B of task 1, but function B has not yet been completed, then the function B of task 1 being executed by the background system will be interrupted by interrupt service program 1, and the background system will suspend the continued processing of function B in task 1 until the foreground system completes processing of interrupt service program 1, and the background system will continue to execute function B from where function B was interrupted.
  • the above method does not require the MCU to have a certain storage space or computing frequency capability, the irregular appearance of the interrupt service program will cause the background system to interrupt the task being executed. Moreover, if this method is used to time-share multiple tasks, it is necessary to consider the priority between multiple tasks, the dependencies between multiple tasks, the response time between multiple tasks and other factors. For multiple tasks, the corresponding multiple functions are arranged in the infinite loop body of the background system. Obviously, this method needs to be based on different tasks. When writing corresponding programs, when the business scenario changes, for example, the number of functions in multiple tasks or the priority, dependency, response time and other factors between multiple functions change, it is necessary to rewrite new programs in the infinite loop body to realize the processing between new multiple tasks, etc. The reusability of the program is low. Therefore, the above method increases the complexity of programming and reduces the efficiency of program development and maintenance.
  • the present application provides a task processing method, after executing the processing function corresponding to the first subtask, the first indication parameter in the progress indication information is updated to the second indication parameter corresponding to the next subtask of the first subtask in the multiple subtasks, so that other tasks can be executed after the first subtask of the first task is executed, avoiding the need to allocate a separate storage space to the currently executed first subtask to save the CPU context of the currently executed first subtask when switching tasks, greatly reducing the consumption of storage resources and CPU, and improving the CPU utilization.
  • such a design method can adopt a modular approach (such as state machine or iterator method) to develop and design multiple subtasks or multiple tasks to be executed separately during the implementation process, increase programming flexibility, reduce the difficulty of task programming, improve the reusability of the program, and achieve the purpose of improving development and maintenance efficiency.
  • a modular approach such as state machine or iterator method
  • a and/or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural.
  • the character "/” generally indicates that the associated objects before and after are in a "or" relationship.
  • references to "one embodiment” or “some embodiments” etc. described in this specification mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment.
  • the statements “in one embodiment”, “in some embodiments”, “in some other embodiments”, “in some other embodiments”, etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean “one or more but not all embodiments", unless otherwise specifically emphasized in other ways.
  • the terms “include”, “comprise”, “have” and their variations all mean “including but not limited to”, unless otherwise specifically emphasized in other ways.
  • connection includes direct connection and indirect connection, unless otherwise specified. "First” and “second” are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.
  • the words “exemplarily” or “for example” are used to indicate examples, illustrations or explanations. Any embodiment or design described as “exemplarily” or “for example” in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as “exemplarily” or “for example” is intended to present related concepts in a specific way.
  • the task processing method provided in the embodiment of the present application can be applied to electronic devices.
  • the electronic device can be a mobile phone, a tablet computer, a wearable device, an augmented reality (AR)/virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), a vehicle-mounted device, a smart screen, a cloud server, etc.
  • AR augmented reality
  • VR virtual reality
  • UMPC ultra-mobile personal computer
  • PDA personal digital assistant
  • vehicle-mounted device a smart screen
  • cloud server etc.
  • the embodiment of the present application does not impose any restrictions on the specific type of the electronic device.
  • the electronic device 300 may include a processor 310, an external memory interface 320, an internal memory 331, a Universal Serial Bus (USB) interface 330, a charging management module 340, a power management module 341, a battery 342, an antenna 1, an antenna 2, a mobile communication module 350, a wireless communication module 360, an audio module 370, a speaker 370A, a receiver 370B, a microphone 370C, an earphone interface 370D, a sensor module 380, a button 390, a motor 391, an indicator 392, a camera 393, a display screen 394, and a Subscriber Identification Module (SIM) card interface 395, etc.
  • SIM Subscriber Identification Module
  • the sensor module 380 may include a pressure sensor 380A, a gyroscope sensor 380B, an air pressure sensor 380C, a magnetic sensor 380D, an acceleration sensor 380E, a distance sensor 380F, a proximity light sensor 380G, a fingerprint sensor 380H, a temperature sensor 380J, a touch sensor 380K, an ambient light sensor 380L, a bone conduction sensor 380M, etc.
  • the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 300.
  • the electronic device 300 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently.
  • the components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
  • the electronic device 300 when the electronic device 300 is a mobile phone or a tablet computer, it may include all the components shown in the figure, or may include only some of the components shown in the figure.
  • the processor 310 may include one or more processing units, for example, the processor 310 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and/or a neural-network processing unit (NPU), etc.
  • AP application processor
  • GPU graphics processor
  • ISP image signal processor
  • controller a memory
  • video codec a digital signal processor
  • DSP digital signal processor
  • NPU neural-network processing unit
  • Different processing units may be independent devices or integrated in one or more processors.
  • the controller may be the nerve center and command center of the electronic device 300.
  • the controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
  • the processor 310 may also be provided with a memory for storing instructions and data.
  • the memory in the processor 310 is a cache memory.
  • the memory may store instructions or data that the processor 310 has just used or cyclically used. If the processor 310 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 310, and thus improves the efficiency of the system.
  • the processor 310 may include one or more interfaces.
  • the interface may include an Inter-integrated Circuit (I2C) interface, an Inter-integrated Circuit Sound (I2S) interface, a Pulse Code Modulation (PCM) interface, a Universal Asynchronous Receiver/Transmitter (UART) interface, a Mobile Industry Processor Interface (MIPI), a General-Purpose Input/Output (GPIO) interface, a Subscriber Identity Module (SIM) interface, and/or a Universal Serial Bus (USB) interface, etc.
  • I2C Inter-integrated Circuit
  • I2S Inter-integrated Circuit Sound
  • PCM Pulse Code Modulation
  • UART Universal Asynchronous Receiver/Transmitter
  • MIPI Mobile Industry Processor Interface
  • GPIO General-Purpose Input/Output
  • SIM Subscriber Identity Module
  • USB Universal Serial Bus
  • the USB interface 330 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc.
  • the USB interface 330 can be used to connect a charger to charge the electronic device 300, and can also be used to transmit data between the electronic device 300 and a peripheral device. It can also be used to connect headphones to play audio through the headphones.
  • the interface can also be used to connect other electronic devices, such as AR devices, etc.
  • the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 300.
  • the electronic device 300 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
  • the charging management module 340 is used to receive charging input from a charger.
  • the charger may be a wireless charger or a wired charger.
  • the charging management module 340 may receive charging input from a wired charger through the USB interface 330.
  • the charging management module 340 may receive wireless charging input through a wireless charging coil of the electronic device 300. While the charging management module 340 is charging the battery 342, it may also power the electronic device through the power management module 341.
  • the power management module 341 is used to connect the battery 342, the charging management module 340 and the processor 310.
  • the power management module 341 receives input from the battery 342 and/or the charging management module 340, and supplies power to the processor 310, the internal memory 331, the external memory interface 320, the display screen 394, the camera 393, and the wireless communication module 360.
  • the power management module 341 can also be used to monitor parameters such as battery capacity, battery cycle number, and battery health status (leakage, impedance).
  • the power management module 341 may also be disposed in the processor 310. In some other embodiments, the power management module 341 and the charging management module 340 may also be disposed in the same device.
  • the wireless communication function of the electronic device 300 can be implemented through the antenna 1, the antenna 2, the mobile communication module 350, the wireless communication module 360, the modem processor and the baseband processor.
  • Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in the electronic device 300 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antennas.
  • antenna 1 can be reused as a diversity antenna for a wireless local area network.
  • the antenna can be used in combination with a tuning switch.
  • the mobile communication module 350 can provide solutions for wireless communications including 2G/3G/4G/5G, etc., applied to the electronic device 300.
  • the mobile communication module 350 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc.
  • the mobile communication module 350 can receive electromagnetic waves from the antenna 1, and filter, amplify, etc. the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation.
  • the mobile communication module 350 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1.
  • At least some functional modules of the mobile communication module 350 may be disposed in the processor 310. In some embodiments, at least some functional modules of the mobile communication module 350 and at least some modules of the processor 310 may be disposed in the same device.
  • the modem processor may include a modulator and a demodulator.
  • the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal.
  • the demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal.
  • the demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing.
  • the application processor outputs a sound signal through an audio device (not limited to a speaker 370A, a receiver 370B, etc.), or displays an image or video through a display screen 394.
  • the modem processor may be an independent device.
  • the modem processor may be independent of the processor 310 and be set in the same device as the mobile communication module 350 or other functional modules.
  • the wireless communication module 360 can provide wireless communication solutions including wireless local area networks (WLAN) (such as Wireless Fidelity (Wi-Fi) network), Bluetooth (BT), Global Navigation Satellite System (GNSS), Frequency Modulation (FM), Near Field Communication (NFC), Infrared (IR), etc., which are applied to the electronic device 300.
  • WLAN wireless local area networks
  • BT Bluetooth
  • GNSS Global Navigation Satellite System
  • FM Frequency Modulation
  • NFC Near Field Communication
  • IR Infrared
  • the wireless communication module 360 can be one or more devices integrating at least one communication processing module.
  • the wireless communication module 360 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 310.
  • the wireless communication module 360 can also receive the signal to be sent from the processor 310, modulate the frequency of the signal, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
  • the antenna 1 of the electronic device 300 is coupled to the mobile communication module 350, and the antenna 2 is coupled to the wireless communication module 360, so that the electronic device 300 can communicate with the network and other devices through wireless communication technology.
  • the wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and/or IR technology.
  • GNSS can include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the Beidou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS) and/or the Satellite Based Augmentation Systems (SBAS).
  • GPS Global Positioning System
  • GLONASS Global Navigation Satellite System
  • BDS Beidou Navigation Satellite System
  • QZSS Quasi-Zenith Satellite System
  • SBAS Satellite Based Augmentation Systems
  • the electronic device 300 implements the display function through a GPU, a display screen 394, and an application processor.
  • the GPU is a microprocessor for image processing, which connects the display screen 394 and the application processor.
  • the GPU is used to perform mathematical and geometric calculations for graphics rendering.
  • the processor 310 may include one or more GPUs, which execute program instructions to generate or change display information.
  • the display screen 394 is used to display images, videos, etc. For example, icons, folders, folder names, etc. of the APP in the embodiment of the present application.
  • the display screen 394 includes a display panel.
  • the display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc.
  • the electronic device 300 may include 1 or N display screens 394, where N is a positive integer greater than 1.
  • the electronic device 300 can realize the shooting function through ISP, camera 393, video codec, GPU, display screen 394 and application processor.
  • the ISP is used to process the data fed back by the camera 393. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye.
  • the ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. The ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP can be set in the camera 393.
  • the camera 393 is used to capture still images or videos.
  • the object generates an optical image through the lens and projects it onto the photosensitive element.
  • the focal length of the lens can be used to indicate the field of view of the camera. The smaller the focal length of the lens, the larger the field of view of the lens.
  • the photosensitive element can be a charge coupled device (CCD) or a complementary metal oxide semiconductor (CMOS) phototransistor.
  • CMOS complementary metal oxide semiconductor
  • the photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP for conversion into a digital image signal.
  • the ISP outputs the digital image signal to the DSP for processing.
  • the DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format.
  • the electronic device 300 may include cameras 393 with 2 or more focal lengths.
  • the digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 300 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
  • the video codec is used to compress or decompress digital video.
  • the electronic device 300 may support one or more video codecs. In this way, the electronic device 300 can play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG1, MPEG3, MPEG4, etc.
  • MPEG Moving Picture Experts Group
  • NPU is a neural network (NN) computing processor.
  • NN neural network
  • applications such as intelligent cognition of the electronic device 300 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.
  • the NPU or other processors may be used to perform operations such as analyzing and processing images in a video stored in the electronic device 300.
  • the external memory interface 320 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 300.
  • the external memory card communicates with the processor 310 through the external memory interface 320 to implement a data storage function. For example, files such as music and videos can be stored in the external memory card.
  • the internal memory 331 can be used to store computer executable program codes, and the executable program codes include instructions.
  • the processor 310 executes various functional applications and data processing of the electronic device 300 by running the instructions stored in the internal memory 331.
  • the internal memory 331 may include a program storage area and a data storage area.
  • the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.).
  • the data storage area can store data created during the use of the electronic device 300 (such as audio data, a phone book, etc.).
  • the internal memory 331 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (Universal Flash Storage, UFS), etc.
  • a non-volatile memory such as at least one disk storage device, a flash memory device, a universal flash storage (Universal Flash Storage, UFS), etc.
  • the electronic device 300 can implement audio functions through an audio module 370, a speaker 370A, a receiver 370B, a microphone 370C, an earphone interface 370D, and an application processor.
  • the audio module 370 is used to convert digital audio signals into analog audio signals for output, and is also used to convert analog audio inputs into digital audio signals.
  • the audio module 370 can also be used to encode and decode audio signals.
  • the audio module 370 can be arranged in the processor 310, or some functional modules of the audio module 370 can be arranged in the processor 310.
  • the speaker 370A also called a "speaker" is used to convert audio electrical signals into sound signals.
  • the electronic device 300 can listen to music or listen to hands-free calls through the speaker 370A.
  • the speaker can play the comparison analysis results provided in the embodiment of the present application.
  • the receiver 370B also called a "earpiece" is used to convert audio electrical signals into sound signals.
  • the voice can be received by placing the receiver 370B close to the human ear.
  • Microphone 370C also called “microphone” or “microphone” is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to the microphone 370C to input the sound signal into the microphone 370C.
  • the electronic device 300 can be provided with at least one microphone 370C. In other embodiments, the electronic device 300 can be provided with two microphones 370C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 300 can also be provided with three, four or more microphones 370C to collect sound signals, reduce noise, identify the sound source, realize directional recording function, etc.
  • the earphone interface 370D is used to connect a wired earphone.
  • the earphone interface 370D may be the USB interface 330, or may be a 3.5 mm Open Mobile Terminal Platform (OMTP) standard interface or a Cellular Telecommunications Industry Association of the USA (CTIA) standard interface.
  • OMTP Open Mobile Terminal Platform
  • CTIA Cellular Telecommunications Industry Association of the USA
  • the key 390 includes a power key, a volume key, etc.
  • the key 390 may be a mechanical key or a touch key.
  • the electronic device 300 may receive key input and generate key signal input related to user settings and function control of the electronic device 300.
  • Motor 391 can generate vibration prompts.
  • Motor 391 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback.
  • touch operations acting on different applications can correspond to different vibration feedback effects.
  • touch operations acting on different areas of the display screen 394 motor 391 can also correspond to different vibration feedback effects.
  • Different application scenarios for example: time reminders, receiving messages, alarm clocks, games, etc.
  • the touch vibration feedback effect can also support customization.
  • Indicator 392 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.
  • the SIM card interface 395 is used to connect a SIM card.
  • the SIM card can be connected to or disconnected from the electronic device 300 by inserting it into the SIM card interface 395 or removing it from the SIM card interface 395.
  • the electronic device 300 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
  • the SIM card interface 395 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 395 at the same time. The types of the multiple cards can be the same or different.
  • the SIM card interface 395 can also be compatible with different types of SIM cards.
  • the SIM card interface 395 can also be compatible with external memory cards.
  • the electronic device 300 interacts with the network through the SIM card, To realize functions such as calls and data communications.
  • the electronic device 300 uses an eSIM, that is, an embedded SIM card.
  • the eSIM card can be embedded in the electronic device 300 and cannot be separated from the electronic device 300.
  • the task processing method provided in this application can be applied to a variety of computer systems.
  • the computer system can be a microcontroller unit (MCU) embedded system.
  • MCU microcontroller unit
  • the execution subject of the task processing method may be different in different computer systems.
  • the execution subject of the task processing method can be the MCU; in other systems, the execution subject of the task processing method can be the control chip.
  • This application does not impose any restrictions on the type of computer system and the execution subject of the task processing method provided in this application.
  • FIG4 a structural diagram of an MCU embedded system provided by an embodiment of the present application is shown.
  • the MCU embedded system includes a sensor electrically connected to the MCU, an actuator electrically connected to the MCU, and a host computer connected to the MCU in communication.
  • the sensor may be a temperature sensor, a position sensor, etc., for real-time monitoring and acquisition of sensor data;
  • the actuator may be a device that can perform one or some actions under certain conditions, for example, the actuator may be a motor, a machine tool, an industrial robot, a stepper motor, a robot arm, and an instrument;
  • the host computer generally refers to a device that plays a role in control and deployment, for example, a laptop computer, etc., which can transmit information such as communication commands with the MCU.
  • the MCU embedded system shown in FIG4 above is only a possible example of the task processing method provided by the embodiment of the present application in practical applications. In practical applications, the corresponding MCU embedded system may change with different business needs, and this application does not make special restrictions on this.
  • the complete operation process of the task in the embodiment of the present application mainly includes initialization processing, determining the first task and executing the first task, wherein the initialization processing can be understood as registering the task to be executed to the corresponding system, and performing initialization processing on the task to obtain a task set after initialization processing, wherein the task set after initialization processing contains the first task; then, determining the first task to be executed from the task set; after determining the first task, executing the first task using the task processing method provided in the embodiment of the present application.
  • a task set may include one or more tasks.
  • the method for determining the first task may be different.
  • the task in the task set is initialized, and after the task initialization is completed, the task is directly determined as the first task; if there are two or more tasks in the task set, the multiple tasks can be initialized separately to obtain a task set consisting of multiple tasks, and then the preset task scheduling strategy can be used to determine the first task to be processed or executed from the above task set.
  • the preset task scheduling strategy may include any one of: a first-in-first-out scheduling strategy, a priority-based scheduling strategy, and a polling scheduling strategy.
  • the task scheduling strategy can also be customized by the user according to different business scenarios, and this application does not limit the specific content of the task scheduling strategy.
  • FIG6 is a flowchart of an embodiment of a task processing method provided by an embodiment of the present application.
  • the task processing method mainly includes the following steps:
  • S601 obtaining progress indication information of a first task, the progress indication information including a first indication parameter corresponding to a first subtask, the first task including a plurality of subtasks, the first subtask being a subtask that has not been executed among the plurality of subtasks.
  • the first task refers to a task (or job flow) to be executed or processed at present.
  • the first task can be understood as a specific function to be processed.
  • the actuator is a motor
  • the specific business scenario is that the MCU controls the motor to rotate 180° clockwise every minute;
  • the sensor is a temperature sensor for real-time temperature monitoring;
  • the host computer is a laptop computer for real-time monitoring of the commands received by the serial port.
  • the motor rotates 180° per minute, the temperature sensor monitors the temperature in real time, and the host computer monitors the serial port command in real time as three tasks (or three job flows).
  • These three tasks constitute a task set.
  • the priorities of these three tasks increase in sequence, and the task scheduling strategy is selected as a priority-based scheduling strategy
  • the third task of the above three tasks the host computer monitors the serial port command in real time can be determined as the first task.
  • each task in the task set has corresponding attribute information
  • the attribute information includes but is not limited to number, name, priority, progress indication information and the task processing function corresponding to the task, among which the number can be used to uniquely identify a task
  • the name is a notation corresponding to each task, which is generally used in the debugging process to display specific debugging information
  • the priority is also a priority processing level, which is used to identify the order of task execution.
  • the task processing function is used to establish a program entry for a specific task, so as to facilitate the subsequent use of the task processing function to call other functions and methods related to the task.
  • the third task is determined as the first task using a priority-based task scheduling strategy, where the third task is real-time monitoring of serial port commands by the host computer, then after the first task is determined, the execution progress of the third task can be determined by obtaining the progress indication information of the first task, that is, the progress indication information corresponding to the third task, and then the first subtask of the third task can be determined.
  • the first subtask is determined according to the progress indication information of the first task, and the first subtask can be understood as the first subtask among the multiple subtasks of the first task that have not been executed and are divided according to the execution order or function of the first task. It is worth noting that in order to better manage the processing functions corresponding to the first task, in actual applications, some first tasks may be divided into one subtask according to the execution order. In this case, the first subtask is usually a task with simple functions, and the first subtask is the same task as the first task.
  • the first subtask is a subtask that has not been executed.
  • task 1 can be divided into: subtask a monitoring data, subtask b receiving the monitored data, and subtask c processing the received monitoring data.
  • the above three subtasks during a complete execution of the first task, the first subtask that has not been executed in task 1 can be determined by obtaining the first indication parameter in the progress indication information corresponding to task 1. As the first indication parameter in the progress indication information changes, the first subtask may be subtask a, may be subtask b, or may be subtask c.
  • S602 Execute a processing function corresponding to the first subtask according to the first indication parameter.
  • the processing function corresponding to the first subtask also refers to the sub-processing function that executes the first subtask. After the first subtask of the first task is determined, the processing of the first subtask can be implemented by executing the sub-processing function corresponding to the first subtask.
  • the second indication parameter of the second subtask is the second indication parameter corresponding to the next subtask of the first subtask in the progress indication information of the first task.
  • the second subtask is the first subtask among the multiple subtasks; if the first subtask is not the last subtask among the multiple subtasks, the first indication parameter is updated to the second indication parameter corresponding to the second subtask, that is, the second subtask is the next subtask of the first subtask.
  • the task processing method provided in the embodiment of the present application updates the first indication parameter in the progress indication information of the first task to the second indication parameter corresponding to the second subtask (such as updating the first indication parameter in the progress indication information according to the execution order of multiple subtasks in the first task).
  • the second task can be executed after the first indication parameter in the progress indication information is updated.
  • the execution progress of the first task is obtained through the second indication parameter in the updated progress indication information, so as to continue to execute the unexecuted subtasks in the first task, thereby quickly realizing the switching management of multiple tasks.
  • the task processing method provided in the embodiment of the present application can be used to execute the first subtask of the second task.
  • the second subtask of the first task is executed according to the updated first indication parameter (i.e., the second indication parameter of the second subtask).
  • the first task and the second task are executed in a cycle until the first task and the second task are completely executed. This not only realizes the switching management of different tasks, but also facilitates different tasks to use shared resources in turn, thereby achieving the effect of load balancing.
  • the second task is executed after the first indication parameter is updated.
  • the second task can be understood as a new task detected when multiple subtasks in the first task have not yet been completely executed.
  • the task processing method ensures that the complete execution process of the first subtask includes both the process of executing the processing function corresponding to the first subtask and the process of updating the progress indication information after the first subtask is processed by the processing function. This design avoids the interruption of the execution of the first subtask due to the influence of other tasks during the execution of the first subtask. By dividing the first task into multiple subtasks, the occurrence rate of exceptions or interruptions during the execution of the first task is reduced.
  • the multiple subtasks in the first task provided in the present application can be implemented by a state machine or by an iterator.
  • the above two implementation methods are exemplified below in conjunction with the MCU embedded system shown in Figure 4.
  • the above task 1 can be divided into three stages, the first stage A corresponds to subtask a; the second stage B corresponds to subtask b, and the third stage C corresponds to subtask c, see Figure 7.
  • the first indication parameter corresponding to the first subtask can be updated to the second indication parameter corresponding to the next subtask of the first subtask among the multiple subtasks of the first task.
  • the first subtask is subtask a
  • the progress indication information can be defined as a pointer variable (or cursor) for the execution progress of the first task.
  • the address pointed to by the pointer variable is the first indication parameter. That is, after obtaining the pointer variable corresponding to the first task, the subtask corresponding to the address pointed to by the pointer variable can be determined as the first subtask.
  • the three subtasks corresponding to the above Task 1 can be defined as three ordered sequences of elements in the array SubFuncArray.
  • the array SubFuncArray includes the first element SubFunc0, the second element SubFunc1, and the third element SubFunc2, a total of three elements.
  • SubFunc0 corresponds to subtask a
  • SubFunc1 corresponds to subtask b
  • SubFunc2 corresponds to subtask c.
  • the progress indication information of Task 1 can be defined as a pointer variable Cursor.
  • the processing function of the first subtask can be determined according to the address pointed to by the pointer variable Cursor. Assuming that the address pointed to by the obtained pointer variable Cursor is the first element SubFunc0 in the array SubFuncArray, and the first subtask of Task 1 is determined to be Subtask a, then SubFunc0 can be determined as the processing function of Subtask a through SubFuncArray[0], see Figure 9, and the processing of the first subtask is realized by executing the processing function SubFunc0.
  • the value of the pointer variable can be updated to the value corresponding to the next subtask of the first subtask to update the first indication parameter.
  • the next subtask to be executed is the processing function SubFunc1 in the array SubFuncArray[1].
  • the corresponding subtask b so executing the processing function SubFunc0 can realize the processing of subtask a, move the address pointed to by the pointer variable Cursor one position backward, so that the pointer variable Cursor points to the address corresponding to the processing function SubFunc1 in the array SubFuncArray[1], and complete the update of the first indication parameter.
  • the execution of the processing function SubFunc2 indicates that the execution of Task 1 is completed, that is, Task 1 has been completely processed.
  • the first subtask of Task 1 will be re-executed from subtask a. Therefore, if the first subtask is subtask c, after the processing function SubFunc2 is executed, the pointer variable Cursor is moved backward by one position so that the pointer variable Cursor continues to point to the first element in the array SubFuncArray, that is, SubFunc0, so that when the first task is re-executed, the first subtask in Task 1 is determined by the address pointed to by the pointer variable Cursor.
  • a modular approach (such as state machine or iterator methods) can be used to develop and design the first task, thereby increasing programming flexibility and reducing the difficulty of task programming; when the actual business scenario changes, the established program framework of the first task can be used to implement the functions corresponding to the new business scenario, thereby improving the reusability of the program and achieving the purpose of improving development and maintenance efficiency.
  • the task processing method provided in the embodiment of the present application is based on the task processing method provided in the present application. After first determining the first subtask of the first task through the progress indication information, the processing function corresponding to the first subtask is executed. After the processing function is executed, the first indication parameter in the progress indication information is updated to the second indication parameter corresponding to the second subtask.
  • the method of dividing the first task into multiple subtasks in this way can greatly shorten the CPU time occupied by the execution of the first subtask, so that other tasks can be executed when at least one subtask of the first task is executed, and a certain amount of time is provided for the execution of other tasks.
  • the above method since after the processing of the first subtask is completed, the above method also updates the first indication parameter in the progress indication information to the second indication parameter corresponding to the second subtask, thus avoiding the need to allocate a separate storage space to the currently executed first task to save the CPU context of the currently executed first task when the task is switched, effectively reducing the dependence of task processing on storage resources, and greatly reducing the consumption of storage resources and CPU.
  • FIG10 is a schematic block diagram of a task processing device 1000 provided in an embodiment of the present application.
  • the task processing device 1000 shown in FIG10 includes: an acquisition unit 1010 , a processing unit 1020 and an update unit 1030 .
  • the acquisition unit 1010 is used to acquire progress indication information of a first task, wherein the progress indication information includes a first indication parameter corresponding to a first subtask, wherein the first task includes multiple subtasks, and the first subtask is a subtask that has not been executed among the multiple subtasks.
  • the processing unit 1020 is configured to execute a processing function corresponding to the first subtask according to the first indication parameter.
  • the updating unit 1030 is used to update the first indication parameter in the progress indication information to a second indication parameter corresponding to a second subtask after the processing function is executed, and the second subtask is a next subtask of the first subtask among the multiple subtasks.
  • the second task is executed after the first indication parameter is updated.
  • the second subtask is the first subtask among the multiple subtasks.
  • the task processing device 1000 before obtaining the progress indication information of the first task, the task processing device 1000 further includes:
  • An initialization processing unit used for performing initialization processing on a plurality of tasks to obtain a task set, wherein the task set includes the first task;
  • the scheduling unit is used to schedule multiple tasks in the task set based on a preset task scheduling strategy.
  • the plurality of subtasks in the first task are implemented by way of a state machine or an iterator.
  • the task scheduling strategy includes: any one of a first-in-first-out scheduling strategy, a priority-based scheduling strategy and a polling scheduling strategy.
  • the description of the device embodiment can refer to the above-mentioned description of the electronic device and the task processing method embodiment. Its implementation principle and technical effect are similar to those of the above-mentioned method embodiment and will not be repeated here.
  • the embodiments of the present application also provide the following contents:
  • An embodiment of the present application provides a computer program product, which includes a program.
  • the program When the program is executed by an electronic device, the electronic device performs the task processing method shown in the above embodiments.
  • An embodiment of the present application provides a computer-readable storage medium, which stores a computer program.
  • the computer program is executed by a processor, the task processing method shown in the above embodiments is implemented.
  • An embodiment of the present application provides a chip, which includes a memory and a processor.
  • the processor executes a computer program stored in the memory to control the above-mentioned electronic device to execute the task processing method shown in the above-mentioned embodiments.
  • processors mentioned in the embodiments of the present application may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • DSP digital signal processors
  • ASIC application-specific integrated circuits
  • FPGA field programmable gate arrays
  • a general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
  • the memory mentioned in the embodiments of the present application may be a volatile memory or a non-volatile memory, or 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), which is used as an external cache.
  • RAM static RAM
  • DRAM dynamic RAM
  • SDRAM synchronous DRAM
  • DDR SDRAM double data rate synchronous dynamic random access memory
  • ESDRAM enhanced synchronous dynamic random access memory
  • Synchlink DRAM SLDRAM
  • Direct Rambus RAM Direct Rambus RAM
  • the technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration.
  • the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
  • the functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
  • the disclosed devices and methods can be implemented in other ways.
  • the system embodiments described above are only schematic.
  • the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
  • Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may be a separate unit.
  • the integrated unit may be implemented in the form of hardware or software functional unit.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.
  • the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program.
  • the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor.
  • the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form.
  • the computer-readable medium may at least include: any entity or device that can carry the computer program code to a large-screen device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electric carrier signal, a telecommunication signal, and a software distribution medium.
  • a USB flash drive for example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk.
  • computer-readable media cannot be electric carrier signals and telecommunication signals.

Landscapes

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

Abstract

The present application relates to the technical field of terminals. Provided are a task processing method and apparatus, and a readable storage medium. The task processing method comprises: acquiring progress indication information of a first task, wherein the progress indication information comprises a first indication parameter corresponding to a first sub-task, the first task comprises a plurality of sub-tasks, and the first sub-task is an unexecuted sub-task among the plurality of sub-tasks; executing, according to the first indication parameter, a processing function corresponding to the first sub-task; and after the processing function is executed, updating the first indication parameter, which is in the progress indication information, to a second indication parameter corresponding to a second sub-task, wherein the second sub-task is the next sub-task of the first sub-task among the plurality of sub-tasks. The problem of the consumption of storage resources and a CPU by means of an existing task processing method being relatively large is solved to a certain extent.

Description

一种任务处理方法、装置及可读存储介质A task processing method, device and readable storage medium

本申请要求于2023年03月14日提交国家知识产权局、申请号为202310282489.5、申请名称为“一种任务处理方法、装置及可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on March 14, 2023, with application number 202310282489.5 and application name “A task processing method, device and readable storage medium”, the entire contents of which are incorporated by reference in this application.

技术领域Technical Field

本申请涉及终端技术领域,尤其涉及一种任务处理方法、装置及可读存储介质。The present application relates to the field of terminal technology, and in particular to a task processing method, device and readable storage medium.

背景技术Background Art

微控制器单元(Microcontroller Unit,MCU)又称单片机,具有体积小、功耗低以及可靠性高的优点,被广泛应用于工业控制、交通管理以及日常生活等领域。在MCU嵌入式系统中,可以通过操作系统(Operating System,OS)实现对任务处理(包括任务的执行和任务切换),该方法中,任务是OS调度的基本单元,每个任务在执行时会独占CPU,且CPU在任务切换的过程中,需要先将当前执行任务的CPU上下文保存至当前任务对应的堆栈空间中,再将新任务的CPU上下文装载至CPU寄存器中,以运行新任务,实现任务的切换。Microcontroller Unit (MCU), also known as single-chip microcomputer, has the advantages of small size, low power consumption and high reliability. It is widely used in industrial control, traffic management and daily life. In MCU embedded system, task processing (including task execution and task switching) can be realized through operating system (OS). In this method, task is the basic unit of OS scheduling. Each task will occupy the CPU exclusively during execution. In the process of task switching, the CPU needs to save the CPU context of the currently executing task to the stack space corresponding to the current task, and then load the CPU context of the new task into the CPU register to run the new task and realize task switching.

不难看出,在任务处理过程中,该方法需要为每个任务的堆栈提供对应的存储资源以在任务切换时存储正在执行任务的CPU上下文,这样增加了任务处理对存储资源以及CPU性能的开销。It is not difficult to see that during the task processing, this method needs to provide corresponding storage resources for each task stack to store the CPU context of the executing task when the task is switched, which increases the storage resource and CPU performance overhead of task processing.

发明内容Summary of the invention

本申请提供一种任务处理方法、装置及可读存储介质,一定程度上解决了现有的任务处理方法对存储资源以及CPU消耗较大的问题。The present application provides a task processing method, device and readable storage medium, which to a certain extent solve the problem that the existing task processing methods consume a lot of storage resources and CPU.

为达到上述目的,本申请采用如下技术方案:In order to achieve the above purpose, this application adopts the following technical solutions:

第一方面,本申请提供一种任务处理方法,该方法包括:In a first aspect, the present application provides a task processing method, the method comprising:

获取第一任务的进度指示信息,所述进度指示信息包括与第一子任务对应的第一指示参数,所述第一任务包括多个子任务,所述第一子任务为多个所述子任务中未被执行的子任务;Acquire progress indication information of a first task, the progress indication information including a first indication parameter corresponding to a first subtask, the first task including a plurality of subtasks, the first subtask being a subtask that has not been executed among the plurality of subtasks;

根据所述第一指示参数执行与所述第一子任务对应的处理函数;Execute a processing function corresponding to the first subtask according to the first indication parameter;

在所述处理函数执行完后,将所述进度指示信息中的第一指示参数更新为与第二子任务对应的第二指示参数,所述第二子任务为所述多个子任务中所述第一子任务的下一个子任务。After the processing function is executed, the first indication parameter in the progress indication information is updated to a second indication parameter corresponding to a second subtask, and the second subtask is a next subtask of the first subtask among the multiple subtasks.

基于本申请提供的任务处理方法,先通过进度指示信息确定第一任务的第一子任务后,执行与第一子任务对应的处理函数,在处理函数执行完成之后,再将进度指示信息中的第一指示参数更新为与第二子任务对应的第二指示参数。这样将第一任务分成多个子任务的方式能够极大的缩短第一子任务执行所占用CPU的时间,以便于在第一任务的至少一个子任务执行完毕的情况下执行其他任务,为其他任务的执行提供一定的时间,且由于在第一子任务处理完成之后,上述方法还将进度指示信息中的第一指示参数更新为与第二子任务对应的第二指示参数,这样就避免了在任务切换时需要给当前执行的第一任务分配单独的存储空间以保存当前执行的第一任务的CPU上下文,有效减少了任务处理对存储资源的依赖,大大降低了对存储资源和CPU的消耗。Based on the task processing method provided by the present application, after first determining the first subtask of the first task through the progress indication information, execute the processing function corresponding to the first subtask, and after the processing function is executed, update the first indication parameter in the progress indication information to the second indication parameter corresponding to the second subtask. In this way, dividing the first task into multiple subtasks can greatly shorten the CPU time occupied by the execution of the first subtask, so that other tasks can be executed when at least one subtask of the first task is executed, and a certain amount of time is provided for the execution of other tasks. Moreover, since after the processing of the first subtask is completed, the above method also updates the first indication parameter in the progress indication information to the second indication parameter corresponding to the second subtask, thus avoiding the need to allocate a separate storage space to the currently executed first task to save the CPU context of the currently executed first task when switching tasks, effectively reducing the dependence of task processing on storage resources, and greatly reducing the consumption of storage resources and CPU.

此外,通过将第一任务划分为多个子任务可以在第一任务中的部分子任务执行完毕后切换执行其他任务,使其他任务得到及时响应或处理,有效避免由于第一任务占用CPU时间过长而导致阻塞情况的发生,达到了多任务并行执行的效果,提高了CPU的利用率。In addition, by dividing the first task into multiple subtasks, other tasks can be switched to execution after some subtasks in the first task are executed, so that other tasks can be responded to or processed in a timely manner, effectively avoiding the occurrence of blocking caused by the first task occupying the CPU for too long, achieving the effect of multi-task parallel execution, and improving CPU utilization.

在第一方面的一种可能的实施方式中,在所述处理函数执行过程中,若检测到新增的第二任务,所述第二任务的任务处理优先级高于所述第一任务,则在对所述第一指示参数更新后,执行所述第二任务。In a possible implementation of the first aspect, during the execution of the processing function, if a newly added second task is detected and the task processing priority of the second task is higher than that of the first task, the second task is executed after the first indication parameter is updated.

基于上述可选的方式,通过上述任务处理方法使得第一子任务完整的处理过程既包括利用与第一子任务对应的处理函数对第一子任务进行处理的过程,又包括利用处理函数对第一子任务处理完成后,根据第一任务中多个子任务的执行顺序对进度指示信息进行更新的过程,这样的设计避免了在第一子任务执行过程中由于其他任务的影响而导致第一子任务执行中断情况的发生,通过将第一任务划分为多个子任务的方式,降低了第一任务执行过程中异常或中断的发生率。Based on the above optional method, the above task processing method makes the complete processing process of the first subtask include both the process of processing the first subtask using the processing function corresponding to the first subtask and the process of updating the progress indication information according to the execution order of multiple subtasks in the first task after the first subtask is processed by the processing function. Such a design avoids the interruption of the execution of the first subtask due to the influence of other tasks during the execution of the first subtask. By dividing the first task into multiple subtasks, the occurrence rate of exceptions or interruptions during the execution of the first task is reduced.

在第一方面的一种可能的实施方式中,若所述第一子任务是所述多个子任务中的最后一个子任务,则所述第二子任务为与所述多个子任务中的第一个子任务。 In a possible implementation manner of the first aspect, if the first subtask is the last subtask among the multiple subtasks, the second subtask is the first subtask among the multiple subtasks.

在第一方面的一种可能的实施方式中,所述获取第一任务的进度指示信息之前,所述方法还包括:In a possible implementation of the first aspect, before obtaining the progress indication information of the first task, the method further includes:

对多个任务进行初始化处理,得到任务集合,所述任务集合包括所述第一任务;Initializing multiple tasks to obtain a task set, where the task set includes the first task;

基于预设的任务调度策略对所述任务集合中的多个任务进行调度。The multiple tasks in the task set are scheduled based on a preset task scheduling strategy.

示例性的,任务调度策略可以包括:先进先出调度策略、基于优先级调度策略以及轮询调度策略中的任意一种。Exemplarily, the task scheduling strategy may include: any one of a first-in-first-out scheduling strategy, a priority-based scheduling strategy, and a polling scheduling strategy.

不难理解的,在实际应用中,任务调度策略还可以根据实际应用需求自定义,本申请对此不作限定。It is not difficult to understand that in actual applications, the task scheduling strategy can also be customized according to actual application requirements, and this application does not limit this.

基于上述可选的实施方式,通过自定义、先进先出调度策略、基于优先级调度策略以及轮询调度策略等调度策略从任务集合中确定第一任务,不仅符合实际应用需求或业务场景,而且调度策略的多样性选择有效保证了不同任务之间的选择任务调度策略的灵活性。Based on the above optional implementation methods, the first task is determined from the task set through scheduling strategies such as customization, first-in-first-out scheduling strategy, priority-based scheduling strategy and polling scheduling strategy. This not only meets the actual application needs or business scenarios, but also the diverse selection of scheduling strategies effectively ensures the flexibility of selecting task scheduling strategies between different tasks.

在第一方面的一种可能的实施方式中,所述第一任务中的多个所述子任务通过状态机或迭代器的方式实现。In a possible implementation of the first aspect, the plurality of subtasks in the first task are implemented by way of a state machine or an iterator.

应理解,第一任务中多个上述子任务的实现方式也可以根据具体的业务场景进行自定义。It should be understood that the implementation methods of the multiple subtasks in the first task can also be customized according to specific business scenarios.

基于上述可选的实施方式,上述任务处理方法在具体实现过程中,可以采用模块化的方式(例如状态机或迭代器等方法)对第一任务进行开发和设计,增加编程的灵活性,降低任务编程的难度;当实际业务场景发生变化时,可以利用已建立的第一任务的程序框架来实现与新业务场景对应的功能,提高了程序的可复用性,实现了提升开发和维护效率的目的。Based on the above optional implementation methods, in the specific implementation process of the above task processing method, a modular approach (such as state machine or iterator methods) can be used to develop and design the first task, thereby increasing programming flexibility and reducing the difficulty of task programming; when the actual business scenario changes, the established program framework of the first task can be used to implement functions corresponding to the new business scenario, thereby improving the reusability of the program and achieving the purpose of improving development and maintenance efficiency.

第二方面,本申请实施例提供一种任务处理装置,该任务处理装置包括:In a second aspect, an embodiment of the present application provides a task processing device, the task processing device comprising:

获取单元,用于获取第一任务的进度指示信息,所述进度指示信息包括与第一子任务对应的第一指示参数,所述第一任务包括多个子任务,所述第一子任务为多个所述子任务中未被执行的子任务;an acquiring unit, configured to acquire progress indication information of a first task, the progress indication information comprising a first indication parameter corresponding to a first subtask, the first task comprising a plurality of subtasks, the first subtask being a subtask that has not been executed among the plurality of subtasks;

处理单元,用于根据所述第一指示参数执行与所述第一子任务对应的处理函数;a processing unit, configured to execute a processing function corresponding to the first subtask according to the first indication parameter;

更新单元,用于在所述处理函数执行完后,将所述进度指示信息中的第一指示参数更新为与第二子任务对应的第二指示参数,所述第二子任务为所述多个子任务中所述第一子任务的下一个子任务。An updating unit is used to update the first indication parameter in the progress indication information to a second indication parameter corresponding to a second subtask after the processing function is executed, and the second subtask is a next subtask of the first subtask among the multiple subtasks.

在第二方面的一种可能的实施方式中,在所述处理函数执行过程中,若检测到新增的第二任务,所述第二任务的任务处理优先级高于所述第一任务,则在对所述第一指示参数更新后,执行所述第二任务。In a possible implementation of the second aspect, during the execution of the processing function, if a newly added second task is detected and the task processing priority of the second task is higher than that of the first task, the second task is executed after the first indication parameter is updated.

在第二方面的一种可能的实施方式中,若所述第一子任务是所述多个子任务中的最后一个子任务,则所述第二子任务为所述多个子任务中的第一个子任务。In a possible implementation of the second aspect, if the first subtask is the last subtask among the multiple subtasks, the second subtask is the first subtask among the multiple subtasks.

在第二方面的一种可能的实施方式中,所述获取第一任务的进度指示信息之前,所述方法还包括:In a possible implementation of the second aspect, before obtaining the progress indication information of the first task, the method further includes:

对多个任务进行初始化处理,得到任务集合,所述任务集合包括所述第一任务;Initializing multiple tasks to obtain a task set, where the task set includes the first task;

基于预设的任务调度策略对所述任务集合中的多个任务进行调度。The multiple tasks in the task set are scheduled based on a preset task scheduling strategy.

在第二方面的一种可能的实施方式中,所述第一任务中的多个所述子任务通过状态机或迭代器的方式实现。In a possible implementation of the second aspect, the plurality of subtasks in the first task are implemented by way of a state machine or an iterator.

在第二方面的一种可能的实施方式中,所述任务调度策略包括:先进先出调度策略、基于优先级调度策略以及轮询调度策略中的任意一种。In a possible implementation of the second aspect, the task scheduling strategy includes: any one of a first-in-first-out scheduling strategy, a priority-based scheduling strategy, and a polling scheduling strategy.

第三方面,本申请实施例提供一种电子设备,包括:处理器,所述处理器用于运行存储器中存储的计算机程序,以实现第一方面或第一方面的任一可能的实现方式中的方法。In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, wherein the processor is used to run a computer program stored in a memory to implement the method in the first aspect or any possible implementation manner of the first aspect.

第四方面,本申请提供一种任务处理系统,该任务处理系统包括第三方面所述的电子设备。In a fourth aspect, the present application provides a task processing system, which includes the electronic device described in the third aspect.

第五方面,本申请提供一种芯片,所述芯片包括处理器,处理器用于读取并执行存储器中存储的计算机程序,以执行第一方面或第一方面的任一可能的实现方式中的方法。In a fifth aspect, the present application provides a chip, comprising a processor, wherein the processor is used to read and execute a computer program stored in a memory to execute the method in the first aspect or any possible implementation of the first aspect.

可选地,所述芯片还包括存储器,存储器与处理器通过电路或电线连接。Optionally, the chip also includes a memory, and the memory is connected to the processor via a circuit or wire.

第六方面,本申请提供一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,计算机程序被处理器执行时实现第一方面或第一方面的任一可能的实现方式中的方法。In a sixth aspect, the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the method in the first aspect or any possible implementation manner of the first aspect is implemented.

第七方面,本申请提供一种计算机程序产品,当计算机程序产品在电子设备上运行时,使得电子设备执行第一方面或第一方面的任一可能的实现方式中的方法。In a seventh aspect, the present application provides a computer program product. When the computer program product runs on an electronic device, the electronic device executes the method in the first aspect or any possible implementation manner of the first aspect.

本申请提供的第二方面至第七方面的技术效果可以参见上述第一方面的各个可能的实现方式的技术效果,此处不再赘述。The technical effects of the second to seventh aspects provided in the present application can refer to the technical effects of the various possible implementation methods of the first aspect mentioned above, and will not be repeated here.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1为本申请实施例提供的现有的一种任务处理方法的结构示意图。 FIG1 is a schematic diagram of the structure of an existing task processing method provided in an embodiment of the present application.

图2为本申请实施例提供的现有的另一种任务处理方法的结构示意图。FIG. 2 is a schematic diagram of the structure of another existing task processing method provided in an embodiment of the present application.

图3为本申请实施例提供的一种电子设备的结构示意图。FIG3 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

图4为本申请实施例提供的一种MCU嵌入式系统的结构框图。FIG4 is a structural block diagram of an MCU embedded system provided in an embodiment of the present application.

图5为本申请实施例提供的一种对多个任务进行处理的流程图。FIG5 is a flowchart of processing multiple tasks provided in an embodiment of the present application.

图6为本申请实施例提供的一种任务处理方法的流程性示意图。FIG6 is a flowchart of a task processing method provided in an embodiment of the present application.

图7为本申请实施例提供的与任务处理方法对应的一种实现方式的流程示意图。FIG. 7 is a flow chart of an implementation method corresponding to the task processing method provided in an embodiment of the present application.

图8为本申请实施例提供的与任务处理方法对应的另一种实现方式中创建的数组结构的示意图。FIG8 is a schematic diagram of an array structure created in another implementation method corresponding to the task processing method provided in an embodiment of the present application.

图9为本申请实施例提供的与任务处理方法对应的另一种实现方式的流程示意图。FIG. 9 is a flow chart of another implementation method corresponding to the task processing method provided in an embodiment of the present application.

图10为本申请实施例提供的一种与任务处理方法对应的任务处理装置的结构框图。FIG10 is a structural block diagram of a task processing device corresponding to the task processing method provided in an embodiment of the present application.

具体实施方式DETAILED DESCRIPTION

MCU又称单片机,具有体积小、功耗低以及可靠性高的优点,被广泛应用于工业控制、交通管理以及日常生活等领域。随着科学技术的发展,基于MCU的嵌入式系统不再局限于实现单一的功能,而需要能够同时处理多个作业流,例如,电机类的MCU在实际使用时既需要控制电机参数,又需要与上位机保持通信连接。MCU, also known as single-chip microcomputer, has the advantages of small size, low power consumption and high reliability, and is widely used in industrial control, traffic management and daily life. With the development of science and technology, MCU-based embedded systems are no longer limited to realizing a single function, but need to be able to handle multiple operation flows at the same time. For example, motor-type MCUs need to control motor parameters and maintain communication connection with the host computer in actual use.

在实际应用中,MCU嵌入式系统对多个工作流的处理可以包括对每个工作流的执行(或运行)以及对多个工作流之间的切换。对于具有一定存储空间或者计算频率能力的MCU可以通过OS实现对多个任务的调度管理(包括对每个工作流的执行和对多个工作流之间的切换),需要说明的是,该方法中将任务作为应用程序的最小调度运行单元,一个任务对应一个独立的任务处理函数。参见图1,假设多个任务包括任务1、任务2……任务n,每个任务具有对应的任务控制块以及属性,其中,属性包括编号、优先级、入口函数、堆栈空间以及当前栈指针等,OS负责管理中央处理器(Central Processing Unit,CPU)在多个任务之间的切换,若任务1是当前正在执行的任务,则任务1在执行过程中将会独占CPU,在一些情况中(例如任务2的优先级高于任务1的优先级),则无论任务1是否运行完成,OS都会控制CPU从任务1切换至任务2,以利用CPU处理任务2,CPU从任务1切换至任务2的过程中,首先会将任务1的CPU上下文保存在任务1对应的堆栈空间中,便于该任务1再次获取CPU时继续执行任务1,在将任务1的CPU上下文保存至任务1的堆栈空间后,再将任务2的CPU上下文装载至CPU寄存器中运行任务2。In practical applications, the processing of multiple workflows by the MCU embedded system may include the execution (or running) of each workflow and the switching between multiple workflows. For MCUs with a certain storage space or computing frequency capability, the scheduling management of multiple tasks (including the execution of each workflow and the switching between multiple workflows) can be implemented through the OS. It should be noted that in this method, the task is used as the minimum scheduling and running unit of the application, and one task corresponds to an independent task processing function. Referring to Figure 1, it is assumed that multiple tasks include Task 1, Task 2...Task n, each task has a corresponding task control block and attributes, wherein the attributes include number, priority, entry function, stack space, and current stack pointer, etc. The OS is responsible for managing the switching of the central processing unit (CPU) between multiple tasks. If Task 1 is the currently executing task, Task 1 will monopolize the CPU during execution. In some cases (for example, the priority of Task 2 is higher than the priority of Task 1), regardless of whether Task 1 is completed or not, the OS will control the CPU to switch from Task 1 to Task 2 to use the CPU to process Task 2. In the process of CPU switching from Task 1 to Task 2, the CPU context of Task 1 will first be saved in the stack space corresponding to Task 1, so that Task 1 can continue to execute Task 1 when it obtains the CPU again. After the CPU context of Task 1 is saved in the stack space of Task 1, the CPU context of Task 2 is loaded into the CPU register to run Task 2.

虽然利用OS可以完成对多个任务的调度管理,但是在任务切换过程需要给每个任务的任务控制块和堆栈提供一定的存储空间,这样极大的提升了任务调度对存储资源的依赖,增加了存储资源以及CPU性能的开销。此外,该方法仅适用于具有一定存储空间或者计算频率能力的MCU,以满足OS进行调度管理的最低运行需求,若MCU的不具有一定存储空间或者计算频率能力,或者无法满足OS进行任务调度处理的最低存储空间或计算频率的实用需求,则无法利用上述方法实现对多个任务的调度管理。Although the OS can be used to complete the scheduling and management of multiple tasks, a certain amount of storage space needs to be provided for the task control block and stack of each task during the task switching process, which greatly increases the reliance of task scheduling on storage resources and increases the overhead of storage resources and CPU performance. In addition, this method is only applicable to MCUs with a certain amount of storage space or computing frequency capabilities to meet the minimum operating requirements of the OS for scheduling and management. If the MCU does not have a certain amount of storage space or computing frequency capabilities, or cannot meet the practical requirements of the minimum storage space or computing frequency for the OS to schedule and process tasks, the above method cannot be used to achieve the scheduling and management of multiple tasks.

对于无法通过OS进行任务调度管理的MCU通常可以采用超级循环系统的软件框架,通过硬编码方式来实现对任务的调度管理。参见图2,超级循环系统即前景/背景系统,换言之,该超级循环系统包括一个背景系统和一个前景系统,背景系统也称为后台系统,通过一个后台程序无限循环处理着一个或多个任务的多个功能;例如,任务1可以包括功能A、功能B、功能C以及功能D等多个功能;或者任务1、任务2以及任务3包括功能A、功能B、功能C以及功能D等多个功能。前景系统也称为前台系统,该前台系统是由多个中断服务程序构成,比如,前台系统中可以包括中断服务程序1和中断服务程序2,在实际应用中,若前台系统未触发了中断服务程序1或中断服务程序2,那么后台系统将会无限循环的执行任务1;若前台系统触发了中断服务程序1,此时,后台系统正在执行任务1的功能B,但功能B尚未执行完成,那么后台系统正在执行任务1的功能B就会被中断服务程序1打断,后台系统暂停对任务1中功能B的继续处理,直至前台系统处理完中断服务程序1,后台系统会从功能B被打断的地方继续执行功能B。For MCUs that cannot perform task scheduling management through OS, the software framework of the super loop system can usually be used to implement task scheduling management through hard coding. Referring to Figure 2, the super loop system is a foreground/background system. In other words, the super loop system includes a background system and a foreground system. The background system is also called the background system, which processes multiple functions of one or more tasks in an infinite loop through a background program; for example, task 1 may include multiple functions such as function A, function B, function C, and function D; or task 1, task 2, and task 3 include multiple functions such as function A, function B, function C, and function D. The foreground system is also called the foreground system. The foreground system is composed of multiple interrupt service programs. For example, the foreground system may include interrupt service program 1 and interrupt service program 2. In actual applications, if the foreground system does not trigger interrupt service program 1 or interrupt service program 2, the background system will execute task 1 in an infinite loop; if the foreground system triggers interrupt service program 1, at this time, the background system is executing function B of task 1, but function B has not yet been completed, then the function B of task 1 being executed by the background system will be interrupted by interrupt service program 1, and the background system will suspend the continued processing of function B in task 1 until the foreground system completes processing of interrupt service program 1, and the background system will continue to execute function B from where function B was interrupted.

上述方法虽然不要求MCU具有一定的存储空间或者计算频率能力,但是,中断服务程序的不定时出现会导致后台系统正在执行任务发生中断,而且若利用该方法对多个任务进行分时处理,则需要考虑多个任务之间的优先级、多个任务之间的依赖关系、多个任务之间的响应时间等因素,针对多个任务在后台系统的无限循环体中编排对应的多个功能,很明显,该方式中需要基于不同的任务 编写对应的程序,当业务场景发生变化时,例如,多个任务中的功能的数量或多个功能之间的优先级、依赖关系、响应时间等因素发生变化,则需要在无限循环体中重新编写新的程序,以实现新的多个任务之间的处理等,程序的可复用性较低,因此,上述方法增加了编程的复杂度,降低了程序的开发和维护效率。Although the above method does not require the MCU to have a certain storage space or computing frequency capability, the irregular appearance of the interrupt service program will cause the background system to interrupt the task being executed. Moreover, if this method is used to time-share multiple tasks, it is necessary to consider the priority between multiple tasks, the dependencies between multiple tasks, the response time between multiple tasks and other factors. For multiple tasks, the corresponding multiple functions are arranged in the infinite loop body of the background system. Obviously, this method needs to be based on different tasks. When writing corresponding programs, when the business scenario changes, for example, the number of functions in multiple tasks or the priority, dependency, response time and other factors between multiple functions change, it is necessary to rewrite new programs in the infinite loop body to realize the processing between new multiple tasks, etc. The reusability of the program is low. Therefore, the above method increases the complexity of programming and reduces the efficiency of program development and maintenance.

因此,针对上述问题,本申请提供一种任务处理方法,执行完与第一子任务对应的处理函数后,将进度指示信息中的第一指示参数更新为所述多个子任务中所述第一子任务的下一个子任务对应的第二指示参数,这样可以在第一任务的第一子任务执行完毕后执行其他任务,避免了在任务切换时需要给当前执行的第一子任务分配单独的存储空间以保存当前执行的第一子任务的CPU上下文,大大降低了对存储资源和CPU的消耗,提高了CPU的利用率。此外,这样的设计方法在实现过程中就可以采用模块化的方式(例如状态机或迭代器等方法)分别对多个子任务或多个待执行的任务进行开发和设计,增加编程的灵活性,降低任务编程的难度,提高程序的可复用性,达到提升开发和维护效率的目的。Therefore, in response to the above problems, the present application provides a task processing method, after executing the processing function corresponding to the first subtask, the first indication parameter in the progress indication information is updated to the second indication parameter corresponding to the next subtask of the first subtask in the multiple subtasks, so that other tasks can be executed after the first subtask of the first task is executed, avoiding the need to allocate a separate storage space to the currently executed first subtask to save the CPU context of the currently executed first subtask when switching tasks, greatly reducing the consumption of storage resources and CPU, and improving the CPU utilization. In addition, such a design method can adopt a modular approach (such as state machine or iterator method) to develop and design multiple subtasks or multiple tasks to be executed separately during the implementation process, increase programming flexibility, reduce the difficulty of task programming, improve the reusability of the program, and achieve the purpose of improving development and maintenance efficiency.

下面结合本申请实施例中的附图以及相关实施例,对本申请实施例中的技术方案进行描述。其中,在本申请实施例的描述中,以下实施例中所使用的术语只是为了描述特定实施例的目的,而并非旨在作为对本申请的限制。如在本申请的说明书和所附权利要求书中所使用的那样,单数表达形式“一种”、“所述”、“上述”、“该”和“这一”旨在也包括例如“一个或多个”这种表达形式,除非其上下文中明确地有相反指示。还应当理解,在本申请以下各实施例中,“至少一个”、“一个或多个”是指一个或两个以上(包含两个)。术语“和/或”,用于描述关联对象的关联关系,表示可以存在三种关系;例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A、B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。The technical solutions in the embodiments of the present application are described below in conjunction with the drawings and related embodiments in the embodiments of the present application. Among them, in the description of the embodiments of the present application, the terms used in the following embodiments are only for the purpose of describing specific embodiments, and are not intended to be used as limitations on the present application. As used in the specification and the appended claims of the present application, the singular expressions "a", "said", "above", "the" and "this" are intended to also include expressions such as "one or more", unless there is a clear indication to the contrary in the context. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" refer to one or more (including two). The term "and/or" is used to describe the association relationship of associated objects, indicating that three relationships can exist; for example, A and/or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character "/" generally indicates that the associated objects before and after are in a "or" relationship.

在本说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“在一个实施例中”、“在一些实施例中”、“在其他一些实施例中”、“在另外一些实施例中”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。术语“包括”、“包含”、“具有”及它们的变形都意味着“包括但不限于”,除非是以其他方式另外特别强调。术语“连接”包括直接连接和间接连接,除非另外说明。“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。References to "one embodiment" or "some embodiments" etc. described in this specification mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Thus, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "include", "comprise", "have" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways. The term "connection" includes direct connection and indirect connection, unless otherwise specified. "First" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.

在本申请实施例中,“示例性地”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性地”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性地”或者“例如”等词旨在以具体方式呈现相关概念。In the embodiments of the present application, the words "exemplarily" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily" or "for example" is intended to present related concepts in a specific way.

本申请实施例提供的任务处理方法可以应用于电子设备。电子设备可以是手机、平板电脑、可穿戴设备、增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR)设备、笔记本电脑、超级移动个人计算机(Ultra-Mobile Personal Computer,UMPC)、上网本、个人数字助理(Personal Digital Assistant,PDA)、车载设备、智慧屏、云端服务器等,本申请实施例对电子设备的具体类型不作任何限制。The task processing method provided in the embodiment of the present application can be applied to electronic devices. The electronic device can be a mobile phone, a tablet computer, a wearable device, an augmented reality (AR)/virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), a vehicle-mounted device, a smart screen, a cloud server, etc. The embodiment of the present application does not impose any restrictions on the specific type of the electronic device.

参见图3,为本申请提供的一种电子设备300的结构示意图。电子设备300可以包括处理器310,外部存储器接口320,内部存储器331,通用串行总线(Universal Serial Bus,USB)接口330,充电管理模块340,电源管理模块341,电池342,天线1,天线2,移动通信模块350,无线通信模块360,音频模块370,扬声器370A,受话器370B,麦克风370C,耳机接口370D,传感器模块380,按键390,马达391,指示器392,摄像头393,显示屏394,以及用户标识模块(Subscriber Identification Module,SIM)卡接口395等。其中传感器模块380可以包括压力传感器380A,陀螺仪传感器380B,气压传感器380C,磁传感器380D,加速度传感器380E,距离传感器380F,接近光传感器380G,指纹传感器380H,温度传感器380J,触摸传感器380K,环境光传感器380L,骨传导传感器380M等。Referring to FIG3 , it is a schematic diagram of the structure of an electronic device 300 provided in the present application. The electronic device 300 may include a processor 310, an external memory interface 320, an internal memory 331, a Universal Serial Bus (USB) interface 330, a charging management module 340, a power management module 341, a battery 342, an antenna 1, an antenna 2, a mobile communication module 350, a wireless communication module 360, an audio module 370, a speaker 370A, a receiver 370B, a microphone 370C, an earphone interface 370D, a sensor module 380, a button 390, a motor 391, an indicator 392, a camera 393, a display screen 394, and a Subscriber Identification Module (SIM) card interface 395, etc. The sensor module 380 may include a pressure sensor 380A, a gyroscope sensor 380B, an air pressure sensor 380C, a magnetic sensor 380D, an acceleration sensor 380E, a distance sensor 380F, a proximity light sensor 380G, a fingerprint sensor 380H, a temperature sensor 380J, a touch sensor 380K, an ambient light sensor 380L, a bone conduction sensor 380M, etc.

可以理解的是,本申请实施例示意的结构并不构成对电子设备300的具体限定。在本申请另一些实施例中,电子设备300可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 300. In other embodiments of the present application, the electronic device 300 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

作为举例,当电子设备300为手机或平板电脑时,可以包括图示中的全部部件,也可以仅包括图示中的部分部件。 For example, when the electronic device 300 is a mobile phone or a tablet computer, it may include all the components shown in the figure, or may include only some of the components shown in the figure.

处理器310可以包括一个或多个处理单元,例如:处理器310可以包括应用处理器(Application Processor,AP),调制解调处理器,图形处理器(Graphics Processing Unit,GPU),图像信号处理器(Image Signal Processor,ISP),控制器,存储器,视频编解码器,数字信号处理器(Digital Signal Processor,DSP),基带处理器,和/或神经网络处理器(Neural-network Processing Unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 310 may include one or more processing units, for example, the processor 310 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and/or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated in one or more processors.

其中,控制器可以是电子设备300的神经中枢和指挥中心。控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。The controller may be the nerve center and command center of the electronic device 300. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

处理器310中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器310中的存储器为高速缓冲存储器。该存储器可以保存处理器310刚用过或循环使用的指令或数据。如果处理器310需要再次使用该指令或数据,可从存储器中直接调用。避免了重复存取,减少了处理器310的等待时间,因而提高了系统的效率。The processor 310 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 310 is a cache memory. The memory may store instructions or data that the processor 310 has just used or cyclically used. If the processor 310 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 310, and thus improves the efficiency of the system.

在一些实施例中,处理器310可以包括一个或多个接口。接口可以包括集成电路(Inter-integrated Circuit,I2C)接口,集成电路内置音频(Inter-integrated Circuit Sound,I2S)接口,脉冲编码调制(Pulse Code Modulation,PCM)接口,通用异步收发传输器(Universal Asynchronous Receiver/Transmitter,UART)接口,移动产业处理器接口(Mobile Industry Processor Interface,MIPI),通用输入输出(General-Purpose Input/Output,GPIO)接口,用户标识模块(Subscriber Identity Module,SIM)接口,和/或通用串行总线(Universal Serial Bus,USB)接口等。In some embodiments, the processor 310 may include one or more interfaces. The interface may include an Inter-integrated Circuit (I2C) interface, an Inter-integrated Circuit Sound (I2S) interface, a Pulse Code Modulation (PCM) interface, a Universal Asynchronous Receiver/Transmitter (UART) interface, a Mobile Industry Processor Interface (MIPI), a General-Purpose Input/Output (GPIO) interface, a Subscriber Identity Module (SIM) interface, and/or a Universal Serial Bus (USB) interface, etc.

USB接口330是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口330可以用于连接充电器为电子设备300充电,也可以用于电子设备300与外围设备之间传输数据。也可以用于连接耳机,通过耳机播放音频。该接口还可以用于连接其他电子设备,例如AR设备等。The USB interface 330 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 330 can be used to connect a charger to charge the electronic device 300, and can also be used to transmit data between the electronic device 300 and a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.

可以理解的是,本申请实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备300的结构限定。在本申请另一些实施例中,电子设备300也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 300. In other embodiments of the present application, the electronic device 300 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

充电管理模块340用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。在一些有线充电的实施例中,充电管理模块340可以通过USB接口330接收有线充电器的充电输入。在一些无线充电的实施例中,充电管理模块340可以通过电子设备300的无线充电线圈接收无线充电输入。充电管理模块340为电池342充电的同时,还可以通过电源管理模块341为电子设备供电。The charging management module 340 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 340 may receive charging input from a wired charger through the USB interface 330. In some wireless charging embodiments, the charging management module 340 may receive wireless charging input through a wireless charging coil of the electronic device 300. While the charging management module 340 is charging the battery 342, it may also power the electronic device through the power management module 341.

电源管理模块341用于连接电池342,充电管理模块340与处理器310。电源管理模块341接收电池342和/或充电管理模块340的输入,为处理器310,内部存储器331,外部存储器接口320,显示屏394,摄像头393,和无线通信模块360等供电。电源管理模块341还可以用于监测电池容量,电池循环次数,电池健康状态(漏电、阻抗)等参数。The power management module 341 is used to connect the battery 342, the charging management module 340 and the processor 310. The power management module 341 receives input from the battery 342 and/or the charging management module 340, and supplies power to the processor 310, the internal memory 331, the external memory interface 320, the display screen 394, the camera 393, and the wireless communication module 360. The power management module 341 can also be used to monitor parameters such as battery capacity, battery cycle number, and battery health status (leakage, impedance).

在其他一些实施例中,电源管理模块341也可以设置于处理器310中。在另一些实施例中,电源管理模块341和充电管理模块340也可以设置于同一个器件中。In some other embodiments, the power management module 341 may also be disposed in the processor 310. In some other embodiments, the power management module 341 and the charging management module 340 may also be disposed in the same device.

电子设备300的无线通信功能可以通过天线1,天线2,移动通信模块350,无线通信模块360,调制解调处理器以及基带处理器等实现。The wireless communication function of the electronic device 300 can be implemented through the antenna 1, the antenna 2, the mobile communication module 350, the wireless communication module 360, the modem processor and the baseband processor.

天线1和天线2用于发射和接收电磁波信号。电子设备300中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 300 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

移动通信模块350可以提供应用在电子设备300上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块350可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块350可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块350还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。The mobile communication module 350 can provide solutions for wireless communications including 2G/3G/4G/5G, etc., applied to the electronic device 300. The mobile communication module 350 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 350 can receive electromagnetic waves from the antenna 1, and filter, amplify, etc. the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 350 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1.

在一些实施例中,移动通信模块350的至少部分功能模块可以被设置于处理器310中。在一些实施例中,移动通信模块350的至少部分功能模块可以与处理器310的至少部分模块被设置在同一个器件中。 In some embodiments, at least some functional modules of the mobile communication module 350 may be disposed in the processor 310. In some embodiments, at least some functional modules of the mobile communication module 350 and at least some modules of the processor 310 may be disposed in the same device.

调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器370A,受话器370B等)输出声音信号,或通过显示屏394显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器310,与移动通信模块350或其他功能模块设置在同一个器件中。The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 370A, a receiver 370B, etc.), or displays an image or video through a display screen 394. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 310 and be set in the same device as the mobile communication module 350 or other functional modules.

无线通信模块360可以提供应用在电子设备300上的包括无线局域网(wireless local area networks,WLAN)(如无线保真(Wireless Fidelity,Wi-Fi)网络),蓝牙(BlueTooth,BT),全球导航卫星系统(Global Navigation Satellite System,GNSS),调频(Frequency Modulation,FM),近距离无线通信技术(Near Field Communication,NFC),红外技术(Infrared,IR)等无线通信的解决方案。无线通信模块360可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块360经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器310。无线通信模块360还可以从处理器310接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。The wireless communication module 360 can provide wireless communication solutions including wireless local area networks (WLAN) (such as Wireless Fidelity (Wi-Fi) network), Bluetooth (BT), Global Navigation Satellite System (GNSS), Frequency Modulation (FM), Near Field Communication (NFC), Infrared (IR), etc., which are applied to the electronic device 300. The wireless communication module 360 can be one or more devices integrating at least one communication processing module. The wireless communication module 360 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 310. The wireless communication module 360 can also receive the signal to be sent from the processor 310, modulate the frequency of the signal, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

在一些实施例中,电子设备300的天线1和移动通信模块350耦合,天线2和无线通信模块360耦合,使得电子设备300可以通过无线通信技术与网络以及其他设备通信。无线通信技术可以包括全球移动通讯系统(Global System for Mobile Communications,GSM),通用分组无线服务(General Packet Radio Service,GPRS),码分多址接入(Code Division Multiple Access,CDMA),宽带码分多址(Wideband Code Division Multiple Access,WCDMA),时分码分多址(Time-Division Code Division Multiple Access,TD-SCDMA),长期演进(Long Term Evolution,LTE),BT,GNSS,WLAN,NFC,FM,和/或IR技术等。GNSS可以包括全球卫星定位系统(Global Positioning System,GPS),全球导航卫星系统(Global Navigation Satellite System,GLONASS),北斗卫星导航系统(Beidou Navigation Satellite System,BDS),准天顶卫星系统(Quasi-Zenith Satellite System,QZSS)和/或星基增强系统(Satellite Based Augmentation Systems,SBAS)。In some embodiments, the antenna 1 of the electronic device 300 is coupled to the mobile communication module 350, and the antenna 2 is coupled to the wireless communication module 360, so that the electronic device 300 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and/or IR technology. GNSS can include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the Beidou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS) and/or the Satellite Based Augmentation Systems (SBAS).

电子设备300通过GPU,显示屏394,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏394和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器310可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。The electronic device 300 implements the display function through a GPU, a display screen 394, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 394 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 310 may include one or more GPUs, which execute program instructions to generate or change display information.

显示屏394用于显示图像,视频等。例如本申请实施例中的APP的图标、文件夹、文件夹名称等。显示屏394包括显示面板。显示面板可以采用液晶显示屏(Liquid Crystal Display,LCD),有机发光二极管(Organic Light-Emitting Diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(Active-Matrix Organic Light Emitting Diode,AMOLED),柔性发光二极管(Flex Light-Emitting Diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(Quantum Dot Light Emitting Diodes,QLED)等。在一些实施例中,电子设备300可以包括1个或N个显示屏394,N为大于1的正整数。The display screen 394 is used to display images, videos, etc. For example, icons, folders, folder names, etc. of the APP in the embodiment of the present application. The display screen 394 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 300 may include 1 or N display screens 394, where N is a positive integer greater than 1.

电子设备300可以通过ISP,摄像头393,视频编解码器,GPU,显示屏394以及应用处理器等实现拍摄功能。The electronic device 300 can realize the shooting function through ISP, camera 393, video codec, GPU, display screen 394 and application processor.

ISP用于处理摄像头393反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,肤色进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头393中。The ISP is used to process the data fed back by the camera 393. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. The ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP can be set in the camera 393.

摄像头393用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。镜头的焦段可以用于表示摄像头的取景范围,镜头的焦段越小,表示镜头的取景范围越大。感光元件可以是电荷耦合器件(Charge Coupled Device,CCD)或互补金属氧化物半导体(Complementary Metal-Oxide-Semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。The camera 393 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The focal length of the lens can be used to indicate the field of view of the camera. The smaller the focal length of the lens, the larger the field of view of the lens. The photosensitive element can be a charge coupled device (CCD) or a complementary metal oxide semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP for conversion into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format.

在本申请中,电子设备300可以包括2个或2个以上焦段的摄像头393。In the present application, the electronic device 300 may include cameras 393 with 2 or more focal lengths.

数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备300在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 300 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.

视频编解码器用于对数字视频压缩或解压缩。电子设备300可以支持一种或多种视频编解码器。 这样,电子设备300可以播放或录制多种编码格式的视频,例如:动态图像专家组(Moving Picture Experts Group,MPEG)1,MPEG1,MPEG3,MPEG4等。The video codec is used to compress or decompress digital video. The electronic device 300 may support one or more video codecs. In this way, the electronic device 300 can play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG1, MPEG3, MPEG4, etc.

NPU为神经网络(Neural-Network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备300的智能认知等应用,例如:图像识别,人脸识别,语音识别,文本理解等。NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of the electronic device 300 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.

在本申请实施例中,NPU或其他处理器可以用于对电子设备300存储的视频中的图像进行分析处理等操作。In an embodiment of the present application, the NPU or other processors may be used to perform operations such as analyzing and processing images in a video stored in the electronic device 300.

外部存储器接口320可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备300的存储能力。外部存储卡通过外部存储器接口320与处理器310通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。The external memory interface 320 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 300. The external memory card communicates with the processor 310 through the external memory interface 320 to implement a data storage function. For example, files such as music and videos can be stored in the external memory card.

内部存储器331可以用于存储计算机可执行程序代码,可执行程序代码包括指令。处理器310通过运行存储在内部存储器331的指令,从而执行电子设备300的各种功能应用以及数据处理。内部存储器331可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)。存储数据区可存储电子设备300使用过程中所创建的数据(比如音频数据,电话本等)。The internal memory 331 can be used to store computer executable program codes, and the executable program codes include instructions. The processor 310 executes various functional applications and data processing of the electronic device 300 by running the instructions stored in the internal memory 331. The internal memory 331 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.). The data storage area can store data created during the use of the electronic device 300 (such as audio data, a phone book, etc.).

此外,内部存储器331可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,闪存器件,通用闪存存储器(Universal Flash Storage,UFS)等。In addition, the internal memory 331 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (Universal Flash Storage, UFS), etc.

电子设备300可以通过音频模块370,扬声器370A,受话器370B,麦克风370C,耳机接口370D,以及应用处理器等实现音频功能。The electronic device 300 can implement audio functions through an audio module 370, a speaker 370A, a receiver 370B, a microphone 370C, an earphone interface 370D, and an application processor.

音频模块370用于将数字音频信号转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块370还可以用于对音频信号编码和解码。在一些实施例中,音频模块370可以设置于处理器310中,或将音频模块370的部分功能模块设置于处理器310中。The audio module 370 is used to convert digital audio signals into analog audio signals for output, and is also used to convert analog audio inputs into digital audio signals. The audio module 370 can also be used to encode and decode audio signals. In some embodiments, the audio module 370 can be arranged in the processor 310, or some functional modules of the audio module 370 can be arranged in the processor 310.

扬声器370A,也称“喇叭”,用于将音频电信号转换为声音信号。电子设备300可以通过扬声器370A收听音乐,或收听免提通话,例如扬声器可以播放本申请实施例提供的比对分析结果。The speaker 370A, also called a "speaker", is used to convert audio electrical signals into sound signals. The electronic device 300 can listen to music or listen to hands-free calls through the speaker 370A. For example, the speaker can play the comparison analysis results provided in the embodiment of the present application.

受话器370B,也称“听筒”,用于将音频电信号转换成声音信号。当电子设备300接听电话或语音信息时,可以通过将受话器370B靠近人耳接听语音。The receiver 370B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 300 receives a call or voice message, the voice can be received by placing the receiver 370B close to the human ear.

麦克风370C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。当拨打电话或发送语音信息时,用户可以通过人嘴靠近麦克风370C发声,将声音信号输入到麦克风370C。电子设备300可以设置至少一个麦克风370C。在另一些实施例中,电子设备300可以设置两个麦克风370C,除了采集声音信号,还可以实现降噪功能。在另一些实施例中,电子设备300还可以设置三个,四个或更多麦克风370C,实现采集声音信号,降噪,还可以识别声音来源,实现定向录音功能等。Microphone 370C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to the microphone 370C to input the sound signal into the microphone 370C. The electronic device 300 can be provided with at least one microphone 370C. In other embodiments, the electronic device 300 can be provided with two microphones 370C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 300 can also be provided with three, four or more microphones 370C to collect sound signals, reduce noise, identify the sound source, realize directional recording function, etc.

耳机接口370D用于连接有线耳机。耳机接口370D可以是USB接口330,也可以是3.5mm的开放移动电子设备平台(Open mobile Terminal Platform,OMTP)标准接口,美国蜂窝电信工业协会(Cellular Telecommunications Industry Association of the USA,CTIA)标准接口。The earphone interface 370D is used to connect a wired earphone. The earphone interface 370D may be the USB interface 330, or may be a 3.5 mm Open Mobile Terminal Platform (OMTP) standard interface or a Cellular Telecommunications Industry Association of the USA (CTIA) standard interface.

按键390包括开机键,音量键等。按键390可以是机械按键。也可以是触摸式按键。电子设备300可以接收按键输入,产生与电子设备300的用户设置以及功能控制有关的键信号输入。The key 390 includes a power key, a volume key, etc. The key 390 may be a mechanical key or a touch key. The electronic device 300 may receive key input and generate key signal input related to user settings and function control of the electronic device 300.

马达391可以产生振动提示。马达391可以用于来电振动提示,也可以用于触摸振动反馈。例如,作用于不同应用(例如拍照,音频播放等)的触摸操作,可以对应不同的振动反馈效果。作用于显示屏394不同区域的触摸操作,马达391也可对应不同的振动反馈效果。不同的应用场景(例如:时间提醒,接收信息,闹钟,游戏等)也可以对应不同的振动反馈效果。触摸振动反馈效果还可以支持自定义。Motor 391 can generate vibration prompts. Motor 391 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 394, motor 391 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.

指示器392可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。Indicator 392 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.

SIM卡接口395用于连接SIM卡。SIM卡可以通过插入SIM卡接口395,或从SIM卡接口395拔出,实现和电子设备300的接触和分离。电子设备300可以支持1个或N个SIM卡接口,N为大于1的正整数。SIM卡接口395可以支持Nano SIM卡,Micro SIM卡,SIM卡等。同一个SIM卡接口395可以同时插入多张卡。多张卡的类型可以相同,也可以不同。SIM卡接口395也可以兼容不同类型的SIM卡。SIM卡接口395也可以兼容外部存储卡。电子设备300通过SIM卡和网络交互, 实现通话以及数据通信等功能。在一些实施例中,电子设备300采用eSIM,即:嵌入式SIM卡。eSIM卡可以嵌在电子设备300中,不能和电子设备300分离。The SIM card interface 395 is used to connect a SIM card. The SIM card can be connected to or disconnected from the electronic device 300 by inserting it into the SIM card interface 395 or removing it from the SIM card interface 395. The electronic device 300 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 395 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 395 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 395 can also be compatible with different types of SIM cards. The SIM card interface 395 can also be compatible with external memory cards. The electronic device 300 interacts with the network through the SIM card, To realize functions such as calls and data communications. In some embodiments, the electronic device 300 uses an eSIM, that is, an embedded SIM card. The eSIM card can be embedded in the electronic device 300 and cannot be separated from the electronic device 300.

本申请提供的任务处理方法可以应用于多种计算机系统中,示例性的,计算机系统可以是微控制单元(Microcontroller Unit,MCU)嵌入式系统。需要说明的是,在不同计算机系统中该任务处理方法的执行主体可能不同。例如,在上述MCU嵌入式系统中,任务处理方法的执行主体可以是MCU;在其他系统中,任务处理方法的执行主体可能是控制芯片。本申请对计算机系统的类型及本申请提供的任务处理方法的执行主体不作任何限定。The task processing method provided in this application can be applied to a variety of computer systems. For example, the computer system can be a microcontroller unit (MCU) embedded system. It should be noted that the execution subject of the task processing method may be different in different computer systems. For example, in the above-mentioned MCU embedded system, the execution subject of the task processing method can be the MCU; in other systems, the execution subject of the task processing method can be the control chip. This application does not impose any restrictions on the type of computer system and the execution subject of the task processing method provided in this application.

在一个示例中,如图4所示为本申请实施例提供的一种MCU嵌入式系统的结构示意图,参见图4,该MCU嵌入式系统中包括与MCU电连接的传感器、与MCU电连接的执行器以及与MCU通信连接的上位机,传感器可以是温度传感器、位置传感器等,用于实时监测并获取传感数据;执行器可以是在满足一些特定的条件下能够执行某一或某些动作的设备,例如,上述执行器可以是电机、机床、工业机器人、步进马达、机器手臂以及仪器仪表等;上位机一般是指起到控制、调配等作用的设备,例如,笔记本电脑等能够与MCU之间进行例如通信命令等信息传输的设备。上述图4所示的MCU嵌入式系统仅是本申请实施例提供的任务处理方法在实际应用中一种可能的示例。实际应用中,随着业务需求的不同,对应的MCU嵌入式系统可能发生变化,本申请对此不做特殊限定。In one example, as shown in FIG4, a structural diagram of an MCU embedded system provided by an embodiment of the present application is shown. Referring to FIG4, the MCU embedded system includes a sensor electrically connected to the MCU, an actuator electrically connected to the MCU, and a host computer connected to the MCU in communication. The sensor may be a temperature sensor, a position sensor, etc., for real-time monitoring and acquisition of sensor data; the actuator may be a device that can perform one or some actions under certain conditions, for example, the actuator may be a motor, a machine tool, an industrial robot, a stepper motor, a robot arm, and an instrument; the host computer generally refers to a device that plays a role in control and deployment, for example, a laptop computer, etc., which can transmit information such as communication commands with the MCU. The MCU embedded system shown in FIG4 above is only a possible example of the task processing method provided by the embodiment of the present application in practical applications. In practical applications, the corresponding MCU embedded system may change with different business needs, and this application does not make special restrictions on this.

下面将结合如图4所示的MCU嵌入式系统对本申请实施例提供的任务处理方法进行示例性说明。The task processing method provided in the embodiment of the present application will be exemplarily described below in conjunction with the MCU embedded system shown in FIG. 4 .

如图5所示为本申请实施例提供的一种任务处理过程的流程示意图,参见图5,本申请实施例中对任务的完整运行过程主要包括初始化处理、确定第一任务以及第一任务执行,其中,初始化处理可以理解为将待执行的任务注册至对应的系统中,以对任务的初始化处理,得到初始化处理后的任务集合,其中,初始化处理后的任务集合中存在第一任务;之后,从任务集合中确定待执行的第一任务;确定了第一任务以后,利用本申请实施例提供的任务处理方法对第一任务进行执行。As shown in Figure 5, it is a flow chart of a task processing process provided by an embodiment of the present application. Referring to Figure 5, the complete operation process of the task in the embodiment of the present application mainly includes initialization processing, determining the first task and executing the first task, wherein the initialization processing can be understood as registering the task to be executed to the corresponding system, and performing initialization processing on the task to obtain a task set after initialization processing, wherein the task set after initialization processing contains the first task; then, determining the first task to be executed from the task set; after determining the first task, executing the first task using the task processing method provided in the embodiment of the present application.

在实际应用中,任务集合中可以包括一个任务或多个任务,进行初始化处理的任务的数量不同时,确定第一任务的方法可能不同。在本申请实施例中,若任务集合中仅存在一个任务,则对任务集合中的该任务进行初始化处理,对该任务初始化处理完成后,直接将该任务确定为第一任务;若任务集合中存在两个或两个以上的任务,则可以先对多个任务分别进行初始化处理,得到由多个任务构成的任务集合,之后,可以利用预设的任务调度策略从上述任务集合中确定待处理或待执行的第一任务。In practical applications, a task set may include one or more tasks. When the number of tasks to be initialized is different, the method for determining the first task may be different. In an embodiment of the present application, if there is only one task in the task set, the task in the task set is initialized, and after the task initialization is completed, the task is directly determined as the first task; if there are two or more tasks in the task set, the multiple tasks can be initialized separately to obtain a task set consisting of multiple tasks, and then the preset task scheduling strategy can be used to determine the first task to be processed or executed from the above task set.

应理解,预设的任务调度策略可以包括:先进先出调度策略、基于优先级调度策略以及轮询调度策略中的任意一种。在实际实现过程中,任务调度策略也可以是用户根据不同的业务场景进行自定义的,本申请对任务调度策略的具体内容不作限定。It should be understood that the preset task scheduling strategy may include any one of: a first-in-first-out scheduling strategy, a priority-based scheduling strategy, and a polling scheduling strategy. In the actual implementation process, the task scheduling strategy can also be customized by the user according to different business scenarios, and this application does not limit the specific content of the task scheduling strategy.

如图6所示为本申请实施例提供的一种任务处理方法的一个实施例的流程图,参见图6,该任务处理方法主要包括如下步骤:FIG6 is a flowchart of an embodiment of a task processing method provided by an embodiment of the present application. Referring to FIG6 , the task processing method mainly includes the following steps:

S601,获取第一任务的进度指示信息,进度指示信息包括与第一子任务对应的第一指示参数,第一任务包括多个子任务,第一子任务为多个子任务中未被执行的子任务。S601, obtaining progress indication information of a first task, the progress indication information including a first indication parameter corresponding to a first subtask, the first task including a plurality of subtasks, the first subtask being a subtask that has not been executed among the plurality of subtasks.

应理解,第一任务(也可以称为目标任务)是指当前待执行或待处理的一个任务(或作业流),在实际应用中,可以将该第一任务理解为待处理的某一具体功能。例如,在图4所示的MCU嵌入式系统中,假设执行器为电机,具体业务场景为MCU每一分钟控制电机顺时针旋转180°;传感器为温度传感器,用于实时监测温度;上位机为笔记本电脑,用于实时监测串口接收到的命令。那么在该示例中,可以将电机每分钟旋转180°、温度传感器实时监测温度以及上位机实时监测串口命令理解为3个任务(或3条作业流),这3个任务构成一个任务集合,假设这3个任务的优先级依次升高,且任务调度策略选择为基于优先级的调度策略,那么可以将上述3个任务中的第三个任务:上位机实时监测串口命令确定为第一任务。It should be understood that the first task (also called the target task) refers to a task (or job flow) to be executed or processed at present. In practical applications, the first task can be understood as a specific function to be processed. For example, in the MCU embedded system shown in FIG4, it is assumed that the actuator is a motor, and the specific business scenario is that the MCU controls the motor to rotate 180° clockwise every minute; the sensor is a temperature sensor for real-time temperature monitoring; the host computer is a laptop computer for real-time monitoring of the commands received by the serial port. Then in this example, the motor rotates 180° per minute, the temperature sensor monitors the temperature in real time, and the host computer monitors the serial port command in real time as three tasks (or three job flows). These three tasks constitute a task set. Assuming that the priorities of these three tasks increase in sequence, and the task scheduling strategy is selected as a priority-based scheduling strategy, the third task of the above three tasks: the host computer monitors the serial port command in real time can be determined as the first task.

需要说明的是,在实际实现过程中,任务集合中的每个任务均具有对应的属性信息,属性信息包括但不限于编号、名称、优先级、进度指示信息以及与该任务对应的任务处理函数等,其中,编号可以用于唯一识别某一任务;名称是与每个任务对应的注记符,一般用于调试过程中,用于显示具体的调测信息;优先级也是优先处理等级,用于标识任务执行的先后顺序,任务的优先级越高,则该任务执行的顺序越靠前;在本申请实施例中,在每个任务的属性信息中新增了进度指示信息,该进度指示信息用于标识每个任务的执行进度;任务处理函数与每个第一任务相对应,也就是说, 该任务处理函数是与每个第一任务对应的主处理函数,在程序执行过程中,该任务处理函数是建立某一具体任务的程序入口,便于后续利用该任务处理函数对与该任务相关的其他的函数、方法的调用。It should be noted that, in the actual implementation process, each task in the task set has corresponding attribute information, and the attribute information includes but is not limited to number, name, priority, progress indication information and the task processing function corresponding to the task, among which the number can be used to uniquely identify a task; the name is a notation corresponding to each task, which is generally used in the debugging process to display specific debugging information; the priority is also a priority processing level, which is used to identify the order of task execution. The higher the priority of the task, the higher the order of execution of the task; in the embodiment of the present application, progress indication information is newly added to the attribute information of each task, and the progress indication information is used to identify the execution progress of each task; the task processing function corresponds to each first task, that is, The task processing function is the main processing function corresponding to each first task. During program execution, the task processing function is used to establish a program entry for a specific task, so as to facilitate the subsequent use of the task processing function to call other functions and methods related to the task.

以图4所示的MCU嵌入式系统为例,假设利用基于优先级的任务调度策略确定了第三个任务为第一任务,其中,第三个任务为上位机实时监测串口命令,那么在确定了第一任务以后就可以通过获取该第一任务的进度指示信息,即与第三个任务对应的进度指示信息,来确定第三个任务的执行进度,进而确定该第三个任务的第一子任务。Taking the MCU embedded system shown in Figure 4 as an example, assuming that the third task is determined as the first task using a priority-based task scheduling strategy, where the third task is real-time monitoring of serial port commands by the host computer, then after the first task is determined, the execution progress of the third task can be determined by obtaining the progress indication information of the first task, that is, the progress indication information corresponding to the third task, and then the first subtask of the third task can be determined.

应理解,第一子任务是根据第一任务的进度指示信息确定的,该第一子任务可以理解为第一任务的多个子任务中,按照第一任务的执行顺序或功能所划分的未被执行的子任务中的第一个子任务。值得注意的是,为了能够更好的对与第一任务对应的处理函数进行管理,在实际应用中,有些第一任务按照执行顺序可能划分为一个子任务,这种情况下,第一子任务通常是功能简单的任务,第一子任务即是与第一任务相同的任务。It should be understood that the first subtask is determined according to the progress indication information of the first task, and the first subtask can be understood as the first subtask among the multiple subtasks of the first task that have not been executed and are divided according to the execution order or function of the first task. It is worth noting that in order to better manage the processing functions corresponding to the first task, in actual applications, some first tasks may be divided into one subtask according to the execution order. In this case, the first subtask is usually a task with simple functions, and the first subtask is the same task as the first task.

本申请实施例中,在第一任务一次完整的执行过程中,第一子任务是未被执行的一个子任务。假设将上述示例中的第三个任务“上位机实时监测串口命令”确定为第一任务,并标记为任务1,那么,可以按照该任务的执行顺序将该任务1依次划分为:子任务a监测数据、子任务b接收监测到的数据以及子任务c对接收到的监测数据的处理以上三个子任务,在第一任务一次完整的执行过程中,可以通过获取该任务1对应的进度指示信息中第一指示参数来确定任务1中未被执行的第一子任务,随着进度指示信息中第一指示参数的变化,第一子任务可能是子任务a,可能是子任务b,也可能是子任务c。In the embodiment of the present application, during a complete execution of the first task, the first subtask is a subtask that has not been executed. Assuming that the third task "real-time monitoring of serial port commands by the host computer" in the above example is determined as the first task and marked as task 1, then, according to the execution order of the task, task 1 can be divided into: subtask a monitoring data, subtask b receiving the monitored data, and subtask c processing the received monitoring data. The above three subtasks, during a complete execution of the first task, the first subtask that has not been executed in task 1 can be determined by obtaining the first indication parameter in the progress indication information corresponding to task 1. As the first indication parameter in the progress indication information changes, the first subtask may be subtask a, may be subtask b, or may be subtask c.

S602,根据第一指示参数执行与第一子任务对应的处理函数。S602: Execute a processing function corresponding to the first subtask according to the first indication parameter.

应理解,与第一子任务对应的处理函数也是指执行第一子任务的子处理函数。在确定了第一任务的第一子任务后,可以通过执行与第一子任务对应的子处理函数实现对第一子任务的处理。It should be understood that the processing function corresponding to the first subtask also refers to the sub-processing function that executes the first subtask. After the first subtask of the first task is determined, the processing of the first subtask can be implemented by executing the sub-processing function corresponding to the first subtask.

S603,在处理函数执行完后,将进度指示信息中的第一指示参数更新为与第二子任务对应的第二指示参数,第二子任务为多个子任务中第一子任务的下一个子任务。S603: After the processing function is executed, the first indication parameter in the progress indication information is updated to a second indication parameter corresponding to the second subtask, where the second subtask is the next subtask of the first subtask among the multiple subtasks.

不难理解的,第二子任务的第二指示参数是第一任务的进度指示信息中与第一子任务的下一个子任务对应的第二指示参数。It is not difficult to understand that the second indication parameter of the second subtask is the second indication parameter corresponding to the next subtask of the first subtask in the progress indication information of the first task.

应理解,若第一子任务是多个子任务中的最后一个子任务,则第二子任务为多个子任务中第一个子任务;若第一子任务不是多个子任务中的最后一个子任务,则将第一指示参数更新为与第二子任务对应的第二指示参数,即第二子任务是第一子任务的下一个子任务。It should be understood that if the first subtask is the last subtask among multiple subtasks, the second subtask is the first subtask among the multiple subtasks; if the first subtask is not the last subtask among the multiple subtasks, the first indication parameter is updated to the second indication parameter corresponding to the second subtask, that is, the second subtask is the next subtask of the first subtask.

也就是说,执行完与第一子任务对应的处理函数后,本申请实施例提供的任务处理方法中将第一任务的进度指示信息中的第一指示参数更新为与第二子任务对应的第二指示参数(如根据第一任务中多个子任务的执行顺序对进度指示信息中的第一指示参数进行更新),这样即使在第一任务执行过程中遇到优先级更高的第二任务需要优先处理第二任务的情况下,也可以在对进度指示信息中第一指示参数的更新后,执行第二任务,在优先级更高的第二任务处理完成后,通过更新后的进度指示信息中的第二指示参数获取到第一任务的执行进度,以便继续执行第一任务中未被执行的子任务,快速实现多个任务的切换管理。或者,在第一任务执行过程中存在优先级相同的第二任务时,可以在对第一任务的第一子任务的第一指示参数的更新后,采用本申请实施例提供的任务处理方法执行第二任务的第一子任务,第二任务的第一子任务执行完毕后,根据更新后的第一指示参数(即第二子任务的第二指示参数)执行第一任务的第二子任务,如此循环执行第一任务和第二任务,直至完全执行完第一任务和第二任务,既实现不同任务的切换管理,又便于不同任务轮流使用共享资源,达到均衡负载的效果。That is to say, after executing the processing function corresponding to the first subtask, the task processing method provided in the embodiment of the present application updates the first indication parameter in the progress indication information of the first task to the second indication parameter corresponding to the second subtask (such as updating the first indication parameter in the progress indication information according to the execution order of multiple subtasks in the first task). In this way, even if a second task with a higher priority is encountered during the execution of the first task and the second task needs to be processed first, the second task can be executed after the first indication parameter in the progress indication information is updated. After the processing of the second task with a higher priority is completed, the execution progress of the first task is obtained through the second indication parameter in the updated progress indication information, so as to continue to execute the unexecuted subtasks in the first task, thereby quickly realizing the switching management of multiple tasks. Alternatively, when there is a second task with the same priority during the execution of the first task, after the first indication parameter of the first subtask of the first task is updated, the task processing method provided in the embodiment of the present application can be used to execute the first subtask of the second task. After the first subtask of the second task is executed, the second subtask of the first task is executed according to the updated first indication parameter (i.e., the second indication parameter of the second subtask). The first task and the second task are executed in a cycle until the first task and the second task are completely executed. This not only realizes the switching management of different tasks, but also facilitates different tasks to use shared resources in turn, thereby achieving the effect of load balancing.

在本申请实施例中,若在处理函数执行过程中,检测到新增的第二任务,第二任务的任务处理优先级高于第一任务,则在对第一指示参数更新后,执行第二任务。In an embodiment of the present application, if a newly added second task is detected during the execution of the processing function, and the task processing priority of the second task is higher than that of the first task, the second task is executed after the first indication parameter is updated.

应理解,第二任务可以理解为是在第一任务中的多个子任务还未都完全执行完毕的过程中,检测到的新的任务。It should be understood that the second task can be understood as a new task detected when multiple subtasks in the first task have not yet been completely executed.

换言之,若执行与第一子任务对应的处理函数的过程中,任务集合中存在新增的任务调度的优先级高于第一任务的第二任务,则将进度指示信息中的第一指示参数更新为与第二子任务对应的第二指示参数之后,再利用本申请实施例提供的任务处理方法执行第二任务。不难理解的,上述任务 处理方法使得第一子任务完整的执行过程既包括执行与第一子任务对应的处理函数的过程,又包括利用处理函数对第一子任务处理完成后,对进度指示信息进行更新的过程,这样的设计避免了在第一子任务执行过程中由于其他任务的影响而导致第一子任务执行中断情况的发生,通过将第一任务划分为多个子任务的方式,降低了第一任务执行过程中异常或中断的发生率。In other words, if during the execution of the processing function corresponding to the first subtask, there is a second task in the task set whose scheduling priority is higher than the first task, then after the first indication parameter in the progress indication information is updated to the second indication parameter corresponding to the second subtask, the task processing method provided in the embodiment of the present application is used to execute the second task. It is not difficult to understand that the above task The processing method ensures that the complete execution process of the first subtask includes both the process of executing the processing function corresponding to the first subtask and the process of updating the progress indication information after the first subtask is processed by the processing function. This design avoids the interruption of the execution of the first subtask due to the influence of other tasks during the execution of the first subtask. By dividing the first task into multiple subtasks, the occurrence rate of exceptions or interruptions during the execution of the first task is reduced.

本申请提供的第一任务中的多个子任务可以通过状态机的方式实现,也可以通过迭代器的方式实现,下面结合如图4所示的MCU嵌入式系统对上述两种实现方式进行示例性说明。The multiple subtasks in the first task provided in the present application can be implemented by a state machine or by an iterator. The above two implementation methods are exemplified below in conjunction with the MCU embedded system shown in Figure 4.

首先针对通过状态机的方式进行示例性的说明。First, an exemplary description is given using a state machine.

基于上述实施例中的示例,可以将上述任务1对应划分为三个阶段,第一阶段A对应子任务a;第二阶段B对应子任务b,第三阶段C对应子任务c,参见图7,在具体编程实现过程中,可以将与任务1对应的进度指示信息定义为stage变量,stage的具体取值表示第一指示参数,若在确定第一任务为任务1之后,获取到第一指示参数stage的取值为A,即stage=A,则可以确定该任务1的第一子任务为子任务a。Based on the example in the above embodiment, the above task 1 can be divided into three stages, the first stage A corresponds to subtask a; the second stage B corresponds to subtask b, and the third stage C corresponds to subtask c, see Figure 7. In the specific programming implementation process, the progress indication information corresponding to task 1 can be defined as a stage variable, and the specific value of stage represents the first indication parameter. If after determining that the first task is task 1, the value of the first indication parameter stage is A, that is, stage=A, then it can be determined that the first subtask of task 1 is subtask a.

然后,可以根据第一指示信息执行与任务a对应的处理函数,以实现对第一子任务的处理。如果根据获取到的第一指示信息stage的取值为A,即stage=A,确定第一子任务为子任务a,那么,可以根据stage=A确定与子任务a对应的处理函数为processA(),确定了子任务a的处理函数processA()后,参见图7,就可以通过执行处理函数processA()完成对第一子任务的处理。Then, the processing function corresponding to task a can be executed according to the first indication information to realize the processing of the first subtask. If the value of the acquired first indication information stage is A, that is, stage=A, and the first subtask is determined to be subtask a, then the processing function corresponding to subtask a can be determined to be processA() according to stage=A. After the processing function processA() of subtask a is determined, referring to FIG7 , the processing of the first subtask can be completed by executing the processing function processA().

执行完与第一子任务对应的处理函数后,可以将与第一子任务对应的第一指示参数更新为第一任务的多个子任务中,第一子任务的下一个子任务对应的第二指示参数。接上述示例,参见图7,假设第一子任务为子任务a,对于任务1(第一任务)来说子任务a执行完成后,下一个待执行的子任务为与第二阶段B对应的子任务b,故执行完与任务a对应子处理函数processA()后,可以将进度指示信息中第一指示参数stage的取值更新为与子任务b对应的第二指示参数B,即stage=B。After executing the processing function corresponding to the first subtask, the first indication parameter corresponding to the first subtask can be updated to the second indication parameter corresponding to the next subtask of the first subtask among the multiple subtasks of the first task. Continuing with the above example, referring to FIG7, assuming that the first subtask is subtask a, for task 1 (the first task), after subtask a is executed, the next subtask to be executed is subtask b corresponding to the second stage B. Therefore, after executing the sub-processing function processA() corresponding to task a, the value of the first indication parameter stage in the progress indication information can be updated to the second indication parameter B corresponding to subtask b, that is, stage=B.

不难理解的,若第一子任务为子任务c,执行完与任务c对应子处理函数processC()后,则应该将第一任务a中进度指示信息中的第一指示参数C更新为与任务a对应的第二指示参数A,即stage=A。不难理解的,对于任务1(第一任务)来说,在执行完子任务c后即能够表示任务1已经执行完一次,当该任务1再次被确定为第一任务时,该任务1的第一个子任务将会从子任务a重新开始执行,以符合实际应用需求。It is not difficult to understand that if the first subtask is subtask c, after executing the sub-processing function processC() corresponding to task c, the first indication parameter C in the progress indication information of the first task a should be updated to the second indication parameter A corresponding to task a, that is, stage = A. It is not difficult to understand that for task 1 (the first task), after executing subtask c, it can be indicated that task 1 has been executed once. When task 1 is determined as the first task again, the first subtask of task 1 will be restarted from subtask a to meet the actual application requirements.

接着针对通过迭代器的方式进行示例性的说明。Next, an exemplary description is given of the method using iterators.

通过迭代器实现第一任务中多个子任务的方式中,可以将进度指示信息定义用于第一任务执行进度的指针变量(或游标),该指针变量所指向的地址即为第一指示参数,即获取到与第一任务对应的指针变量后,能够将与指针变量指向的地址对应的子任务确定为第一子任务。In the method of implementing multiple subtasks in the first task through an iterator, the progress indication information can be defined as a pointer variable (or cursor) for the execution progress of the first task. The address pointed to by the pointer variable is the first indication parameter. That is, after obtaining the pointer variable corresponding to the first task, the subtask corresponding to the address pointed to by the pointer variable can be determined as the first subtask.

基于上述同一示例,参见图8、图9,可以将上述任务1对应的三个子任务分别定义为数组SubFuncArray中三个有序的元素序列,该数组SubFuncArray中依次包括第一个元素SubFunc0、第二个元素SubFunc1以及第三个元素SubFunc2共三个元素,其中,SubFunc0对应子任务a;SubFunc1对应子任务b,SubFunc2对应子任务c,在具体编程实现过程中,可以将任务1的进度指示信息定义为指针变量Cursor,若指针变量Cursor指向的地址为0,则对应指向数组SubFuncArray中的第一个元素,即第一子任务是与SubFunc0对应的子任务a;若指针变量Cursor指向的地址为1,则对应指向数组SubFuncArray中的第二个元素,即第一子任务是与SubFunc1对应的子任务b;若指针变量Cursor指向的地址为2,则对应指向数组SubFuncArray中的第三个元素,即第一子任务是与SubFunc2对应的子任务c,指针变量指向的地址的实际取值i与第一任务中子任务的数量N之间满足i=N-1。因此,若在确定第一任务为任务1之后,获取到的指针变量Cursor指向的地址对应指向数组SubFuncArray中的第一个元素,则可以确定该任务1的第一子任务为子任务a。Based on the same example above, see Figures 8 and 9. The three subtasks corresponding to the above Task 1 can be defined as three ordered sequences of elements in the array SubFuncArray. The array SubFuncArray includes the first element SubFunc0, the second element SubFunc1, and the third element SubFunc2, a total of three elements. Among them, SubFunc0 corresponds to subtask a; SubFunc1 corresponds to subtask b, and SubFunc2 corresponds to subtask c. In the specific programming implementation process, the progress indication information of Task 1 can be defined as a pointer variable Cursor. If the pointer variable Cursor points to the location If the address pointed to by the pointer variable Cursor is 0, it corresponds to the first element in the array SubFuncArray, that is, the first subtask is subtask a corresponding to SubFunc0; if the address pointed to by the pointer variable Cursor is 1, it corresponds to the second element in the array SubFuncArray, that is, the first subtask is subtask b corresponding to SubFunc1; if the address pointed to by the pointer variable Cursor is 2, it corresponds to the third element in the array SubFuncArray, that is, the first subtask is subtask c corresponding to SubFunc2, and the actual value i of the address pointed to by the pointer variable and the number N of subtasks in the first task satisfy i=N-1. Therefore, if after determining that the first task is task 1, the address pointed to by the pointer variable Cursor corresponds to the first element in the array SubFuncArray, it can be determined that the first subtask of task 1 is subtask a.

将任务1中的第一子任务确定为子任务a后,可以根据指针变量Cursor指向的地址确定第一子任务的处理函数。假设根据获取到的指针变量Cursor指向的地址是数组SubFuncArray中的第一个元素SubFunc0,确定了任务1的第一子任务为子任务a,那么可以通过SubFuncArray[0]将SubFunc0确定为子任务a的处理函数,参见图9,通过执行处理函数SubFunc0实现对第一子任务的处理。After the first subtask in Task 1 is determined as Subtask a, the processing function of the first subtask can be determined according to the address pointed to by the pointer variable Cursor. Assuming that the address pointed to by the obtained pointer variable Cursor is the first element SubFunc0 in the array SubFuncArray, and the first subtask of Task 1 is determined to be Subtask a, then SubFunc0 can be determined as the processing function of Subtask a through SubFuncArray[0], see Figure 9, and the processing of the first subtask is realized by executing the processing function SubFunc0.

执行完处理函数SubFunc0后,可以将该指针变量的取值更新为与第一子任务的下一个子任务对应的取值,以实现对第一指示参数的更新。基于上述示例,假设第一子任务为子任务a,对于任务1来说子任务a执行完成后,下一个待执行的子任务为与数组SubFuncArray[1]中处理函数SubFunc1 对应的子任务b,故执行处理函数SubFunc0可以实现对子任务a的处理,将指针变量Cursor指向的地址向后移动一位,使得指针变量Cursor指向与数组SubFuncArray[1]中处理函数SubFunc1对应的地址,完成对第一指示参数的更新。After executing the processing function SubFunc0, the value of the pointer variable can be updated to the value corresponding to the next subtask of the first subtask to update the first indication parameter. Based on the above example, assuming that the first subtask is subtask a, for task 1, after subtask a is executed, the next subtask to be executed is the processing function SubFunc1 in the array SubFuncArray[1]. The corresponding subtask b, so executing the processing function SubFunc0 can realize the processing of subtask a, move the address pointed to by the pointer variable Cursor one position backward, so that the pointer variable Cursor points to the address corresponding to the processing function SubFunc1 in the array SubFuncArray[1], and complete the update of the first indication parameter.

类似的,对于任务1来说,执行完处理函数SubFunc2后即可表示任务1的执行完成,也就是说,已经完整的处理完了该任务1。当该任务1再次被确定为第一任务时,那么该任务1的第一个子任务将会从子任务a重新开始执行。因此,若第一子任务为子任务c,执行完处理函数SubFunc2后,则通过将指针变量Cursor向后循环移动一位,使得指针变量Cursor继续指向数组SubFuncArray中的第一个元素,即SubFunc0,以便在重新执行第一任务时,通过指针变量Cursor指向的地址确定任务1中的第一个子任务。Similarly, for Task 1, the execution of the processing function SubFunc2 indicates that the execution of Task 1 is completed, that is, Task 1 has been completely processed. When Task 1 is determined as the first task again, the first subtask of Task 1 will be re-executed from subtask a. Therefore, if the first subtask is subtask c, after the processing function SubFunc2 is executed, the pointer variable Cursor is moved backward by one position so that the pointer variable Cursor continues to point to the first element in the array SubFuncArray, that is, SubFunc0, so that when the first task is re-executed, the first subtask in Task 1 is determined by the address pointed to by the pointer variable Cursor.

基于上述两个示例,上述任务处理方法在具体实现过程中,可以采用模块化的方式(例如状态机或迭代器等方法)对第一任务进行开发和设计,增加编程的灵活性,降低任务编程的难度;当实际业务场景发生变化时,可以利用已建立的第一任务的程序框架来实现与新业务场景对应的功能,提高了程序的可复用性,实现了提升开发和维护效率的目的。Based on the above two examples, in the specific implementation process of the above task processing method, a modular approach (such as state machine or iterator methods) can be used to develop and design the first task, thereby increasing programming flexibility and reducing the difficulty of task programming; when the actual business scenario changes, the established program framework of the first task can be used to implement the functions corresponding to the new business scenario, thereby improving the reusability of the program and achieving the purpose of improving development and maintenance efficiency.

本申请实施例提供的任务处理方法,基于本申请提供的任务处理方法,先通过进度指示信息确定第一任务的第一子任务后,执行与第一子任务对应的处理函数,在处理函数执行完成之后,再将进度指示信息中的第一指示参数更新为与第二子任务对应的第二指示参数。这样将第一任务分成多个子任务的方式能够极大的缩短第一子任务执行所占用CPU的时间,以便于在第一任务的至少一个子任务执行完毕的情况下执行其他任务,为其他任务的执行提供一定的时间,且由于在第一子任务处理完成之后,上述方法还将进度指示信息中的第一指示参数更新为与第二子任务对应的第二指示参数,这样就避免了在任务切换时需要给当前执行的第一任务分配单独的存储空间以保存当前执行的第一任务的CPU上下文,有效减少了任务处理对存储资源的依赖,大大降低了对存储资源和CPU的消耗。The task processing method provided in the embodiment of the present application is based on the task processing method provided in the present application. After first determining the first subtask of the first task through the progress indication information, the processing function corresponding to the first subtask is executed. After the processing function is executed, the first indication parameter in the progress indication information is updated to the second indication parameter corresponding to the second subtask. The method of dividing the first task into multiple subtasks in this way can greatly shorten the CPU time occupied by the execution of the first subtask, so that other tasks can be executed when at least one subtask of the first task is executed, and a certain amount of time is provided for the execution of other tasks. Moreover, since after the processing of the first subtask is completed, the above method also updates the first indication parameter in the progress indication information to the second indication parameter corresponding to the second subtask, thus avoiding the need to allocate a separate storage space to the currently executed first task to save the CPU context of the currently executed first task when the task is switched, effectively reducing the dependence of task processing on storage resources, and greatly reducing the consumption of storage resources and CPU.

此外,通过将第一任务划分为多个子任务可以在第一任务中的部分子任务执行完毕后切换执行其他任务,使其他任务得到及时响应或处理,有效避免由于第一任务占用CPU时间过长而导致阻塞情况的发生,达到了多任务并行执行的效果,提高了CPU的利用率。In addition, by dividing the first task into multiple subtasks, other tasks can be switched to execution after some subtasks in the first task are executed, so that other tasks can be responded to or processed in a timely manner, effectively avoiding the occurrence of blocking caused by the first task occupying the CPU for too long, achieving the effect of multi-task parallel execution, and improving CPU utilization.

应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

对应于上文实施例所述的任务处理方法,图10是本申请实施例提供的一种任务处理装置1000的示意性框图。图10所示的任务处理装置1000包括:获取单元1010、处理单元1020和更新单元1030。Corresponding to the task processing method described in the above embodiment, FIG10 is a schematic block diagram of a task processing device 1000 provided in an embodiment of the present application. The task processing device 1000 shown in FIG10 includes: an acquisition unit 1010 , a processing unit 1020 and an update unit 1030 .

获取单元1010,用于获取第一任务的进度指示信息,所述进度指示信息包括与第一子任务对应的第一指示参数,所述第一任务包括多个子任务,所述第一子任务为多个所述子任务中未被执行的子任务。The acquisition unit 1010 is used to acquire progress indication information of a first task, wherein the progress indication information includes a first indication parameter corresponding to a first subtask, wherein the first task includes multiple subtasks, and the first subtask is a subtask that has not been executed among the multiple subtasks.

处理单元1020,用于根据所述第一指示参数执行与所述第一子任务对应的处理函数。The processing unit 1020 is configured to execute a processing function corresponding to the first subtask according to the first indication parameter.

更新单元1030,用于在所述处理函数执行完后,将所述进度指示信息中的第一指示参数更新为与第二子任务对应的第二指示参数,所述第二子任务为所述多个子任务中所述第一子任务的下一个子任务。The updating unit 1030 is used to update the first indication parameter in the progress indication information to a second indication parameter corresponding to a second subtask after the processing function is executed, and the second subtask is a next subtask of the first subtask among the multiple subtasks.

可选地,在所述处理函数执行过程中,若检测到新增的第二任务,所述第二任务的任务处理优先级高于所述第一任务,则在对所述第一指示参数更新后,执行所述第二任务。Optionally, during the execution of the processing function, if a newly added second task is detected and the task processing priority of the second task is higher than that of the first task, the second task is executed after the first indication parameter is updated.

可选地,若所述第一子任务是所述多个子任务中的最后一个子任务,则所述第二子任务为与所述多个子任务中的第一个子任务。Optionally, if the first subtask is the last subtask among the multiple subtasks, the second subtask is the first subtask among the multiple subtasks.

可选地,所述获取第一任务的进度指示信息之前,所述任务处理装置1000还包括:Optionally, before obtaining the progress indication information of the first task, the task processing device 1000 further includes:

初始化处理单元,用于对多个任务进行初始化处理,得到任务集合,所述任务集合包括所述第一任务;An initialization processing unit, used for performing initialization processing on a plurality of tasks to obtain a task set, wherein the task set includes the first task;

调度单元,用于基于预设的任务调度策略对所述任务集合中的多个任务进行调度。The scheduling unit is used to schedule multiple tasks in the task set based on a preset task scheduling strategy.

可选地,所述第一任务中的多个所述子任务通过状态机或迭代器的方式实现。Optionally, the plurality of subtasks in the first task are implemented by way of a state machine or an iterator.

可选地,所述任务调度策略包括:先进先出调度策略、基于优先级调度策略以及轮询调度策略中的任意一种。 Optionally, the task scheduling strategy includes: any one of a first-in-first-out scheduling strategy, a priority-based scheduling strategy and a polling scheduling strategy.

应理解,装置实施例的描述可以参考上述对电子设备以及任务处理方法实施例的相关描述,其实现原理与技术效果与上述方法实施例类似,此处不再赘述。It should be understood that the description of the device embodiment can refer to the above-mentioned description of the electronic device and the task processing method embodiment. Its implementation principle and technical effect are similar to those of the above-mentioned method embodiment and will not be repeated here.

基于上述各个实施例提供的方法,本申请实施例还提供以下内容:Based on the methods provided in the above embodiments, the embodiments of the present application also provide the following contents:

本申请实施例提供了一种计算机程序产品,该程序产品包括程序,当该程序被电子设备运行时,使得电子设备上述各实施例中示出的任务处理方法。An embodiment of the present application provides a computer program product, which includes a program. When the program is executed by an electronic device, the electronic device performs the task processing method shown in the above embodiments.

本申请实施例提供一种计算机可读存储介质,该计算机可读存储介质存储有计算机程序,该计算机程序被处理器执行时实现上述各个实施例中示出的任务处理方法。An embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the task processing method shown in the above embodiments is implemented.

本申请实施例提供一种芯片,该芯片包括存储器和处理器,该处理器执行存储器中存储的计算机程序,以实现控制上述电子设备执行上述各个实施例中示出的任务处理方法。An embodiment of the present application provides a chip, which includes a memory and a processor. The processor executes a computer program stored in the memory to control the above-mentioned electronic device to execute the task processing method shown in the above-mentioned embodiments.

应理解,本申请实施例中提及的处理器可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。It should be understood that the processor mentioned in the embodiments of the present application may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

还应理解,本申请实施例中提及的存储器可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(Read-only Memory,ROM)、可编程只读存储器(Programmable ROM,PROM)、可擦除可编程只读存储器(Erasable PROM,EPROM)、电可擦除可编程只读存储器(Electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(Random access Memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用,例如静态随机存取存储器(Static RAM,SRAM)、动态随机存取存储器(Dynamic RAM,DRAM)、同步动态随机存取存储器(Synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(Double Data Rate SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(Enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(Synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(Direct Rambus RAM,DR RAM)。It should also be understood that the memory mentioned in the embodiments of the present application may be a volatile memory or a non-volatile memory, or 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), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (Synchlink DRAM, SLDRAM) and direct memory bus random access memory (Direct Rambus RAM, DR RAM).

所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

在本申请所提供的实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的系统实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单 独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may be a separate unit. The integrated unit may be implemented in the form of hardware or software functional unit.

所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质至少可以包括:能够将计算机程序代码携带到大屏设备的任何实体或装置、记录介质、计算机存储器、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、电载波信号、电信信号以及软件分发介质。例如U盘、移动硬盘、磁碟或者光盘等。在某些司法管辖区,根据立法和专利实践,计算机可读介质不可以是电载波信号和电信信号。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to a large-screen device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

最后应说明的是:以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。 Finally, it should be noted that the above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims (11)

一种任务处理方法,其特征在于,所述方法包括:A task processing method, characterized in that the method comprises: 获取第一任务的进度指示信息,所述进度指示信息包括与第一子任务对应的第一指示参数,所述第一任务包括多个子任务,所述第一子任务为多个所述子任务中未被执行的子任务;Acquire progress indication information of a first task, the progress indication information including a first indication parameter corresponding to a first subtask, the first task including a plurality of subtasks, the first subtask being a subtask that has not been executed among the plurality of subtasks; 根据所述第一指示参数执行与所述第一子任务对应的处理函数;Execute a processing function corresponding to the first subtask according to the first indication parameter; 在所述处理函数执行完后,将所述进度指示信息中的第一指示参数更新为与第二子任务对应的第二指示参数,所述第二子任务为所述多个子任务中所述第一子任务的下一个子任务。After the processing function is executed, the first indication parameter in the progress indication information is updated to a second indication parameter corresponding to a second subtask, and the second subtask is a next subtask of the first subtask among the multiple subtasks. 根据权利要求1所述的任务处理方法,其特征在于,在所述处理函数执行过程中,若检测到新增的第二任务,所述第二任务的任务处理优先级高于所述第一任务,则在对所述第一指示参数更新后,执行所述第二任务。The task processing method according to claim 1 is characterized in that, during the execution of the processing function, if a newly added second task is detected and the task processing priority of the second task is higher than that of the first task, the second task is executed after the first indication parameter is updated. 根据权利要求1或2所述的任务处理方法,其特征在于,若所述第一子任务是所述多个子任务中的最后一个子任务,则所述第二子任务为所述多个子任务中的第一个子任务。The task processing method according to claim 1 or 2 is characterized in that if the first subtask is the last subtask among the multiple subtasks, then the second subtask is the first subtask among the multiple subtasks. 根据权利要求1-3任一项所述的任务处理方法,其特征在于,所述获取第一任务的进度指示信息之前,所述方法还包括:The task processing method according to any one of claims 1 to 3, characterized in that before obtaining the progress indication information of the first task, the method further comprises: 对多个任务进行初始化处理,得到任务集合,所述任务集合包括所述第一任务;Initializing multiple tasks to obtain a task set, where the task set includes the first task; 基于预设的任务调度策略对所述任务集合中的所述多个任务进行调度。The multiple tasks in the task set are scheduled based on a preset task scheduling strategy. 根据权利要求4所述的任务处理方法,其特征在于,所述任务调度策略包括:先进先出调度策略、基于优先级调度策略以及轮询调度策略中的任意一种。The task processing method according to claim 4 is characterized in that the task scheduling strategy includes: any one of a first-in-first-out scheduling strategy, a priority-based scheduling strategy and a polling scheduling strategy. 根据权利要求1-5任一项所述的任务处理方法,其特征在于,所述第一任务中的多个所述子任务通过状态机或迭代器的方式实现。The task processing method according to any one of claims 1 to 5 is characterized in that the multiple subtasks in the first task are implemented by means of a state machine or an iterator. 一种任务处理装置,其特征在于,所述装置包括:A task processing device, characterized in that the device comprises: 获取单元,用于获取第一任务的进度指示信息,所述进度指示信息包括与第一子任务对应的第一指示参数,所述第一任务包括多个子任务,所述第一子任务为多个所述子任务中未被执行的子任务;an acquiring unit, configured to acquire progress indication information of a first task, the progress indication information comprising a first indication parameter corresponding to a first subtask, the first task comprising a plurality of subtasks, the first subtask being a subtask that has not been executed among the plurality of subtasks; 处理单元,用于根据所述第一指示参数执行与所述第一子任务对应的处理函数;a processing unit, configured to execute a processing function corresponding to the first subtask according to the first indication parameter; 更新单元,用于在所述处理函数执行完后,将所述进度指示信息中的第一指示参数更新为与第二子任务对应的第二指示参数,所述第二子任务为所述多个子任务中所述第一子任务的下一个子任务。An updating unit is used to update the first indication parameter in the progress indication information to a second indication parameter corresponding to a second subtask after the processing function is executed, and the second subtask is a next subtask of the first subtask among the multiple subtasks. 一种任务处理系统,其特征在于,包括:如权利要求7所述的任务处理装置。A task processing system, characterized by comprising: the task processing device as described in claim 7. 一种电子设备,其特征在于,包括:处理器,所述处理器用于运行存储器中存储的计算机程序,以实现如权利要求1至6任一项所述的方法。An electronic device, characterized in that it comprises: a processor, wherein the processor is used to run a computer program stored in a memory to implement the method according to any one of claims 1 to 6. 一种芯片,其特征在于,所述芯片包括处理器和存储器,所述存储器中存储有计算机程序,所述计算机程序被所述处理器执行时实现如权利要求1至6任一项所述的方法。A chip, characterized in that the chip comprises a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the method according to any one of claims 1 to 6 is implemented. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1至6任一项所述的方法。 A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the method according to any one of claims 1 to 6.
PCT/CN2024/081123 2023-03-14 2024-03-12 Task processing method and apparatus, and readable storage medium Pending WO2024188228A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202310282489.5A CN118672739A (en) 2023-03-14 2023-03-14 Task processing method and device and readable storage medium
CN202310282489.5 2023-03-14

Publications (1)

Publication Number Publication Date
WO2024188228A1 true WO2024188228A1 (en) 2024-09-19

Family

ID=92720182

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2024/081123 Pending WO2024188228A1 (en) 2023-03-14 2024-03-12 Task processing method and apparatus, and readable storage medium

Country Status (2)

Country Link
CN (1) CN118672739A (en)
WO (1) WO2024188228A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118863476A (en) * 2024-09-24 2024-10-29 深圳市兴海物联科技有限公司 Task allocation method, system, device and medium based on computing power of Internet of Things

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130160017A1 (en) * 2011-12-14 2013-06-20 Robert Scott Hartog Software Mechanisms for Managing Task Scheduling on an Accelerated Processing Device (APD)
CN112698927A (en) * 2019-10-23 2021-04-23 杭州海康威视数字技术股份有限公司 Bidirectional communication method, device, electronic equipment and machine-readable storage medium
CN113986500A (en) * 2021-10-28 2022-01-28 浙江中控技术股份有限公司 Task deterministic scheduling method and task diagnosis method in multi-task system
CN115145698A (en) * 2022-07-27 2022-10-04 济南浪潮数据技术有限公司 Management method, system and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130160017A1 (en) * 2011-12-14 2013-06-20 Robert Scott Hartog Software Mechanisms for Managing Task Scheduling on an Accelerated Processing Device (APD)
CN112698927A (en) * 2019-10-23 2021-04-23 杭州海康威视数字技术股份有限公司 Bidirectional communication method, device, electronic equipment and machine-readable storage medium
CN113986500A (en) * 2021-10-28 2022-01-28 浙江中控技术股份有限公司 Task deterministic scheduling method and task diagnosis method in multi-task system
CN115145698A (en) * 2022-07-27 2022-10-04 济南浪潮数据技术有限公司 Management method, system and device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118863476A (en) * 2024-09-24 2024-10-29 深圳市兴海物联科技有限公司 Task allocation method, system, device and medium based on computing power of Internet of Things

Also Published As

Publication number Publication date
CN118672739A (en) 2024-09-20

Similar Documents

Publication Publication Date Title
WO2021052200A1 (en) Device capability scheduling method and electronic device
EP4231147A1 (en) Drawing command processing method and related device therefor
CN112527476A (en) Resource scheduling method and electronic equipment
WO2023035837A1 (en) Data synchronization method, and device
WO2024051634A1 (en) Screen projection display method and system, and electronic device
WO2024188228A1 (en) Task processing method and apparatus, and readable storage medium
CN116709016B (en) Ratio switching method and ratio switching device
CN117407127A (en) Thread scheduling method and electronic equipment
WO2025026077A1 (en) Method and apparatus for starting application program, and electronic device
WO2025001352A1 (en) Method for sharing input device, and electronic device and storage medium
CN116048772B (en) Central processing unit frequency adjustment method, device and terminal equipment
CN115291919B (en) Packet searching method and related device
CN114828098B (en) Data transmission method and electronic device
CN118689482A (en) Compiling method and electronic device
CN117724860B (en) Data processing method and electronic device
CN116700660B (en) Audio playing method and electronic device
CN117729561B (en) System upgrade method, terminal and storage medium
CN114449622B (en) Method and electronic device for calculating Wi-Fi power consumption
WO2025026022A1 (en) Operating system starting method, and terminal device
WO2023005783A1 (en) Data processing method and electronic device
CN119536868A (en) Application display status switching method and device
CN115269485A (en) Data processing method, multi-core multi-system module and electronic device
WO2024140123A1 (en) Stop motion animation generation method, electronic device, cloud server, and system
WO2025026076A1 (en) Method and apparatus for call switching, and electronic device
WO2024041006A1 (en) Method for controlling frame rate of camera, and electronic device

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

Country of ref document: EP

Kind code of ref document: A1