Data processing method and device, equipment and medium
By analyzing and processing data status flags in the ring buffer, ensuring that the data is switched to the next frame of data when data processing errors is wrong, the data interruption problem caused by data errors in network communication is solved, and the reliability and performance of the system are improved.
Patent Information
- Application Number
- CN202411439208.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-15
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2044-10-15
AI Technical Summary
In network communication, due to external reasons, the data processing program makes an error when processing one frame of data, resulting in the inability to process subsequent data, resulting in the problem of interruption of network data.
By reading the current frame data pointed to by the read pointer from the ring buffer, parsing its status flag. If it is an error state, configure the read pointer to point to the next frame data to ensure the continuity and correctness of data processing, and if necessary Delete the error data to restore the buffer state.
When encountering wrong data, you can correctly process subsequent data, restore communication, improve system maintainability and reliability, reduce the risk of data loss, and improve communication stability and performance.
Smart Images

Figure CN119254392A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of testing technology, and in particular to a data processing method, device, equipment and medium. Background Art
[0002] In network communication, when the network driver receives data, it processes it through buffer. After processing one frame of data, the soft interrupt function will process the next frame of data, and repeat the cycle. When the program processes the buffer, it will read the status flag of the buffer frame data. However, due to some external reasons, sometimes after the flag of processing a frame of data is wrong, the processing program will be stuck and will not process subsequent data, resulting in network data interruption. Summary of the invention
[0003] In view of the above-mentioned shortcomings of the prior art, the present application provides a data processing method, apparatus, device and medium to solve at least one defect in the prior art.
[0004] To achieve the above objectives and other objectives, the present application provides a data processing method, which includes:
[0005] Read the current frame data pointed to by the read pointer from the ring buffer as data to be processed;
[0006] A data processing process is performed on the data to be processed; the data processing process includes: when it is determined that the state of the data to be processed is an error state according to the state flag of the data to be processed, configuring a read pointer to point to the next frame of data of the data to be processed in the ring buffer.
[0007] In one embodiment of the present invention, the data processing process further includes:
[0008] When it is determined according to the status flag of the data to be processed that the state of the data to be processed is a correct state, the data to be processed is forwarded, and a read pointer is configured to point to the next frame of data of the data to be processed in the ring buffer.
[0009] In one embodiment of the present invention, the step of determining the state of the data to be processed according to the state flag of the data to be processed includes:
[0010] Parsing the data to be processed, obtaining a status flag of the data to be processed, and identifying the status flag;
[0011] If the status flag is the first preset flag, the status of the data to be processed is a correct status;
[0012] If the status flag is the second preset flag, the status of the data to be processed is an error status.
[0013] In one embodiment of the present invention, when the status flag is a second preset flag, the data processing process further includes:
[0014] The status flag is repeatedly identified at least twice, and if the results of at least two repeated identifications are both the second preset flag, it is determined that the status of the data to be processed is an error status.
[0015] In one embodiment of the present invention, the method further includes:
[0016] When the state of the data to be processed is an error state, the data to be processed is deleted from the ring buffer, and the state of the buffer is reset.
[0017] To achieve the above objectives and other objectives, the present application also provides a data processing device, the data processing device comprising:
[0018] A data reading module is used to read the current frame data pointed to by the read pointer from the ring buffer as data to be processed;
[0019] The data processing module is used to perform a data processing process on the data to be processed; the data processing process includes: when it is determined that the state of the data to be processed is an error state according to the state flag of the data to be processed, configuring a read pointer to point to the next frame of data of the data to be processed in the ring buffer.
[0020] To achieve the above objectives and other objectives, the present application provides a data processing method, which includes:
[0021] Receive the data to be processed by using the network adapter, and write the data to be processed into the ring buffer; after storing the data to be processed in the ring buffer, initiate a hard interrupt to the central processing unit;
[0022] The hard interrupt is shielded by the central processing unit, and the soft interrupt is started; when the ksoftirqd process in the kernel of the central processing unit receives the soft interrupt, the soft interrupt processing function is called to process the data to be processed by the data processing method to obtain the target data; wherein the target data is cached on the corresponding socket;
[0023] The application calls the read function to read the target data on the socket and copy the target data from the kernel space to the user space.
[0024] To achieve the above objectives and other objectives, the present application provides a data processing device, the data processing device comprising:
[0025] A network adapter, configured to receive data to be processed, write the data to be processed into a ring buffer, and initiate a hard interrupt to a central processing unit after the data to be processed is stored in the ring buffer;
[0026] The central processing unit is used to shield the hard interrupt and start the soft interrupt; receive the soft interrupt through the ksoftirqd process in the kernel, and call the soft interrupt processing function when receiving the soft interrupt to process the data to be processed through the data processing method to obtain the target data; wherein the target data is cached on the corresponding socket;
[0027] The application is used to call the read function to read the target data on the socket and copy the target data from the kernel space to the user space.
[0028] To achieve the above objectives and other related objectives, the present application provides a data processing device, including:
[0029] one or more processors; and
[0030] The memory is used to store one or more programs. When the one or more programs are executed by the one or more processors, the memory implements the method described.
[0031] To achieve the above objectives and other related objectives, the present application provides one or more machine-readable media having instructions stored thereon, which, when executed by one or more processors, enable the processors to execute the described methods.
[0032] Beneficial effects of this application:
[0033] A data processing method of the present application includes: reading the current frame data pointed to by a read pointer from a ring buffer as data to be processed; executing a data processing process on the data to be processed; the data processing process includes: when it is determined that the state of the data to be processed is an error state according to a state flag of the data to be processed, configuring the read pointer to point to the next frame data of the data to be processed in the ring buffer; in the present application, when reading data, if it is identified that the data of the current frame is error data, the data pointed to by the next read pointer is read from the ring buffer as the data to be processed, so that when a data error is caused by external reasons, subsequent data can be correctly processed, that is, communication can be restored when error data is encountered, thereby improving the maintainability and reliability of the system.
[0034] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0036] Figure 1 This is a schematic diagram of normal data processing;
[0037] Figure 2 This is a schematic diagram of error data processing;
[0038] Figure 3 A schematic diagram of an implementation environment of a data processing method according to an embodiment of the present application;
[0039] Figure 4 A schematic diagram of a data processing method according to an embodiment of the present application;
[0040] Figure 5 A flowchart of a data processing method according to an embodiment of the present application;
[0041] Figure 6 A block diagram of a data processing device for illustrating an example of an embodiment of the present application;
[0042] Figure 7 A flowchart of a data processing method according to another embodiment of the present application;
[0043] Figure 8 A flowchart of a data processing method according to another embodiment of the present application;
[0044] Fig. 9 A block diagram of a data processing device according to another embodiment of the present application;
[0045] Fig.10 A schematic diagram of the structure of a computer system suitable for implementing the memory of an embodiment of the present application is shown. DETAILED DESCRIPTION
[0046] The following describes the embodiments of the present application through specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0047] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present application, and thus the drawings only show components related to the present application rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed at will, and the component layout may also be more complicated.
[0048] Although the terms "first", "second", "A", and "B", etc. may be used herein to describe various elements, these elements should not be limited by these terms and are only used to distinguish one element from another. For example, a first element may be referred to as a second element, and similarly, a second element may be referred to as a first element without departing from the scope of the following technology. The term "and / or" includes a combination of multiple related items or any of the multiple related items.
[0049] As used herein, unless the context indicates otherwise, the singular form is intended to include the plural form, and it will be understood that the term "comprising" means the presence of stated features, quantities, steps, operations, elements, or combinations thereof, but does not exclude the presence or addition of one or more other features, quantities, steps, operations, elements, components, or combinations thereof.
[0050] Before the detailed description, it is intended to clarify that the division of components in this specification is divided only by the main function of each component. That is, two or more components to be described below can be combined into one component, or can be divided into two or more components according to more detailed functions. In addition to the main function of the component, each component to be described below can also perform some or all of the functions of other components, and some of the main functions of each component can be exclusively performed by other components.
[0051] When the network driver receives data, it temporarily stores it in the ringbuffer (circular buffer). Ringbuffer is a data structure commonly used when the network receives data. It provides an efficient way to temporarily store and process data. It provides an intermediary between data producers (such as network receiving threads) and data consumers (such as processing threads) to ensure that data can be transmitted efficiently and in an orderly manner. When the data consumer reads the data, the soft interrupt function first obtains a frame of data in the ringbuffer for processing. After processing a frame of data, it continues to process the next frame of data, and repeats the cycle in sequence. When processing frame data, the program will read the data status flag (TRUE / FALSE). If this flag is TRUE, it means that the current frame data is normal. This interrupt processing function will continue to process the data in the ringbuffer in a loop. Figure 1However, due to some external reasons, the frame data flag is always FALSE. When the interrupt processing function processes this frame data, it will jump out of the processing flow every time because the flag is FALSE. Subsequent data will not be processed, which will eventually lead to network data interruption, such as Figure 2 Therefore, in order to solve the above problems, this application provides a data processing method, which can correctly process subsequent data when data errors are caused by external reasons, that is, it can restore communication when encountering erroneous data, and improve the maintainability and reliability of the system.
[0052] Figure 3 Schematic diagram of the implementation environment of the data processing method of an embodiment of the present application. Figure 3 The data producer 310 generates data and stores the data in the ring buffer 320, and then the data consumer 330 reads data from the ring buffer 320 according to demand. When reading data, the data consumer 330 reads the current frame data pointed to by the read pointer from the ring buffer as the data to be processed; performs a data processing process on the data to be processed; the data processing process includes: when the state of the data to be processed is judged to be an error state according to the state flag of the data to be processed, configure the read pointer to point to the next frame data of the data to be processed in the ring buffer. In the present application, when reading data, if the data of the current frame is identified as error data, the read pointer is pointed to the next frame data and used as the data to be processed, so that when the data error is caused by external reasons, the subsequent data can be processed correctly, that is, the communication can be restored when the error data is encountered, and the maintainability and reliability of the system are improved.
[0053] See also Figure 5 , Figure 5 This is a flow chart of a data processing method according to an embodiment of the present application. Figure 5 As shown, the data processing method at least includes steps S510 to S520:
[0054] Step S510, reading the current frame data pointed to by the read pointer from the ring buffer as data to be processed;
[0055] The data producer 310 generates corresponding data and then sends the data. The network adapter receives the data generated by the data producer 310 and stores the received data message in the ring buffer. Specifically, the network adapter can store the received data message in the ring buffer by means of DMA (Data Memory Access, direct memory access), and then the network adapter notifies the central processing unit that the data message has arrived in the ring buffer by means of an interrupt request. The interrupt request (InterruptReQuest, IRQ) here refers to the action of executing a hardware interrupt request in the computer. For example, when a piece of data in the hard disk needs to be read, when the data is read, the hard disk notifies the system through IRQ. Of course, the corresponding data has also been written to the specified memory or cache.
[0056] When a data consumer needs to consume data, it reads the current frame data pointed to by the read pointer from the ring buffer as the data to be processed; the read pointer points to the location of the data to be read.
[0057] Step S520, executing a data processing process on the data to be processed; the data processing process includes: when it is determined that the state of the data to be processed is an error state according to the state flag of the data to be processed, configuring a read pointer to point to the next frame of data of the data to be processed in the ring buffer.
[0058] After reading data from the ring buffer, it is necessary to determine whether the read data is correct. The correct data is forwarded to the subsequent processing steps, while the incorrect data can be deleted.
[0059] The status flag of the data represents whether the data is correct, so the state of the data to be processed can be judged according to the status flag of the data, that is, whether the data to be processed is correct.
[0060] In an embodiment of the present application, the step of judging the state of the data to be processed according to the state flag of the data to be processed includes: parsing the data to be processed, obtaining the state flag of the data to be processed, and identifying the state flag; if the state flag is a first preset flag, the state of the data to be processed is a correct state; if the state flag is a second preset flag, the state of the data to be processed is an error state.
[0061] After obtaining the data to be processed, the data content and status flag can be obtained by parsing the data to be processed, and whether the data to be processed is correct can be determined by identifying the status flag. It should be noted that before judging whether the data is correct according to the status flag, the status flag of the data needs to be preset. For example, if the status flag is TURE, the status of the corresponding data is a correct state; and if the status flag is FALSE, the status of the corresponding data is an error state. That is, the first preset flag can be set to TURE, and the second preset flag can be set to FALSE.
[0062] After the data to be processed is obtained, the data to be processed is parsed to obtain the status flag of the data to be processed. If the status flag is identified as the first preset flag, that is, the status flag is TURE, then the status of the data to be processed is determined to be a correct state, that is, the data to be processed is correct data; if the status flag is identified as the second preset flag, that is, the status flag is FALSE, then the status of the data to be processed is determined to be an error state, that is, the data to be processed is error data.
[0063] When it is identified that the status flag of the data to be processed is FALSE, that is, when the data to be processed is erroneous data, the indexes of all frame data in the ringbuffer can be read. If the subsequent frames of the ringbuffer have been filled with data, the next frame data in the ringbuffer is read and its status flag is identified, and the corresponding data is processed according to the status flag.
[0064] It should be noted that the next frame of data refers to the next data frame between two data frames adjacent to the current frame of data.
[0065] In an embodiment of the present application, the data processing process also includes: when it is determined that the state of the data to be processed is a correct state according to the state flag of the data to be processed, forwarding the data to be processed, and configuring the read pointer to point to the next frame of data of the data to be processed in the ring buffer.
[0066] After obtaining the data to be processed, the data to be processed is parsed to obtain the status flag of the data to be processed. If the status flag is identified as TURE, that is, the data to be processed is correct data, the data to be processed is forwarded as the target data for subsequent data processing steps. After forwarding the correct data, the read pointer is configured to point to the next frame of data of the data to be processed in the ring buffer to determine the status of the next frame of data.
[0067] In the embodiment of the present application, when the status flag is the second preset flag, the data processing process further includes:
[0068] The status flag is repeatedly identified at least twice, and if the results of at least two repeated identifications are both the second preset flag, it is determined that the status of the data to be processed is an error status.
[0069] When judging the status flag of the data to be processed, if a status flag indicating an error state is encountered, multiple loop judgments are performed on whether the data is correct. If multiple loop judgments are all error states, the status flag of the data is determined to be FALSE. The number of loop judgments can be set according to actual needs. For example, the number of loop judgments is 3 times. This embodiment does not specifically limit the number of loop judgments.
[0070] By making multiple judgments on erroneous data, the accuracy of data recognition is improved.
[0071] In the embodiment of the present application, the method further includes: when the state of the data to be processed is an error state, deleting the data to be processed from the ring buffer and resetting the state of the buffer.
[0072] By deleting the data to be processed from the ring buffer and resetting the state of the buffer, it is possible to ensure that the data can be written normally next time. Resetting means restoring the state of the buffer to the initial state through corresponding programming instructions. In the initial state, the buffer does not store any data.
[0073] To summarize, the present application reads the data pointed to by the current read pointer from the circular buffer as the data to be processed; executes a data processing process on the data to be processed, and the data processing process includes: judging the state of the data to be processed according to the state flag of the data to be processed; when the state of the data to be processed is an error state, reading the data pointed to by the next read pointer from the circular buffer as the data to be processed and executing the data processing process; in the present application, when reading data, if it is identified that the data of the current frame is error data, the data pointed to by the next read pointer is read from the circular buffer as the data to be processed, so that when the data error is caused by external reasons, the subsequent data can be processed correctly, that is, when encountering error data, the communication can be restored, thereby improving the maintainability and reliability of the system.
[0074] At the same time, since error frames usually contain data corruption caused by transmission errors, hardware failures, or software defects; by detecting and processing these error frames, the system can reduce or avoid passing data to the upper protocol stack, thereby reducing the risk of data loss and improving the reliability of communication. In addition, unprocessed error frames may cause system resource exhaustion, buffer overflow, or software anomalies, which in turn may cause system crashes; by processing these error frames in a timely manner, the risk of system crashes can be reduced and the stability and availability of the system can be improved; finally, by processing error frames in a timely manner and releasing related resources (such as buffers, memory, etc.), the system can use these resources more effectively to handle normal network communication tasks, reducing processing delays caused by error frames, shortening the response time of network communications, and improving resource utilization, thereby improving overall performance.
[0075] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0076] Figure 6 This is a block diagram of a data processing device according to an embodiment of the present application. The device can be applied to Figure 1 The device may also be applicable to other exemplary implementation environments and specifically configured in other devices, and this embodiment does not limit the implementation environment to which the device is applicable.
[0077] like Figure 6 As shown, a data processing device includes:
[0078] The data reading module 610 is used to read the current frame data pointed to by the read pointer from the ring buffer as data to be processed;
[0079] The data processing module 620 is used to perform a data processing process on the data to be processed; the data processing process includes: when the state of the data to be processed is judged to be an error state according to the state flag of the data to be processed, configuring a read pointer to point to the next frame of data of the data to be processed in the ring buffer.
[0080] It should be noted that the data processing device provided in the above embodiment and the data processing method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment, and will not be repeated here. In practical applications, the data processing device provided in the above embodiment can distribute the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.
[0081] See also Figure 7 , 8 , Figure 7 This is a flow chart of a data processing method according to an embodiment of the present application. Figure 8 Flow chart of a data processing method according to an embodiment of the present application. Figure 7 As shown, the data processing method includes:
[0082] Step S710, receiving the data to be processed by using the network adapter, and writing the data to be processed into the ring buffer; after storing the data to be processed in the ring buffer, a hard interrupt is initiated to the central processing unit;
[0083] The data to be processed enters the network adapter from the network; the network adapter writes the data packet to the specified memory address (allocated and initialized by the network adapter driver) through DMA, that is, puts it into the RingBuffer. After the data is written to the ring buffer, the network adapter notifies the CPU (Central Processing Unit, referred to as CPU) that data has arrived through a hardware interrupt (IRQ).
[0084] Step S720, shielding the hard interrupt through the central processing unit and starting the soft interrupt; when the ksoftirqd process in the kernel of the central processing unit receives the soft interrupt, calling the soft interrupt processing function to process the data to be processed through the data processing method to obtain the target data; wherein the target data is cached on the corresponding socket;
[0085] The interrupt processing function of the CPU kernel will first disable the interrupt of the network adapter (to avoid frequent interrupts), and then start the soft interrupt processing process. The ksoftirqd process in the kernel is responsible for processing soft interrupts. When the ksoftirqd process receives a soft interrupt, it will call the corresponding soft interrupt processing function (such as net_rx_action), and the net_rx_action function will call the poll function in the network adapter driver to process data packets one by one. Among them, the method for the poll function to process data packets can adopt the data processing method of the aforementioned embodiment. In the poll function, the driver will read the data packet written to the memory by the network adapter and convert the data packet into the skb (socket buffer) format that the kernel network module can recognize. Call functions such as napi_gro_receive to perform GRO (Generic Receive Offload) processing to merge the data packets that can be merged. Call functions such as __netif_receive_skb to hand over the data packet to the protocol stack for processing. After the data packet enters the protocol stack, the corresponding processing function will be called according to its protocol type (such as IP, TCP, UDP, etc.). After a series of protocol processing (such as routing, fragmentation reassembly, verification, etc.), the data packet is finally cached on the corresponding socket.
[0086] Step S730, the application calls the read function to read the target data on the socket, and copies the target data from the kernel space to the user space.
[0087] The application reads the data on the socket by calling the read function and other system calls. The data is copied from the kernel space to the user space for the application to use.
[0088] See also Fig. 9 , Fig. 9 FIG. 1 is a schematic diagram of a data processing device according to an embodiment of the present application. Fig. 9 As shown, the data processing device includes:
[0089] The network adapter 910 is used to receive the data to be processed, write the data to be processed into the ring buffer, and initiate a hard interrupt to the central processor after the data to be processed is stored in the ring buffer;
[0090] The central processing unit 920 is used to shield the hard interrupt and start the soft interrupt; receive the soft interrupt through the ksoftirqd process in the kernel, and call the soft interrupt processing function when receiving the soft interrupt to process the data to be processed through the data processing method to obtain the target data; wherein the target data is cached on the corresponding socket;
[0091] The application 930 is used to call the read function to read the target data on the socket, and copy the target data from the kernel space to the user space.
[0092] It should be noted that the data processing device provided in the above embodiment and the data processing method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment, and will not be repeated here. In practical applications, the data processing device provided in the above embodiment can distribute the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.
[0093] An embodiment of the present application also provides a device, including: one or more processors; and a memory for storing one or more programs, when the one or more programs are executed by one or more processors, the memory implements the data processing method in the above embodiment.
[0094] The embodiments of the present application further provide one or more machine-readable media on which instructions are stored, which, when executed by one or more processors, enable the processors to execute the data processing method in the above embodiments.
[0095] Fig.10 The schematic diagram of the structure of a computer system suitable for implementing the memory of the embodiment of the present application is shown. It should be noted that: Fig.10 The computer system of the memory shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0096] like Fig.10 As shown, the computer system includes a central processing unit (CPU), which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) or the program loaded from the storage part to the random access memory (RAM), such as the method in the above embodiment. In the RAM, various programs and data required for system operation are also stored. The CPU, ROM and RAM are connected to each other through a bus. The input / output (I / O) interface is also connected to the bus.
[0097] The following components are connected to the I / O interface: an input part including a keyboard, a mouse, etc.; an output part including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage part including a hard disk, etc.; and a communication part including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication part performs communication processing via a network such as the Internet. A drive is also connected to the I / O interface as needed. Removable media, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., are installed on the drive as needed so that a computer program read therefrom is installed into the storage part as needed.
[0098] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the data processing method implemented above. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part, and / or installed from a removable medium. When the computer program is executed by a central processing unit (CPU), various functions defined in the system of the present application are executed.
[0099] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal can take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0100] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0101] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0102] Another aspect of the present application further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor of a computer, the computer executes the data processing method as described above. The computer-readable storage medium may be included in the memory described in the above embodiment, or may exist independently without being assembled into the memory.
[0103] Another aspect of the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the data processing method provided in each of the above embodiments.
[0104] The above embodiments are merely illustrative of the principles and effects of the present application, and are not intended to limit the present application. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed in the present application shall still be covered by the claims of the present application.
Claims
1. A data processing method, characterized in that: The data processing method comprises: Read the current frame data pointed to by the read pointer from the ring buffer as data to be processed; A data processing process is performed on the data to be processed; the data processing process includes: when it is determined that the state of the data to be processed is an error state according to the state flag of the data to be processed, configuring a read pointer to point to the next frame of data of the data to be processed in the ring buffer.
2. The data processing method according to claim 1, characterized in that: The data processing process also includes: When it is determined according to the status flag of the data to be processed that the state of the data to be processed is a correct state, the data to be processed is forwarded, and a read pointer is configured to point to the next frame of data of the data to be processed in the ring buffer.
3. The data processing method according to claim 2, characterized in that: The step of judging the state of the data to be processed according to the state flag of the data to be processed comprises: Parsing the data to be processed, obtaining a status flag of the data to be processed, and identifying the status flag; If the status flag is the first preset flag, the status of the data to be processed is a correct status; If the status flag is the second preset flag, the status of the data to be processed is an error status.
4. The data processing method according to claim 3, characterized in that: When the status flag is a second preset flag, the data processing process further includes: The status flag is repeatedly identified at least twice, and if the results of at least two repeated identifications are both the second preset flag, it is determined that the status of the data to be processed is an error status.
5. The data processing method according to claim 1, 2 or 3, characterized in that: The method further comprises: When the state of the data to be processed is an error state, the data to be processed is deleted from the ring buffer, and the state of the buffer is reset.
6. A data processing device, characterized in that: The data processing device comprises: A data reading module is used to read the current frame data pointed to by the read pointer from the ring buffer as data to be processed; The data processing module is used to perform a data processing process on the data to be processed; the data processing process includes: when it is determined that the state of the data to be processed is an error state according to the state flag of the data to be processed, configuring a read pointer to point to the next frame of data of the data to be processed in the ring buffer.
7. A data processing method, characterized in that: The data processing method comprises: Receive the data to be processed by using the network adapter, and write the data to be processed into the ring buffer; after storing the data to be processed in the ring buffer, initiate a hard interrupt to the central processing unit; The hard interrupt is shielded by the central processing unit, and a soft interrupt is started; when the ksoftirqd process in the kernel of the central processing unit receives the soft interrupt, a soft interrupt processing function is called to process the data to be processed by the data processing method according to any one of claims 1 to 5 to obtain target data; wherein the target data is cached on a corresponding socket; The application calls the read function to read the target data on the socket and copy the target data from the kernel space to the user space.
8. A data processing device, characterized in that: The data processing device comprises: A network adapter, for receiving data to be processed, writing the data to be processed into a ring buffer, and initiating a hard interrupt to a central processing unit after the data to be processed is stored in the ring buffer; A central processing unit, configured to shield the hard interrupt and start the soft interrupt; and receive the soft interrupt through the ksoftirqd process in the kernel, and call the soft interrupt processing function when receiving the soft interrupt to process the data to be processed by the data processing method according to any one of claims 1 to 5 to obtain target data; wherein the target data is cached on a corresponding socket; The application is used to call the read function to read the target data on the socket and copy the target data from the kernel space to the user space.
9. A data processing device, characterized in that: include: one or more processors; and A memory, used to store one or more programs, when the one or more programs are executed by the one or more processors, the memory implements the method according to any one of claims 1 to 5.
10. A machine-readable medium, characterized in that Instructions are stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Message processing method and device
CN110138797A
Annular buffer queue data receiving mechanism based on single-chip microcomputer
CN112235206A
Ring buffer control method and system and storage medium
CN118227206A
Method and system of controlling transfer of data by updating descriptors in descriptor rings
US6327615B1
Methods and apparatus for dynamically switching between polling and interrupt mode for a ring buffer of a network interface card
US7937499B1
