CN114077500A - Data processing method, data processing device, computer readable storage medium and processor - Google Patents

Data processing method, data processing device, computer readable storage medium and processor Download PDF

Info

Publication number
CN114077500A
CN114077500A CN202010802238.1A CN202010802238A CN114077500A CN 114077500 A CN114077500 A CN 114077500A CN 202010802238 A CN202010802238 A CN 202010802238A CN 114077500 A CN114077500 A CN 114077500A
Authority
CN
China
Prior art keywords
target application
kernel
request message
memory address
memory
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010802238.1A
Other languages
Chinese (zh)
Inventor
杨文成
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN202010802238.1A priority Critical patent/CN114077500A/en
Publication of CN114077500A publication Critical patent/CN114077500A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/545Interprogram communication where tasks reside in different layers, e.g. user- and kernel-space
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Systems (AREA)

Abstract

The invention discloses a data processing method, a data processing device, a computer readable storage medium and a processor. Wherein, the method comprises the following steps: the method comprises the steps that a kernel sends a first request message to a target application, wherein the kernel and the target application run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory address allocation in a heap of the target application; and the kernel receives a memory address returned by the target application in response to the first request message and provides the memory address to the external equipment, wherein the memory address is used for enabling the external equipment to write data into the memory. The invention solves the technical problem of low efficiency of transmitting the data of the external equipment to the application of the user mode.

Description

