Task processing method and apparatus, and readable storage medium
By dividing tasks into multiple subtasks and managing the order of execution, the problem of task processing in MCU embedded systems that consumes large amounts of storage resources and CPU is solved, efficient task switching and parallel execution are achieved, and the performance and maintainability of the system are improved. .
Patent Information
- Application Number
- PCT/CN2024/081123
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-14
- Filing Date
- 2024-03-12
- Publication Date
- 2024-09-19
AI Technical Summary
Existing task processing methods consume a lot of storage resources and CPU performance in MCU embedded systems, resulting in a large amount of storage space and CPU time required when switching tasks, which increases system overhead and blocking risks.
By dividing the task into multiple subtasks and managing the execution order of the subtasks through progress indication information, we avoid the need to save and restore the CPU context when switching tasks, directly update the progress indication parameters to switch tasks, reduce storage resource dependence and CPU consumption, and Improve task parallel execution efficiency.
It effectively reduces the consumption of storage resources and CPU by task processing, improves CPU utilization, avoids task blocking and interruption, realizes multi-task parallel execution, and improves system development and maintenance efficiency.
Smart Images

Figure CN2024081123_19092024_PF_FP_ABST
Abstract
Description
A task processing method, device and readable storage medium
[0001] 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 into this application. Technical Field
[0002] 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
[0003] Microcontroller units (MCUs), also known as single-chip microcomputers, are compact, low-power, and highly reliable, making them widely used in industrial control, traffic management, and everyday life. In MCU embedded systems, task processing (including task execution and task switching) is implemented through the operating system (OS). In this approach, tasks are the basic units of OS scheduling. Each task has exclusive CPU usage during execution. During task switching, the CPU first saves the CPU context of the currently executing task to the corresponding stack space, then loads the CPU context of the new task into the CPU registers to run the new task and implement task switching.
[0004] 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 overhead of task processing on storage resources and CPU performance.
[0005] Summary of the Invention
[0006] The present application provides a task processing method, device and readable storage medium, which to some extent solve the problem of large storage resource and CPU consumption of existing task processing methods.
[0007] To achieve the above objectives, this application adopts the following technical solutions:
[0008] In a first aspect, the present application provides a task processing method, the method comprising:
[0009] 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 an unexecuted subtask among the plurality of subtasks;
[0010] executing a processing function corresponding to the first subtask according to the first indication parameter;
[0011] 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, where the second subtask is a next subtask of the first subtask among the multiple subtasks.
[0012] 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, 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. 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 completed, providing a certain amount of time 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 executing first task to save the CPU context of the currently executing 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.
[0013] 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 completed, 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.
[0014] 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.
[0015] 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 using 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 abnormalities or interruptions during the execution of the first task is reduced.
[0016] 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.
[0017] In a possible implementation of the first aspect, before obtaining the progress indication information of the first task, the method further includes:
[0018] Initializing a plurality of tasks to obtain a task set, wherein the task set includes the first task;
[0019] The multiple tasks in the task set are scheduled based on a preset task scheduling strategy.
[0020] Exemplarily, the task scheduling strategy may include any one of a first-in-first-out scheduling strategy, a priority-based scheduling strategy, and a round-robin scheduling strategy.
[0021] 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.
[0022] 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 requirements or business scenarios, but also the diverse selection of scheduling strategies effectively ensures the flexibility of selecting task scheduling strategies between different tasks.
[0023] In a possible implementation of the first aspect, the multiple subtasks in the first task are implemented by way of a state machine or an iterator.
[0024] It should be understood that the implementation of the plurality of the above subtasks in the first task may also be customized according to specific business scenarios.
[0025] Based on the above optional implementation methods, during the specific implementation process of the above task processing method, the first task can be developed and designed in a modular manner (such as state machine or iterator methods), which increases programming flexibility and reduces 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.
[0026] In a second aspect, an embodiment of the present application provides a task processing device, the task processing device comprising:
[0027] an acquiring unit, configured to 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 an unexecuted subtask among the plurality of subtasks;
[0028] a processing unit, configured to execute a processing function corresponding to the first subtask according to the first indication parameter;
[0029] An updating unit is configured 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, where the second subtask is a subtask next to the first subtask in the plurality of subtasks.
[0030] 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.
[0031] 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.
[0032] In a possible implementation of the second aspect, before obtaining the progress indication information of the first task, the method further includes:
[0033] Initializing a plurality of tasks to obtain a task set, wherein the task set includes the first task;
[0034] The multiple tasks in the task set are scheduled based on a preset task scheduling strategy.
[0035] In a possible implementation of the second aspect, the multiple subtasks in the first task are implemented by way of a state machine or an iterator.
[0036] 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 round-robin scheduling strategy.
[0037] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, wherein the processor is configured to run a computer program stored in a memory to implement the method in the first aspect or any possible implementation of the first aspect.
[0038] In a fourth aspect, the present application provides a task processing system, which includes the electronic device described in the third aspect.
[0039] In a fifth aspect, the present application provides a chip, comprising a processor, the processor being configured 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.
[0040] Optionally, the chip further includes a memory, and the memory is connected to the processor via a circuit or wire.
[0041] 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, it implements the method in the first aspect or any possible implementation of the first aspect.
[0042] In a seventh aspect, the present application provides a computer program product, which, when executed on an electronic device, enables the electronic device to execute the method in the first aspect or any possible implementation of the first aspect.
[0043] The technical effects of the second to seventh aspects provided in this 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
[0044] FIG1 is a schematic structural diagram of an existing task processing method provided in an embodiment of the present application.
[0045] FIG2 is a schematic diagram of the structure of another existing task processing method provided in an embodiment of the present application.
[0046] FIG3 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
[0047] FIG4 is a structural block diagram of an MCU embedded system provided in an embodiment of the present application.
[0048] FIG5 is a flowchart of processing multiple tasks provided by an embodiment of the present application.
[0049] FIG6 is a flow chart of a task processing method provided in an embodiment of the present application.
[0050] FIG7 is a flow chart of an implementation method corresponding to the task processing method provided in an embodiment of the present application.
[0051] FIG8 is a schematic diagram of an array structure created in another implementation corresponding to the task processing method provided in an embodiment of the present application.
[0052] FIG9 is a flow chart of another implementation method corresponding to the task processing method provided in an embodiment of the present application.
[0053] 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
[0054] MCUs, also known as single-chip microcomputers, offer advantages such as small size, low power consumption, and high reliability, making them widely used in industrial control, traffic management, and daily life. With the advancement of science and technology, MCU-based embedded systems are no longer limited to single functions; they must be able to handle multiple operations simultaneously. For example, motor-related MCUs must control motor parameters while maintaining a communication connection with a host computer.
[0055] In practical applications, the processing of multiple workflows by an MCU embedded system can include executing (or running) each workflow and switching between them. For MCUs with a certain amount of storage space or computing frequency, the OS can be used to implement the scheduling and management of multiple tasks (including the execution of each workflow and switching between them). It should be noted that this method uses tasks as the smallest scheduling and operation unit of an application, with each task corresponding to an independent task processing function. Referring to Figure 1, it is assumed that multiple tasks include Task 1, Task 2...Task n, and each task has a corresponding task control block and attributes, where the attributes include number, priority, entry function, stack space, and current stack pointer. 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, 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 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 saving the CPU context of Task 1 to the stack space of Task 1, the CPU context of Task 2 will be loaded into the CPU register to run Task 2.
[0056] While the OS can manage the scheduling of multiple tasks, the task switching process requires a certain amount of storage space for each task's task control block and stack. This significantly increases task scheduling's reliance on storage resources, increasing both storage and CPU performance overhead. Furthermore, this method only works on MCUs with sufficient storage space or computing frequency to meet the minimum operating requirements for OS scheduling. If the MCU lacks sufficient storage space or computing frequency, or if it cannot meet the minimum storage space or computing frequency requirements for OS task scheduling, the above method cannot be used to manage the scheduling of multiple tasks.
[0057] For MCUs that cannot manage task scheduling through the OS, a super-loop system software framework can often be used to implement task scheduling and management through hard-coded methods. As shown in 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, also known as the backend system, 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 may 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 application, 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 background system is executing function B of task 1, which will be interrupted by interrupt service program 1. The background system suspends the continued processing of function B in task 1 until the foreground system completes processing interrupt service program 1. The background system will continue to execute function B from where function B was interrupted.
[0058] 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 perform time-sharing processing on multiple tasks, it is necessary to consider factors such as the priority between multiple tasks, the dependency between multiple tasks, and the response time between multiple tasks. For multiple tasks, the corresponding multiple functions are arranged in the infinite loop body of the background system. Obviously, this method requires writing corresponding programs based on different tasks. 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 a new program in the infinite loop body to realize the processing between the 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.
[0059] Therefore, in response to the above problems, the present application provides a task processing method, which updates the first indication parameter in the progress indication information to the second indication parameter corresponding to the next subtask of the first subtask among the multiple subtasks after executing the processing function corresponding to the first subtask. In this way, 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 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, increasing programming flexibility, reducing the difficulty of task programming, and improving the reusability of the program, thereby achieving the purpose of improving development and maintenance efficiency.
[0060] 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 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 contrary indication 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: the existence of A alone, the existence of A and B at the same time, and the existence of B alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in a kind of "or" relationship.
[0061] References to "one embodiment" or "some embodiments" etc. described in this specification mean that the specific features, structures or characteristics described in conjunction with the embodiment are included in one or more embodiments of the present application. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing 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 another way. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in another way. The term "connected" includes direct and indirect connections, unless otherwise stated. "First" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.
[0062] In the embodiments of this application, words such as "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 this application should not be interpreted as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplarily" or "for example" is intended to present the relevant concepts in a concrete manner.
[0063] The task processing method provided in the embodiments of the present application can be applied to electronic devices. The electronic devices can be mobile phones, tablet computers, wearable devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), in-vehicle devices, smart screens, cloud servers, etc. The embodiments of the present application do not impose any restrictions on the specific types of electronic devices.
[0064] 3 , which 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 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.
[0065] It should be understood that the structure illustrated in the embodiments 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, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0066] 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.
[0067] 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). The different processing units may be independent devices or integrated into one or more processors.
[0068] 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.
[0069] Processor 310 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 310 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 310. If processor 310 needs to use the same instruction or data again, it can directly retrieve it from the memory. This avoids duplicate accesses, reduces processor 310 latency, and thus improves system efficiency.
[0070] In some embodiments, the processor 310 may include one or more interfaces. The interfaces 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.
[0071] USB interface 330 is an interface that complies with USB standards and specifications, and may be a Mini USB interface, a Micro USB interface, a USB Type-C interface, or the like. USB interface 330 can be used to connect a charger to charge electronic device 300, or to transfer data between electronic device 300 and peripheral devices. It can also be used to connect headphones to play audio. This interface can also be used to connect other electronic devices, such as AR devices.
[0072] It is understood that the interface connection relationship between the modules illustrated in the embodiment of the present application is merely an illustrative 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 a different interface connection method from the above embodiment, or a combination of multiple interface connection methods.
[0073] The charging management module 340 is configured to receive charging input from a charger. The charger can be either a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 340 can receive charging input from the wired charger via the USB interface 330. In some wireless charging embodiments, the charging management module 340 can receive wireless charging input via the wireless charging coil of the electronic device 300. While charging the battery 342, the charging management module 340 can also provide power to the electronic device via the power management module 341.
[0074] 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 provides power to the processor 310, the internal memory 331, the external memory interface 320, the display 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 count, and battery health status (leakage, impedance), etc.
[0075] In some other embodiments, the power management module 341 may also be provided in the processor 310. In some other embodiments, the power management module 341 and the charging management module 340 may also be provided in the same device.
[0076] 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.
[0077] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 300 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.
[0078] The mobile communication module 350 can provide wireless communication solutions, including 2G / 3G / 4G / 5G, for 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), and the like. The mobile communication module 350 can receive electromagnetic waves from the antenna 1, filter and amplify the received electromagnetic waves, and transmit them to the modem processor for demodulation. The mobile communication module 350 can also amplify the signals modulated by the modem processor and convert them into electromagnetic waves for radiation via the antenna 1.
[0079] In some embodiments, at least some functional modules of the mobile communication module 350 may be provided in the processor 310. In some embodiments, at least some functional modules of the mobile communication module 350 may be provided in the same device as at least some functional modules of the processor 310.
[0080] The modem processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted 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 being processed by the baseband processor, the low-frequency baseband signal is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 370A, the receiver 370B, etc.) or displays an image or video through the 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 provided in the same device as the mobile communication module 350 or other functional modules.
[0081] The wireless communication module 360 can provide wireless communication solutions including wireless local area networks (WLAN) (such as Wireless Fidelity (Wi-Fi) networks), Bluetooth (BT), Global Navigation Satellite System (GNSS), Frequency Modulation (FM), Near Field Communication (NFC), and Infrared (IR) for application on the electronic device 300. The wireless communication module 360 can be one or more devices that integrate at least one communication processing module. The wireless communication module 360 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 310. The wireless communication module 360 can also receive the signal to be sent from the processor 310, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0082] In some embodiments, antenna 1 of electronic device 300 is coupled to mobile communication module 350, and antenna 2 is coupled to wireless communication module 360, so that electronic device 300 can communicate with a network and other devices through wireless communication technology. 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 may 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 System (SBAS).
[0083] Electronic device 300 implements display functionality through a GPU, display screen 394, and an application processor. A GPU is a microprocessor for image processing that connects display screen 394 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 310 may include one or more GPUs that execute program instructions to generate or modify display information.
[0084] The display screen 394 is used to display images, videos, etc. For example, the 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 use 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.
[0085] The electronic device 300 can realize the shooting function through the ISP, camera 393, video codec, GPU, display screen 394 and application processor.
[0086] The ISP processes data fed back by camera 393. For example, when taking a photo, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, which is then passed to the ISP for processing and transformed into a visible image. The ISP can also perform algorithmic optimization on image noise, brightness, and skin tone. The ISP can also optimize parameters such as exposure and color temperature of the captured scene. In some embodiments, the ISP can be located within camera 393.
[0087] The camera 393 is used to capture still images or videos. The object generates an optical image through the lens and is projected onto the photosensitive element. The focal length of the lens can be used to indicate the camera's field of view. The smaller the focal length of the lens, the larger the lens's field of view. The photosensitive element can be a charge coupled device (CCD) or a complementary metal oxide semiconductor (CMOS) phototransistor. The photosensitive element converts the light 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 standard RGB, YUV, and other formats.
[0088] In the present application, the electronic device 300 may include cameras 393 with two or more focal lengths.
[0089] The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 300 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
[0090] Video codecs are used to compress or decompress digital video. Electronic device 300 may support one or more video codecs. This allows electronic device 300 to play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG1, MPEG3, and MPEG4.
[0091] The NPU is a neural network (NN) computing processor. Drawing on the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it rapidly processes input information and can continuously self-learn. The NPU can enable intelligent cognitive applications in electronic device 300, such as image recognition, face recognition, voice recognition, and text comprehension.
[0092] In an embodiment of the present application, the NPU or other processors can be used to perform operations such as analyzing and processing images in the video stored in the electronic device 300.
[0093] 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 via the external memory interface 320 to implement data storage functions. For example, files such as music and videos can be stored on the external memory card.
[0094] The internal memory 331 can be used to store computer executable program code, which includes 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 may store an operating system and at least one application required for a function (such as a sound playback function, an image playback function, etc.). The data storage area may store data created during the use of the electronic device 300 (such as audio data, a phone book, etc.).
[0095] 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.
[0096] The electronic device 300 can implement audio functions through the audio module 370, the speaker 370A, the receiver 370B, the microphone 370C, the headphone jack 370D, and the application processor.
[0097] 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 input 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 provided in the processor 310, or some functional modules of the audio module 370 can be provided in the processor 310.
[0098] Speaker 370A, also called a "horn," is used to convert audio electrical signals into sound signals. Electronic device 300 can listen to music or listen to hands-free calls through speaker 370A. For example, the speaker can play the comparison and analysis results provided in the embodiments of the present application.
[0099] The receiver 370B, also called a "handset", is used to convert audio electrical signals into sound signals. When the electronic device 300 receives a call or a voice message, the user can place the receiver 370B close to the ear to hear the voice.
[0100] Microphone 370C, also known as "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 source of sound, realize directional recording function, etc.
[0101] The headphone jack 370D is used to connect a wired headphone. The headphone jack 370D can be a USB interface 330 or a 3.5mm Open Mobile Terminal Platform (OMTP) standard interface or a Cellular Telecommunications Industry Association of the USA (CTIA) standard interface.
[0102] The buttons 390 include a power button, a volume button, and the like. The buttons 390 may be mechanical buttons or touch buttons. The electronic device 300 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 300.
[0103] 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.
[0104] Indicator 392 can be an indicator light, which can be used to indicate charging status, power changes, messages, missed calls, notifications, etc.
[0105] The SIM card interface 395 is used to connect a SIM card. A SIM card can be connected to and disconnected from the electronic device 300 by inserting or removing it from the SIM card interface 395. The electronic device 300 can support one or N SIM card interfaces, where N is a positive integer greater than one. 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 simultaneously. The multiple cards can be of the same or different types. The SIM card interface 395 is also compatible with different types of SIM cards. The SIM card interface 395 is also compatible with external memory cards. The electronic device 300 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 300 uses an eSIM, or embedded SIM card. The eSIM card can be embedded in the electronic device 300 and cannot be separated from the electronic device 300.
[0106] 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 may be a 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.
[0107] 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 communicatively connected to the MCU. The sensor may be a temperature sensor, a position sensor, etc., for real-time monitoring and obtaining sensor data; the actuator may be a device that can perform one or more actions under certain specific conditions, for example, the actuator may be a motor, a machine tool, an industrial robot, a stepper motor, a robotic 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 to the MCU. The MCU embedded system shown in FIG4 above is only a possible example of the task processing method provided by an embodiment of the present application in actual application. In actual application, the corresponding MCU embedded system may change with different business needs, and the present application does not make any special restrictions on this.
[0108] The task processing method provided in the embodiment of the present application will be exemplarily described below with reference to the MCU embedded system shown in FIG4 .
[0109] 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; thereafter, the first task to be executed is determined from the task set; after determining the first task, the task processing method provided by the embodiment of the present application is used to execute the first task.
[0110] 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 initialization of the task 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. After that, the first task to be processed or executed can be determined from the above task set using a preset task scheduling strategy.
[0111] It should be understood that the preset task scheduling policy may include any of: a first-in-first-out scheduling policy, a priority-based scheduling policy, and a round-robin scheduling policy. In actual implementation, the task scheduling policy may also be customized by the user based on different business scenarios. This application does not limit the specific content of the task scheduling policy.
[0112] FIG6 is a flowchart of an embodiment of a task processing method provided in an embodiment of the present application. Referring to FIG6 , the task processing method mainly includes the following steps:
[0113] S601: Acquire progress indication information of a first task, where the progress indication information includes a first indication parameter corresponding to a first subtask. The first task includes multiple subtasks, and the first subtask is an unexecuted subtask among the multiple subtasks.
[0114] It should be understood that a first task (also called a target task) refers to a task (or job flow) currently to be executed or processed. In practical applications, this first task can be understood as a specific function to be processed. For example, in the MCU embedded system shown in Figure 4, assume 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; and the host computer is a laptop for real-time monitoring of commands received by the serial port. In this example, the motor rotating 180° per minute, the temperature sensor monitoring temperature in real time, and the host computer monitoring serial port commands in real time can be understood as three tasks (or three job flows). These three tasks constitute a task set. Assuming that the priorities of these three tasks are ascending, and the task scheduling strategy is a priority-based scheduling strategy, the third of these three tasks: the host computer monitoring serial port commands in real time, can be determined as the first task.
[0115] It should be noted that, in the actual implementation process, each task in the task set has corresponding attribute information, including but not limited to number, name, priority, progress indication information and the task processing function corresponding to the task, etc., wherein the number can be used to uniquely identify a task; the name is a note corresponding to each task, generally used in the debugging process to display specific debugging information; the priority is also a priority processing level, 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 the execution of the program, the task processing function is the program entry for establishing 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.
[0116] 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 for the host computer to monitor serial port commands in real time, then after determining the first task, 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.
[0117] It should be understood that the first subtask is determined based on the progress indicator information of the first task. The first subtask can be understood as the first subtask among the multiple subtasks of the first task that has not been executed, 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 functionality, that is, the same task as the first task.
[0118] 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 "host computer real-time monitoring of serial port commands" in the above example is determined as the first task and marked as task 1, then, according to the execution order of the task, the 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 the task 1. As the first indication parameter in the progress indication information changes, the first subtask may be subtask a, subtask b, or subtask c.
[0119] S602: Execute a processing function corresponding to the first subtask according to the first indication parameter.
[0120] 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 achieved by executing the sub-processing function corresponding to the first subtask.
[0121] 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.
[0122] It is easy 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.
[0123] 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.
[0124] 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, and quickly realize 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 updating the first indication parameter of the first subtask of the first task, 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.
[0125] 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.
[0126] 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.
[0127] 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 that of 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-mentioned task processing method makes the complete execution process of the first subtask include both the process of executing the processing function corresponding to the first subtask and the process of updating the progress indication information after the processing of the first subtask by the processing function is completed. Such a design avoids the occurrence of 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 abnormalities or interruptions during the execution of the first task is reduced.
[0128] The multiple subtasks in the first task provided in this 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.
[0129] First, an exemplary description is given using a state machine.
[0130] Based on the example in the above embodiment, the above-mentioned 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 the stage variable. 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.
[0131] 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 stage obtained from the first indication information 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 Figure 7, the processing of the first subtask can be completed by executing the processing function processA().
[0132] 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.
[0133] It is easy to understand that if the first subtask is subtask c, after executing the sub-processing function processC() corresponding to task c, the first indicator parameter C in the progress indicator information of the first task a should be updated to the second indicator parameter A corresponding to task a, that is, stage = A. It is easy to understand that for task 1 (the first task), after executing subtask c, it can be said 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 actual application requirements.
[0134] Next, an example explanation is given using an iterator.
[0135] 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.
[0136] 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 element sequences 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. 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, then it can be determined that the first subtask of Task 1 is Subtask a.
[0137] After the first subtask in Task 1 is determined to be Subtask a, the processing function of the first subtask can be determined based on 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 achieved by executing the processing function SubFunc0.
[0138] 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 achieve the update of the first indication parameter. Based on the above example, assuming that the first subtask is subtask a, for task 1, after subtask a is completed, the next subtask to be executed is subtask b corresponding to the processing function SubFunc1 in the array SubFuncArray[1]. Therefore, executing the processing function SubFunc0 can achieve the processing of subtask a, and move the address pointed to by the pointer variable Cursor backward by one position, so that the pointer variable Cursor points to the address corresponding to the processing function SubFunc1 in the array SubFuncArray[1], completing the update of the first indication parameter.
[0139] Similarly, for Task 1, the execution of the processing function SubFunc2 is completed, which means that 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. In this way, 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.
[0140] 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 functions corresponding to the new business scenario, thereby improving the reusability of the program and achieving the purpose of improving development and maintenance efficiency.
[0141] 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 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. 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 completed, providing a certain amount of time 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 executing first task to save the CPU context of the currently executing 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.
[0142] 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 completed, 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.
[0143] 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 this application.
[0144] 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 updating unit 1030.
[0145] The acquiring unit 1010 is configured to 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 multiple subtasks, and the first subtask being an unexecuted subtask among the multiple subtasks.
[0146] The processing unit 1020 is configured to execute a processing function corresponding to the first subtask according to the first indication parameter.
[0147] The updating unit 1030 is configured 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, where the second subtask is a next subtask of the first subtask among the multiple subtasks.
[0148] 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.
[0149] Optionally, if the first subtask is the last subtask among the multiple subtasks, the second subtask is the first subtask among the multiple subtasks.
[0150] Optionally, before obtaining the progress indication information of the first task, the task processing apparatus 1000 further includes:
[0151] an initialization processing unit, configured to perform initialization processing on a plurality of tasks to obtain a task set, wherein the task set includes the first task;
[0152] The scheduling unit is used to schedule multiple tasks in the task set based on a preset task scheduling strategy.
[0153] Optionally, the multiple subtasks in the first task are implemented by means of a state machine or an iterator.
[0154] Optionally, the task scheduling strategy includes any one of a first-in-first-out scheduling strategy, a priority-based scheduling strategy, and a round-robin scheduling strategy.
[0155] 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 effects are similar to those of the above-mentioned method embodiment and will not be repeated here.
[0156] Based on the methods provided in the above embodiments, the embodiments of the present application also provide the following content:
[0157] 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.
[0158] 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, it implements the task processing method shown in the above embodiments.
[0159] 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 perform the task processing method shown in the above-mentioned embodiments.
[0160] It should be understood that the processor mentioned in the embodiments of the present application may be a central processing unit (CPU), or may be 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. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0161] 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 random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct RAMbus RAM (DR RAM).
[0162] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and 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 into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into 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, and will not be repeated here.
[0163] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0164] Those skilled 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 beyond the scope of this application.
[0165] In the embodiments provided in this 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 merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, 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.
[0166] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0167] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0168] 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, when executed by the processor, can implement the steps of the above-mentioned various method embodiments. Wherein, 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 include at least: any entity or device capable of carrying 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.
[0169] Finally, it should be noted that the above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A task processing method, It is 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.
2. The task processing method according to claim 1, It 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.
3. The task processing method according to claim 1 or 2, It is characterized in that If the first subtask is the last subtask among the multiple subtasks, the second subtask is the first subtask among the multiple subtasks.
4. The task processing method according to any one of claims 1 to 3, It is characterized in that 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.
5. The task processing method according to claim 4, It 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.
6. The task processing method according to any one of claims 1 to 5, It is characterized in that The multiple subtasks in the first task are implemented by means of a state machine or an iterator.
7. A task processing device, It is 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.
8. A task processing system, It is characterized in that include: The task processing device as claimed in claim 7.
9. An electronic device, It is characterized in that include: A processor, wherein the processor is configured to run a computer program stored in a memory to implement the method according to any one of claims 1 to 6.
10. A chip, It is characterized in that The chip includes 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.
11. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Bidirectional communication method and device, electronic equipment and machine readable storage medium
CN112698927A
Task deterministic scheduling method and task diagnosis method in multi-task system
CN113986500A
Management method, system and device
CN115145698A
Software Mechanisms for Managing Task Scheduling on an Accelerated Processing Device (APD)
US20130160017A1
Cited By
Task allocation method, system and equipment based on computing power of internet of things, and medium
CN118863476A
Event processing method, electronic equipment, storage medium and program product
CN120670101A
An event processing method, electronic device, storage medium and program product
CN120670101B
Event processing method, electronic device, storage medium and program product
WO2026214167A1
