Data processing method, electronic equipment and readable storage medium

By loading the data processing logic of network data transmission services in the operating system kernel, the problems of frequent CPU switching and multiple data copying are solved, and more efficient network data transmission is achieved.

CN119847779APending Publication Date: 2025-04-18HUAWEI TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202311345533.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-16
Publication Date
2025-04-18

Smart Images

  • Figure CN119847779A_ABST
    Figure CN119847779A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data processing, in particular to a data processing method, electronic equipment and a readable storage medium. The method comprises the steps that the electronic equipment can load data processing logic corresponding to a network data transmission service in application programs operated by the electronic equipment into a kernel of an operating system, and data processing system calling and data writing system calling of the corresponding network data transmission service are provided for all the application programs. Therefore, since the kernel of the operating system processes the data of the network data transmission service and stores the data in the kernel space, the data does not need to be copied in the kernel space and the user space, and the efficiency of sending and / or storing the data by the network is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a data processing method, an electronic device and a readable storage medium. Background Art

[0002] The operating state of the central processing unit (CPU) of an electronic device usually includes kernel state and user state. The permissions of the instructions that the CPU can execute are different when it runs in different working states. When the CPU runs in user state, the CPU can only execute instructions with lower permissions in the CPU instruction set, such as reading and writing files, creating processes, accessing user space, etc.; when the CPU runs in kernel state, the CPU can execute all instructions in the CPU instruction set, such as instructions for accessing hardware (such as disks, network cards, other input devices or output devices, etc.), accessing kernel space, etc.

[0003] When an application installed in an electronic device needs to perform a hardware access service (such as a service that reads data from hardware, a service that writes data to hardware, etc.), it can call the kernel of the operating system in user mode through a system call provided by the operating system to perform the hardware access service. The kernel of the operating system can respond to the call of the application program by switching the CPU to the kernel mode and performing the application program hardware access service. In the process of performing the hardware access service, the kernel of the operating system needs to copy the read data from the kernel space to the user space, or copy the data to be written from the user space to the kernel space.

[0004] That is to say, every time an application accesses hardware, the CPU needs to copy data between the user space and the kernel space. As a result, for some services that require multiple accesses to hardware, such as network data transmission services, the CPU of the electronic device needs to copy data between the user space and the kernel space multiple times, affecting the operating efficiency of these services. Summary of the invention

[0005] The embodiment of the present application provides a data processing method, an electronic device and a readable storage medium. Through the data processing method provided by the present application, data does not need to be copied between the kernel space and the user space, which is conducive to improving the transmission efficiency of network data.

[0006] In a first aspect, an embodiment of the present application provides a data processing method, which includes: a first application running on an electronic device detects that a first service to be executed satisfies a kernel execution condition, and the first service is used to process first data in a first hardware of the electronic device into second data, and write the second data into a second hardware of the electronic device; the first application sends a first request corresponding to the first service to the kernel of an operating system of the electronic device; the kernel obtains the first data in the first hardware in response to the first request, and processes the first data into second data; the kernel stores the second data in kernel space; the kernel receives a second request for the first service from the first application, and writes the second data into a data buffer corresponding to the second hardware in response to the second request.

[0007] It can be understood that the above-mentioned first service can, for example, be the network data transmission service mentioned in the present application; the above-mentioned first request can, for example, be the call request corresponding to the network data transmission service initiated by the application mentioned in the present application to the kernel through the data processing system call; the above-mentioned second request can, for example, be the call request corresponding to the network data transmission service initiated by the application mentioned in the present application to the kernel through the data writing system call.

[0008] It can be understood that when the first application detects that the first service meets the kernel execution condition, it sends a first request to the kernel of the operating system, requesting the kernel to obtain the first data from the above-mentioned first hardware, wherein the first data can be, for example, network data received through the network card below, or data to be sent read through the memory. Further, the kernel processes the first data into second data and stores the second data in the kernel space. Then, the kernel receives the second request for the first service from the first application and writes the second data into the data buffer corresponding to the second hardware.

[0009] In this way, since the data of the first service is processed by the kernel of the operating system and stored in the kernel space, the data does not need to be copied between the kernel space and the user space, which is conducive to improving the transmission efficiency of network data.

[0010] In a possible implementation of the first aspect above, the above-mentioned first application sends a first request corresponding to the first service to the kernel of the operating system of the electronic device, including: when the processor of the electronic device is in user mode, the first application sends the first request corresponding to the first service to the kernel of the operating system of the electronic device.

[0011] It can be understood that since the application program corresponding to the first application cannot directly access the underlying resources of the operating system, when the first application needs to execute the first service, such as network data receiving and storage service and / or sending storage data through the network, it can initiate a call to the kernel of the operating system through the above-mentioned first request (i.e., data processing system call), requesting the kernel of the operating system to execute the privileged operation corresponding to the first service, such as accessing hardware.

[0012] In a possible implementation of the first aspect, the kernel stores the second data in the kernel space, including: in kernel mode, the kernel stores the second data in the kernel space.

[0013] In a possible implementation of the first aspect above, the kernel receives a second request for the first service from the first application, and writes the second data into a data buffer corresponding to the second hardware in response to the second request, including: the first application sends the second request to the kernel when the processor of the electronic device is in user mode; the kernel responds to the second request, switches the processor from user mode to kernel mode, and then writes the second data stored in the kernel space into the data buffer corresponding to the second hardware.

[0014] It can be understood that when the data processing is completed and the second data is obtained, the second data needs to be written into the data buffer corresponding to the second hardware. Since the CPU does not have the hardware access permission when running in the user state, the application needs to send a second request to the kernel, requesting the kernel to write the second data into the data buffer corresponding to the second hardware. Therefore, the kernel responds to the second request, switches the processor from the user state to the kernel state, and writes the second data stored in the kernel space into the data buffer corresponding to the second hardware.

[0015] In a possible implementation of the first aspect, the first hardware is a memory or a network card of the electronic device, and the second hardware is a network card or a memory of the electronic device.

[0016] In a possible implementation of the first aspect above, the kernel obtains first data in the first hardware in response to the first request, and processes the first data into second data, including: corresponding to the first hardware being a memory and the second hardware being a network card, obtaining the first data from the memory and packaging the first data into second data; corresponding to the first hardware being a network card and the second hardware being a memory, obtaining the first data from the network card and parsing the first data to obtain the second data.

[0017] In a possible implementation of the first aspect above, the obtaining of the first data in the first hardware includes: corresponding to the first hardware being a memory and the second hardware being a network card, the kernel reads the first data from the memory and stores the first data in a data buffer corresponding to the memory, and obtains the first data from the data buffer corresponding to the memory; corresponding to the first hardware being a network card and the second hardware being the memory, the kernel reads the first data from the data buffer corresponding to the network card.

[0018] It can be understood that, corresponding to the first hardware being a memory and the second hardware being a network card, the above-mentioned kernel switches the CPU from user mode to kernel mode in response to the first request, the kernel reads the first data from the memory and stores the first data in a data buffer corresponding to the memory, and obtains the first data from the data buffer corresponding to the memory.

[0019] Corresponding to the first hardware being a network card and the second hardware being a memory, after receiving the network data, the network card will automatically transfer the network data to the corresponding data buffer. Therefore, the kernel switches the CPU from user mode to kernel mode in response to the first request, and the kernel reads the first data from the data buffer corresponding to the network card.

[0020] In a possible implementation of the first aspect above, the method also includes: corresponding to the second hardware being a memory, the kernel writes the second data in the data buffer corresponding to the second hardware into the memory; corresponding to the second hardware being a network card, the kernel writes the second data in the data buffer corresponding to the second hardware into the network card.