Data processing method, data processing device, computer readable storage medium and processor
Technical Field
The present invention relates to the field of data processing, and in particular, to a data processing method, apparatus, computer-readable storage medium, and processor.
Background
Currently, in an operating system, an application accesses an external device, as well as accesses a file, and data of the external device can be read through a read () function, the read () function transmits a user-mode memory and a memory length as function parameters, and the number of bytes actually read is returned. The number of bytes actually read cannot exceed the memory length of the read () function parameter.
However, data of the external device needs to be transferred to the memory of the user mode application at least twice through data copying, wherein once the data of the external device is copied to the kernel memory, and once the data of the external device is copied from the kernel memory to the user memory, so that the efficiency of transferring the data of the external device to the user mode application is low.
In view of the above problems, no effective solution has been proposed.
Disclosure of Invention
Embodiments of the present invention provide a data processing method, an apparatus, a computer-readable storage medium, and a processor, so as to at least solve the technical problem of low efficiency in transferring data of an external device to a user-mode application.
According to an aspect of an embodiment of the present invention, there is provided a data processing method. The method can comprise the following steps: the method comprises the steps that a kernel sends a first request message to a target application, wherein the kernel and the target application run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory address allocation in a heap of the target application; and the kernel receives a memory address returned by the target application in response to the first request message and provides the memory address to the external equipment, wherein the memory address is used for enabling the external equipment to write data into the memory.
According to another aspect of the embodiments of the present invention, another data processing method is also provided. The method can comprise the following steps: the method comprises the steps that a target application obtains a first request message sent by a kernel, wherein the target application and the kernel run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory address allocation in a heap of the target application; and the target application responds to the first request message and returns a memory address to the kernel, wherein the memory address is provided for the external equipment by the kernel, and the memory address is used for enabling the external equipment to write data into the memory.
According to another aspect of the embodiments of the present invention, another data processing method is also provided. The method is applied to external equipment and comprises the following steps: sending a data transfer request to the kernel; receiving a memory address sent by a kernel, wherein the memory address is obtained by the kernel responding to a data transmission request and requesting a target application, the kernel and the target application run in the same operating system, and the target application runs in a user mode; and writing the data into the memory of the external device based on the memory address.
According to another aspect of the embodiments of the present invention, another data processing method is also provided. The method is applied to the current equipment and comprises the following steps: receiving a third request message of the external device through the kernel; responding to the third request message, and requesting to allocate a memory address to the target application through the kernel, wherein the kernel and the target application run in the same operating system, and the target application runs in a user mode; sending the allocated memory address to an external device through the kernel; and receiving data to be written, and writing the data into the memory of the external equipment based on the memory address.
According to another aspect of the embodiments of the present invention, there is also provided an embedded device, including: the system comprises a kernel and a target application, wherein the kernel and the target application run in the same operating system, the kernel is used for sending a first request message to the target application, and the first request message is used for requesting to allocate a memory address in a heap of the target application; and the target application is used for responding to the first request message and returning a memory address to the kernel, wherein the memory address is provided for the external equipment by the kernel, and the memory address is used for enabling the external equipment to write data into the memory.
According to another aspect of the embodiment of the invention, a data processing device is also provided. The apparatus may include: a sending unit, configured to enable a kernel to send a first request message to a target application, where the kernel and the target application run in a same operating system, the target application runs in a user mode, and the first request message is used to request that a memory address is allocated in a heap of the target application; and the receiving unit is used for enabling the kernel to receive the memory address returned by the target application in response to the first request message and provide the memory address for the external equipment, wherein the memory address is used for enabling the external equipment to write the data into the memory.
According to another aspect of the embodiments of the present invention, there is provided another data processing apparatus. The apparatus may include: the device comprises an acquisition unit, a storage unit and a processing unit, wherein the acquisition unit is used for enabling a target application to acquire a first request message sent by a kernel, the target application and the kernel run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory address allocation in a heap of the target application; and the return unit is used for enabling the target application to respond to the first request message and return a memory address to the kernel, wherein the memory address is provided for the external equipment by the kernel, and the memory address is used for enabling the external equipment to write the data into the memory.
According to another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium including a stored program, wherein when the program is executed by a processor, the apparatus on which the computer-readable storage medium is controlled performs the following steps: the method comprises the steps that a kernel is controlled to send a first request message to a target application, wherein the kernel and the target application run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory addresses to be allocated in a heap of the target application; and the control kernel receives a memory address returned by the target application in response to the first request message and provides the memory address to the external equipment, wherein the memory address is used for enabling the external equipment to write data into the memory.
According to another aspect of the embodiments of the present invention, there is also provided a processor configured to execute a program, where the program executes the following steps: the method comprises the steps that a kernel is controlled to send a first request message to a target application, wherein the kernel and the target application run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory addresses to be allocated in a heap of the target application; and the control kernel receives a memory address returned by the target application in response to the first request message and provides the memory address to the external equipment, wherein the memory address is used for enabling the external equipment to write data into the memory.
According to another aspect of the embodiment of the invention, the invention also provides the mobile terminal. The mobile terminal includes: a processor; a memory coupled to the processor for providing instructions to the processor for processing the following processing steps: the method comprises the steps that a kernel is controlled to send a first request message to a target application, wherein the kernel and the target application run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory addresses to be allocated in a heap of the target application; and the control kernel receives a memory address returned by the target application in response to the first request message and provides the memory address to the external equipment, wherein the memory address is used for enabling the external equipment to write data into the memory.
In the embodiment of the invention, a kernel sends a first request message to a target application, wherein the kernel and the target application run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting to allocate a memory address in a heap of the target application; and the kernel receives a memory address returned by the target application in response to the first request message and provides the memory address to the external equipment, wherein the memory address is used for enabling the external equipment to write data into the memory. That is to say, the kernel of the present application requests allocation of a memory address from the heap of the target application in the user state, and after obtaining the allocated memory address, the external device can directly write data into the memory address allocated from the heap of the target application in the user state, so that only one memory copy is required, thereby avoiding that the data of the external device is transferred to the memory of the target application in the user state, and at least two data copies are required, saving a CPU clock, achieving a technical effect of improving efficiency of transferring the data of the external device to the application in the user state, and solving a technical problem of low efficiency of transferring the data of the external device to the application in the user state.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
fig. 1 is a block diagram of a hardware structure of a computer terminal (or mobile device) for implementing a data processing method according to an embodiment of the present invention;
FIG. 2 is a flow chart of a method of data processing according to an embodiment of the present invention;
FIG. 3 is a flow diagram of another data processing method according to an embodiment of the invention;
FIG. 4 is a schematic diagram of an embedded device according to an embodiment of the present invention;
FIG. 5 is a diagram illustrating a pair of buffer queues according to an embodiment of the present invention;
FIG. 6 is a flowchart of a method for a kernel to request allocation of memory from an application heap in a user state, according to an embodiment of the present invention;
FIG. 7 is a flowchart of a method for a kernel to request memory release from an application heap in a user state according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of a data processing method according to an embodiment of the present invention;
FIG. 9 is a schematic diagram of a data processing apparatus according to an embodiment of the present invention;
FIG. 10 is a schematic diagram of another data processing apparatus according to an embodiment of the present invention; and
fig. 11 is a block diagram of a computer terminal according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
First, some terms or terms appearing in the description of the embodiments of the present application are applicable to the following explanations:
a user mode, which is a calling method relative to the kernel mode, in the user mode, a Central Processing Unit (CPU) has a lower authority, and executes an application program of a user in the mode;
the kernel state, the kernel of the operating system runs in the kernel state, at this moment, the CPU has higher authority;
the heap is used for managing the allocation and the recovery of the memory in an operating system;
the data synchronization method comprises the steps of a cache queue (buf queue), a queue mechanism in an operating system, and is used for achieving data synchronization between a producer and a consumer, wherein the buf queue can only carry out one-way data transmission, the producer writes data to be transmitted into the buf queue, the consumer reads data from the buf queue, and if the buf queue is empty, the consumer can block a plurality of times or permanently block waiting until the waiting time is up or the producer writes data into the buf queue.
Example 1
There is also provided, in accordance with an embodiment of the present invention, an embodiment of a data processing method, to note that the steps illustrated in the flowchart of the figure may be performed in a computer system such as a set of computer-executable instructions, and that, although a logical order is illustrated in the flowchart, in some cases, the steps illustrated or described may be performed in an order different than here.
The method provided by the first embodiment of the present application may be executed in a mobile terminal, a computer terminal, or a similar computing device. Fig. 1 is a block diagram of a hardware structure of a computer terminal (or mobile device) for implementing a data processing method according to an embodiment of the present invention. As shown in fig. 1, the computer terminal 10 (or mobile device 10) may include one or more (shown as 102a, 102b, … …, 102 n) processors 102 (the processors 102 may include, but are not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. Besides, the method can also comprise the following steps: a display, an input/output interface (I/O interface), a Universal Serial Bus (USB) port (which may be included as one of the ports of the I/O interface), a network interface, a power source, and/or a camera. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration and is not intended to limit the structure of the electronic device. For example, the computer terminal 10 may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
It should be noted that the one or more processors 102 and/or other data processing circuitry described above may be referred to generally herein as "data processing circuitry". The data processing circuitry may be embodied in whole or in part in software, hardware, firmware, or any combination thereof. Further, the data processing circuit may be a single stand-alone processing module, or incorporated in whole or in part into any of the other elements in the computer terminal 10 (or mobile device). As referred to in the embodiments of the application, the data processing circuit acts as a processor control (e.g. selection of a variable resistance termination path connected to the interface).
The memory 104 may be used to store software programs and modules of application software, such as program instructions/data storage devices corresponding to the data processing method in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by executing the software programs and modules stored in the memory 104, that is, implementing the data processing method of the application program. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network adapter (NIC) that can be connected to other Network devices through a base station to communicate with the internet. In one example, the transmission device 106 can be a Radio Frequency (RF) module, which is used to communicate with the internet in a wireless manner.
The display may be, for example, a touch screen type Liquid Crystal Display (LCD) that may enable a user to interact with a user interface of the computer terminal 10 (or mobile device).
It should be noted here that in some alternative embodiments, the computer device (or mobile device) shown in fig. 1 described above may include hardware elements (including circuitry), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware and software elements. It should be noted that fig. 1 is only one example of a particular specific example and is intended to illustrate the types of components that may be present in the computer device (or mobile device) described above.
In the operating environment shown in fig. 1, the present application provides a data processing method as shown in fig. 2. It should be noted that the data processing method of this embodiment is executed by the mobile terminal of the embodiment shown in fig. 1.
Fig. 2 is a flow chart of a data processing method according to an embodiment of the present invention. As shown in fig. 2, the method may include the steps of:
in step S202, the kernel sends a first request message to the target application.
In the technical solution provided by step S202 of the present invention, the kernel and the target application run in the same operating system, the target application runs in a user mode, and the first request message is used to request that a memory address is allocated in the heap of the target application.
In this embodiment, the kernel of the operating system may run in kernel mode, where the CPU has higher permissions. The kernel and the target application of this embodiment run in the same operating system, which may be an embedded operating system, for example, a linux operating system, whose kernel state is separated from the user state, and the target application runs in the user state, which is a calling name relative to the kernel state, in which the CPU has a lower authority, and executes a program of the target application corresponding to the user in this mode. The target application may be referred to as a user-mode application, among others.
In this embodiment, the kernel sends a first request message to the target application, where the first request message is used to request the target application to allocate memory, i.e., allocate a memory address, in a heap of the target application, where the heap is used to manage allocation and reclamation of memory in the operating system.
In step S204, the kernel receives a memory address returned by the target application in response to the first request message, and provides the memory address to the external device, where the memory address is used for enabling the external device to write data into the memory.
In the technical solution provided in step S204 of the present invention, after the kernel sends the first request message to the target application, the kernel receives the memory address returned by the target application in response to the first request message, and provides the memory address to the external device, so that the external device can write the data into the memory of the external device.
In the programming of the operating system, the external device may be set in a kernel mode and the target application may be set in a user mode. When the external device is ready for data, the data needs to be transferred to the target application in the user state. Since the target application cannot directly access the memory of the external device in the kernel mode, the data of the external device needs to be copied into the memory of the target application in the user mode.
In this embodiment, the kernel may receive the message that the target application parses the first request message, allocate the memory address requested by the kernel from the heap, and the kernel may obtain the message obtained by encapsulating the memory address by the target application, and then obtain the memory address from the message, so that the external device may directly write the data thereof into the memory corresponding to the memory address allocated from the heap, or directly copy the data from the external device into the allocated memory by the kernel, where the external device may be referred to as a peripheral device and may include a peripheral driver, and write the data into the memory allocated from the heap through the peripheral driver, thereby achieving the purpose that the external device directly writes the data into the memory allocated from the target application in the user mode.
In the related art, data of the external device is transferred to the memory of the application in the user mode, and at least two data copies are performed, one for copying the data of the external device to the kernel memory, and one for copying the data from the kernel memory to the user memory.
Through the above steps S202 to S204 in the present application, the kernel sends a first request message to the target application, where the kernel and the target application run in the same operating system, the target application runs in a user mode, and the first request message is used to request allocation of a memory address in a heap of the target application; and the kernel receives a memory address returned by the target application in response to the first request message and provides the memory address to the external equipment, wherein the memory address is used for enabling the external equipment to write data into the memory. That is to say, the kernel in this embodiment requests to allocate a memory address from the heap of the target application in the user state first, and after obtaining the allocated memory address, the external device can directly write data into the memory address allocated from the heap of the target application in the user state, so that only one memory copy is required, which avoids that the data of the external device is transferred to the memory of the target application in the user state and at least two data copies are required, thereby saving a CPU clock, achieving a technical effect of improving efficiency of transferring the data of the external device to the application in the user state, and solving a technical problem of low efficiency of transferring the data of the external device to the application in the user state.
The above-described method of this embodiment is further described below.
As an optional implementation manner, after the kernel receives, in step S204, a memory address returned by the target application in response to the first request message, the method further includes: and the kernel sends a second request message to the target application, wherein the second request message is used for requesting to release the memory address to the heap of the target application.
In this embodiment, the kernel may further send a second request message to the target application, where the second request message may release the memory address from the heap of the target application in the user mode to the heap, that is, the kernel of this embodiment may request to release the memory from the heap of the target application in the user mode in addition to requesting to allocate the memory from the heap of the target application in the user mode.
As an optional implementation, the kernel sends the second request message to the target application, including: the kernel packages the memory address requested to be released into a second request message, and writes the second request message into the first cache queue; and the kernel sends a second request message to the target application through the first cache queue.
In this embodiment, a buffer queue (buf queue) is a queue mechanism in an operating system, and can be used for the purpose of synchronizing data between a producer and a consumer. In this embodiment, when the kernel sends the second request message to the target application, the kernel may first determine a memory address to be released, then encapsulate the memory address to be released as the second request message, and write the second request message into a first cache Queue (QA) provided by the kernel, where the second request message may be written into the first cache queue by a kernel task, and thus the kernel sends the second request message to the target application through the first cache queue, so that the target application responds to the second request message and releases the memory address in the second request message into a heap of the target application in a user state.
As an alternative embodiment, in step S202, the kernel sends a first request message to the target application, including: the kernel packages the memory address requested to be allocated into a first request message, and writes the first request message into a first cache queue; the kernel sends a first request message to the target application through the first cache queue.
In this embodiment, when the core sends the first request message to the target application, the core may determine a memory address to be allocated, encapsulate the memory address to be allocated as the first request message, and write the first request message into a first cache Queue (QA) provided by the core, where the first cache queue is used for the core to send a message to the target application in the user state, and thus the core sends the first request message to the target application through the first cache queue, so that the target application allocates the requested memory address from a heap of the target application in the user state in response to the first request message.
As an optional implementation manner, in step S202, the receiving, by the kernel, the memory address returned by the target application in response to the first request message includes: and the kernel receives the memory address returned by the target application through the second cache queue, wherein the memory address is written into the second cache queue by the target application.
In this embodiment, in addition to the first cache queue, the core may further provide a second cache Queue (QB), where the second cache queue is configured to send a message to the core by the target application in the user state, that is, the embodiment uses two unidirectional cache queues for the core to deliver the message to the target application in the user state and the target application in the user state to deliver the message to the core respectively. In this embodiment, when the kernel receives the memory address returned by the target application in response to the first request message, the kernel may receive the memory address returned by the target application through the second cache queue.
Optionally, the target application of this embodiment writes the obtained message of the memory address into the second cache queue, and then wakes up the kernel task, where the kernel task may block the message waiting in the second cache queue, and parse the message in the second cache queue, so as to obtain the allocated memory address.
In this embodiment, after the kernel writes a first request message for requesting allocation of a memory or a second request message for requesting release of the memory into the first cache queue, a target task (taskA) in a target application in a user mode receives the first request message or the second request message, and then parses the first request message or the second request message. For a first request message requesting to allocate memory, the kernel program may, after writing a message requesting the memory size into the first cache queue, then block and wait on the second cache queue, waiting for a message of the allocated memory address to be returned by the target application in the user state.
As an optional implementation manner, before the kernel sends the first request message to the target application in step S202, the method further includes: the method comprises the following steps that a kernel obtains the data length of data from external equipment; the kernel determines a storage space corresponding to the memory address based on the data length, wherein the first request message is used for requesting allocation of the memory address with the storage space in the heap of the target application.
In this embodiment, for variable data length external devices, the data length that the external device needs to transmit to the target application may change each time. Therefore, only after the external device prepares the data, the kernel obtains the data length, then allocates the memory with the required size from the heap of the target application in the user mode, and finally copies the data from the external device to the allocated memory.
In the related art, when an application program of a target application calls a read () function, how much data of an external device needs to be transferred cannot be predicted, and the read () function copies only byte data not exceeding the memory length at most even if the external device has more data to be transferred. In this embodiment, the kernel may first obtain the data length of the data to be transmitted from the external device at the beginning of requesting to allocate the memory from the heap of the target application in the user state, and determine the storage space corresponding to the memory address based on the data length, that is, determine the size of the memory to be requested, so as to request, through the first request message, to allocate the memory address having the storage space in the heap of the target application, thereby achieving the purpose that the kernel may request to allocate the memory of the specified size from the heap of the target application in the user state.
The data processing method according to the embodiment of the present invention will be described below from the target application side.
Fig. 3 is a flow chart of another data processing method according to an embodiment of the present invention. As shown in fig. 3, the method may include the steps of:
step S302, the target application acquires a first request message sent by the kernel.
In the technical solution provided in step S302 of the present invention, the target application and the kernel run in the same operating system, the target application runs in a user mode, and the first request message is used to request that a memory address is allocated in the heap of the target application.
In this embodiment, the kernel and the target application run in the same operating system, which may be an embedded operating system, and the kernel mode and the user mode of the embedded operating system are separated, and the target application runs in the user mode, so that the target application may be referred to as a user mode application.
In this embodiment, the target application obtains a first request message sent by the kernel, where the first request message is used to request the target application to allocate memory in the heap of the target application, that is, allocate a memory address.
Step S304, the target application returns a memory address to the kernel in response to the first request message, where the memory address is provided to the external device by the kernel, and the memory address is used for writing data of the external device.
In the technical solution provided in step S304 of the present invention, after the target application acquires the first request message sent by the kernel, the target application returns a memory address to the kernel in response to the first request message, and the memory address is further provided to the external device by the kernel, so that the external device can write data into the memory.
In this embodiment, the target application may parse the received first request message, allocate a memory address requested by the kernel from the heap, encapsulate the memory address to obtain a message, and then send the message to the kernel, so that the kernel may obtain the memory address from the message, and thus the external device may directly write the data thereof into the memory allocated from the heap, or write the data into the memory allocated from the heap through the peripheral driver, thereby achieving a purpose that the external device directly writes the data into the memory allocated from the user-mode target application.
In the related art, data of the external device is transferred to the memory of the application in the user mode, and at least two data copies are performed, one for copying the data of the external device to the kernel memory, and one for copying the data from the kernel memory to the user memory.
Through the steps S302 to S304 in the present application, the target application obtains a first request message sent by the kernel, where the target application and the kernel operate in the same operating system, the target application operates in a user mode, and the first request message is used to request allocation of a memory address in a heap of the target application; and the target application responds to the first request message and returns a memory address to the kernel, wherein the memory address is provided for the external equipment by the kernel, and the memory address is used for enabling the external equipment to write data into the memory. That is to say, in the embodiment, a memory address is requested to be allocated in the heap of the target application in the user state, and the external device can directly write data into the memory address allocated in the heap of the target application in the user state, so that only one memory copy is required, the data of the external device is prevented from being transmitted to the memory of the target application in the user state and at least two data copies are required, a CPU clock is saved, the technical effect of improving the efficiency of transmitting the data of the external device to the application in the user state is achieved, and the technical problem of low efficiency of transmitting the data of the external device to the application in the user state is solved.
The above-described method of this embodiment is further described below.
As an optional implementation manner, in step S304, after the target application returns the memory address to the kernel in response to the first request message, the method further includes: the target application acquires a second request message sent by the kernel, wherein the second request message is used for requesting to release the allocated memory address; and the target application responds to the second request message and releases the memory address to the heap of the target application through the target task.
In this embodiment, the target application may further obtain a second request message sent by the kernel, where the second request message may release the memory address in the heap from the target application in the user mode to the heap. Optionally, the target task in the target application of this embodiment blocks and waits for the second request message in the first cache Queue (QA), and may parse the second request message, and release the memory address in the second request message to the heap of the target application through the target task. The target task may also be referred to as a user-mode task, and is configured to permanently block a first cache queue waiting for a core to send a message to the target application in the user mode, and to receive a message sent by the core to the target application in the user mode, so that the core in this embodiment may request, in addition to requesting allocation of memory to a heap of the target application in the user mode, to release memory to the heap of the target application in the user mode.
As an optional implementation manner, the acquiring, by the target application, the second request message sent by the kernel includes: and the target application acquires a second request message sent by the kernel through the first cache queue.
In this embodiment, when the target application acquires the second request message sent by the kernel, the memory address to be released may be encapsulated by the kernel as the second request message, and the second request message is written into the first cache queue provided by the kernel, and at this time, the target task of the target application is woken up, so that the target application acquires the second request message sent by the kernel through the first cache queue, and the target application may receive the second request message through the target task and release the memory address in the second request message to the heap of the target application in the user state.
As an optional implementation manner, in step S302, the obtaining, by the target application, the first request message sent by the kernel includes: the target application acquires a first request message sent by a kernel through a first cache queue.
In this embodiment, when the target application acquires the first request message sent by the kernel, the memory address to be allocated may be encapsulated as the first request message by the kernel, and the first request message is written into the first cache queue provided by the kernel, and the target task of the target application is woken up at the same time, so that the kernel target application acquires the first request message sent by the kernel through the first cache queue, and after receiving the first request message, the target task of the target application may parse the first request message, and allocate the requested memory address from the heap of the target application in the user state.
As an optional implementation manner, in step S304, the returning, by the target application, the memory address to the kernel in response to the first request message includes: the target application writes the memory address into a second cache queue through the target task; and the target application sends the memory address to the kernel through the second cache queue.
In this embodiment, in addition to the first cache queue, the core may provide a second cache Queue (QB) for a target application in a user state to send messages to the core. In this embodiment, when the target application returns a memory address to the core in response to the first request message, the target application may write the memory address requested to be allocated into the second cache queue, and then send the allocated memory address to the core through the second cache queue.
Optionally, the target application in the user mode in this embodiment receives the first request message from the first cache queue, requests to allocate a memory address from the heap of the target application in the user mode, encapsulates the memory address into a message, writes the message into the second cache queue, and the kernel receives a message returned by the target application through the second cache queue, and obtains the memory address allocated from the heap of the target application in the user mode through the message.
In this embodiment, a dedicated target task is used in the user-mode target application for the kernel to allocate memory from the user-mode heap or to release memory to the user-mode heap. After the kernel writes a first request message for requesting to allocate the memory or a second request message for requesting to release the memory into the first cache queue, a target task (taskA) in a target application in a user mode receives the first request message or the second request message, and then analyzes the first request message or the second request message. For a first request message requesting to allocate memory, the kernel program may, after writing a message requesting the memory size into the first cache queue, then block and wait on the second cache queue, waiting for a message of the allocated memory address to be returned by the target application in the user state.
In this embodiment, when a target task receives a request message from a kernel requesting to allocate memory, the target task allocates memory of a request size from a user-mode heap, and transmits an allocated memory address as a message to the kernel through a second cache queue; when the target task receives the request message from the kernel to request to release the memory, the target task releases the memory address to be released requested by the kernel to the user-mode heap.
The embodiment of the invention also provides another data processing method applied to the external equipment. The method can comprise the following steps: sending a data transfer request to the kernel; receiving a memory address sent by a kernel, wherein the memory address is obtained by the kernel responding to a data transmission request and requesting a target application, the kernel and the target application run in the same operating system, and the target application runs in a user mode; and writing the data into the memory of the external device based on the memory address.
In this embodiment, the external device may send a data transfer request to the kernel, which may be used to request the kernel to transfer data. Optionally, the external device of this embodiment receives a memory address obtained by requesting the target application from the kernel in response to the data transfer request, where the kernel of the operating system may run in a kernel mode, and the CPU has a higher authority at this time. The kernel and the target application of the embodiment run in the same operating system, which may be an embedded operating system, and the target application runs in a user mode in which a program of the target application corresponding to a user is executed.
In this embodiment, the external device may receive a memory address allocated in a heap requested by the kernel to the target application, where the heap is used to manage allocation and recovery of memory in the operating system, and the kernel may obtain a message obtained by encapsulating the memory address by the target application, then obtain the memory address from the message, and provide the memory address to the external device, so that the external device may directly write data into a memory corresponding to the memory address allocated in the heap, or directly copy the data into the allocated memory. Optionally, the external device of this embodiment may include a peripheral driver, and data is written into the memory allocated from the heap by the peripheral driver, so that the purpose that the external device directly writes data into the memory allocated from the target application in the user state is achieved, data transfer from the external device to the memory of the target application in the user state is avoided, data copy is performed at least twice, a CPU clock is saved, a technical effect of improving efficiency of transferring data from the external device to the application in the user state is achieved, and a technical problem of low efficiency of transferring data from the external device to the application in the user state is solved.
The embodiment of the invention also provides another data processing method applied to the current equipment. The method can comprise the following steps: receiving a third request message of the external device through the kernel; responding to the third request message, and requesting to allocate a memory address to the target application through the kernel, wherein the kernel and the target application run in the same operating system, and the target application runs in a user mode; sending the allocated memory address to an external device through the kernel; and receiving data to be written, and writing the data into the memory of the external equipment based on the memory address.
In this embodiment, the current device may receive, through the kernel, a third request message of the external device, where the third request message is used to request allocation of a memory address. After the current device receives the third request message, the current device may request, in response to the third request message, to allocate a memory address to the target application through the kernel, where the kernel of the operating system may run in a kernel mode, and at this time, the CPU has a higher authority. The kernel and the target application of the embodiment run in the same operating system, which may be an embedded operating system, and the target application runs in a user mode in which a program of the target application corresponding to a user is executed.
Optionally, the current device of this embodiment requests the target application to allocate a memory address through the kernel, which may be a memory address allocated in a heap when the current device requests the target application through the kernel, where the heap is used to manage allocation and reclamation of memory in the operating system. Optionally, the current device of this embodiment obtains, by the kernel, a message obtained by encapsulating the memory address by the target application, and then obtains, by the kernel, the memory address from the message, so that the current device receives the data to be written in, and can send the data to the external device, and the external device can directly write the data in the memory corresponding to the memory address allocated from the heap, and can directly copy the data into the allocated memory, thereby avoiding that the data of the external device is transferred to the memory of the target application in the user state, and at least two data copies are performed, saving the CPU clock, achieving the technical effect of improving the efficiency of transferring the data of the external device to the application in the user state, and solving the technical problem of low efficiency of transferring the data of the external device to the application in the user state.
The kernel of the embodiment requests to allocate the memory from the heap of the target application in the user state, and after obtaining the allocated memory address, the external device can directly write the data into the memory corresponding to the memory address allocated from the heap of the target application in the user state, so that the data of the external device can be transmitted to the target application in the user state only by one-time memory copy, thereby saving a CPU clock, improving the data processing efficiency, realizing that the kernel can request to allocate the memory with a specified size from the heap of the target application in the user state, and further realizing the purpose of releasing the memory address from the heap of the user state application into the user state heap; in addition, the kernel of this embodiment can obtain the data length of the secondary transmission from the peripheral device at the beginning of requesting to allocate the memory from the user mode application heap, that is, obtain the size of the memory to be requested, thereby avoiding the problem that how much data of the peripheral device needs to be transmitted cannot be predicted.
Example 2
The embodiment of the invention also provides embedded equipment which comprises the kernel and the target application, wherein the kernel and the target application run in the same operating system. It should be noted that the embedded device of this embodiment may be used to execute the data processing method of this embodiment of the present invention.
Fig. 4 is a schematic diagram of an embedded device according to an embodiment of the present invention. As shown in fig. 4, the embedded device 40 may include: a kernel 41 and a target application 42.
The kernel 41 is configured to send a first request message to the target application 42, where the first request message is used to request that a memory address is allocated in the heap of the target application 42.
In this embodiment, the kernel 41 of the operating system may run in kernel mode, where the CPU has higher authority. The kernel 41 and the target application 42 of this embodiment run in the same operating system, which may be an embedded operating system, and the kernel mode and the user mode of the operating system are separated, and the target application 42 runs in the user mode, which is a calling method with respect to the kernel mode, in which the CPU has a lower authority, and executes a program of the target application 42 corresponding to a user. The target application 42 may be referred to herein as a user-mode application.
In this embodiment, the kernel 41 sends a first request message to the target application 42, the first request message being used to request the target application 42 to allocate memory in the heap of the target application 42, i.e. to allocate a memory address.
And the target application 42 is used for responding to the first request message and returning a memory address to the kernel 41, wherein the memory address is provided for the external device by the kernel, and the memory address is used for enabling the external device to write data into the memory.
In this embodiment, the target application 42 may parse the received first request message, allocate a memory address requested by the kernel 41 from the heap, encapsulate the memory address to obtain a message, and then send the message to the kernel 41, where the kernel 41 may obtain the memory address from the message, so that the external device may directly write its data into the memory allocated from the heap, or write the data into the memory allocated from the heap through a peripheral driver, thereby achieving a purpose that the external device directly writes the data into the memory allocated from the target application 42 in a user state.
In the related art, data of the external device is transferred to the memory of the application in the user mode, and at least two data copies are performed, one for copying the data of the external device to the kernel memory, and one for copying the data from the kernel memory to the user memory.
The application can be applied to an embedded device running an operating system with a kernel mode and a user mode separated, wherein the kernel of the operating system needs to allocate the memory or release the memory from a heap running in the user mode application program. In the embodiment, the memory address is requested to be allocated in the heap of the target application in the user state, and the external device can directly write the data into the memory address allocated in the heap of the target application in the user state, so that only one memory copy is needed, the data of the external device is prevented from being transmitted to the memory of the target application in the user state and at least two data copies are needed, the CPU clock is saved, the technical effect of improving the efficiency of transmitting the data of the external device to the application in the user state is achieved, and the technical problem of low efficiency of transmitting the data of the external device to the application in the user state is solved.
Example 3
The above data processing method according to the embodiment of the present invention is further described below with reference to preferred embodiments.
In the linux operating system, an external device can register a device driver in a kernel, an application program accesses the device and can read data of the external device through a read () function as well as an access file, the read () function transmits a user-state memory and a memory length as function parameters, and the number of bytes actually read is returned. The number of bytes actually read cannot exceed the memory length of the read () function parameter.
For the linux operating system, data of the external device is transferred to the memory of the application in the user mode, and at least two times of data copying are performed, wherein one time is to copy the data of the external device to the memory of the kernel, and the other time is to copy the data from the memory of the kernel to the memory of the application in the user mode; in addition, when the application program calls the read () function, how much data of the external device needs to be transmitted cannot be predicted, and the read () function can only copy data which does not exceed the length of the memory at most, even though more data need to be transmitted.
In view of the foregoing problems, the embodiment provides a method for allocating memory and releasing memory from a heap of an application in a user mode by a kernel, which can be applied to an embedded device running an operating system with a kernel mode and a user mode separated from each other, where the kernel of the operating system needs to allocate memory or release memory from the heap running the application in the user mode. The above-described method of this embodiment is further described below.
In this embodiment, the kernel provides a pair of buffer queues (buf _ queue), one for sending messages to the application in user mode, which may be denoted as QA; another example for sending a message to the kernel by the application in the user state, which may be denoted as QB, is shown in fig. 5, where fig. 5 is a schematic diagram of a pair of cache queues according to an embodiment of the present invention, where this embodiment uses two unidirectional cache queues for respectively delivering a message to the application in the user state by the kernel and delivering a message to the kernel by the application in the user state, and the application in the user state has a special task, denoted as taskA, for permanently blocking QA waiting for sending a message to the application in the user state by the kernel to receive the message in the user state sent by the kernel. When the kernel writes a request message requesting to allocate the memory or release the memory into the QA, the taskA in the application in the user mode receives the message and then parses the message. For the request message of requesting to allocate the memory, the kernel writes the request message of requesting the memory into QA, then blocks and waits on QB, and waits for the application in the user mode to return the allocated memory address message.
FIG. 6 is a flowchart of a method for a kernel to request allocation of memory from an application heap in a user state according to an embodiment of the present invention. As shown in fig. 6, the method may include the steps of:
step S601, the kernel writes the message of the requested memory length into QA.
After the kernel writes the requested memory length message into QA, the taskA of the application is woken up.
Step S602, tasKA blocks waiting for messages in QA.
Step S603, parsing the message in QA, and allocating the requested memory length memory from the heap.
Step S604, the message of the allocated memory address is written into the QB.
After the message of the allocated memory address is written into the QB, the kernel task is awakened, and the step SS602 may be further executed, and the taskA blocks the message waiting for the QA.
In step S605, the kernel task blocks messages waiting in QB.
Step S606, analyzing the message in QB to obtain the distributed memory address.
In this embodiment, the application in the user mode receives the message from the QA, allocates a memory with a requested memory size from the heap of the application in the user mode, encapsulates the address of the memory into a message, writes the message into the QB, and the kernel obtains the message and further obtains the memory address allocated from the heap of the application in the user mode, so that the external device can directly write data into the memory allocated from the heap of the application in the user mode.
Fig. 7 is a flowchart of a method for requesting memory release from an application heap in a user mode by a kernel according to an embodiment of the present invention. As shown in fig. 7, the method may include the steps of:
step S701, the kernel task writes the message of the memory address into QA.
After the kernel task writes the message of the memory address into QA, the taskA of the application is woken up.
Step S702, tasKA blocks waiting for messages in QA.
Step S703, the tasKA analyzes the message in the QA and releases the memory address in the message to the heap.
Step S702 can also be executed after the taskA parses the message in QA and releases the memory address therein to the heap, and the taskA blocks the message waiting in QA.
In this embodiment, after writing a message requesting to release the memory into QA, the kernel encapsulates the memory address to be released into the heap of the user-mode application into a message and writes the message into QA, and after receiving the message, the user-mode task taskA releases the memory address in the message into the heap of the user-mode application.
In this embodiment, the kernel requests allocation of the memory from the heap of the user mode application, and after obtaining the allocated memory, the external device directly writes the data into the memory allocated from the heap of the user mode application. Therefore, the data of the external equipment can be transmitted to the user mode application only by once memory copy, thereby saving a CPU clock and improving the efficiency.
The user-mode application of this embodiment uses a special task (taskA) to serve the kernel to allocate memory from the user-mode heap or to release memory to the user-mode heap. When the type of the request message received by the task from the kernel is the type of the request for allocating the memory, the task allocates the memory with the request size from the heap in the user state, and transmits the allocated memory address as a message to the kernel through the QB; when the type of the request message received by the task from the kernel is the type of releasing the memory, the task releases the memory address to be released requested by the kernel to the heap in the user mode.
Fig. 8 is a schematic view of a data processing method according to an embodiment of the present invention. As shown in fig. 8, the data processing method is executed by the current device 81, the kernel 82, the target application 83 and the external device 84, and involves the following flow implementation:
in step S801, the external device 84 transmits a third request message for requesting allocation of a memory address to the core 82.
In step S802, the core 82 transmits a third request message to the current device 81.
In this embodiment, the current device 81 may receive a third request message of the external device 84 through the kernel 82 to request allocation of a memory address.
In step S803, the current device 81 responds to the third request message to request the target application 83 to allocate a memory address through the kernel 82.
In this embodiment, the kernel 82 and the target application 83 run in the same operating system a, and the target application 83 runs in a user mode.
After the current device 81 receives the third request message, it may respond to the third request message to request allocation of a memory address to the target application 83 through the kernel 82.
In step S804, the kernel 82 sends a first request message to the target application 83.
This embodiment may be implemented when the current device 81 requests the target application 83 to allocate a memory address through the kernel 82, where the kernel 82 sends a first request message to the target application 83, and the first request message may be a request for allocating a memory address in a heap of the target application 83.
In step S805, the target application 83 returns a memory address to the kernel 82 in response to the first request message.
The target application 83 may parse the received first request message, allocate a memory address requested by the kernel 82 from the heap, encapsulate the memory address to obtain a message, and then send the message to the kernel 82, so that the kernel 82 may obtain the memory address from the message.
In step S806, the core 82 provides the received memory address to the external device 84.
The kernel 82 receives the memory address returned by the target application 83 in response to the first request message and provides it to the external device 84.
In step S807, the external device 84 writes data into the memory of the external device 84 based on the memory address.
The external device 84 may directly write the data to the memory corresponding to the memory address allocated from the heap, or may directly copy the data to the allocated memory. Optionally, the external device 84 of this embodiment may include a peripheral driver, and data is written into the memory allocated from the heap through the peripheral driver, so that the purpose that the external device 84 directly writes data into the memory allocated from the target application in the user state is achieved, data transfer from the external device 84 to the memory of the target application in the user state is avoided, data copy is performed at least twice, a CPU clock is saved, a technical effect of improving efficiency of transferring data from the external device 84 to the application in the user state is achieved, and a technical problem of low efficiency of transferring data from the external device 84 to the application in the user state is solved.
The kernel of the embodiment requests to allocate the memory from the heap of the application in the user state, after obtaining the allocated memory address, the external device can directly write the data into the memory corresponding to the memory address allocated from the heap of the application in the user state, so that the data of the external device can be transmitted to the application in the user state only by once memory copy, the CPU clock is saved, the data processing efficiency is improved, the kernel can request to allocate the memory with the specified size from the heap of the application in the user state, and the purpose of releasing the memory address from the heap of the application in the user state into the heap in the user state can be realized; in addition, the kernel of this embodiment can obtain the data length of the secondary transmission from the peripheral device at the beginning of requesting to allocate the memory from the user mode application heap, that is, obtain the size of the memory to be requested, thereby avoiding the problem that how much data of the peripheral device needs to be transmitted cannot be predicted.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
Example 4
According to the embodiment of the invention, the data processing device for implementing the data processing method is also provided. It should be noted that the data processing apparatus of this embodiment can be used to execute the data processing method shown in fig. 2 according to the embodiment of the present invention.
Fig. 9 is a schematic diagram of a data processing apparatus according to an embodiment of the present invention. As shown in fig. 9, the data processing apparatus 90 may include: a transmitting unit 91 and a receiving unit 92.
A sending unit 91, configured to enable a kernel to send a first request message to a target application, where the kernel and the target application run in the same operating system, the target application runs in a user mode, and the first request message is used to request that a memory address is allocated in a heap of the target application.
The receiving unit 92 is configured to enable the kernel to receive a memory address returned by the target application in response to the first request message, and provide the memory address to the external device, where the memory address is used to enable the external device to write data into the memory.
It should be noted here that the above-mentioned sending unit 91 and receiving unit 9 correspond to steps S202 to S204 in embodiment 1, and the two units are the same as the example and application scenarios realized by the corresponding steps, but are not limited to the disclosure of the above-mentioned embodiment one. It should be noted that the modules described above as part of the apparatus may be run in the computer terminal 10 provided in the first embodiment.
According to an embodiment of the present invention, there is provided another data processing apparatus for implementing the data processing method. It should be noted that the data processing apparatus of this embodiment can be used to execute the data processing method shown in fig. 3 according to the embodiment of the present invention.
FIG. 10 is a schematic diagram of another data processing apparatus according to an embodiment of the present invention. As shown in fig. 10, the data processing apparatus 100 may include: an acquisition unit 101 and a return unit 102.
An obtaining unit 101, configured to enable a target application to obtain a first request message sent by a kernel, where the target application and the kernel operate in the same operating system, the target application operates in a user mode, and the first request message is used to request that a memory address is allocated in a heap of the target application.
The returning unit 102 is configured to enable the target application to return a memory address to the kernel in response to the first request message, where the memory address is provided to the external device by the kernel, and the memory address is used to enable the external device to write data into the memory.
It should be noted here that the above-mentioned acquiring unit 101 and the returning unit 102 correspond to steps S302 to S304 in embodiment 1, and the two units are the same as the example and application scenarios realized by the corresponding steps, but are not limited to the disclosure of the above-mentioned embodiment one. It should be noted that the modules described above as part of the apparatus may be run in the computer terminal 10 provided in the first embodiment.
In the data processing apparatus in this embodiment, the kernel first requests to allocate a memory address from the heap of the target application in the user mode, and after the allocated memory address is obtained, the external device may directly write data into the memory address allocated from the heap of the target application in the user mode, so that only one memory copy is required, which avoids that the data of the external device is transferred to the memory of the target application in the user mode, and at least two data copies are required, thereby saving a CPU clock, achieving a technical effect of improving efficiency of transferring the data of the external device to the application in the user mode, and solving a technical problem of low efficiency of transferring the data of the external device to the application in the user mode.
Example 5
The embodiment of the invention can provide a computer terminal which can be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the computer terminal may also be replaced with a terminal device such as a mobile terminal.
Optionally, in this embodiment, the computer terminal may be located in at least one network device of a plurality of network devices of a computer network.
In this embodiment, the computer terminal may execute program codes of the following steps in the data processing method of the application program: the method comprises the steps that a kernel sends a first request message to a target application, wherein the kernel and the target application run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory address allocation in a heap of the target application; and the kernel receives a memory address returned by the target application in response to the first request message and provides the memory address to the external equipment, wherein the memory address is used for enabling the external equipment to write data into the memory.
Alternatively, fig. 11 is a block diagram of a computer terminal according to an embodiment of the present invention. As shown in fig. 11, the mobile terminal a may include: one or more processors 1102 (only one of which is shown), a memory 1104, and a transmitting device 1106.
The memory may be configured to store software programs and modules, such as program instructions/modules corresponding to the data processing method and apparatus in the embodiments of the present invention, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory, so as to implement the data processing method. The memory may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory located remotely from the processor, which may be connected to the mobile terminal a via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The processor can call the information and application program stored in the memory through the transmission device to execute the following steps: the method comprises the steps that a kernel sends a first request message to a target application, wherein the kernel and the target application run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory address allocation in a heap of the target application; and the kernel receives a memory address returned by the target application in response to the first request message and provides the memory address to the external equipment, wherein the memory address is used for enabling the external equipment to write data into the memory.
Optionally, the processor may further execute the program code of the following steps: and after the kernel receives the memory address returned by the target application in response to the first request message, the kernel sends a second request message to the target application, wherein the second request message is used for requesting to release the memory address to the heap of the target application.
Optionally, the processor may further execute the program code of the following steps: the kernel packages the memory address requested to be released into a second request message, and writes the second request message into the first cache queue; and the kernel sends a second request message to the target application through the first cache queue.
Optionally, the processor may further execute the program code of the following steps: the kernel packages the memory address requested to be allocated into a first request message, and writes the first request message into a first cache queue; the kernel sends a first request message to the target application through the first cache queue.
Optionally, the processor may further execute the program code of the following steps: and the kernel receives the memory address returned by the target application through the second cache queue, wherein the memory address is written into the second cache queue by the target application.
Optionally, the processor may further execute the program code of the following steps: before the kernel sends a first request message to the target application, the kernel acquires the data length of data from the external equipment; the kernel determines a storage space corresponding to the memory address based on the data length, wherein the first request message is used for requesting allocation of the memory address with the storage space in the heap of the target application.
As an alternative example, the processor may invoke the information stored in the memory and the application program via the transmission means to perform the following steps: the method comprises the steps that a target application obtains a first request message sent by a kernel, wherein the target application and the kernel run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory address allocation in a heap of the target application; and the target application responds to the first request message and returns a memory address to the kernel, wherein the memory address is provided for the external equipment by the kernel, and the memory address is used for enabling the external equipment to write data into the memory.
Optionally, the processor may further execute the program code of the following steps: after the target application responds to the first request message and returns a memory address to the kernel, the target application acquires a second request message sent by the kernel, wherein the second request message is used for requesting to release the allocated memory address; and the target application responds to the second request message and releases the memory address to the heap of the target application through the target task.
Optionally, the processor may further execute the program code of the following steps: and the target application acquires a second request message sent by the kernel through the first cache queue.
Optionally, the processor may further execute the program code of the following steps: the target application acquires a first request message sent by a kernel through a first cache queue.
Optionally, the processor may further execute the program code of the following steps: the target application writes the memory address into a second cache queue through the target task; and the target application sends the memory address to the kernel through the second cache queue.
Optionally, the processor may further execute the program code of the following steps: and the target application analyzes the first request message through the target task to obtain the memory address.
As an alternative example, the processor may invoke the information stored in the memory and the application program via the transmission means to perform the following steps: sending a data transfer request to the kernel; receiving a memory address sent by a kernel, wherein the memory address is obtained by the kernel responding to a data transmission request and requesting a target application, the kernel and the target application run in the same operating system, and the target application runs in a user mode; and writing the data into the memory of the external device based on the memory address.
As an alternative example, the processor may invoke the information stored in the memory and the application program via the transmission means to perform the following steps: receiving a third request message of the external device through the kernel; responding to the third request message, and requesting to allocate a memory address to the target application through the kernel, wherein the kernel and the target application run in the same operating system, and the target application runs in a user mode; sending the allocated memory address to an external device through the kernel; and receiving data to be written, and writing the data into the memory of the external equipment based on the memory address.
The embodiment of the invention provides a scheme of a data processing method. The method comprises the steps that a kernel sends a first request message to a target application, wherein the kernel and the target application run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory address allocation in a heap of the target application; the kernel receives a memory address returned by the target application in response to the first request message and provides the memory address for the external device, wherein the memory address is used for enabling the external device to write data into the memory, that is, the kernel requests to allocate the memory address from the heap of the target application in the user mode first, and after the allocated memory address is obtained, the external device can directly write the data into the memory address allocated from the heap of the target application in the user mode, so that only one memory copy is needed, the data of the external device is prevented from being transmitted to the memory of the target application in the user mode, at least two data copies are needed, a CPU clock is saved, the technical effect of improving the efficiency of transmitting the data of the external device to the application in the user mode is achieved, and the technical problem of low efficiency of transmitting the data of the external device to the application in the user mode is solved.
It can be understood by those skilled in the art that the structure shown in fig. 11 is only an illustration, and the Mobile terminal may also be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palmtop computer, a Mobile Internet Device (MID), a PAD, and the like. Fig. 11 is a diagram illustrating a structure of the mobile terminal. For example, mobile terminal a may also include more or fewer components (e.g., network interfaces, display devices, etc.) than shown in fig. 11, or have a different configuration than shown in fig. 11.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a computer-readable storage medium, and the storage medium may include: flash disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
Example 6
The embodiment of the invention also provides a storage medium. Optionally, in this embodiment, the storage medium may be configured to store a program code executed by the data processing method provided in the first embodiment.
Optionally, in this embodiment, the storage medium may be located in any one of computer terminals in a computer terminal group in a computer network, or in any one of mobile terminals in a mobile terminal group.
Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps: the method comprises the steps that a kernel sends a first request message to a target application, wherein the kernel and the target application run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory address allocation in a heap of the target application; and the kernel receives a memory address returned by the target application in response to the first request message and provides the memory address to the external equipment, wherein the memory address is used for enabling the external equipment to write data into the memory.
Optionally, the storage medium is further arranged to store program code for performing the steps of: and after the kernel receives the memory address returned by the target application in response to the first request message, the kernel sends a second request message to the target application, wherein the second request message is used for requesting to release the memory address to the heap of the target application.
Optionally, the storage medium is further arranged to store program code for performing the steps of: the kernel packages the memory address requested to be released into a second request message, and writes the second request message into the first cache queue; and the kernel sends a second request message to the target application through the first cache queue.
Optionally, the storage medium is further arranged to store program code for performing the steps of: the kernel packages the memory address requested to be allocated into a first request message, and writes the first request message into a first cache queue; the kernel sends a first request message to the target application through the first cache queue.
Optionally, the storage medium is further arranged to store program code for performing the steps of: and the kernel receives the memory address returned by the target application through the second cache queue, wherein the memory address is written into the second cache queue by the target application.
Optionally, the storage medium is further arranged to store program code for performing the steps of: before the kernel sends a first request message to the target application, the kernel acquires the data length of data from the external equipment; the kernel determines a storage space corresponding to the memory address based on the data length, wherein the first request message is used for requesting allocation of the memory address with the storage space in the heap of the target application.
As an alternative example, the storage medium is arranged to store program code for performing the steps of: the method comprises the steps that a target application obtains a first request message sent by a kernel, wherein the target application and the kernel run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory address allocation in a heap of the target application; and the target application responds to the first request message and returns a memory address to the kernel, wherein the memory address is provided for the external equipment by the kernel, and the memory address is used for enabling the external equipment to write data into the memory.
Optionally, the storage medium is further arranged to store program code for performing the steps of: after the target application responds to the first request message and returns a memory address to the kernel, the target application acquires a second request message sent by the kernel, wherein the second request message is used for requesting to release the allocated memory address; and the target application responds to the second request message and releases the memory address to the heap of the target application through the target task.
Optionally, the storage medium is further arranged to store program code for performing the steps of: and the target application acquires a second request message sent by the kernel through the first cache queue.
Optionally, the storage medium is further arranged to store program code for performing the steps of: the target application acquires a first request message sent by a kernel through a first cache queue.
Optionally, the storage medium is further arranged to store program code for performing the steps of: the target application writes the memory address into a second cache queue through the target task; and the target application sends the memory address to the kernel through the second cache queue.
Optionally, the storage medium is further arranged to store program code for performing the steps of: and the target application analyzes the first request message through the target task to obtain the memory address.
As an alternative example, the storage medium is arranged to store program code for performing the steps of: sending a data transfer request to the kernel; receiving a memory address sent by a kernel, wherein the memory address is obtained by the kernel responding to a data transmission request and requesting a target application, the kernel and the target application run in the same operating system, and the target application runs in a user mode; and writing the data into the memory of the external device based on the memory address.
As an alternative example, the storage medium is arranged to store program code for performing the steps of: receiving a third request message of the external device through the kernel; responding to the third request message, and requesting to allocate a memory address to the target application through the kernel, wherein the kernel and the target application run in the same operating system, and the target application runs in a user mode; sending the allocated memory address to an external device through the kernel; and receiving data to be written, and writing the data into the memory of the external equipment based on the memory address.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of division of logical functions, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (20)

1. A data processing method, comprising:
a kernel sends a first request message to a target application, wherein the kernel and the target application run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory address allocation in a heap of the target application;
and the kernel receives the memory address returned by the target application in response to the first request message and provides the memory address to an external device, wherein the memory address is used for enabling the external device to write data into a memory.
2. The method of claim 1, wherein after the kernel receives the memory address returned by the target application in response to the first request message, the method further comprises:
and the kernel sends a second request message to the target application, wherein the second request message is used for requesting to release the memory address to the heap of the target application.
3. The method of claim 2, wherein the kernel sends a second request message to the target application, comprising:
the kernel packages the memory address requested to be released into the second request message and writes the second request message into a first cache queue;
and the kernel sends the second request message to the target application through the first cache queue.
4. The method of claim 1, wherein the kernel sends the first request message to the target application, comprising:
the kernel packages the memory address requested to be allocated into the first request message and writes the first request message into a first cache queue;
and the kernel sends the first request message to the target application through the first cache queue.
5. The method of claim 1, wherein the kernel receiving the memory address returned by the target application in response to the first request message comprises:
and the kernel receives the memory address returned by the target application through a second cache queue, wherein the memory address is written into the second cache queue by the target application.
6. The method of any of claims 1 to 5, wherein prior to the kernel sending the first request message to the target application, the method further comprises:
the kernel acquires the data length of the data from the external equipment;
the kernel determines a storage space corresponding to the memory address based on the data length, wherein the first request message is used for requesting allocation of the memory address with the storage space in the heap of the target application.
7. A data processing method, comprising:
a target application acquires a first request message sent by a kernel, wherein the target application and the kernel run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory address allocation in a heap of the target application;
and the target application responds to the first request message and returns the memory address to the kernel, wherein the memory address is provided for external equipment by the kernel, and the memory address is used for enabling the external equipment to write data into a memory.
8. The method of claim 7, wherein after the target application returns the memory address to the kernel in response to the first request message, the method further comprises:
the target application acquires a second request message sent by the kernel, wherein the second request message is used for requesting to release the allocated memory address;
and the target application responds to the second request message and releases the memory address to the heap of the target application through a target task.
9. The method of claim 8, wherein the obtaining, by the target application, the second request message sent by the kernel comprises:
and the target application acquires the second request message sent by the kernel through a first cache queue.
10. The method of claim 7, wherein the obtaining, by the target application, the first request message sent by the kernel comprises:
and the target application acquires the first request message sent by the kernel through a first cache queue.
11. The method of claim 7, wherein returning the memory address to the kernel by the target application in response to the first request message comprises:
the target application writes the memory address into a second cache queue through a target task;
and the target application sends the memory address to the kernel through the second cache queue.
12. The method of claim 7, wherein the target application responding to the first request message comprises:
and the target application analyzes the first request message through a target task to obtain the memory address.
13. A data processing method applied to an external device includes:
sending a data transfer request to the kernel;
receiving a memory address sent by the kernel, wherein the memory address is obtained by the kernel responding to the data transmission request and requesting a target application, the kernel and the target application run in the same operating system, and the target application runs in a user mode;
and writing data into the memory of the external equipment based on the memory address.
14. A data processing method is applied to current equipment and comprises the following steps:
receiving a third request message of the external device through the kernel;
responding to the third request message, and requesting to allocate a memory address to a target application through the kernel, wherein the kernel and the target application run in the same operating system, and the target application runs in a user mode;
sending the allocated memory address to an external device through the kernel;
and receiving data to be written, and writing the data into the memory of the external equipment based on the memory address.
15. An embedded device, comprising: a kernel and a target application, the kernel and the target application running in the same operating system, wherein,
the kernel is configured to send a first request message to the target application, where the first request message is used to request that a memory address is allocated in a heap of the target application;
and the target application is configured to respond to the first request message and return the memory address to the kernel, where the memory address is provided to an external device by the kernel, and the memory address is used to enable the external device to write data into a memory.
16. A data processing apparatus, comprising:
a sending unit, configured to enable a kernel to send a first request message to a target application, where the kernel and the target application run in a same operating system, the target application runs in a user mode, and the first request message is used to request that a memory address is allocated in a heap of the target application;
a receiving unit, configured to enable the kernel to receive the memory address returned by the target application in response to the first request message, and provide the memory address to an external device, where the memory address is used to enable the external device to write data into a memory.
17. A data processing apparatus, comprising:
an obtaining unit, configured to enable a target application to obtain a first request message sent by a kernel, where the target application and the kernel run in a same operating system, the target application runs in a user mode, and the first request message is used to request that a memory address is allocated in a heap of the target application;
a returning unit, configured to enable the target application to return the memory address to the kernel in response to the first request message, where the memory address is provided to an external device by the kernel, and the memory address is used to enable the external device to write data into a memory.
18. A computer-readable storage medium, comprising a stored program, wherein the program, when executed by a processor, controls an apparatus in which the computer-readable storage medium is located to perform the steps of:
the method comprises the steps that a control kernel sends a first request message to a target application, wherein the kernel and the target application run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory addresses to be allocated in a heap of the target application;
and controlling the kernel to receive the memory address returned by the target application in response to the first request message and provide the memory address to an external device, wherein the memory address is used for enabling the external device to write data into a memory.
19. A processor, wherein the processor is configured to execute a program, wherein the program executes to perform the following steps:
the method comprises the steps that a control kernel sends a first request message to a target application, wherein the kernel and the target application run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory addresses to be allocated in a heap of the target application;
and controlling the kernel to receive the memory address returned by the target application in response to the first request message and provide the memory address to an external device, wherein the memory address is used for enabling the external device to write data into a memory.
20. A mobile terminal, comprising:
a processor;
a memory coupled to the processor for providing instructions to the processor for processing the following processing steps: the method comprises the steps that a control kernel sends a first request message to a target application, wherein the kernel and the target application run in the same operating system, the target application runs in a user mode, and the first request message is used for requesting memory addresses to be allocated in a heap of the target application; and controlling the kernel to receive the memory address returned by the target application in response to the first request message and provide the memory address to an external device, wherein the memory address is used for enabling the external device to write data into a memory.
CN202010802238.1A 2020-08-11 2020-08-11 Data processing method, data processing device, computer readable storage medium and processor Pending CN114077500A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010802238.1A CN114077500A (en) 2020-08-11 2020-08-11 Data processing method, data processing device, computer readable storage medium and processor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010802238.1A CN114077500A (en) 2020-08-11 2020-08-11 Data processing method, data processing device, computer readable storage medium and processor

Publications (1)

Publication Number Publication Date
CN114077500A true CN114077500A (en) 2022-02-22

Family

ID=80280094

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010802238.1A Pending CN114077500A (en) 2020-08-11 2020-08-11 Data processing method, data processing device, computer readable storage medium and processor

Country Status (1)

Country Link
CN (1) CN114077500A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115658242A (en) * 2022-10-21 2023-01-31 芯华章科技股份有限公司 Task processing method for logic system design and electronic equipment

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115658242A (en) * 2022-10-21 2023-01-31 芯华章科技股份有限公司 Task processing method for logic system design and electronic equipment
CN115658242B (en) * 2022-10-21 2024-04-26 芯华章科技股份有限公司 Task processing method for logic system design and electronic equipment

Similar Documents

Publication Publication Date Title
WO2021217529A1 (en) Method and system for inter-process communication
CN107967225B (en) Data transmission method and device, computer readable storage medium and terminal equipment
US11281388B2 (en) Method for managing a multi-system shared memory, electronic device and non-volatile computer-readable storage medium
CN112148422A (en) IO processing method and device
EP3651545A1 (en) System, method, and device for exposing wireless module data storage
CN114553635B (en) Data processing method, data interaction method and product in DPU network equipment
EP4187386A1 (en) Interprocess communication method and apparatus
CN116302141B (en) Serial port switching method, chip and serial port switching system
CN113419845A (en) Calculation acceleration method and device, calculation system, electronic equipment and computer readable storage medium
CN114945009A (en) Method, device and system for communication among devices connected through PCIe bus
CN113296871A (en) Method, equipment and system for processing container group instance
CN112256460A (en) Inter-process communication method and device, electronic equipment and computer readable storage medium
CN114077500A (en) Data processing method, data processing device, computer readable storage medium and processor
CN116243853A (en) Data transmission method and device, electronic equipment and nonvolatile storage medium
CN115905095A (en) USB drive-free communication method, device, electronic equipment and storage medium
CN116166434A (en) Processor allocation method and system, device, storage medium and electronic equipment
CN109857553B (en) Memory management method and device
CN112422485A (en) Communication method and device of transmission control protocol
CN116521324B (en) Interrupt virtualization processing method and device and electronic equipment
CN117312229A (en) Data transmission device, data processing equipment, system, method and medium
CN116848519A (en) Method and device for generating hardware interface signal and electronic equipment
CN113110950A (en) Processor, communication method, storage medium, and computing device
CN108874699B (en) Method and device for using MTP (Multi-time transfer protocol) function by multiple systems and electronic equipment
CN108153564B (en) Interface management method, device and system and computer readable storage medium
CN115982161A (en) Data management method, device, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination