Data processing method and device, equipment, storage medium and vehicle
Patent Information
- Application Number
- CN202310312596.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-28
- Publication Date
- 2024-10-01
AI Technical Summary
In the prior art, during the data transmission process, when the data to be sent crosses the end of the ring buffer queue, two copies of the data are required to copy the data to the temporary buffer area, resulting in reduced data transmission efficiency.
Determine the cache area of the data to be sent in the ring cache queue, and copy it to the target cache queue. The length of the target cache queue is half the length of the ring cache queue, including the forward and backward cache queues, ensuring that sendPtr and length are valid. performance, reducing the number of copies and the amount of data copied.
By reducing the number and volume of data copies, the efficiency of data transmission is improved, CPU occupancy time and packet processing delay are reduced, and the overall bandwidth is improved.
Smart Images

Figure CN118740928A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of communication technology, and in particular, relates to a data processing method, device, equipment, storage medium and vehicle. Background Art
[0002] In the field of communication technology, Ethernet and Transmission Control Protocol / Internet Protocol (TCP / IP) protocol stacks are usually used for data transmission. The upper-layer application of the AUTomotive Open System Architecture (AUTOSAR) can process the data transmitted by the TCP / IP protocol stack to implement the corresponding functions. Usually, the socket adapter layer (SoAd) can be located between the TCP / IP protocol stack and the upper-layer application of AUTOSAR, which is used to cache the data sent by the TCP / IP protocol stack and transmit the data to the upper-layer application when the upper-layer application needs to process the data. In order to cache data, a circular buffer queue can be created in SoAd. When transmitting data, SoAd needs to provide the upper-layer application with the address sendPtr and size length of the data to be sent in the circular buffer queue. If the data to be sent spans the tail of the circular buffer queue, the upper-layer application cannot obtain the required data based on sendPtr and length.
[0003] In order to enable the upper layer application to successfully obtain the required data, the prior art usually copies all the data to be sent to a temporary buffer area twice to ensure the validity of sendPtr and length. However, the above data processing method will reduce the data transmission efficiency. Summary of the invention
[0004] The embodiments of the present application provide a data processing method, apparatus, device, storage medium and vehicle, which can improve the data transmission efficiency.
[0005] In a first aspect, an embodiment of the present application provides a data processing method, the method comprising:
[0006] Determine a cache area for data to be sent in a circular cache queue, wherein the circular cache queue is connected end to end with a corresponding target cache queue, the length of the target cache queue is half the length of the circular cache queue, the target cache queue includes any one of a forward cache queue and a backward cache queue, the tail of the forward cache queue is connected to the head of the circular cache queue, and the head of the backward cache queue is connected to the tail of the circular cache queue;
[0007] In a case where the data to be sent crosses the tail of the circular buffer queue, determining a buffer sub-region corresponding to the data to be sent in the buffer region, the buffer sub-region including any one of the head buffer region and the tail buffer region of the circular buffer queue;
[0008] The to-be-sent data in the cache sub-area is copied to a target cache queue corresponding to the cache sub-area.
[0009] In a possible implementation manner, before copying the to-be-sent data in the cache sub-region to a target cache queue corresponding to the cache sub-region, the method further includes:
[0010] Determine the size relationship between the amount of data corresponding to the head buffer area and the amount of data corresponding to the tail buffer area;
[0011] The step of copying the to-be-sent data in the cache sub-area to a target cache queue corresponding to the cache sub-area includes:
[0012] When the amount of data corresponding to the head buffer area is less than the amount of data corresponding to the tail buffer area, copying the to-be-sent data in the head buffer area to the backward buffer queue;
[0013] When the amount of data corresponding to the head buffer area is not less than the amount of data corresponding to the tail buffer area, the to-be-sent data in the tail buffer area is copied to the forward buffer queue.
[0014] In a possible implementation, the cache control structure corresponding to the ring cache queue includes a free cache start position, a cache data start position, and a queue head position. After copying the to-be-sent data in the cache sub-area to a target cache queue corresponding to the cache sub-area, the method further includes:
[0015] Sending the data to be sent to an upper layer application;
[0016] Determining whether there is cache data in the circular cache queue;
[0017] In the case that the cache data does not exist in the circular cache queue, the free cache start position and the cache data start position are both moved to the head position corresponding to the circular cache queue.
[0018] In a possible implementation, determining whether cache data exists in the circular cache queue includes:
[0019] Acquire the free cache starting position and the cache data starting position corresponding to the circular cache queue;
[0020] When the free cache start position and the cache data start position are the same position, it is determined that the cache data does not exist in the circular cache queue.
[0021] In a possible implementation, the cache control structure corresponding to the circular cache queue also includes the size of the cache data, and the determining whether there is cache data in the circular cache queue further includes:
[0022] Obtaining the size of the cache data corresponding to the circular cache queue;
[0023] When the size of the cached data is zero, it is determined that the cached data does not exist in the circular cache queue.
[0024] In a possible implementation, determining a buffer area for data to be sent in the ring buffer queue includes:
[0025] A cache area for data to be sent is determined in a first circular cache queue, wherein the first circular cache queue and the second circular cache queue share the same target cache queue, wherein the forward cache queue of the first circular cache queue is the backward cache queue of the second circular cache queue, or the backward cache queue of the first circular cache queue is the forward cache queue of the second circular cache queue.
[0026] In a second aspect, an embodiment of the present application provides a data processing device, the device comprising:
[0027] A first determining module is used to determine a cache area of data to be sent in a circular cache queue, wherein the length of the target cache queue is half of the length of the circular cache queue, the circular cache queue is connected end to end with its corresponding target cache queue, the target cache queue includes any one of a forward cache queue and a backward cache queue, the tail of the forward cache queue is connected to the head of the circular cache queue, and the head of the backward cache queue is connected to the tail of the circular cache queue;
[0028] A second determining module is used to determine, in the cache area, a cache sub-area corresponding to the data to be sent when the data to be sent crosses the tail of the circular cache queue, the cache sub-area including any one of the head cache area and the tail cache area of the circular cache queue;
[0029] The copy module is used to copy the to-be-sent data in the cache sub-area to a target cache queue corresponding to the cache sub-area.
[0030] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device comprising: a processor and a memory storing computer program instructions;
[0031] When the processor executes the computer program instructions, the processor implements any possible implementation method of the first aspect described above.
[0032] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, implements a method in any possible implementation method of the first aspect described above.
[0033] In a fifth aspect, an embodiment of the present application provides a vehicle, the vehicle comprising at least one of the following:
[0034] A data processing device as in any one of the embodiments of the second aspect;
[0035] An electronic device as in any one of the embodiments of the third aspect;
[0036] A computer-readable storage medium as in any embodiment of the fourth aspect.
[0037] In the data processing method, device, equipment, storage medium and vehicle of the embodiment of the present application, since the target cache queue includes any one of the forward cache queue and the backward cache queue, and the tail of the forward cache queue is connected to the head of the circular cache queue, and the head of the backward cache queue is connected to the tail of the circular cache queue, therefore, by copying the data to be sent in the cache sub-area to the target cache queue corresponding to the cache sub-area, the validity of sendPtr and length can be ensured. Since the cache sub-area includes any one of the head cache area and the tail cache area of the circular cache queue, that is, only the data to be sent in the head cache area or the data to be sent in the tail cache area is copied, so the number of copies and the amount of data copied can be reduced. Since the length of the target cache queue is half the length of the circular cache queue, it can be guaranteed that the data is copied at most once in the process of transmitting data to the upper-level application. In this way, through the embodiment of the present application, the data transmission efficiency can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0039] Figure 1 is a schematic diagram of AUTOSAR-based data transmission provided in an embodiment of the present application;
[0040] Figure 2 It is a schematic diagram of a corresponding relationship between a cache control structure and a ring receiving cache area provided in an embodiment of the present application;
[0041] Figure 3 It is a schematic diagram of two scenarios of cache data in a circular cache queue provided by an embodiment of the present application;
[0042] Figure 4 This is a schematic diagram of a cached data that does not cross the end of a queue provided by an embodiment of the present application;
[0043] Figure 5 This is a schematic diagram of a cache data crossing the tail of a queue provided by an embodiment of the present application;
[0044] Figure 6 It is a flowchart of a data processing method provided in an embodiment of the present application;
[0045] Figure 7 is a schematic diagram of a corresponding relationship between another buffer control structure and a ring receiving buffer area provided in an embodiment of the present application;
[0046] Figure 8 is a schematic diagram of a data processing method provided in an embodiment of the present application;
[0047] Fig. 9 is a schematic diagram of another data processing method provided in an embodiment of the present application;
[0048] Fig.10 is a schematic diagram of another data processing method provided in an embodiment of the present application;
[0049] Fig.11 It is a flowchart of another data processing method provided in an embodiment of the present application;
[0050] Fig.12 is a structural schematic diagram of a data processing device provided in an embodiment of the present application;
[0051] Fig.13 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0053] In the following description, many specific details are set forth to facilitate a full understanding of the present application, but the present application may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only part of the embodiments of the present application, rather than all of the embodiments.
[0054] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprises" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0055] As described in the background technology, the socket adaptor (SoAd) can be located between the TCP / IP protocol stack and the upper-layer application of AUTOSAR, and is used to cache the data sent by the TCP / IP protocol stack, and transmit data to the upper-layer application when the upper-layer application needs to process the data. Among them, the AUTOSAR standard follows the concept of static communication relationship, that is, it is predetermined at compile time and strictly enforced at runtime. The AUTOSAR communication service module is based on the transmission of protocol data unit (PDU), and the source and destination of the transmitted data are predetermined at compile time. Among them, PDU can be the data format for communication between upper-layer applications. Socket Adaptor can provide PDU-based AUTOSAR communication services on the basis of the TCP / IP protocol stack by establishing a predetermined configuration (including the information required by AUTOSAR) and opening some options for updating at runtime. In addition, the Socket Adaptor module can decouple the callback-based AUTOSAR software architecture from the socket-based communication processing in TCP / IP, and create an interface between the PDU-based AUTOSAR communication service module and the socket-based TCP / IP protocol stack to map the PDU ID to the socket connection and vice versa.
[0056] Based on this, the schematic diagram of AUTOSAR-based data transmission can be as follows Figure 1As shown. Among them, the TCP / IP network protocol stack can receive Ethernet messages sent by the vehicle-mounted Ethernet switch, and then perform data transmission based on the messages. In addition, the receiving cache may include a circular cache queue and its corresponding cache control structure, and the circular cache queue may specifically be a circular receiving cache queue. Generally, the circular cache queue can also be called a circular cache area, and the circular receiving cache queue can also be called a circular receiving cache area. A circular cache queue can correspond to a cache control structure.
[0057] In the prior art, the corresponding relationship between the buffer control structure and the ring receiving buffer area can be as follows: Figure 2 As shown. The ring buffer control structure may include buffer, head, tail and size. Among them, the buffer pointer may point to the head of the ring buffer area, the head may save the starting position of the cached data, the tail may save the starting position of the free cache, and the size may indicate the length of the ring buffer queue.
[0058] When SoAd transmits data to the upper layer application, SoAd needs to provide the upper layer application with the address sendPtr and size length of the data to be sent in the circular buffer queue. Figure 3 The two scenarios shown in FIG. 1 are as follows. Therefore, when a circular buffer queue is used to transmit data to an upper layer application, the following two situations are usually encountered.
[0059] Case 1: If Figure 4 As shown, if the data to be sent does not cross the tail of the queue, directly point sendPtr to the head position, and then provide sendPtr and the size of the data to be sent to the upper-layer application.
[0060] Case 2: If Figure 5 As shown, if the data to be sent crosses the end of the queue, a temporary buffer area is usually provided in the prior art, and then the data to be sent is copied to the temporary buffer area through the following two steps:
[0061] (1) copying the data to be sent in the tail buffer area of the ring buffer area to the head buffer area of the temporary buffer area;
[0062] (2) The data to be sent in the head buffer area of the ring buffer area is copied to an area of the temporary buffer area that is adjacent to the head buffer area and located after the head buffer area.
[0063] In this way, sendPtr is pointed to the head of the queue in the temporary buffer, and then sendPtr and length are provided to the upper-level application.
[0064] If the data to be sent crosses the end of the queue, the defects of the solutions in the prior art are: (1) it is necessary to copy all the data to be sent to the temporary buffer area through two memory copies; (2) the amount of data to be copied is the amount of data corresponding to all the data to be sent. Here, the number of copies and the amount of copied data are both large, which will reduce the data transmission efficiency. In addition, multiple copies and copying all the data to be sent will cause performance consumption.
[0065] Therefore, in order to solve the problems of the prior art, the embodiments of the present application provide a data processing method, device, equipment, storage medium and vehicle.
[0066] The following first introduces the data processing method provided in the embodiment of the present application.
[0067] Figure 6 FIG. 1 is a flow chart of a data processing method provided by an embodiment of the present application. Figure 6 As shown, the data processing method provided in the embodiment of the present application includes the following steps:
[0068] S610, determining a cache area for data to be sent in a circular cache queue, the circular cache queue and its corresponding target cache queue are connected end to end, the length of the target cache queue is half the length of the circular cache queue, the target cache queue includes any one of a forward cache queue and a backward cache queue, the tail of the forward cache queue is connected to the head of the circular cache queue, and the head of the backward cache queue is connected to the tail of the circular cache queue;
[0069] S620: When the data to be sent crosses the tail of the circular buffer queue, determine a buffer sub-region corresponding to the data to be sent in the buffer region, where the buffer sub-region includes any one of the head buffer region and the tail buffer region of the circular buffer queue;
[0070] S630: Copy the to-be-sent data in the cache sub-region to a target cache queue corresponding to the cache sub-region.
[0071] In the data processing method of the embodiment of the present application, since the target cache queue includes any one of the forward cache queue and the backward cache queue, and the tail of the forward cache queue is connected to the head of the circular cache queue, and the head of the backward cache queue is connected to the tail of the circular cache queue, the validity of sendPtr and length can be ensured by copying the data to be sent in the cache sub-area to the target cache queue corresponding to the cache sub-area. Since the cache sub-area includes any one of the head cache area and the tail cache area of the circular cache queue, that is, only the data to be sent in the head cache area or the data to be sent in the tail cache area is copied, so the number of copies and the amount of data copied can be reduced. Since the length of the target cache queue is half the length of the circular cache queue, it can be guaranteed that the data is copied at most once in the process of transmitting data to the upper-level application. In this way, through the embodiment of the present application, the data transmission efficiency can be improved.
[0072] The specific implementation methods of the above steps are introduced below.
[0073] In some embodiments, in S610, a cache control structure may point to a circular cache queue. Wherein, each circular cache queue pointed to by the cache control structure may be connected end to end with its corresponding target cache queue. The target cache queue may be a cache queue specially opened to reduce the number of data copies, and the length of the target cache queue may specifically be half the length of the circular cache queue. The target cache queue corresponding to the circular cache queue may include any one of a forward cache queue and a backward cache queue. Wherein, the tail of the forward cache queue may be connected to the head of the circular cache queue, and the head of the backward cache queue may be connected to the tail of the circular cache queue.
[0074] In the embodiment of the present application, the target cache queue can also be referred to as the target cache area. Correspondingly, the backward cache queue can be referred to as the backward cache area, and the forward cache queue can be referred to as the forward cache area. Based on this, the corresponding relationship between the cache control structure and the ring receiving cache area can be as follows: Figure 7 As shown. Among them, the cache control structure corresponding to different circular receiving buffers can be the same. The cache control structure can include buffer, head, tail and size. In addition, the cache control structure can also include data_length, and data_length can store the size of the cached data. The cached data can be all the data in the circular cache queue, and the cached data can include data to be sent. That is, the data to be sent can be all the cached data or part of the cached data. If the cache control structure includes data_length, the specific data structure of the cache control structure can be as follows:
[0075]
[0076]
[0077] As an example, the cache area may be the area between the head and the tail (excluding the tail). Figure 3 As shown, the cache area can be an area between 3 and n as shown in scenario one, or an area between 4094 and n as shown in scenario two.
[0078] Based on this, in order to reduce resource consumption, in some embodiments, the above S610 may specifically include:
[0079] A cache area for data to be sent is determined in a first circular cache queue, and the first circular cache queue and the second circular cache queue share the same target cache queue, wherein the forward cache queue of the first circular cache queue is the backward cache queue of the second circular cache queue, or the backward cache queue of the first circular cache queue is the forward cache queue of the second circular cache queue.
[0080] Here, since the first circular buffer queue and the adjacent second circular buffer queue can share the same target buffer queue, the buffer space allocated for buffering data can be saved, thereby reducing resource consumption.
[0081] In some embodiments, in S620, if the cache area satisfies the inequality head+length>size, it can be determined that the data to be sent spans the tail of the target circular buffer queue. In addition, the head cache area can be the area between buffer and tail (excluding tail), and the tail cache area can be the area between head and tail.
[0082] As an example, Figure 3 As shown in the scenario 2 in , since the cache area satisfies the inequality head+length>size, the data to be sent spans the tail of the target circular cache queue. That is, the cache area can include both the head position 0 and the tail position 4095 of the target circular cache queue. At this time, the cache sub-area can include the area between 4094 and 4095 (i.e., the tail cache area) and the area between 0 and n (i.e., the head cache area).
[0083] In some embodiments, in S630, if the cache sub-region is a head cache region, the target cache queue corresponding to the head cache region may be a backward cache queue (i.e., a backward cache area). If the cache sub-region is a tail cache region, the target cache queue corresponding to the tail cache region may be a forward cache queue (i.e., a forward cache area).
[0084] Based on this, in order to further improve the efficiency of data transmission, in some embodiments, before the above S630, the following steps may also be included:
[0085] Determine the size relationship between the amount of data corresponding to the cache area at the head of the queue and the amount of data corresponding to the cache area at the tail of the queue;
[0086] Based on this, the above S630 may specifically include:
[0087] When the amount of data corresponding to the buffer area at the head of the team is less than the amount of data corresponding to the buffer area at the tail of the team, the data to be sent in the buffer area at the head of the team is copied to the backward buffer queue;
[0088] When the amount of data corresponding to the head buffer area is not less than the amount of data corresponding to the tail buffer area, the data to be sent in the tail buffer area is copied to the forward buffer queue.
[0089] Here, the amount of data corresponding to the head buffer area may specifically be the data length head_length of the data to be sent in the head buffer area. The calculation method of head_length may be as follows:
[0090] head_length=head+length-size.
[0091] The amount of data corresponding to the tail buffer area may specifically be the data length tail_length of the data to be sent in the tail buffer area. The calculation method of tail_length may be as follows:
[0092] tail_length=size-head.
[0093] In this way, after obtaining the data volume corresponding to the cache area at the head of the team and the data volume corresponding to the cache area at the tail of the team through the above calculation method, by preferentially copying the data with smaller data volume, the time of data copying can be reduced, and the efficiency of data transmission can be further improved. In addition, if the data volume corresponding to the cache area at the head of the team is equal to the data volume corresponding to the cache area at the tail of the team, it is not limited to copying the data to be sent in the cache area at the head of the team or the data to be sent in the cache area at the tail of the team.
[0094] Based on this, in order to further improve the data transmission efficiency, in some embodiments, after the above S630, the following steps may also be included:
[0095] Send the data to be sent to the upper layer application;
[0096] Determine whether cached data exists in the ring cache queue;
[0097] When there is no cache data in the circular cache queue, both the free cache start position and the cache data start position are moved to the head position corresponding to the circular cache queue.
[0098] Here, after the data copy is completed, the address sendPtr and size length of the data to be sent in the circular cache queue can be provided to the upper-layer application, so that the upper-layer application can obtain the data to be sent according to sendPtr and length. After the data to be sent is sent, it can be determined whether there is cached data in the circular cache queue. Since the head can save the starting position of the cached data and the tail can save the starting position of the free cache, if there is no cached data in the circular cache queue after the data to be sent is sent, the head pointer can remain unchanged and the tail pointer can be moved to the head pointer. That is, if there is no cached data in the circular cache queue, the tail pointer and the head pointer can point to the same position in the circular cache queue. In this case, if data is cached again in this circular cache queue, the data can be cached starting from the head position.
[0099] Based on this, since the buffer pointer can point to the head position of the circular buffer queue, when there is no cached data in the circular buffer queue, the tail pointer and the head pointer are moved to point to the head position of the circular buffer queue, that is, the tail pointer and the head pointer are moved to the buffer pointer, so that when data is cached again in this circular buffer queue, data can be cached from the head position. In this way, the occurrence of data crossing the tail of the queue can be reduced, and the data transmission efficiency can be further improved.
[0100] As an example, Figure 8 As shown in the figure, since head+length>4096, or head+length>buffer+4096, it can be determined that the data to be sent this time crosses the tail of the circular buffer. And since head_length<tail_length, the data to be sent in the head buffer area can be copied to the backward buffer area. After the copy is completed, sendPtr can point to head. In this way, by providing sendPtr and length to the upper-layer application, the data to be sent can be sent to the upper-layer application. Figure 8 It can be seen that after the data to be sent is sent, there is no cached data in the circular buffer, so the head and tail can be moved to the head position pointing to the circular buffer.
[0101] As another example, Fig. 9As shown in the figure, since head+length>4096, or head+length>buffer+4096, it can be determined that the data to be sent this time crosses the tail of the circular buffer. And since head_length>tail_length, the data to be sent in the tail buffer area can be copied to the forward buffer area. After the copy is completed, sendPtr can point to head. In this way, by providing sendPtr and length to the upper-layer application, the data to be sent can be sent to the upper-layer application. Fig. 9 It can be seen that after the data to be sent is sent, there is no cached data in the circular buffer, so the head and tail can be moved to the head position pointing to the circular buffer.
[0102] As another example, Fig.10 As shown in the figure, since head+length<4096, or head+length<buffer+4096, it can be determined that the data to be sent this time does not cross the tail of the circular buffer. Therefore, sendPtr can be directly pointed to head, and sendPtr and length can be provided to the upper layer application. Fig.10 It can be seen that after the data to be sent is sent, there is no cached data in the circular buffer, so the head and tail can be moved to the head position pointing to the circular buffer.
[0103] Based on this, in order to accurately determine whether there is cached data in the ring cache queue, in some embodiments, the above determination of whether there is cached data in the ring cache queue may specifically include:
[0104] Get the free buffer start position and buffer data start position corresponding to the circular buffer queue;
[0105] When the free buffer start position and the buffer data start position are the same position, it is determined that there is no buffer data in the circular buffer queue.
[0106] Based on this, in order to improve the efficiency of determining whether there is cached data in the circular cache queue, in some embodiments, the above-mentioned determination whether there is cached data in the circular cache queue may further include:
[0107] Get the size of the cache data corresponding to the ring cache queue;
[0108] When the size of the cached data is zero, it is determined that no cached data exists in the circular cache queue.
[0109] Here, the cache control structure may include data_length, and the size of the cached data may be stored in data_length. If the value of data_length is 0, it may be determined that there is no cached data in the circular cache queue.
[0110] In this way, by setting data_length in the cache control structure to store the size of the cached data, the efficiency of determining whether there is cached data in the circular cache queue can be improved.
[0111] In order to better describe the entire solution, some specific examples are given based on the above embodiments.
[0112] For example, Fig.11 As shown, the data processing method in the embodiment of the present application may specifically include the following steps:
[0113] S111, determine whether the data to be sent crosses the tail of the circular buffer, if so, execute S112, if not, execute S115;
[0114] S112, determine whether the amount of data in the buffer area at the head of the team is greater than the amount of data in the buffer area at the tail of the team, if so, execute S113, if not, execute S114;
[0115] S113, copying the data to be sent in the tail buffer area to the forward buffer area;
[0116] S114, copying the data to be sent in the head buffer area to the backward buffer area;
[0117] S115, provide sndPtr and length to the upper layer application to transmit data;
[0118] S116, determine whether there is cache data in the circular buffer area, if yes, execute S117, if no, end;
[0119] S117. Move head and tail to point to the head of the team.
[0120] For another example, taking the case where the ring buffer queue length is 4096 bytes and the average PDU length is 1400 bytes, the number of copies and the number of bytes copied of the prior art and the embodiment of the present application under different bandwidths are compared. The comparison results can be shown in Table 1.
[0121] Table 1
[0122]
[0123]
[0124] In this way, the number of memory copies and the amount of memory copied data can be effectively reduced during the data transmission from the Soad receiving buffer to the upper-level application. By reducing the number of memory copies and the amount of memory copied data, the CPU usage time of the current message processing task can be reduced, the overall operation efficiency of the system can be improved, and the processing of the current message can be accelerated, effectively reducing the delay of message processing and improving the overall bandwidth.
[0125] Based on the data processing method provided in the above embodiment, the present application also provides a specific implementation of a data processing device. Please refer to the following embodiment.
[0126] like Fig.12 As shown, the data processing device 1200 provided in the embodiment of the present application includes the following modules:
[0127] The first determining module 1210 is used to determine a buffer area of data to be sent in a circular buffer queue, the circular buffer queue is connected end to end with its corresponding target buffer queue, the length of the target buffer queue is half the length of the circular buffer queue, the target buffer queue includes any one of a forward buffer queue and a backward buffer queue, the tail of the forward buffer queue is connected to the head of the circular buffer queue, and the head of the backward buffer queue is connected to the tail of the circular buffer queue;
[0128] A second determining module 1220 is used to determine, in a cache area, a cache sub-area corresponding to the transmitted data when the data to be transmitted crosses the tail of the circular cache queue, the cache sub-area including any one of the head cache area and the tail cache area of the circular cache queue;
[0129] The copy module 1230 is used to copy the to-be-sent data in the cache sub-region to the target cache queue corresponding to the cache sub-region.
[0130] The data processing device 1200 is described in detail below, as follows:
[0131] In some embodiments, the data processing device 1200 may further include:
[0132] A third determination module is used to determine the size relationship between the amount of data corresponding to the head cache area and the amount of data corresponding to the tail cache area before copying the to-be-sent data in the cache sub-area to the target cache queue corresponding to the cache sub-area;
[0133] Based on this, the copy module 1230 may specifically include:
[0134] The first copy submodule is used to copy the to-be-sent data in the head buffer area to the backward buffer queue when the amount of data corresponding to the head buffer area is less than the amount of data corresponding to the tail buffer area;
[0135] The second copy submodule is used to copy the to-be-sent data in the tail buffer area to the forward buffer queue when the data amount corresponding to the head buffer area is not less than the data amount corresponding to the tail buffer area.
[0136] In some embodiments, the cache control structure corresponding to the circular cache queue includes a free cache start position, a cache data start position and a queue head position. Based on this, the data processing device 1200 may also include:
[0137] A sending module, used for copying the data to be sent in the cache sub-area to the target cache queue corresponding to the cache sub-area, and then sending the data to be sent to the upper layer application;
[0138] A fourth determination module, used to determine whether there is cache data in the ring cache queue;
[0139] The moving module is used to move both the free cache start position and the cache data start position to the head position corresponding to the circular cache queue when there is no cache data in the circular cache queue.
[0140] In some embodiments, the fourth determining module may specifically include:
[0141] A first acquisition submodule, used to acquire a free cache start position and a cache data start position corresponding to the circular cache queue;
[0142] The first determining submodule is used to determine that there is no cache data in the circular cache queue when the free cache start position and the cache data start position are the same position.
[0143] In some embodiments, the fourth determining module may further include:
[0144] A second acquisition submodule is used to acquire the size of the cache data corresponding to the circular cache queue;
[0145] The second determining submodule is used to determine that there is no cached data in the circular cache queue when the size of the cached data is zero.
[0146] In some embodiments, the first determining module 1210 may specifically include:
[0147] The third determination submodule is used to determine the cache area of the data to be sent in the first circular cache queue, the first circular cache queue and the second circular cache queue share the same target cache queue, wherein the forward cache queue of the first circular cache queue is the backward cache queue of the second circular cache queue, or the backward cache queue of the first circular cache queue is the forward cache queue of the second circular cache queue.
[0148] In the data processing device of the embodiment of the present application, since the target cache queue includes any one of the forward cache queue and the backward cache queue, and the tail of the forward cache queue is connected to the head of the circular cache queue, and the head of the backward cache queue is connected to the tail of the circular cache queue, the validity of sendPtr and length can be ensured by copying the data to be sent in the cache sub-area to the target cache queue corresponding to the cache sub-area. Since the cache sub-area includes any one of the head cache area and the tail cache area of the circular cache queue, that is, only the data to be sent in the head cache area or the data to be sent in the tail cache area is copied, so the number of copies and the amount of data copied can be reduced. Since the length of the target cache queue is half the length of the circular cache queue, it can be guaranteed that the data is copied at most once in the process of transmitting data to the upper-level application. In this way, through the embodiment of the present application, the data transmission efficiency can be improved.
[0149] Based on the data processing method provided in the above embodiment, the embodiment of the present application also provides a specific implementation of the electronic device. Fig.13 A schematic diagram of an electronic device 1300 provided in an embodiment of the present application is shown.
[0150] The electronic device 1300 may include a processor 1310 and a memory 1320 storing computer program instructions.
[0151] Specifically, the processor 1310 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0152] The memory 1320 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 1320 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 1320 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 1320 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 1320 is a non-volatile solid-state memory.
[0153] The memory may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Thus, typically, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to the first aspect of the present application.
[0154] The processor 1310 implements any one of the data processing methods in the above embodiments by reading and executing computer program instructions stored in the memory 1320 .
[0155] In one example, the electronic device 1300 may further include a communication interface 1330 and a bus 1340. Fig.13 As shown, the processor 1310, the memory 1320, and the communication interface 1330 are connected via a bus 1340 and communicate with each other.
[0156] The communication interface 1330 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0157] Bus 1340 includes hardware, software or both, and the parts of electronic equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front side bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 1340 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the application considers any suitable bus or interconnection.
[0158] Exemplarily, the electronic device 1300 may be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA).
[0159] The electronic device can execute the data processing method in the embodiment of the present application, thereby realizing the combination Figures 6 to 12 The data processing method and device described.
[0160] In addition, in combination with the data processing method in the above embodiments, the present application embodiment can provide a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any one of the data processing methods in the above embodiments is implemented.
[0161] In addition, the embodiment of the present application further provides a vehicle, which may include at least one of the following:
[0162] A data processing device as in any one of the embodiments of the second aspect;
[0163] An electronic device as in any one of the embodiments of the third aspect;
[0164] The computer-readable storage medium in any one of the embodiments of the fourth aspect will not be described in detail here.
[0165] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0166] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0167] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0168] The above reference is according to the method of the embodiment of the present application, the flow chart of the device (system) and the computer program product and / or the block diagram described various aspects of the present application.It should be understood that each square box in the flow chart and / or the block diagram and the combination of each square box in the flow chart and / or the block diagram can be realized by computer program instructions.These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the realization of the function / action specified in one or more square boxes of the flow chart and / or the block diagram.Such a processor can be but is not limited to a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit.It can also be understood that each square box in the block diagram and / or the flow chart and the combination of the square boxes in the block diagram and / or the flow chart can also be realized by the dedicated hardware that performs the specified function or action, or can be realized by the combination of dedicated hardware and computer instructions.
[0169] The above is only a specific implementation of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.
Claims
1. A data processing method, characterized in that: include: Determine a cache area for data to be sent in a circular cache queue, wherein the circular cache queue is connected end to end with a corresponding target cache queue, the length of the target cache queue is half the length of the circular cache queue, the target cache queue includes any one of a forward cache queue and a backward cache queue, the tail of the forward cache queue is connected to the head of the circular cache queue, and the head of the backward cache queue is connected to the tail of the circular cache queue; In a case where the data to be sent crosses the tail of the circular buffer queue, determining a buffer sub-region corresponding to the data to be sent in the buffer region, the buffer sub-region including any one of the head buffer region and the tail buffer region of the circular buffer queue; The to-be-sent data in the cache sub-area is copied to a target cache queue corresponding to the cache sub-area.
2. The method according to claim 1, characterized in that Before copying the to-be-sent data in the cache sub-area to a target cache queue corresponding to the cache sub-area, the method further includes: Determine the size relationship between the amount of data corresponding to the head buffer area and the amount of data corresponding to the tail buffer area; The step of copying the to-be-sent data in the cache sub-area to a target cache queue corresponding to the cache sub-area includes: When the amount of data corresponding to the head buffer area is less than the amount of data corresponding to the tail buffer area, copying the to-be-sent data in the head buffer area to the backward buffer queue; When the amount of data corresponding to the head buffer area is not less than the amount of data corresponding to the tail buffer area, the to-be-sent data in the tail buffer area is copied to the forward buffer queue.
3. The method according to claim 1, characterized in that: The cache control structure corresponding to the ring cache queue includes an idle cache start position, a cache data start position and a queue head position. After copying the to-be-sent data in the cache sub-area to a target cache queue corresponding to the cache sub-area, the method further includes: Sending the data to be sent to an upper layer application; Determining whether there is cache data in the circular cache queue; In the case that the cache data does not exist in the circular cache queue, the free cache start position and the cache data start position are both moved to the head position corresponding to the circular cache queue.
4. The method according to claim 3, characterized in that The determining whether there is cache data in the circular cache queue comprises: Acquire the free cache starting position and the cache data starting position corresponding to the circular cache queue; When the free cache start position and the cache data start position are the same position, it is determined that the cache data does not exist in the circular cache queue.
5. The method according to claim 3, characterized in that: The cache control structure corresponding to the circular cache queue also includes the size of the cache data, and the determining whether there is cache data in the circular cache queue further includes: Obtaining the size of the cache data corresponding to the circular cache queue; When the size of the cached data is zero, it is determined that the cached data does not exist in the circular cache queue.
6. The method according to claim 1, characterized in that Determining a cache area for data to be sent in the ring cache queue includes: A cache area for data to be sent is determined in a first circular cache queue, wherein the first circular cache queue and the second circular cache queue share the same target cache queue, wherein the forward cache queue of the first circular cache queue is the backward cache queue of the second circular cache queue, or the backward cache queue of the first circular cache queue is the forward cache queue of the second circular cache queue.
7. A data processing device, characterized in that: The device comprises: A first determining module is used to determine a cache area of data to be sent in a circular cache queue, wherein the circular cache queue is connected end to end with a corresponding target cache queue, the length of the target cache queue is half the length of the circular cache queue, the target cache queue includes any one of a forward cache queue and a backward cache queue, the tail of the forward cache queue is connected to the head of the circular cache queue, and the head of the backward cache queue is connected to the tail of the circular cache queue; A second determining module is used to determine, in the cache area, a cache sub-area corresponding to the data to be sent when the data to be sent crosses the tail of the circular cache queue, the cache sub-area including any one of the head cache area and the tail cache area of the circular cache queue; The copy module is used to copy the to-be-sent data in the cache sub-area to a target cache queue corresponding to the cache sub-area.
8. An electronic device, characterized in that: The electronic device comprises: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the data processing method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the data processing method according to any one of claims 1 to 6 is implemented.
10. A vehicle, characterized in that: Include at least one of the following: The data processing device according to claim 7; The electronic device as claimed in claim 8; The computer readable storage medium of claim 9.
Citation Information
Cited By
Data storage and sending method and device and Internet of Things system
CN119629140A