[0021] In a possible implementation of the first aspect, the processing of the first data into the second data includes: the kernel processes the first data into the second data based on a preloaded instruction corresponding to the first application processing the first data into the second data.

[0022] It can be understood that the above-mentioned instruction corresponding to processing the first data into the second data in the first application can be, for example, the data processing logic mentioned in this application. The above-mentioned loading process can be, for example, through the loading interface of the programmable framework added to the kernel of the operating system, the data processing logic of the running application corresponding to the first service is loaded into the kernel of the operating system, or the data processing logic can be loaded into the kernel of the operating system through the programmable program loader of the electronic device, which is not limited here. Among them, the data processing logic corresponding to the network data transmission service in the above-mentioned application can be loaded in the sandbox processing module of the kernel.

[0023] In a possible implementation of the first aspect above, the first application sends a first request corresponding to the first service to the kernel of the operating system of the electronic device, including: the first application sends the first request corresponding to the first service to the kernel of the operating system of the electronic device based on the first system call corresponding to the first service.

[0024] It can be understood that the above-mentioned first system call can be, for example, the data processing system call mentioned in this application.

[0025] In a possible implementation of the first aspect above, the method also includes: when the processor of the electronic device in which the first application is located is in user mode, the first application sends a second request to the kernel, including: based on the second system call corresponding to the first service, the first application sends the second request corresponding to the first service to the kernel of the operating system of the electronic device.

[0026] It can be understood that the above-mentioned first system call can be, for example, the data write system call mentioned in this application.

[0027] In a possible implementation of the first aspect, the method further includes: the kernel execution condition includes: the permission of at least part of the instructions corresponding to the first business is ring3.

[0028] For example, in a Linux system on Windows, the application or user process corresponding to the first application runs at the privilege level of ring3 (i.e., user mode or non-privileged mode). However, for security and stability reasons, applications in ring3 cannot directly access the underlying hardware devices or execute some privileged instructions. Therefore, the application must request the operating system to provide access rights and services through system calls and other means.

[0029] In a second aspect, the present application provides an electronic device, comprising: a memory and a processor, wherein the memory is used to store instructions executed by one or more processors of the electronic device, and the processor is one of the one or more processors of the electronic device, and is used to execute the data processing method mentioned in the present application.

[0030] In a third aspect, the present application provides a readable storage medium, wherein the readable storage medium stores instructions, and when the instructions are executed on an electronic device, the electronic device executes the data processing method mentioned in the present application.

[0031] In a fourth aspect, the present application provides a computer program product, characterized in that it includes a computer program / instructions, which, when executed by a processor, implement the data processing method provided by the above-mentioned first aspect and various possible implementations. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1aAccording to an embodiment of the present application, a schematic diagram of an application scenario for executing a network data receiving and storing service is shown.

[0033] Figure 1b According to an embodiment of the present application, a schematic diagram of an application scenario for executing a storage data service sending via a network is shown.

[0034] Figure 2 According to an embodiment of the present application, a flow chart of a data processing method is shown.

[0035] Figure 3 According to an embodiment of the present application, a framework diagram for implementing a data processing method is shown.

[0036] Figure 4 According to an embodiment of the present application, a flowchart of another data processing method is shown.

[0037] Figure 5 According to an embodiment of the present application, a component structure diagram for implementing a data processing method is shown.

[0038] Figure 6 According to an embodiment of the present application, a flowchart for implementing a network data receiving and storing service is shown.

[0039] Figure 7 According to an embodiment of the present application, a flowchart for implementing another network data receiving and storing service is shown.

[0040] Figure 8 According to an embodiment of the present application, a flowchart for implementing a network data receiving and storing service is provided.

[0041] Fig. 9 According to an embodiment of the present application, another implementation flow chart of a network data receiving and storing service is provided.

[0042] Fig.10 According to an embodiment of the present application, a structural schematic diagram of an electronic device 100 is shown. DETAILED DESCRIPTION

[0043] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0044] It should also be stated that the steps in the methods and processes in the embodiments of the present application are numbered for ease of reference, rather than to limit the order of precedence. If there is an order between the steps, the text description shall prevail.

[0045] In order to facilitate those skilled in the art to understand the solutions in the embodiments of the present application, some concepts and terms involved in the embodiments of the present application are explained below.

[0046] (1) Socket buffer: It is a memory area in a computer network used to store data to be sent or received. It is divided into a read buffer and a send buffer.

[0047] (2) Receive buffer: A memory area used to temporarily store data received from the network. When network data is received, it is temporarily stored in the receive buffer. The application can then read the data from the receive buffer and process it accordingly.

[0048] (3) Send buffer: A memory area used to store data that an application is about to send to the network. The application puts the data into the send buffer, and then the operating system kernel or network protocol stack reads the data from the send buffer and sends the data to the network.

[0049] (4) Read buffer: A memory area used to temporarily store data to be read. Generally, data in the memory is first stored in the read buffer, and then the data is read byte by byte from the read buffer.

[0050] (5) Write buffer: A memory area used to temporarily store data to be written. Generally, data to be written to the memory is first placed in the write buffer, and then the operating system kernel reads the data from the write buffer and stores it in the memory.

[0051] (6) User space: refers to the memory area allocated by the operating system for each process to store the code and data of the process. Among them, the application program in the user space cannot directly access the underlying resources of the system, but requests the kernel to perform privileged operations through system calls.

[0052] (7) Kernel space: It is the core part of the operating system and is responsible for managing and controlling the computer's hardware resources. Code running in kernel space has the highest permissions and can directly access the system's underlying resources, such as the processor, memory, network card, hard disk, etc. The kernel provides a set of system call interfaces for user space applications to use. When a user space program needs to perform a privileged operation, it transfers control to the kernel through a system call, and the kernel completes the corresponding operation and then returns the result to the user space.

[0053] The technical solution of the present application is described below in conjunction with the accompanying drawings.

[0054] Every time an application accesses hardware, the electronic device needs to copy data between the user space and the kernel space. As a result, for some services that require multiple accesses to hardware (such as services that send data over the network, services that receive data from the network, etc.), the CPU of the electronic device needs to copy data between the user space and the kernel space multiple times, affecting the operating efficiency of these services.

[0055] For example, corresponding to the network data receiving and storing service, the electronic device needs to first access the network card through the kernel of the operating system to read the data received by the network card from the network card, and copy the received data from the kernel space to the user space. Then, the application in the electronic device can process the received data in the user space. Secondly, the electronic device copies the processed data from the user space to the kernel space through the kernel of the operating system, and stores the processed data in the memory. In other words, the network data receiving and storing service includes two data copies between the user space and the kernel space, which affects the operating efficiency of the network data receiving and storing service.

[0056] For example, Figure 1a According to an embodiment of the present application, a schematic diagram of an application scenario for executing a network data receiving and storing service is shown.

[0057] like Figure 1a As shown, the scenario includes: user space, kernel space and hardware.

[0058] The user space mentioned above includes application programs (not shown in the figure).

[0059] The kernel space includes multiple buffers, such as a socket buffer 1 and a write buffer, wherein the socket buffer 1 may be a receive buffer for temporarily storing data received from a network.

[0060] The hardware includes a network card and a memory, wherein the network card can be used to receive or send data, and the memory is used to store data.

[0061] Continue to refer Figure 1aWhen an application needs to receive data through the network and save it to a storage device (hereinafter referred to as the network data receiving and storage service), it can first initiate a request to read the data in the network card to the kernel of the operating system through a system call in the user state, for example, by initiating a request to read the data in the network card to the kernel of the operating system through a receive system call. The kernel of the operating system can respond to the receive system call by switching the CPU from user state to kernel state, copying the network data cached in socket buffer 1 (i.e., the receive buffer) from kernel space to user space, and switching the CPU from kernel state back to user state. In this way, the CPU switches from user state to kernel state, and then switches from kernel state back to user state (i.e., Figure 1a The first switch in the process). After the CPU switches back from kernel state to user state, the application can perform application layer network protocol parsing on the network data to obtain the processing result, and in user state, request the CPU to execute the service of writing the network data (processing result) to the memory in kernel state through a write system call. After receiving the request, the kernel of the operating system can switch the CPU from user state to kernel state again, copy the processing result from user space to the write buffer of kernel space, and write the processing result stored in the buffer to the memory. Finally, the kernel of the operating system switches the CPU from kernel state back to user state again. In this way, the CPU switches from user state to kernel state, and then from kernel state back to user state (i.e. Figure 1b The second switch in the process) and returns the service execution result (such as completion of network data reception, etc.) to the user-state application.

[0062] That is to say, when executing the network data receiving and storing service, data needs to be copied twice between the user space and the kernel space.

[0063] For another example, corresponding to the service of reading data from the memory and sending it through the network card (hereinafter referred to as the service of sending storage data through the network), the electronic device needs to first access the memory through the kernel of the operating system to read the data to be sent from the memory, and copy the data to be sent from the kernel space to the user space. Then, the application in the electronic device can package the data to be sent in the user space. Secondly, the electronic device copies the packaged data from the user space to the kernel space through the kernel of the operating system, and sends the packaged data to the network through the network card. In other words, sending the storage data service through the network includes copying data twice between the user space and the kernel space, which affects the operating efficiency of the network data receiving and storage service.

[0064] For example, Figure 1b According to an embodiment of the present application, a schematic diagram of an application scenario for executing a storage data service sending via a network is shown.

[0065] like Figure 1b As shown, the scenario includes user space, kernel space, and hardware.

[0066] The user space includes a user buffer and a user program (not shown in the figure). The kernel space includes a socket buffer 2 and a read buffer. The socket buffer 2 can be a send buffer for storing data that the application is ready to send to the network.

[0067] The hardware includes a network card and a memory, wherein the network card can be used to receive or send data, and the memory is used to store data.

[0068] Continue to refer Figure 1b When executing the service of sending stored data over the network, the application can first initiate a request to read the data in the memory to the kernel of the operating system through a system call in the user state, for example, by initiating a request to read the data in the memory to the kernel of the operating system through a read system call. In response to receiving the read system call, the kernel of the operating system can switch the CPU from the user state to the kernel state, copy the data to be sent cached in the read buffer from the kernel space to the user space, and switch the CPU from the kernel state back to the user state. In this way, the CPU switches from the user state to the kernel state, and then switches from the kernel state back to the user state (i.e. Figure 1b The first switch in the process) After the CPU switches from kernel state back to user state, the application processes the data to be sent in the user buffer and obtains the processing result. Then the application in user state requests the CPU in kernel state to execute the service of sending network data through the network card through the send system call. After receiving the request, the operating system switches the CPU from user state to kernel state again, copies the above processing results from user space to socket buffer 2 in kernel space (i.e., the send buffer), sends the processing results to the network through the network card, and switches the CPU from kernel state back to user state again. In this way, the CPU switches from user state to kernel state, and then switches from kernel state back to user state (i.e., Figure 1b The second switch in the process) and returns the service execution result to the user state, such as completion of network data transmission.

[0069] From the above process, it can be seen that when an application sends storage data through a network card, or receives and stores data from a network card, it needs to copy data twice between the user space and the kernel space, which affects the operating efficiency of the data transmission service.

[0070] In order to solve the above problems, the embodiment of the present application shows a data processing method. Specifically, the electronic device can load the data processing logic corresponding to the network data transmission service in the application program running on the electronic device into the kernel of the operating system, and provide the corresponding data processing system call and data writing system call of the network data transmission service for each application program.

[0071] When an application needs to perform a network data transmission service, it can initiate a call to the kernel of the operating system through a data processing system call. Then, the kernel of the operating system can respond to the data processing system call of the application, and based on the data processing logic corresponding to the network data transmission service of the loaded application, process the data of the network data transmission service to obtain the processing result, and store the processing result in the kernel space. Secondly, the application can initiate a call to the kernel of the operating system through a data write system call. In response to the data write system call, the kernel of the operating system transfers the data stored in the kernel space to the data buffer. Thirdly, the kernel of the operating system writes the data to be written to the network card in the data buffer to the network card, or writes the data to be written to the memory to the memory.

[0072] For example, when developing an application, the developer of the application can set a loading interface in the operating system for the application to load the data processing logic of the corresponding network data transmission service. The developer of the operating system can set a framework for loading the data processing logic of the network data transmission service of the application according to the loading interface of the application in the kernel of the operating system, and set the aforementioned data processing system call for the application to call the data processing logic to implement the processing of network data, and the data writing system call for the application to call the data processing logic to implement the writing of network data.

[0073] When the application is running, the kernel of the operating system of the electronic device can load the data processing logic of the network data transmission service corresponding to the application into the kernel of the operating system based on the loading interface set in the application, and provide the application with corresponding processing system calls and data writing system calls.

[0074] When the application needs to perform network data reception and storage services, it can initiate a data processing system call corresponding to the network data reception and storage services to the kernel of the operating system. In response to the data processing system call, the kernel of the operating system switches the CPU from the user state to the kernel state, reads the temporarily stored data from the input buffer, and transmits the data to the processing module where the loaded data processing logic is located. After receiving the network data, the network card automatically transmits the network data to the input buffer of the kernel. Then, the kernel of the operating system switches the CPU from the kernel state to the user state and sends a message to the application indicating that the data is transmitted to the processing module where the loaded data processing logic is located. Then, the kernel of the operating system processes the read data according to the data processing logic corresponding to the loaded application to obtain the processing result. The kernel of the operating system stores the processing result in the kernel space. In response to the data processing system call, the kernel of the operating system switches the CPU from the user state to the kernel state, and the operating system transmits the processing result stored in the kernel space to the output buffer. Then, the kernel of the operating system switches the CPU from the kernel state to the user state and sends a message to the application indicating that the data processing result is stored in the output buffer. Finally, the kernel of the operating system stores the data in the output buffer in the memory.

[0075] When the application needs to send a storage data service through the network, it can initiate a data processing system call corresponding to the storage data service sent through the network to the kernel of the operating system. In response to the data processing system call, the kernel of the operating system switches the CPU from the user state to the kernel state, first reads data from the storage device, and temporarily stores the data in the input buffer. The kernel of the operating system then reads the temporarily stored data from the input buffer and transmits the data to the processing module where the loaded data processing logic is located. Then, the kernel of the operating system switches the CPU from the kernel state to the user state and sends a message to the application indicating that the data is transmitted to the processing module where the loaded data processing logic is located. Furthermore, the kernel of the operating system processes the read data according to the data processing logic corresponding to the loaded application, obtains the processing result, and stores the processing result in the kernel space. The application initiates a data write system call corresponding to the storage data service sent through the network to the kernel of the operating system. In response to the data write system call, the kernel of the operating system switches the CPU from the user state to the kernel state, transmits the processing result to the output buffer, switches the CPU from the kernel state to the user state, and sends a message to the application indicating that the processing result is transmitted to the output buffer. Finally, the kernel of the operating system sends the data in the output buffer to the network through the network card.

[0076] In this way, since the data of the network data transmission service is processed and stored in the kernel space by the kernel of the operating system, the data does not need to be copied between the kernel space and the user space, which is conducive to improving the efficiency of network transmission and / or storage of data.

[0077] It can be understood that the data processing method provided in the embodiments of the present application can be applicable to electronic devices including but not limited to mobile phones, tablet computers, desktops, laptops, handheld computers, netbooks, and augmented reality (AR) and virtual reality (VR) devices, smart TVs, smart watches and other wearable devices, servers, mobile email devices, car equipment, portable game consoles, portable music players, reader devices, televisions in which one or more processors are embedded or coupled, or other electronic devices that can access the Internet.

