Data processing method, device, computing equipment and system
Through the use of coroutines in computer systems and robot systems to process data, resource consumption problems caused by multi -threaded processing are solved, and more efficient resource use and context switch are realized.
Patent Information
- Application Number
- CN202310940235.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-27
- Publication Date
- 2025-01-28
AI Technical Summary
When communicating with multiple peripherals, computer systems and robot systems need to start multiple threads or processes to process peripheral data, resulting in the consumption of large amounts of memory resources and computing resources.
Use coroutines to process data from the peripherals, and schedule the coroutine by monitoring the data events of the peripherals to achieve asynchronous operation. In one thread or process, multiple coroutines are used to process data from multiple peripherals, reducing the number of thread parallel.
Reduce multi -threaded parallel processing of multiple peripheral data to consume memory resources and computing resources, increase resource utilization, and reduce the expenses of context switching.
Smart Images

Figure CN119376868A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a data processing method, device, computing equipment and system. Background Art
[0002] Computer systems, robot systems and other systems usually need to communicate with external devices (full name in English: peripheral device, English abbreviation: PD, Chinese abbreviation: peripherals) such as input devices, output devices and external storage devices, so as to use peripherals to transmit, transfer and store data, and process the data of peripherals to realize the corresponding functions of computer systems, robot systems and other systems.
[0003] However, when a computer system, a robot system, or other systems communicate with peripherals, a thread or process is started for each peripheral to process the data of the peripheral separately. The more peripherals there are, the more threads or processes the system needs to start. Processing the data of multiple peripherals based on multiple threads or processes consumes a large amount of system memory resources and computing resources. Summary of the invention
[0004] The present application provides a data processing method, apparatus, computing device and system, which can solve the problem of consuming a large amount of system memory resources and computing resources by processing data of multiple peripherals based on multiple threads or processes.
[0005] In a first aspect, a data processing method is provided, which includes: when data of a first peripheral device is monitored, starting a coroutine of the first peripheral device, and then executing the coroutine of the first peripheral device to process the data of the first peripheral device.
[0006] Compared with the problem of consuming a large amount of system memory resources and computing resources in the scenario of multiple peripherals based on processes or threads, the solution provided by this application is to process the data of peripherals based on coroutines, that is, to schedule the coroutines of peripherals after listening to the data of peripherals, and to replace threads with coroutines to process the data of peripherals. In the scenario of multiple peripherals, based on the asynchronous operation characteristics of coroutines, the coroutine is started only when the data of peripherals needs to be processed. Using multiple coroutines in one thread or process to process the data of multiple peripherals separately reduces the number of parallel threads, thereby reducing the consumption of memory resources and computing resources for multi-threaded parallel processing of data of multiple peripherals.
[0007] The present application does not limit the application scenario of the data processing method, and the data processing method can be executed by any computing device capable of coroutine scheduling. For example, the execution subject of the data processing method can be a processor (central processing unit, CPU) in a computing device such as a computer system or a robot system.
[0008] In a possible implementation, when the computing device monitors data from the first peripheral device, the computing device implements a state switch of the coroutine of the first peripheral device through a waiting queue and a running queue to start the coroutine of the first peripheral device.
[0009] Optionally, the computing device schedules the coroutine of the first peripheral device from the waiting queue to the running queue, thereby switching the coroutine of the first peripheral device from a suspended state to a ready state. The waiting queue is used to store the coroutines of the peripheral device in the suspended state for which there is no readable data. The running queue is used to store the coroutines of the peripheral device in the ready state for which there is readable data.
[0010] In this way, the running queue and the waiting queue are maintained according to whether there is a coroutine that can read the data of the peripheral device, and the coroutine is scheduled based on the two queues. The coroutine of the peripheral device is executed asynchronously in one thread, and the data of different peripheral devices can be processed respectively through different coroutines, reducing the consumption of memory resources and computing resources for running multiple threads or processes. For example, when there is no readable data of the first peripheral device, the coroutine of the first peripheral device is in the waiting queue, and the computing device can start other peripheral devices to asynchronously process the data of other peripheral devices, so that the coroutines of multiple peripheral devices can be switched in one thread. Compared with the context switching of threads / processes to receive data from different peripherals, the context switching of coroutines has the characteristics of lower overhead and faster speed, which reduces the consumption of memory resources and computing resources for context switching in multi-peripheral scenarios.
[0011] In one possible implementation, a computing device may be connected to multiple peripherals, each of which is used to process data of a peripheral. When the computing device monitors data of a first peripheral, it determines the coroutine of the first peripheral from multiple coroutines. In this way, the computing device can process data of different peripherals through different coroutines.
[0012] In one possible implementation, the computing device monitors data of the peripheral device by monitoring an event. The monitoring event of the first peripheral device is triggered when there is readable data in the first peripheral device. When the monitoring event of the first peripheral device is triggered, the computing device switches the coroutine of the first peripheral device from a suspended state to a ready state, for example, scheduling the coroutine of the first peripheral device from a waiting queue to a running queue.
[0013] Optionally, before monitoring the data of the first peripheral device, the computing device registers a monitoring event of the first peripheral device in a coroutine for monitoring events, and the coroutine for monitoring events is used to monitor data of multiple peripheral devices.
[0014] Optionally, the coroutine of each peripheral among the multiple peripherals is respectively registered with the monitoring events of the respective peripherals, and all the monitoring events can be uniformly executed by one thread or one coroutine.
[0015] In this way, the computing device can register monitoring events for different peripherals, perform monitoring operations in a unified manner, and use the monitoring events as trigger conditions for scheduling coroutines between the waiting queue and the running queue, so that the computing device can execute the coroutines in the running queue in sequence to realize asynchronous processing of data from different peripherals. As a result, there is no need to set up a separate thread to monitor the data of each peripheral, which reduces the consumption of memory resources and computing resources by multi-threaded parallelism.
[0016] This application does not limit the implementation method of monitoring the data of the first peripheral device. For example, the first thread includes a plurality of peripheral coroutines and a coroutine for monitoring events. For another example, the first thread includes a plurality of peripheral coroutines, and the second thread is used to execute monitoring events.
[0017] In a possible implementation, when the computing device is not running a coroutine of a peripheral device, the computing device monitors whether there is readable data in the first peripheral device.
[0018] Optionally, when there is no coroutine of any peripheral device in the running queue, the computing device executes the coroutine for monitoring in the first thread to monitor whether there is readable data in the first peripheral device. In this way, the coroutine for monitoring is executed during the execution interval of the coroutine of the peripheral device without affecting the execution efficiency of the coroutine of the peripheral device, thereby improving the resource utilization of the processor.
[0019] In one possible implementation, the computing device is further connected to a second peripheral device. When the computing device completes data processing of the first peripheral device and monitors data of the second peripheral device, it starts the coroutine of the second peripheral device and then executes the coroutine of the second peripheral device to process the data of the second peripheral device.
[0020] In a second aspect, a data processing device is provided, which includes various modules for executing the data processing method in the first aspect or any possible implementation of the first aspect. The data processing device in the present application may include a scheduling module and a processing module. The scheduling module is used to start the coroutine of the first peripheral when monitoring the data of the first peripheral. The processing module is used to execute the coroutine of the first peripheral to process the data of the first peripheral.
[0021] In a possible implementation, the scheduling module is specifically used to: when monitoring data of the first peripheral device, schedule the coroutine of the first peripheral device from the waiting queue to the running queue, the waiting queue is used to store the coroutine in the suspended state, and the running queue is used to store the coroutine in the ready state.
[0022] In a possible implementation, the scheduling module is further used to: when monitoring data of the first peripheral device, determine the coroutine of the first peripheral device from multiple coroutines, each coroutine in the multiple coroutines is used to process data of one peripheral device.
[0023] In a possible implementation, the scheduling module is specifically used to: trigger a listening event of the first peripheral device, schedule the coroutine of the first peripheral device from the waiting queue to the running queue, and the listening event of the first peripheral device is used to monitor data of the first peripheral device.
[0024] In a possible implementation, the scheduling module is further used to: register a monitoring event of the first peripheral device in a coroutine for monitoring events, and the coroutine for monitoring events is used to monitor data of multiple peripheral devices.
[0025] In a possible implementation, the first thread includes a coroutine of the first peripheral and a coroutine for monitoring events.
[0026] In a possible implementation, the scheduling module is specifically used to: when there is no coroutine of any peripheral in the running queue, trigger a listening event of the first peripheral, and schedule the coroutine of the first peripheral from the waiting queue to the running queue.
[0027] In a possible implementation, the scheduling module is further used to: when the data processing of the first peripheral is completed and the data of the second peripheral is monitored, start the coroutine of the second peripheral. The processing module is further used to: execute the coroutine of the second peripheral to process the data of the second peripheral.
[0028] According to a third aspect, a processor is provided, which, when executing a set of computer instructions, is used to execute the operating steps of the data processing method in the first aspect or any possible implementation of the first aspect.
[0029] In a fourth aspect, a chip is provided, the chip comprising a processor and a power supply circuit, wherein the power supply circuit is used to supply power to the processor, and the processor is used to execute the operation steps of the data processing method in the first aspect or any possible implementation of the first aspect.
[0030] In a fifth aspect, a computing device is provided, comprising a memory and a processor, wherein the memory is used to store a set of computer instructions, and when the processor executes the set of computer instructions, it is used to execute the operating steps of the data processing method in the first aspect or any possible implementation of the first aspect.
[0031] In a sixth aspect, a data processing system is provided, which includes a plurality of peripheral devices and the above-mentioned computing device, wherein the computing device is used to process data of the plurality of peripheral devices according to the operation steps of the data processing method in the first aspect or any possible implementation of the first aspect.
[0032] In addition, the technical effects of the data processing apparatus described in the second aspect, the technical effects of the processor described in the third aspect, the technical effects of the chip described in the fourth aspect, the technical effects of the computing device described in the fifth aspect, and the technical effects of the data processing system described in the sixth aspect can refer to the technical effects of the data processing method described in the first aspect, and will not be repeated here.
[0033] In a seventh aspect, a readable storage medium is provided, which includes: a computer program or instructions; when the computer program or instructions are executed on a computer, the computer executes the data processing method described in any possible implementation manner in the first aspect.
[0034] In an eighth aspect, a computer program product is provided, which includes a computer program or instructions, and when the computer program or instructions are executed on a computer, the computer executes the data processing method described in any possible implementation manner of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 This is a schematic diagram of coroutine scheduling switching;
[0036] Figure 2 It is a flow chart of a traditional thread peripheral data processing;
[0037] Figure 3 A schematic diagram of the architecture of a data processing system provided for this application;
[0038] Figure 4 A schematic diagram of the architecture of a computing device provided for this application;
[0039] Figure 5 A flowchart of a data processing method provided in this application;
[0040] Figure 6 A flowchart of a monitoring operation provided by this application;
[0041] Figure 7 A schematic diagram of a coroutine scheduling process provided for this application;
[0042] Figure 8 A schematic diagram of the structure of a data processing device provided in this application;
[0043] Fig. 9 A schematic diagram of the structure of a computing device provided in this application. DETAILED DESCRIPTION
[0044] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings in the embodiments of the present application. In the present application, "at least one" refers to one or more, and "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may 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 an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can represent: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b and c can be single or multiple.
[0045] It should be noted that, in this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in this application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0046] The data processing method provided in the embodiment of the present application can be applied in scenarios where a computer system, a robot system, or other systems are connected to multiple peripherals. The following is a brief introduction to the technologies that may be involved in the present application.
[0047] (1) External devices
[0048] External devices are referred to as peripherals. They are a general term for input devices, output devices, and external storage devices in a computer system. Their function is to transmit, transfer, and store data and information. Computer system peripherals usually include keyboards, mice, scanners, cameras, monitors, printers, etc.
[0049] The computer system may refer to a computer device such as a personal computer, or any type of system with computing functions, such as a robot system, a vehicle-mounted system, etc. For a robot system, the peripherals may be various types of sensors, such as an inertial measurement unit (IMU), a positioning device (such as a global positioning system (GPS) module, a Beidou navigation satellite system (BDS) module, etc.), a camera (such as a universal serial bus (USB) camera, a webcam, a three-dimensional camera, etc.), a radar, etc.
[0050] (2) Process
[0051] A process is a program in a computer system running on a certain data set. It is the basic unit for resource allocation in a computer system and the foundation of the operating system structure. A process is the basic unit of dynamic execution of an operating system. In a traditional operating system, a process is both a basic allocation unit and a basic execution unit. Different processes will have independent address spaces in memory, and data between processes is not shared by default.
[0052] (3) Threads
[0053] A thread is the smallest unit that an operating system can schedule operations on. A process contains threads, which are the actual operating units in a process. A thread refers to a single sequential control flow in a process. A process can have multiple threads running concurrently, and each thread executes different tasks in parallel.
[0054] A thread is a basic unit of independent scheduling and dispatching. Multiple threads in the same process will share all system resources in the process, such as virtual address space, file descriptors, and signal processing, but multiple threads in the same process have their own call stack, register context, and thread-local storage.
[0055] (4) Coroutines
[0056] A coroutine, also known as a microthread or fiber, is a lightweight thread in user mode. A coroutine is a way to implement multitasking and is a smaller execution unit than a thread. A coroutine has its own CPU context, and the current coroutine controls the switch from the current coroutine to another coroutine.
[0057] In contrast to threads, in a function in a thread, a coroutine can save some temporary variables and other information of the current function anywhere, and then switch to another function for execution. Since coroutines are in user mode, that is, controlled by the user, the process of coroutines saving the information of the current function and switching to another function for execution is not achieved by calling a function, and the number of switches and when to switch to the original function are all controlled by the user.
[0058] (5) Context
[0059] Context refers to the context of the program, which is all the resources and data required by the CPU to execute the program.
[0060] Context switching is to first save the context of the previous task, that is, the task being executed, and then load the context of the new task and run the new task.
[0061] Depending on the task, context switching can be divided into process context switching, thread context switching, coroutine context switching, etc.
[0062] Regarding the process context, the process context is actually a static description of the entire process of process execution activities. The process context includes not only user space resources such as virtual memory, stack, global variables, but also the status of kernel space such as kernel stack and registers. The contents of the executed process instructions and data in the relevant registers and kernel stack are called the previous context, the contents of the instructions and data being executed in the registers and kernel stack are called the main text, and the contents of the instructions and data to be executed in the registers and kernel stack are called the following context. Specifically, process context switching is switching from one process to another, which involves switching all process resources of the previous process with the resources required by the new process, and the address space of the process, i.e., virtual memory, needs to be switched.
[0063] For thread context, one or more threads in the same process share the same resources such as virtual memory and global variables. These thread-shared resources do not need to be modified when the thread context is switched. Therefore, the thread context includes the state of kernel space such as kernel stack and registers. Thread context switch is the context switch from one thread to another in the same process, which only involves the switching of thread identity and resources (such as the contents of registers, program counters, kernel stacks, etc.), and does not involve the switching of address space.
[0064] For the coroutine context, the coroutine is not managed by the operating system kernel, but is completely controlled by the program (that is, it is executed in user mode). The coroutine context switch does not need to switch between kernel mode and user mode. Therefore, compared with process context switch and thread context switch, the coroutine context switch only needs to switch its own registers and stack. Among them, the register context can include data such as the stack pointer (stack pointer, SP) register, the return address (link register, LR) register and the general register, and the stack can be a function call process stack. The stack pointer register is used to store the stack top pointer, the return address register is used to store the entry point, and the general register is used to store the entry parameter.
[0065] like Figure 1As shown, a coroutine context switch is required when a coroutine is switched. For example, when the executing coroutine 1 is switched to the coroutine 2, the stack area 2 stores the previously saved register context and stack of the coroutine 2. The register context and stack of the coroutine 1 are saved to the thread's stack area 1, and the previously saved register context and stack of the coroutine 2 are restored from the stack area 2, and the coroutine jumps to the position pointed to by the return address register to continue executing the switched coroutine 2.
[0066] Compared with thread context switching or process context switching, coroutine context switching only requires switching of a few registers. Coroutine context switching has lower overhead and is faster. The switching speed is 12 to 20 times that of threads or processes.
[0067] After describing the technologies that may be involved in the embodiments of the present application, Figure 2 This article describes the method by which a traditional computer system uses threads or processes to read and process peripheral data from a peripheral. Figure 2 , the computer system needs to start a thread or process for each peripheral to monitor, read, and process the peripheral data of the peripheral separately. For example, thread 1 is used to monitor, read, and process the peripheral data of peripheral 1, thread 2 is used to monitor, read, and process the peripheral data of peripheral 2, ..., thread n is used to monitor, read, and process the peripheral data of peripheral n. The above-mentioned thread 1, thread 2, and thread n are only examples. In the traditional solution, the peripheral data can be monitored, read, and processed by not only threads but also processes.
[0068] For each thread, the process of reading and processing peripheral data can be as follows:
[0069] a. Create a handle;
[0070] The computer system creates thread 1 of the peripheral device, and also creates a handle of thread 1 when creating thread 1 of the peripheral device.
[0071] b. Set peripheral parameters;
[0072] Thread 1 sets the parameters of the peripheral according to the handle. The parameters of the peripheral can be preset parameters corresponding to the type of the peripheral, for example, the parameters corresponding to the camera include data collection cycle, sensitivity, exposure time, etc.
[0073] c. Monitor peripheral data;
[0074] Thread 1 monitors peripheral data based on the handle.
[0075] d. Read peripheral data;
[0076] Thread 1 reads peripheral data based on the handle.
[0077] e. Process the peripheral data and repeat steps a to e based on another peripheral to enter the next loop.
[0078] It can be seen from the above steps a to e of each thread or process that when a computer system needs to process peripheral data of multiple peripherals at the same time, a large number of threads or processes are needed in the computer system to read and process the peripheral data, which will consume a large amount of memory resources and computing resources of the computer system.
[0079] The present application provides a data processing method, in particular, a data processing method of "reading and processing data of a peripheral device (also referred to as peripheral device data) through a coroutine". When a computing device (such as a processor, etc.) monitors data of a first peripheral device, it starts a coroutine of the first peripheral device and executes the coroutine of the first peripheral device to process the data of the first peripheral device.
[0080] Based on the above data processing method, the coroutine of the peripheral is triggered by monitoring the data of the peripheral, so that the coroutine of the peripheral is used to process the data of the peripheral. In the scenario of multiple peripherals, due to the characteristics of asynchronous operation of the coroutine, the coroutine of the peripheral is started only when the data of the peripheral needs to be processed, and the data of multiple peripherals can be processed asynchronously through the coroutine of the peripheral. In this way, compared with executing a separate thread or process for each peripheral to process the data of the peripheral, the number of parallel threads is reduced, thereby reducing the consumption of memory resources and computing resources by multi-threaded parallelism.
[0081] The implementation of the embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0082] Figure 3 This is a schematic diagram of the architecture of a data processing system provided in this application. Figure 3 As shown, the data processing system 300 includes a computing device 310 and N peripheral devices 320 , and the computing device 310 is connected to the N peripheral devices 320 .
[0083] The computing device 310 may be a terminal device or a network device, or a computer, a robot, a vehicle-mounted computer, etc., or a chip (system) or other parts or components that can be set in a terminal device or a network device. The above-mentioned computer, robot, vehicle-mounted computer, etc. may be a system composed of multiple functional parts or components, and therefore may also be called a computer system, a robot system, a vehicle-mounted computer system, etc.
[0084] The computing device 310 includes at least one processor 301, each processor includes one or more cores, and the architecture of each processor supports single thread or multi-thread. Figure 4As shown, each thread can be responsible for scheduling one or more peripheral coroutines using the coroutine scheduler, and maintaining a waiting queue and a running queue. The waiting queue is used to store coroutines for which there is no readable peripheral data, and the coroutines of the peripherals in the waiting queue cannot read the data of the peripherals. The running queue is used to store coroutines for which there is readable peripheral data, and the coroutines of the peripherals in the running queue can read the data of the peripherals.
[0085] The processor 301 may start a thread or a coroutine to monitor the data of the peripheral device. Figure 4 As shown, the data thread or coroutine that monitors the peripheral device can be regarded as the monitoring module 302. The monitoring module 302 can be implemented by a separate thread other than the coroutine that executes the peripheral device, or by a coroutine in the thread that is used to implement the monitoring function (such as Figure 4 The monitoring coroutine shown in the dotted box is implemented.
[0086] In the embodiment provided in the present application, the processor 301 is used to schedule the coroutine of the peripheral. When the coroutine of the peripheral has readable peripheral data, the coroutine of the peripheral is scheduled from the waiting queue to the running queue, and the coroutine of the peripheral is executed according to the queue order of the running queue to process the data of the peripheral.
[0087] The peripheral device 320 is an input device, an output device or an external storage device connected to the computing device 310 , and is used to generate peripheral data according to peripheral parameters or user operations, and transmit the peripheral data to the computing device 310 .
[0088] In some possible embodiments, the computing device 310 is a computer such as a personal computer or a tablet computer, and correspondingly, the peripheral device 320 may be a keyboard, a mouse, a scanner, a camera, a display, a printer, etc.
[0089] In some other possible embodiments, the computing device 310 is a computing system of the type of a robot system, an unmanned aerial vehicle system, etc. Correspondingly, the peripheral device 320 may be various types of sensors, such as inertial sensors, global positioning system modules, Beidou satellite navigation system modules, three-dimensional cameras, radars, etc.
[0090] It is worth noting that Figure 3 and Figure 4 This is only a schematic diagram and should not be construed as limiting the present application. The architecture of the data processing system 300 or the computing device 310 may also include other modules. Figure 3 and Figure 4 Not drawn in.
[0091] Next, the data processing method provided by this embodiment is described in detail with reference to the accompanying drawings.
[0092] The steps of the data processing method provided in this embodiment are performed by the computing device 310 and the peripheral device 320 in the data processing system 300. Figure 5 Steps 510 to 530 are shown to illustrate the data processing method provided in the embodiment of the present application.
[0093] Step 510 : The peripheral device 320 sends the data of the first peripheral device to the computing device 310 .
[0094] As a possible example, after generating the first peripheral device data, the peripheral device 320 sends the first peripheral device data to the computing device 310 .
[0095] Optionally, the computing device 310 is a personal computer, and the peripheral device 320 is a keyboard. When the key "K" of the keyboard is triggered, data of the first peripheral device indicating that the key K is triggered is generated, and the data of the first peripheral device is sent to the personal computer.
[0096] Optionally, the computing device 310 is a robot system, and the peripheral device 320 is a radar. When the radar detects an obstacle ahead, it generates data of a first peripheral device representing a radar signal of the obstacle ahead, and sends the data of the first peripheral device to the robot system.
[0097] Step 520: When the computing device 310 monitors the data of the first peripheral device, it starts the coroutine of the first peripheral device.
[0098] As a possible example, when the computing device 310 monitors that the coroutine of the first peripheral device has data of the first peripheral device that can be read, the first peripheral device is switched from a suspended state to a ready state to start the coroutine of the first peripheral device. The coroutine in the suspended state can be referred to as an unstarted coroutine, and the coroutine in the ready state can be referred to as a started coroutine.
[0099] Optionally, the computing device 310 uses the monitoring module 302 to monitor whether there is currently readable data of the first peripheral device. For the monitoring operation of the monitoring module 302, please refer to Figure 6 Steps 610 to 640 are shown and will not be described in detail here.
[0100] Optionally, when the computing device 310 detects that there is readable data of the first peripheral device, the computing device 310 schedules the coroutine of the first peripheral device in the waiting queue to, for example, a running queue.
[0101] The waiting queue is used to store coroutines for peripherals that do not have data that can be read. One or more coroutines in the waiting queue are in a suspended state and cannot read data from the peripherals. The running queue is used to store coroutines for peripherals that can read data. One or more coroutines in the running queue are in a ready state and can read data from the peripherals.
[0102] In a possible embodiment of the present application, the above-mentioned running queue can be the running queue of the CPU, and the waiting queue can be the waiting queue of the CPU, both of which are linked lists composed of several peripheral coroutines linked in queue order.
[0103] Optionally, considering that different peripherals have different importance according to their functions when the computer system or robot system is running, the above-mentioned running queue and waiting queue may have priorities. The coroutines of different peripherals in the queue have different priorities according to the corresponding peripheral types. The queue order of the waiting queue and the running queue is arranged from high to low according to the priority of the coroutines in the queue to ensure that the data of peripherals with higher importance will be processed first. Among them, the queue order refers to the order in which the coroutine scheduler schedules the coroutines in the waiting queue or the running queue.
[0104] For example, when the computing device 310 is a robot system, the inertial sensor is used to determine the movement posture of the robot system, and the temperature sensor is used to sense the external environment temperature of the robot system. If ensuring the movement stability of the robot system is more important than sensing external data such as temperature, the priority of the coroutine of the peripheral corresponding to the inertial sensor in the above-mentioned running queue and waiting queue is higher than the priority of the coroutine of the peripheral corresponding to the temperature sensor in the above-mentioned running queue and waiting queue.
[0105] In the scenario where the running queue and the waiting queue are priority queues, when there are two or more peripheral coroutines in the waiting queue that need to be scheduled to the running queue at the same time, the computing device 310 moves the peripheral coroutines in order from high to low priority.
[0106] For example, there are coroutines of an inertial sensor and a temperature sensor in the waiting queue, and the computing device 310 monitors the data of the inertial sensor and the temperature sensor, then the computing device 310 first schedules the coroutine of the inertial sensor to the running queue, and then schedules the coroutine of the temperature sensor to the running queue.
[0107] When there are two or more peripheral coroutines in the running queue of the computing device 310, the coroutines of the peripherals are executed in order from high to low priority.
[0108] For example, there are a coroutine of an inertial sensor and a coroutine of a temperature sensor in the running queue. The computing device 310 first executes the coroutine of the inertial sensor to process the data of the inertial sensor, and then executes the coroutine of the temperature sensor to process the data of the temperature sensor.
[0109] Step 530 : The computing device 310 executes the coroutine of the first peripheral device to process data of the first peripheral device.
[0110] As a possible example, the computing device 310 executes a coroutine of the first peripheral device to read data of the first peripheral device and process the data of the first peripheral device.
[0111] Optionally, the computing device 310 sequentially executes the coroutines of the peripherals included in the run queue according to the queue order of the run queue, so as to sequentially read and process the data of the peripherals corresponding to the coroutines of the peripherals. The coroutines of the peripherals included in the run queue may be one or more, and include the coroutine of the first peripheral.
[0112] Optionally, if Figure 5 The peripheral 320 in the figure is the peripheral corresponding to the coroutine of the first peripheral, the computing device 310 executes the coroutine of the first peripheral, reads data from the peripheral 320 corresponding to the coroutine of the first peripheral, and processes the read data.
[0113] Optionally, the coroutine of the first peripheral device periodically reads data of the peripheral device 320. The period of reading the data of the first peripheral device can be flexibly adjusted according to the type of the first peripheral device.
[0114] In a possible embodiment of the present application, the way in which the computing device 310 processes the data of the first peripheral device may vary depending on the type of data of the peripheral device. For example, the data of the first peripheral device is image data collected by a camera, and the processing of the data of the first peripheral device may be image recognition, screen playback, image forwarding, etc. For another example, the data of the first peripheral device is audio data collected by a microphone, and the processing of the data of the first peripheral device may be voiceprint recognition, speech recognition, etc. For another example, the data of the first peripheral device is a radar signal collected by a radar, and the processing of the data of the first peripheral device may be distance measurement, obstacle recognition, etc.
[0115] In some possible implementations, the above step 530 may be implemented by a coroutine scheduler in a thread of the processor 301 of the computing device 310. For specific steps, please refer to the following text. Figure 7 Steps 531 to 535 shown are not repeated here.
[0116] Based on the data processing method shown in the above steps 510-530, when the peripheral device is monitored to have readable data, the coroutine of the peripheral device is started, and the coroutine of the peripheral device that has not been monitored to have readable data is not executed temporarily. In this way, the start and stop of the coroutine of the peripheral device is determined according to whether the coroutine of the peripheral device has readable data, and the asynchronous execution of the coroutines of one or more peripheral devices can be scheduled in one thread, so that the data of multiple peripheral devices can be processed respectively through the coroutines of multiple peripheral devices. Therefore, there is no need to start a separate thread or process for each peripheral device to process the data of the peripheral device, which reduces the number of parallel threads, thereby reducing the consumption of memory resources and computing resources of the computing device by multi-thread parallel. In addition, since the register context and stack are saved to other places when the coroutine scheduling is switched, when it is switched back, the previously saved register context and stack are restored, and the stack is directly operated, so there is basically no kernel switching overhead, and global variables can be accessed without locking, so the context switching is very fast. Therefore, the context switching overhead involved in processing the data of the peripheral device through the coroutine is much smaller than the thread context switching overhead, thereby further reducing the consumption of memory resources and computing resources of the computing device.
[0117] Combination of the above Figure 3-Figure 5 The data processing method provided in this application is generally described. Figure 6 This paper describes in detail how to monitor the data of peripherals in the data processing method. Figure 6 As shown, the processor 301 of the computing device 310 processes the data of the first peripheral, namely the peripheral 320, using the coroutine in the first thread, and performs a monitoring operation on the data of the first peripheral using the second thread. The monitoring operation may include the following steps 610 to 640.
[0118] Step 610: The processor 301 creates a first monitoring event in the second thread.
[0119] As a possible example, the processor 301 creates a first listening event in the second thread according to the operation of the first thread registering the listening event for the peripheral 320. The first listening event is used to monitor the data input by the peripheral 320, and is triggered when the first listening event is triggered, that is, the data of the peripheral 320 that can be read is monitored.
[0120] Optionally, the processor 301 creates the first monitoring event in the second thread, including creating a first monitoring handle of the first monitoring event, wherein the first monitoring handle is used to call a method of the first monitoring event to implement a function of monitoring data of the first peripheral device.
[0121] Step 620: The processor 301 executes the second thread to monitor data from the first peripheral device.
[0122] As a possible example, the processor 301 executes the second thread to monitor whether there is readable data in the peripheral device 320 based on the first monitoring handle.
[0123] Optionally, in addition to monitoring the data of the first peripheral device, the second thread may also need to monitor multiple peripheral devices. The second thread can monitor the monitoring handles of the monitoring events of multiple peripheral devices based on multi-channel input / output (I / O) multiplexing. Once one of the monitoring handles is ready, it can notify the corresponding coroutine to perform the corresponding operation.
[0124] Step 630: The processor 301 executes the second thread to determine the coroutine of the first peripheral.
[0125] As a possible example, the processor 301 executes the second thread to query the coroutine corresponding to the first listening handle according to the correspondence between the listening handle and the coroutine of the peripheral device when monitoring the data of the first peripheral device, so as to obtain the coroutine of the first peripheral device.
[0126] Optionally, the correspondence between the listening handle and the peripheral coroutine is recorded by the peripheral coroutine when registering the listening event. The correspondence between the listening handle and the peripheral coroutine can be a one-to-one correspondence between the listening handle and the peripheral coroutine.
[0127] In a possible embodiment of the present application, after the processor 301 determines the coroutine of the first peripheral in step 630, it is necessary to restore the coroutine of the first peripheral to the ready state, that is, to set the coroutine of the first peripheral to the ready state, for example, to schedule the coroutine of the first peripheral from the waiting queue to the running queue. The above-mentioned state switching operation can be performed by the second thread, or the second thread notifies the first thread to perform. Taking the operation performed by the second thread as an example, the monitoring operation also includes the following step 640.
[0128] Step 640: The processor 301 executes the second thread to schedule the coroutine of the first peripheral from the waiting queue to the running queue.
[0129] For instructions on waiting queues and running queues, please refer to Figure 5 Step 520 shown is not repeated here.
[0130] In the above embodiment, the processor 301 uses the second thread to implement the monitoring operation. In another possible embodiment, the processor 301 can also create a coroutine in the first thread to implement the monitoring function, that is, a coroutine for monitoring (events) to implement the monitoring operation. The difference between the monitoring coroutine and the coroutine of the peripheral is that the functions implemented are different. The only difference is that the processor 301 executes the coroutine of the monitoring (event) of the first thread to implement the effects of the above steps 610-640. The scheduling methods of the two are the same and will not be repeated here.
[0131] Optionally, the above-mentioned monitored coroutine can be executed when there is no coroutine of the peripheral to be executed. For example, when there is no coroutine of any peripheral in the running queue, the first thread executes the monitored coroutine.
[0132] The above embodiment is described by taking the monitoring operation of the data of the first peripheral device as an example. In another possible embodiment, the processor 301 may set a separate monitoring event for each coroutine of different peripheral devices in the second thread.
[0133] Based on the above steps 610 to 640, the monitoring operations of the peripheral data are unified into one thread or coroutine for execution. There is no need to start a thread for monitoring the data of each peripheral, which reduces the number of parallel threads and thus reduces the consumption of memory resources and computing resources of the computing device by multi-thread parallelism.
[0134] Combination of the above Figure 6 The monitoring operation is described in detail. After the processor 301 monitors that there is data of the first peripheral device that can be read, it schedules the coroutine of the first peripheral device to the running queue to execute the coroutine of the first peripheral device to process the data of the first peripheral device. Figure 7 In the steps 531 to 535 shown, the execution process of the first thread is described in detail by taking the processor 301 executing the first thread to process the data of the first peripheral device as an example.
[0135] Step 531: The processor 301 creates a coroutine of a first peripheral in a first thread.
[0136] As a possible example, the processor 301 creates a coroutine of the first peripheral and a first peripheral handle in the first thread. The first peripheral handle is an object identifier of the coroutine of the first peripheral.
[0137] Step 532: The processor 301 sets parameters of the first peripheral device in the first thread.
[0138] As a possible example, the processor 301 executes the coroutine of the first peripheral of the first thread to set the parameters of the first peripheral according to the type of the first peripheral.
[0139] Optionally, the parameters of the first peripheral device may be a preset parameter group matched according to the type of the first peripheral device. For example, when the first peripheral device is a camera, the parameters of the first peripheral device may be a preset camera data acquisition cycle, sensitivity, exposure time, etc. For another example, when the first peripheral device is a GPS module, the parameters of the first peripheral device may be a preset positioning accuracy, etc.
[0140] Step 533: The processor 301 registers a first monitoring event in the second thread.
[0141] As a possible example, the processor 301 executes the coroutine of the first peripheral in the first thread to register the first monitoring event to the second thread (or monitoring module 302) based on the first peripheral handle.
[0142] Optionally, the registration operation of the first listening event includes binding the first listening handle of the first listening event to the coroutine identifier of the coroutine of the first peripheral. Wherein, the coroutine identifier is the unique identity identifier (identify, ID) of the coroutine in the system. In this way, when the first listening event is triggered, the listening module 302 can determine the coroutine of the first peripheral according to the correspondence between the first listening handle and the coroutine identifier of the coroutine of the first peripheral.
[0143] Optionally, the monitoring interface in the first thread that communicates with the monitoring module 302 may be implemented by a hook, that is, the first thread registers the first monitoring event in the monitoring module 302 based on the hook.
[0144] In the above embodiment, the processor 301 registers the first monitoring event in the second thread. In another possible embodiment, the processor 301 can also register the first monitoring event in the coroutine that monitors (events) in the first thread to monitor the data of the first peripheral device through the monitoring coroutine.
[0145] Step 534: The processor 301 suspends the coroutine of the first peripheral.
[0146] As a possible example, the processor 301 executes the first thread to set the coroutine of the first peripheral device to a suspended state, for example, scheduling the coroutine of the first peripheral device to a waiting queue.
[0147] Optionally, operations such as suspending and resuming the coroutine of the first peripheral may be implemented by the above-mentioned hook-based monitoring interface.
[0148] Optionally, the register context and stack of the coroutine of the first peripheral in the suspended state are saved to the heap area of the first thread.
[0149] Step 535 : When there is readable data of the first peripheral device, the processor 301 executes the coroutine of the first peripheral device in the first thread according to the queue order of the running queue to process the data of the first peripheral device.
[0150] As a possible example, the processor 301 resumes and executes the coroutines of the peripherals in the running queue in sequence in the first thread according to the queue order, and processes the data of the first peripheral when executing the coroutine of the first peripheral.
[0151] Optionally, when the processor 301 restores the coroutine of the first peripheral in the first thread, the register context and stack of the coroutine of the first peripheral are restored from the first thread to the register.
[0152] Optionally, the queue order is in descending order of priority of the peripheral coroutines in the queue.
[0153] Optionally, the frequency at which the coroutine of the first peripheral reads the data of the first peripheral can be flexibly adjusted according to different types of peripherals. For example, the data reading frequency of the radar peripheral can be 10 times / second, 15 times / second, etc., the data reading frequency of the inertial sensor peripheral can be 100 times / second, 208 times / second, etc., and the data reading frequency of the camera can be 25 times / second, etc.
[0154] In a possible embodiment of the present application, operations such as creation, enqueueing, dequeueing, and execution of the coroutine of the above-mentioned first peripheral can all be implemented by a coroutine scheduler.
[0155] Based on the above steps 531-535, the data of the peripherals are uniformly monitored through a thread or a coroutine, and the coroutine of the peripherals is started only when the data of the peripherals is monitored, so that the data of multiple peripherals can be asynchronously processed using multiple coroutines in one thread. In this way, there is no need to start a separate thread or process for each peripheral to process the data of the peripheral, which reduces the number of parallel threads or processes, thereby reducing the consumption of memory resources and computing resources of the computing device. In addition, based on the characteristic that the consumption of coroutine context switching is less than the consumption of thread context switching, the consumption of memory resources and computing resources of the computing device is further reduced.
[0156] Figure 8 Schematic diagram of the structure of a possible data processing device provided in this embodiment. The data processing device can be used to implement the functions of the computing device 310 in the above method embodiment, and thus also has the beneficial effects possessed by the above method embodiment. In this embodiment, the data processing device can be as follows Figure 3 The computing device 310, processor 301 or other device with computing function shown may also be a module (such as a chip) applied to a server.
[0157] like Figure 8 As shown, the data processing device 800 includes a scheduling module 810 and a processing module 820 .
[0158] The data processing device 800 can be used to implement the above Figure 5 In the method embodiment shown in FIG. , the functions of the computing device 310 are shown, and the modules included in the data processing apparatus 800 are specifically used to implement the following functions.
[0159] The scheduling module 810 is used to start the coroutine of the first peripheral device when monitoring the data of the first peripheral device. For example, the scheduling module 810 is used to execute the following Figure 5 Step 520 is shown.
[0160] The processing module 820 is used to execute the coroutine of the first peripheral to process the data of the first peripheral. For example, the processing module 820 is used to execute Figure 5 Step 530 is shown.
[0161] In a possible implementation, the scheduling module 810 is specifically used to: when monitoring data of the first peripheral device, schedule the coroutine of the first peripheral device from the waiting queue to the running queue, the waiting queue is used to store the coroutines in the suspended state, and the running queue is used to store the coroutines in the ready state.
[0162] In a possible implementation, the scheduling module 810 is further used to: when monitoring data of the first peripheral device, determine the coroutine of the first peripheral device from multiple coroutines, each coroutine in the multiple coroutines is used to process data of one peripheral device.
[0163] In a possible implementation, the scheduling module 810 is specifically used to: trigger a listening event of the first peripheral device, schedule the coroutine of the first peripheral device from the waiting queue to the running queue, and the listening event of the first peripheral device is used to monitor data of the first peripheral device.
[0164] In a possible implementation, the scheduling module 810 is further used to: register a monitoring event of the first peripheral device in a coroutine for monitoring events, and the coroutine for monitoring events is used to monitor data of multiple peripheral devices.
[0165] In a possible implementation, the first thread includes a coroutine of the first peripheral and a coroutine for monitoring events.
[0166] In a possible implementation, the scheduling module 810 is specifically used to: when there is no coroutine of any peripheral in the running queue, trigger a listening event of the first peripheral, and schedule the coroutine of the first peripheral from the waiting queue to the running queue.
[0167] In a possible implementation, the scheduling module 810 is further used to: when the data processing of the first peripheral is completed and the data of the second peripheral is monitored, start the coroutine of the second peripheral. The processing module 820 is further used to: execute the coroutine of the second peripheral to process the data of the second peripheral.
[0168] In a possible implementation, the data processing device 800 further includes a monitoring module 830 for monitoring monitoring events of peripheral devices.
[0169] It should be understood that the data processing device 800 of the embodiment of the present invention can be implemented by a CPU, or by an application specific integrated circuit (ASIC), or a programmable logic device (PLD), and the PLD can be a complex programmable logical device (CPLD), a field programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof. The data processing device 800 is implemented by software Figure 5 When the data processing method shown in , the data processing device 800 and its various modules can also be software modules.
[0170] It should be understood that the computing device 310 in the embodiment of the present application may correspond to the data processing device 800 in the embodiment of the application, and may correspond to the corresponding subject in executing the method according to the embodiment of the present application, and the above and other operations and / or functions of each module in the data processing device 800 are respectively to implement Figure 5 For the sake of brevity, the corresponding process of the method in will not be repeated here.
[0171] For example, Fig. 9 This is a schematic diagram of the structure of a computing device provided in an embodiment of the present application. The computing device may be a terminal device, a network device, a robot system, etc., or may be a chip (system) or other parts or components that can be set in a terminal device, a network device or a robot system. Fig. 9 As shown, the computing device 900 may include a processor 901. Optionally, the computing device 900 may also include a memory 902 and / or a transceiver 903. The processor 901 is coupled with the memory 902 and the transceiver 903, such as being connected via a communication bus.
[0172] Combine the following Fig. 9 The components of the computing device 900 are described in detail:
[0173] The processor 901 is the control center of the computing device 900, and may be a processor or a general term for multiple processing elements. For example, the processor 901 is one or more central processing units, or may be a dedicated integrated circuit, or may be configured to implement one or more integrated circuits of the embodiments of the present application, such as one or more microprocessors (digital signal processor, DSP), or one or more field programmable gate arrays.
[0174] Optionally, the processor 901 may execute various functions of the computing device 900 by running or executing software programs stored in the memory 902 and calling data stored in the memory 902, such as Figure 5 Steps 510 to 530 shown in the figure or the functions implemented by the scheduling module 810 and the processing module 820 in the data processing device 800.
[0175] In a specific implementation, as an embodiment, the processor 901 may include one or more CPUs, such as Fig. 9 CPU0 and CPU1 are shown in FIG.
[0176] In a specific implementation, as an embodiment, the computing device 900 may also include multiple processors, such as Fig. 9 901 and processor 904 are shown in FIG. Each of these processors may be a single-core processor (single-CPU) or a multi-core processor (multi-CPU). A processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0177] The memory 902 is used to store a software program for executing the solution of the present application, for example, to enable the processor 901 to execute the following Figure 5 The software program of the functions implemented by the scheduling module 810 and the processing module 820 in the data processing device 800 is shown in step 510-step 530, and is controlled and executed by the processor 901. The specific implementation method can refer to the above method embodiment, which will not be repeated here. In addition, the memory 902 can also be used to store data of peripherals.
[0178] Optionally, the memory 902 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 902 may be integrated with the processor 901, or may exist independently and accessed through the interface circuit ( Fig. 9 (not shown) is coupled to the processor 901, which is not specifically limited in the embodiment of the present application.
[0179] The transceiver 903 is used for communication with other communication devices. For example, the computing device 900 is a terminal device, and the transceiver 903 can be used to communicate with a network device, or with another terminal device. For another example, the computing device 900 is a network device, and the transceiver 903 can be used to communicate with a terminal device, or with another network device. For another example, the computing device 900 is a robot system, and the transceiver 903 can be used to communicate with a control device of the robot system, or with another robot system. In addition, the transceiver 903 is also used to communicate with peripherals to send and receive data to the peripherals.
[0180] Optionally, the transceiver 903 may include a receiver and a transmitter ( Fig. 9 The receiver is used to implement a receiving function, and the transmitter is used to implement a sending function.
[0181] Optionally, the transceiver 903 may be integrated with the processor 901, or may exist independently and be connected to the processor 901 through the interface circuit ( Fig. 9 (not shown) is coupled to the processor 901, which is not specifically limited in the embodiment of the present application.
[0182] If the computing device 900 is a chip, it may also include a power supply circuit for supplying power to components such as the processor 901 and the memory 902 in the computing device 900 .
[0183] It should be noted that Fig. 9The structure of the computing device 900 shown in the figure does not constitute a limitation on the device, and the actual device may include more or less components than those shown in the figure, or combine certain components, or arrange the components differently.
[0184] In addition, the technical effects of the computing device 900 can refer to the technical effects of the data processing method described in the above method embodiment, which will not be repeated here.
[0185] It should be understood that the processor in the embodiments of the present application may be a central processing unit, and the processor may also be other general-purpose processors, digital signal processors, application-specific integrated circuits, field programmable gate arrays 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.
[0186] It should also be understood that the memory 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 random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (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 (SLDRAM), and direct rambus RAM (DR RAM).
[0187] The above embodiments can be implemented in whole or in part by software, hardware (such as circuits), firmware or any other combination. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.
[0188] 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.
[0189] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0190] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the 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 through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0191] 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.
[0192] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0193] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk, or an optical disk.
[0194] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which 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
1. A data processing method, characterized in that: include: When data of a first peripheral device is monitored, starting a coroutine of the first peripheral device; Execute the coroutine of the first peripheral to process data of the first peripheral.
2. The method according to claim 1, characterized in that When the data of the first peripheral device is monitored, starting the coroutine of the first peripheral device includes: When data of the first peripheral device is monitored, the coroutine of the first peripheral device is scheduled from the waiting queue to the running queue, the waiting queue is used to store the coroutines in the suspended state, and the running queue is used to store the coroutines in the ready state.
3. The method according to claim 1 or 2, characterized in that: The method further comprises: When data of the first peripheral device is monitored, a coroutine of the first peripheral device is determined from a plurality of coroutines, each of the plurality of coroutines being used to process data of one peripheral device.
4. The method according to any one of claims 1 to 3, characterized in that The method of dispatching the coroutine of the first peripheral device from the waiting queue to the running queue when the data of the first peripheral device is monitored includes: A monitoring event of the first peripheral device is triggered, and the coroutine of the first peripheral device is scheduled from the waiting queue to the running queue, wherein the monitoring event of the first peripheral device is used to monitor data of the first peripheral device.
5. The method according to claim 4, characterized in that The method further comprises: The monitoring event of the first peripheral is registered in the monitoring event coroutine, and the monitoring event coroutine is used to monitor data of multiple peripherals.
6. The method according to claim 5, characterized in that The first thread includes the coroutine of the first peripheral and the coroutine of the monitoring event.
7. The method according to any one of claims 1 to 6, characterized in that The method further comprises: When the data processing of the first peripheral is completed and the data of the second peripheral is monitored, the coroutine of the second peripheral is started; Execute the coroutine of the second peripheral to process data of the second peripheral.
8. A data processing device, characterized in that: The data processing device includes modules for executing the operation steps of any one of the methods of claims 1-7.
9. A processor, characterized in that: When the processor executes a set of computer instructions, the operating steps of the method described in any one of claims 1 to 7 are performed.
10. A chip, characterized in that: The chip includes a processor and a power supply circuit; wherein the power supply circuit is used to supply power to the processor; and the processor is used to execute the operation steps of the method described in any one of claims 1 to 7.
11. A computing device, characterized in that: The computing device includes a memory and a processor, wherein the memory is used to store a set of computer instructions; when the processor executes the set of computer instructions, the operation steps of the method described in any one of claims 1 to 7 are performed.
12. A data processing system, characterized in that: The data processing system comprises a plurality of peripheral devices and a computing device as claimed in claim 11, wherein the computing device is used to process the plurality of peripheral device data according to the operating steps of the method according to any one of claims 1 to 7.