[0078] In some embodiments, before executing the above-mentioned network data transmission service, the application program may also first bind the network data transmission service to the corresponding data processing logic through the communication interface provided by the kernel of the operating system. Furthermore, when a network data transmission service is detected, the kernel of the operating system transmits the data to the input buffer through the communication interface based on the data processing logic bound to the network data transmission service, and after being processed by the data processing logic, the data is transferred to the output buffer through the communication interface. Finally, the kernel of the operating system writes the transmission data of the output buffer into the memory and saves it or writes it into the network card and sends it to the network through the network card. Based on this, in the process of performing the network data transmission service, the CPU does not need to switch between the kernel state and the user state, and does not need to copy data.

[0079] Combine the following Figure 2 The specific implementation process of the data processing method provided in this application is described in detail. Figure 2 According to an embodiment of the present application, a flow chart of a data processing method is shown.

[0080] Figure 2 The specific steps are as follows:

[0081] 201: The application program loads the data processing logic corresponding to the currently running network data transmission service into the kernel of the operating system.

[0082] Exemplarily, the above loading operation can be performed by loading the data processing logic of the network data transmission service of the running application program into the kernel of the operating system through the loading interface of the programmable framework added to the kernel of the operating system, or by loading the above data processing logic into the kernel of the operating system through the programmable program loader of the electronic device, without limitation. Among them, the data processing logic corresponding to the network data transmission service in the above application program can be loaded into the sandbox processing module of the kernel.

[0083] It can be understood that in some embodiments, after the data processing logic is loaded into the kernel, the network data transmission service can also be bound to the corresponding data processing logic through the event binding interface provided by the kernel programmable framework. For example, the network data sending service is bound to the data packaging processing logic, and the network data receiving and storing service event is bound to the data parsing processing logic.

[0084] 202: The application program initiates a data processing system call to the kernel of the operating system.

[0085] It is understandable that, since the application cannot directly access the underlying resources of the operating system, when the application needs to perform network data transmission services, such as network data receiving and storage services and / or sending storage data services through the network, it can initiate a call to the kernel of the operating system through the above-mentioned data processing system call, requesting the kernel of the operating system to perform privileged operations corresponding to the network data transmission services, such as access to hardware. For example, in a Linux system on Windows, applications or user processes run at the privilege level of ring3 (i.e., user mode or non-privileged mode). However, for reasons of security and stability, applications in ring3 cannot directly access underlying hardware devices or execute some privileged instructions. Therefore, applications must request the operating system to provide access rights and services through system calls and other means.

[0086] 203: In response to the data processing system call of the application program, the kernel of the operating system processes the transmission data of the network data transmission service based on the loaded data processing logic to obtain a processing result.

[0087] It is understandable that after the application initiates the call, the CPU needs to access the hardware to obtain the corresponding transmission data. However, the CPU does not have the authority to access the hardware when running in user mode. Therefore, when the application initiates a data processing system call, the kernel of the operating system can switch the CPU to kernel mode. For example, in the Linux system of Windows, at the privilege level of ring0 (kernel mode or privileged mode), the kernel of the operating system has full control over system resources, can execute any instructions and access all hardware devices.

[0088] Exemplarily, for example, corresponding to sending a storage data service through a network, in response to a data processing system call of an application, the kernel of the operating system transfers the data to be sent temporarily stored in an input buffer (i.e., a read buffer) to a processing module corresponding to the data processing logic, such as a sandbox processing module. At this time, the kernel of the operating system switches the CPU to user mode, and feeds back to the user program a message indicating that the network data has been transferred to the processing module corresponding to the data processing logic. Furthermore, the kernel of the operating system processes the data to be sent of the storage data service sent through the network based on the loaded data processing logic, and then obtains a processing result in which the data to be sent is packaged.

[0089] For another example, corresponding to the network data receiving and storing service, in response to the data processing system call of the application program, after the kernel of the operating system switches the CPU to the kernel state, the kernel of the operating system transfers the network data temporarily stored in the input buffer (i.e., the receiving buffer) to the processing module corresponding to the data processing logic, such as the sandbox processing module. At this time, the kernel of the operating system switches the CPU to the user state, and feeds back to the user program a message indicating that the data to be sent has been transferred to the processing module corresponding to the data processing logic. Furthermore, the kernel of the operating system processes the network data of the network data receiving and storing service based on the loaded data processing logic, and then obtains the processing result of the network data data parsing completion.

[0090] 204: The application initiates a data write system call to the kernel of the operating system.

[0091] It can be understood that when the data processing is completed, since the CPU does not have the permission to access the hardware when running in the user state, the application needs to call the data write system call to request the CPU to complete privileged operations such as hardware access in the kernel state.

[0092] 205: In response to the application program initiating a data write system call to the kernel of the operating system, the kernel of the operating system stores the processing result in the kernel space.

[0093] Exemplarily, for example, corresponding to the storage data service sent through the network, after receiving the message indicating that the data processing has been completed, the application program calls the data write system call in the user state, and switches the CPU to the kernel state, so that the kernel of the operating system can transfer the processed data to the corresponding output buffer (i.e., the sending buffer) through the communication module / interface corresponding to the data write system call. At this time, the kernel of the operating system switches the CPU to the user state, and feeds back to the user program a message indicating that the data to be sent has been transferred to the output buffer (i.e., the sending buffer). Further, the kernel of the operating system sends the data in the sending buffer to the network through the network card.

[0094] For another example, corresponding to the network data receiving and storing service, upon receiving a message indicating that data processing has been completed, the application program calls the data writing interface in the user state and switches the CPU to the kernel state, so that the kernel of the operating system can transfer the processed data to the corresponding output buffer (i.e., write buffer) by calling the corresponding communication module / interface through the data writing system. At this time, the kernel of the operating system switches the CPU to the user state and feeds back a message to the user program indicating that the network data has been transferred to the output buffer (i.e., write buffer). Further, the kernel of the operating system writes the data in the memory buffer to the storage.

[0095] It can be understood that since the above data processing method is that the kernel of the operating system processes the data of the network data transmission service and stores it in the kernel space, the data does not need to be copied between the kernel space and the user space, which is beneficial to improving the transmission efficiency of network data.

[0096] Figure 3 According to an embodiment of the present application, a framework diagram for implementing a data processing method is shown. Figure 3 Includes software layer and hardware layer.

[0097] The hardware layer includes memory and network card. The network card can be used to receive or send data, and the memory is used to store data.

[0098] The software layer includes an application layer and a kernel layer. The application layer includes a data processing logic module. The data processing logic module may include a network data receiving processing logic and a network data sending processing logic. The kernel layer includes a system call 1, a programmable framework, a system call 2, a file system, a communication module / interface 1, a sandbox processing module, a communication module / interface 2, and a network protocol stack. The network protocol stack includes a socket buffer, and the file system includes a memory buffer.

[0099] refer to Figure 3 As shown, the electronic device can load the data processing logic corresponding to the network data transmission service in the application into the kernel of the operating system when the application is running. The programmable framework is used to provide a loading mechanism and a loading interface. The above-mentioned network data transmission service can be a network sending and storing data service and / or a network data receiving and storing service, and the above-mentioned data processing logic can be a network data packaging processing logic and a network data parsing processing logic corresponding to the network sending and storing data service and the network data receiving and storing service.

[0100] Continue to refer Figure 3For example, in the scenario of network data receiving and storing services, when the network data arrives at the network card, the network data will be automatically temporarily stored in the socket buffer (i.e., the receiving buffer). At this time, after the application initiates system call 2 (i.e., data processing system call) in user mode, in response to the application's call request, the kernel of the operating system can switch the CPU from user mode to kernel mode. The kernel of the operating system transmits the network data temporarily stored in the socket buffer (i.e., the receiving buffer) to the sandbox processing module through the communication module / interface 2. Then the kernel of the operating system switches the CPU from kernel mode to user mode, and feeds back to the user program information indicating that the network data has been transmitted to the sandbox processing module. The sandbox processing module processes the network data based on the loaded data processing logic, for example, parses and processes the network data. Then, the application initiates system call 1 (i.e., data writing system call) in user mode. In response to the application's call request, the kernel of the operating system switches the CPU from user mode to kernel mode, and transmits the processed network data to the memory buffer (i.e., write buffer) through the communication module / interface 1. The kernel of the operating system feeds back to the user program a message indicating that the network data has been transferred to the memory buffer (i.e., the write buffer) and switches the CPU from the kernel state to the user state. Further, the kernel of the operating system accesses the memory and stores the network data in the write buffer in the memory.

[0101] For another example, in a scenario where a storage data service is sent over a network, after the application initiates system call 1 (i.e., a data processing system call) in user mode, the kernel of the operating system switches the CPU from user mode to kernel mode in response to the call of the application. Then, the kernel of the operating system transmits the data to be sent temporarily stored in the memory buffer (i.e., the read buffer) to the sandbox processing module through the communication module / interface 1, and then the kernel of the operating system switches the CPU from kernel mode to user mode, and feeds back to the user program information indicating that the data to be sent has been transferred to the sandbox processing module. The sandbox processing module processes the data to be sent based on the data processing logic loaded in the kernel through the programmable framework, for example, the data to be sent is packaged and processed. Then, the application initiates system call 2 (i.e., a data write system call) in user mode. In response to the call request of the application, the kernel of the operating system switches the CPU from user mode to kernel mode, and transmits the processed data to be sent to the socket buffer (i.e., the send buffer) through the communication module / interface 2. The kernel of the operating system feeds back to the user program a message indicating that the network data has been transferred to the memory buffer (i.e., the write buffer) and switches the CPU from kernel mode to user mode. Furthermore, the kernel of the operating system accesses the network card, writes the data to be sent in the sending buffer into the network card, and sends the data to the network through the network card.

[0102] It is understandable that before performing the network data transmission service, the application can also first bind the network data transmission service with the corresponding data processing logic through the event binding interface provided by the programmable framework. For example, the business event of sending and storing data through the network is bound to the data packaging processing logic, and the network data receiving and storage business event is bound to the data parsing processing logic. Furthermore, when a network data transmission service is detected, the operating system directly transfers the data to the corresponding buffer through the communication interface / module based on the data processing logic bound to the network data transmission service. The CPU only needs to be in the kernel state to complete the network data transmission service, and there is no need to switch between the user state and the kernel state.

[0103] Combination Figure 3 , Figure 4 According to an embodiment of the present application, a flowchart of another data processing method is shown.

[0104] Figure 4 The specific steps are as follows:

[0105] 401: The application program loads the data processing logic into the sandbox processing module of the kernel through the programmable framework provided by the kernel of the operating system.

[0106] Understandably, through Figure 3 The programmable framework in the kernel loads the data processing logic into the kernel's sandbox processing module. The above loading operation can be performed during the application development phase. For example, the application developer can call the loading interface of the programmable framework according to the data processing logic corresponding to the network data transmission service of the application to load the above data processing logic into the kernel's sandbox processing module; the data processing logic can also be loaded into the kernel's sandbox processing module based on the programmable program loader provided by the operating system itself, which is not limited here.

[0107] In some implementations, after the data processing logic is loaded into the kernel, the network data transmission service can also be bound to the corresponding data processing logic through the event binding interface provided by the programmable framework. For example, the service event of sending and storing data through the network is bound to the data packaging processing logic, and the service event of receiving and storing network data is bound to the data parsing processing logic.

[0108] It is understandable that in the process of loading the data processing logic into the kernel, it is also necessary to perform security analysis on the program code corresponding to the data processing logic to check for security risks. The above programmable framework may be, for example, an extended Berkeley packet filter framework (EBPF).

[0109] 402: When the transmission data is temporarily stored in the input buffer, the kernel of the operating system transmits the transmission data to the sandbox processing module through the communication module / interface of the kernel.

[0110] It can be understood that after the application initiates the first system call (i.e., data processing system call) in user mode, the kernel of the operating system switches the CPU from user mode to kernel mode, and transmits the transmission data to the sandbox processing module through the communication module / interface, at which time the kernel of the operating system switches the CPU from kernel mode to user mode again. The sandbox processing module parses and processes the transmission data based on the loaded data processing logic, for example, parses and processes the transmission data corresponding to the network data receiving and storage service or packages and processes the transmission data corresponding to the network data receiving and storage service.

[0111] Alternatively, based on the binding operation completed in step 401, when a network data transmission service is detected, the kernel of the operating system directly transmits the transmission data to the sandbox processing module through the communication module / interface of the kernel based on the data processing logic bound to the network data transmission service. Then, the sandbox processing module parses and processes the transmission data based on the loaded data processing logic.

[0112] 403: After the sandbox processing module completes the data processing, it transmits the transmission data to the output buffer through the communication module / interface of the kernel.

[0113] It can be understood that the application initiates a second system call (i.e., a data write system call) in the user state to call the communication module / interface to transfer the transmission data to the output buffer. At this time, the kernel of the operating system switches the CPU from the user state to the kernel state. Then, the data transmission service is completed through the hardware, such as storing the transmission data in the memory, or sending the transmission data to the network through the network card.

[0114] Combine the following Figure 5 Describe the functions of each component when executing the data processing method provided by this application. Figure 5 According to an embodiment of the present application, a component structure diagram for implementing a data processing method is shown. Figure 5 As shown, in Figure 5 In the paper, based on the LINUX kernel, the EBPF framework is used as the programmable framework, and splice is used as the system call to execute data transmission services.

[0115] Continue to refer Figure 5In the application development stage, application developers need to write one or more EBPF programs first. For example, a parsing program for network data corresponding to the network data receiving and storage service, and a packaging program for storage data corresponding to the storage data service sent over the network. After the program is written, the program is packaged into a specific loading directory, and loaded into the operating system kernel by an application or a programmable program loader at a specific time. Further, the packaging program is bound to the calling interface of the splice system call that triggers the packaging process, and the parsing program is bound to the calling interface of the splice system call that triggers the parsing process. Furthermore, the above-mentioned EBPF program can be parsed according to the system loader of the LINUX kernel itself, and then these parsed programs can be loaded into the kernel through the framework interface of EBPF. In the process of loading the parsed program into the kernel, it is also necessary to perform security analysis on the program code to check for security risks.

[0116] It can be understood that, for example, when executing the network data receiving and storing service, the application calls the splice system call 2 provided in the present application in the user state, and the kernel of the operating system switches the CPU from the user state to the kernel state. Then, the kernel of the operating system transmits the network data in the socket buffer (i.e., the receiving buffer) to the pipe 2 with zero copy, and then transmits the network data to the application layer network data processing sandbox program through the pipe 2. The kernel of the operating system switches the CPU from the kernel state to the user state again, and feeds back to the application a message indicating that the network data has been transmitted to the application layer network data processing sandbox program. The kernel of the operating system parses and processes the network data based on the bound data processing logic. After the kernel of the operating system parses and processes the network data, it obtains the processing result. The application calls the splice system call 1 provided in the present application in the user state. The kernel of the operating system switches the CPU from the user state to the kernel state and transmits the parsed network data to the pipe 1 with zero copy, and then transmits the network data to the memory buffer (i.e., the write buffer) through the pipe 1. The kernel of the operating system then switches the CPU from kernel mode to user mode, and feeds back to the application a message indicating that the network data has been transferred to the memory buffer (i.e., write buffer). Finally, the kernel of the operating system stores the network data in the memory buffer (i.e., write buffer) in a storage device, such as a memory. In some embodiments, the data processed by the application layer network data processing sandbox program can be transferred to the memory buffer (i.e., write buffer) through pipe 1 in the form of a file descriptor.

[0117] For another example, when executing a storage data service sent over a network, the application calls the splice system call 1 provided in the present application in user mode, and the kernel of the operating system switches the CPU from user mode to kernel mode. Then, the kernel of the operating system transmits the data to be sent in the memory buffer (i.e., the read buffer) to pipe 1 with zero copy, and then transmits the data to be sent to the application layer network data processing sandbox program through pipe 1. The kernel of the operating system switches the CPU from kernel mode to user mode again, and feeds back to the application a message indicating that the data to be sent has been transferred to the application layer network data processing sandbox program. The kernel of the operating system packages the data to be sent based on the loaded data processing logic. The kernel of the operating system will package the data to be sent. The application calls the splice system call 2 provided in the present application in user mode. The kernel of the operating system transmits the data to be sent after the packaging process to pipe 2 with zero copy, and then transmits the data to be sent to the socket buffer (i.e., the send buffer) through pipe 2. The kernel of the operating system switches the CPU from kernel mode to user mode again, and feeds back to the application a message indicating that the data to be sent has been transferred to the socket buffer (i.e., the send buffer). Finally, the kernel of the operating system sends the data to be sent in the socket buffer (i.e., the sending buffer) to the network through the network card. Among them, the data processed by the application layer network data processing sandbox program can be transmitted to the socket buffer (i.e., the sending buffer) through pipe 1 in the form of a file descriptor.

[0118] according to Figure 5 The component structure diagram shown in the figure, Figure 6 The invention shows a flow chart of implementing a service of receiving data from a network card and storing the data in a memory.

[0119] 601: The application program loads the corresponding network data parsing and processing logic into the kernel of the operating system.

[0120] It can be understood that the above-mentioned loading operation can be performed by adding a loading interface of the EBPF framework in the kernel of the operating system to load the network data parsing and processing logic of the business corresponding to the running application that receives data from the network card and stores it in the memory into the kernel of the operating system, or the above-mentioned network data parsing and processing logic can be loaded into the kernel of the operating system through a programmable program loader of an electronic device, and no limitation is made here.

[0121] In some embodiments, after the network data parsing and processing logic is loaded into the kernel, the service of receiving data from the network card and storing it in the memory can be bound to the corresponding network data parsing and processing logic through the event binding interface provided by the kernel EBPF framework.

[0122] 602: The application transfers the network data in the socket buffer to the network data parsing processing logic loaded in the kernel through a data processing system call.

[0123] It can be understood that after the user state program passes the data processing system call, the kernel of the operating system switches the CPU to the kernel state. The kernel of the operating system transfers the network data stored in the socket buffer to the network data parsing processing logic loaded in the kernel. For example, the kernel of the operating system can Figure 5 Pipeline 2 in the example transfers the network data to a module loaded in the kernel corresponding to the network data parsing and processing logic, such as the aforementioned sandbox processing module.

[0124] 603: The kernel of the operating system processes the network data based on the loaded network data parsing and processing logic to obtain a processing result.

[0125] It can be understood that the kernel of the operating system processes the data to be saved based on the loaded network data parsing processing logic, and then obtains the processing result of the network data parsing. Then, the kernel of the operating system can switch the CPU from the kernel state to the user state, and feed back a message indicating that the data to be saved has been parsed to the application of the electronic device.

[0126] 604: The application initiates a data write system call to transfer the processed data to be sent to the memory buffer.

[0127] It can be understood that when the data processing is completed, since the CPU does not have the permission to access the hardware when running in the user state, the application needs to call the data write system call to request the CPU to complete privileged operations such as hardware access in the kernel state.

[0128] After receiving a message indicating that data processing has been completed, the application calls a data write system call in user mode, so that the kernel of the operating system can transfer the processed network data to the corresponding memory buffer (i.e., write buffer) through the communication module / interface corresponding to the data write system call, and the kernel of the operating system switches the CPU from kernel mode to user mode, and feeds back a message indicating that the packaged network data has been transferred to the memory buffer to the application of the electronic device.

[0129] 605: The kernel of the operating system writes the data in the memory buffer to the storage.

[0130] Exemplarily, the kernel of the operating system may write the data to be written to the memory stored in the kernel memory buffer into the memory, etc.

[0131] Understandably, according to Figure 5 The component structure diagram shown in the figure, Figure 7The invention shows a flow chart for implementing a service of reading data from a memory and sending the data through a network card.

[0132] 701: The application program loads the network data packaging processing logic into the kernel of the operating system through the kernel loading interface.

[0133] It can be understood that the above-mentioned loading operation can be performed by adding a loading interface of the EBPF framework in the kernel of the operating system to load the network data packaging and processing logic of the service corresponding to the running application that reads data from the memory and sends it through the network card into the kernel of the operating system, or the above-mentioned network data packaging and processing logic can be loaded into the kernel of the operating system through the programmable program loader of the electronic device, and no limitation is made here.

[0134] In some embodiments, after the network data packaging processing logic is loaded into the kernel, the service that reads data from the memory and sends it through the network card can be bound to the corresponding network data parsing processing logic through the event binding interface provided by the kernel EBPF framework.

[0135] 702: The application transfers the to-be-sent data in the storage device to the network data parsing processing logic loaded in the kernel through a data processing system call.

[0136] It is understandable that, since the application cannot directly access the underlying resources of the operating system, when the application needs to execute a service that reads data from the memory and sends it through the network card, it can initiate a call to the kernel of the operating system through the aforementioned data processing system call, requesting the kernel of the operating system to execute the privileged operation (such as the operation of accessing hardware) corresponding to the service that reads data from the memory and sends it through the network card. The kernel of the operating system transmits the data to be sent stored in the storage device to the network data packaging processing logic loaded in the kernel. In some embodiments, the kernel of the operating system can first temporarily store the data to be sent in the storage device in the socket buffer. For example, the kernel of the operating system can Figure 5 Pipeline 1 in the example transfers the data to be sent to the module corresponding to the network data packaging processing logic loaded in the kernel, such as the aforementioned sandbox processing module. The kernel of the operating system then switches the CPU from kernel mode to user mode, and feeds back a message to the application indicating that the data to be sent has been transferred to the network data parsing processing logic.

[0137] 703: The kernel of the operating system processes the data to be sent based on the loaded network data packaging processing logic to obtain a processing result.

[0138] It can be understood that the kernel of the operating system processes the data to be sent based on the loaded network data packaging processing logic, and then obtains the processing result that the data to be sent is packaged. Then, the kernel of the operating system can switch the CPU from the kernel state to the user state, and feed back a message indicating that the data to be sent has been packaged to the application of the electronic device.

[0139] 704: The application initiates a data write system call to transfer the processed data to be sent to the socket buffer.

[0140] It can be understood that after receiving the message indicating that the data processing has been completed, the application calls the data write system call in the user state, so that the kernel of the operating system can transfer the processed data to the corresponding socket buffer (i.e., the send buffer) through the communication module / interface corresponding to the data write system call, and the kernel of the operating system switches the CPU from the kernel state to the user state, and feeds back a message indicating that the packaged data to be saved has been transferred to the socket buffer to the application of the electronic device.

[0141] 705: The kernel of the operating system sends the data to be sent in the socket buffer through the network card.

[0142] Exemplarily, the kernel of the operating system may write the data to be written into the network card and to be sent, which is stored in the socket buffer of the kernel, into the network card and send it out through the network card.

[0143] In some embodiments, based on Figure 5 The component structure diagram shown in the figure, Figure 8 The specific implementation process of network data receiving and storage services is also described in detail. Figure 8 According to an embodiment of the present application, a flowchart for implementing a network data receiving and storing service is provided.

[0144] like Figure 8 As shown, the electronic device sinks the data processing logic (i.e. Figure 8 The user-mode logic in the application program) is loaded into the kernel of the operating system, that is, the data processing logic corresponding to the network data transmission service of the application program is loaded into the kernel of the operating system (such as Figure 8 Step 1 in ). When network data is detected arriving at the socket buffer (such as Figure 8 In step 2), the application can initiate a system call to call the splice system call 1. The kernel of the operating system switches the CPU from user mode to kernel mode and imports the data in the socket buffer into the first pipeline (such as Figure 8Then, the kernel of the operating system transmits the data to the sinking user state logic through the first pipeline, switches the CPU from the kernel state to the user state, and feeds back to the application a message that the network data has been transmitted to the sinking user state logic. The kernel of the operating system processes the data based on the sinking user state logic. After parsing the network data, the kernel of the operating system further transmits the processed data to the second pipeline (such as Figure 8 The application initiates the splice system call 2 in the user state. The kernel of the operating system switches the CPU from the user state to the kernel state again and transfers the data in the second pipe to the memory buffer (such as Figure 8 At this point, the kernel of the operating system switches the CPU from kernel mode to user mode, and sends a message to the application that the network data has been transferred to the memory buffer. Finally, the kernel of the operating system writes the data in the memory buffer to the storage device (e.g. Figure 8 In step 6), the network data receiving and storage service is completed.

[0145] Combination Figure 5 The component structure diagram, Fig. 9 Another implementation flow chart of the network data receiving and storing service is also provided.

[0146] refer to Fig. 9 ,and Figure 8 The difference is that Fig. 9 The electronic device loads the data processing logic corresponding to the network data transmission service of the application program into the kernel of the operating system ( Fig. 9 After step a. sinking the data processing logic), you can also bind events, that is, bind the network data transmission service with the data processing logic ( Fig. 9 Step b in the above. For example, the business event of sending and storing data through the network is bound to the data packaging processing logic, and the business event of receiving and storing network data is bound to the data parsing processing logic, etc. Among them, the above binding events can be based on the event binding interface (not shown in the figure) provided by the programmable framework, and combined with the binding function (such as a hook function) added in the file system (not shown in the figure) and the network protocol stack (not shown in the figure) in the kernel of the operating system to bind the data processing logic to the network data transmission business in the file system or the network protocol stack.

[0147] When network data is detected arriving at the socket buffer ( Fig. 9 In step c), the kernel of the operating system automatically performs data processing operations and transmits the network data to the sinking user state logic through the first pipeline. Then, the kernel of the operating system processes the network data based on the sinking user state logic ( Fig. 9After the data is processed, the kernel of the operating system transmits the data to the memory buffer through the second pipeline, and writes the network data temporarily stored in the memory buffer into the storage device ( Fig. 9 Step e) in step 2).

[0148] In some embodiments, Fig. 9 The method further includes step f, performing callback notification, that is, the kernel of the operating system sends a message to the application in the user space indicating that the application's network data reception and storage service is completed. After receiving the message indicating that the application's network data reception and storage service is completed, the application decides whether to continue to execute the network data reception and storage service processing logic based on the binding event according to the user state logic of the application, or cancel the binding event and no longer continue to execute the network data reception and storage service processing logic based on the binding event.

[0149] The present application embodiment also provides an electronic device 100 for executing the above Figure 2 The data processing method shown. Fig.10 According to an embodiment of the present application, a structural schematic diagram of an electronic device 100 is shown.

[0150] like Fig.10 As shown, the electronic device 100 includes one or more processors 101, a system memory 102, a non-volatile memory (NVM) 103, an input / output (I / O) device 104, a network card 105, and a system control logic 106 for coupling the processor 101, the system memory 102, the non-volatile memory 103, the network card 105 and the input / output (I / O) device 104. Among them:

[0151] The processor 101 may include one or more processing units, for example, a central processing unit CPU (central processing unit), an image processor GPU (graphics processing unit), a digital signal processor DSP (digital signal processor), a microprocessor MCU (micro-programmed control unit), artificial intelligence (artificial intelligence, AI), a processor or a programmable logic device FPGA (fieldprogrammable gate array), a neural network processor (Neural-network Processing Unit, NPU), etc. The data processing unit or processing circuit may include one or more single-core or multi-core processors.

[0152] The system memory 102 is a volatile memory, such as a random-access memory (RAM), a double data rate synchronous dynamic random access memory (DDR SDRAM), etc. The system memory is used to temporarily store data and / or instructions.

[0153] The non-volatile memory 103 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. In some embodiments, the non-volatile memory 103 may include any suitable non-volatile memory such as a flash memory and / or any suitable non-volatile memory, such as a hard disk drive (HDD), a compact disc (CD), a digital versatile disc (DVD), a solid-state drive (SSD), etc. In some embodiments, the non-volatile memory 103 may also be a removable storage medium, such as a secure digital (SD) memory card, etc. For example, the memory mentioned in the present application may be any one of the above-mentioned volatile memory and the non-volatile memory 103.

[0154] In particular, the system memory 102 and the non-volatile memory 103 may respectively include: a temporary copy and a permanent copy of the instruction 107. The instruction 107 may include: when executed by at least one of the processors 101, the electronic device 100 implements the data processing method provided by each embodiment of the present application.

[0155] The network card 105 (network interface card) is a hardware device in the electronic device 100 for connecting to the network, and is mainly used for sending and receiving data packets, configuring and managing network addresses, controlling data flow, etc. The network card 105 can convert transmission data into a format suitable for network transmission, and allow the electronic device 100 to perform network data transmission with other electronic devices. For example, in the embodiment of the present application, when executing the network data receiving and storing service, the network data is received through the network card, or when executing the storage data sending service through the network, the network card sends data to the network.

[0156] The input / output (I / O) device 104 may include input devices such as a keyboard, a mouse, etc., and output devices such as a display, etc. A user may interact with the electronic device 100 via the input / output (I / O) device 104 .

[0157] System control logic 106 may include any suitable interface controller to provide any suitable interface with other modules of electronic device 100. For example, in some embodiments, system control logic 106 may include one or more memory controllers to provide interfaces to system memory 102 and non-volatile memory 103.

[0158] In some embodiments, at least one of the processors 101 may be packaged together with the logic of one or more controllers for the system control logic 106 to form a system in package (SiP). In other embodiments, at least one of the processors 101 may also be integrated with the logic of one or more controllers for the system control logic 106 on the same chip to form a system-on-chip (SOC).

[0159] Understandably, Fig.10 The structure of the electronic device 100 shown is only an example. In other embodiments, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware, which is not limited here.

[0160] An embodiment of the present application also provides a computer program product, including a computer program / instruction, which implements the data processing method provided in the above embodiments when the computer program / instruction is executed by a processor.

[0161] The various embodiments of the mechanism disclosed in the present application can be implemented in hardware, software, firmware or a combination of these implementation methods. The embodiments of the present application can be implemented as a computer module or module code executed on a programmable system, and the programmable system includes at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device and at least one output device.

[0162] The module code may be applied to input instructions to perform the functions described herein and generate output information. The output information may be applied to one or more output devices in a known manner. For purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.

[0163] Module code can be implemented with high-level modular language or object-oriented programming language to communicate with the processing system. When necessary, module code can also be implemented with assembly language or machine language. In fact, the mechanism described in this application is not limited to the scope of any specific programming language. In either case, the language can be a compiled language or an interpreted language.

[0164] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, instructions may be distributed over a network or through other computer-readable media. Therefore, machine-readable media may include any mechanism for storing or transmitting information in a machine (e.g., computer) readable form, including but not limited to floppy disks, optical disks, optical disks, read-only memories (CD-ROMs), magneto-optical disks, read-only memories (ROM), random access memories (RAM), erasable programmable read-only memories (EPROM), electrically erasable programmable read-only memories (EEPROM), magnetic or optical cards, flash memory, or a tangible machine-readable memory for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) using the Internet in electrical, optical, acoustic, or other forms of propagation signals. Accordingly, machine-readable media include any type of machine-readable media suitable for storing or transmitting electronic instructions or information in a form readable by a machine (eg, a computer).

[0165] In the accompanying drawings, some structural or method features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be required. Instead, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of structural or method features in a specific figure does not mean that such features are required in all embodiments, and in some embodiments, these features may not be included or may be combined with other features. Reference to "one embodiment" or "embodiment" in the specification means that the specific features, structures or characteristics described in conjunction with the embodiment are included in at least one exemplary embodiment or technology disclosed according to the embodiment of the present application. The appearance of the phrase "in one embodiment" in various places in the specification does not necessarily all refer to the same embodiment.

[0166] The disclosure of the embodiment of the present application also relates to an operating device for executing the text. The device can be specially constructed for the required purpose or it can include a general-purpose computer selectively activated or reconfigured by a computer program stored in the computer. Such a computer program can be stored in a computer-readable medium, such as, but not limited to any type of disk, including a floppy disk, an optical disk, a CD-ROM, a magneto-optical disk, a read-only memory (ROM), a random access memory (RAM), an EPROM, an EEPROM, a magnetic or optical card, an application-specific integrated circuit (ASIC) or any type of medium suitable for storing electronic instructions, and each can be coupled to a computer system bus. In addition, the computer mentioned in the specification may include a single processor or may be an architecture involving multiple processors for increased computing power.

[0167] It should also be stated that the steps in the methods and processes in the embodiments of the present application are numbered for ease of reference, rather than to limit the order of precedence. If there is an order between the steps, the text description shall prevail.

[0168] In addition, the language used in this specification has been primarily selected for readability and instructional purposes and may not be selected to describe or limit the disclosed subject matter. Therefore, the present application embodiment disclosure is intended to illustrate rather than limit the scope of the concepts discussed herein.

[0169] References to "one embodiment" or "an embodiment" in the specification mean that the specific features, structures, or characteristics described in conjunction with the embodiment are included in at least one exemplary implementation or technology disclosed according to the embodiment of the present application. The appearance of the phrase "in one embodiment" in various places in the specification does not necessarily all refer to the same embodiment.

[0170] The disclosure of the embodiment of the present application also relates to an operating device for executing the text. The device can be specially constructed for the required purpose or it can include a general-purpose computer selectively activated or reconfigured by a computer program stored in the computer. Such a computer program can be stored in a computer-readable medium, such as, but not limited to any type of disk, including a floppy disk, an optical disk, a CD-ROM, a magneto-optical disk, a read-only memory (ROM), a random access memory (RAM), an EPROM, an EEPROM, a magnetic or optical card, an application-specific integrated circuit (ASIC) or any type of medium suitable for storing electronic instructions, and each can be coupled to a computer system bus. In addition, the computer mentioned in the specification may include a single processor or may be an architecture involving multiple processors for increased computing power.

[0171] In addition, the language used in this specification has been primarily selected for readability and instructional purposes and may not be selected to describe or limit the disclosed subject matter. Therefore, the present application embodiment disclosure is intended to illustrate rather than limit the scope of the concepts discussed herein.

Claims

1. A data processing method, characterized in that: The method comprises: A first application running on the electronic device detects that a first service to be executed meets a kernel execution condition, wherein the first service is used to process first data in a first hardware of the electronic device into second data and write the second data into a second hardware of the electronic device; The first application sends a first request corresponding to the first service to the kernel of the operating system of the electronic device; In response to the first request, the kernel obtains the first data in the first hardware and processes the first data into second data; The kernel stores the second data in kernel space; The kernel receives a second request for a first service from the first application, and writes the second data into a data buffer corresponding to the second hardware in response to the second request.

2. The method according to claim 1, characterized in that The first application sends a first request corresponding to the first service to the kernel of the operating system of the electronic device, including: When the processor of the electronic device is in user mode, the first application sends a first request corresponding to the first service to the kernel of the operating system of the electronic device.

3. The method according to claim 1, characterized in that The kernel stores the second data in the kernel space, including: In the case of kernel mode, the kernel stores the second data in kernel space.

4. The method according to claim 3, characterized in that The kernel receives a second request for the first service from the first application, and writes the second data into a data buffer corresponding to the second hardware in response to the second request, including: The first application sends the second request to the kernel when the processor of the electronic device where the first application is located is in user mode; In response to the second request, the kernel switches the processor from the user state to the kernel state, and then writes the second data stored in the kernel space into a data buffer corresponding to the second hardware.

5. The method according to any one of claims 1 to 4, characterized in that The first hardware is a memory or a network card of the electronic device, and the second hardware is a network card or a memory of the electronic device.

6. The method according to claim 5, characterized in that The kernel obtains, in response to the first request, the first data in the first hardware, and processes the first data into second data, including: Corresponding to the first hardware being the memory and the second hardware being the network card, acquiring the first data from the memory and packaging the first data into second data; Corresponding to the first hardware being the network card and the second hardware being the memory, the first data is acquired from the network card, and the first data is parsed to obtain the second data.

7. The method according to claim 5, characterized in that The acquiring the first data in the first hardware includes: Corresponding to the first hardware being the memory and the second hardware being the network card, the kernel reads the first data from the memory and stores the first data in a data buffer corresponding to the memory, and obtains the first data from the data buffer corresponding to the memory; Corresponding to the first hardware being the network card and the second hardware being the memory, the kernel reads the first data from a data buffer corresponding to the network card.

8. The method according to claim 1, characterized in that The method further comprises: Corresponding to the second hardware being a memory, the kernel writes the second data in the data buffer corresponding to the second hardware into the memory; Corresponding to the second hardware being a network card, the kernel writes the second data in the data buffer corresponding to the second hardware into the network card.

9. The method according to claim 1, characterized in that: The processing of the first data into second data comprises: The kernel processes the first data into second data based on a preloaded instruction corresponding to processing the first data into the second data in the first application.

10. The method according to claim 1, characterized in that The first application sends a first request corresponding to the first service to the kernel of the operating system of the electronic device, including: The first application sends a first request corresponding to the first service to the kernel of the operating system of the electronic device based on a first system call corresponding to the first service.

11. The method according to claim 4, characterized in that When the processor of the electronic device where the first application is located is in user mode, sending the second request to the kernel includes: The first application sends a second request corresponding to the first service to the kernel of the operating system of the electronic device based on a second system call corresponding to the first service.

12. The method according to claim 1, characterized in that The kernel execution conditions include: The authority of at least some of the instructions corresponding to the first service is ring3.

13. An electronic device, characterized in that: include: A memory and a processor, wherein the memory is used to store instructions executed by one or more processors of the electronic device, and the processor is one of the one or more processors of the electronic device, and is used to execute the data processing method described in any one of claims 1-12.

14. A readable storage medium, characterized in that: The readable storage medium stores instructions, and when the instructions are executed on an electronic device, the electronic device executes the data processing method according to any one of claims 1 to 12.

Citation Information

Cited By

  • Data processing method, electronic equipment, program product and storage medium

    CN120216208A