Computer software data transmission method, device and equipment
By establishing a data queue in computer software data transmission and using the identification and effective length of data blocks to perform data operations, the problem of low data transmission efficiency in the prior art is solved, and efficient and low-latency data transmission is achieved.
Patent Information
- Application Number
- CN202411658768.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2044-11-20
AI Technical Summary
In the prior art, software data transmission efficiency is low, especially in high-frequency data interaction scenarios, due to the dependence of limited kernel resources such as mutex locks and semaphores, the transmission efficiency is reduced.
By establishing a data queue, the data queue includes multiple data blocks, each data block contains an identity, an effective length and a data area. The data sending and receiving end respectively detect the identification as empty or non-empty states in the order of the data blocks, complete the data writing and reading operations, and avoid the use of mutex locks and semaphores.
It realizes that without relying on limited kernel resources, ensures the efficiency of data transmission and reduces delays, and maintains the same high efficiency whether it is large data blocks or small data blocks.
Smart Images

Figure CN119166392B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer software communication technology, and in particular to a method, device and equipment for transmitting computer software data. Background Art
[0002] The transmission of computer software data can refer to exchanging software data from one thread to another, or exchanging software data from one process to another. In the process of software data transmission, mutexes and semaphores are often used to control software data, and the synchronization of software data is completed with the help of computer system kernel resources.
[0003] However, mutexes (applying for locks / releasing locks) and semaphores (applying for resources / releasing resources) are both time-consuming operations. At the same time, mutexes and semaphores are limited kernel resources. Therefore, relying on mutexes and semaphores to complete data transmission will have a certain impact on transmission efficiency, especially in high-frequency data interaction scenarios. Each transmission and reception of data will access kernel resources. At this time, limited kernel resources will seriously reduce the efficiency of data transmission. The higher the frequency of data transmission, the lower the data transmission efficiency. Summary of the invention
[0004] The present invention provides a method, device and equipment for transmitting computer software data, so as to solve the technical problem of low software data transmission efficiency in the prior art.
[0005] In one aspect, the present invention provides a method for transmitting computer software data, comprising:
[0006] Applying for memory space, and establishing a data queue in the memory space; wherein the data queue includes a plurality of data blocks, each of which includes an identifier, a valid length and a data area;
[0007] Initializing the data queue to determine the size and total number of data blocks in the data queue, and setting the identifier and data area of each data block in the data queue to an empty state;
[0008] Start a data sending end and a data receiving end of computer software data;
[0009] Control the data sending end to detect the target data block marked as empty according to the sequence of the data blocks in the data queue, write the computer software data to be transmitted into the data area of the target data block, record the actual length of the written data in the effective length, and set the mark of the target data block to a non-empty state;
[0010] The control data receiving end detects the target data block marked as non-empty according to the sequence of data blocks in the data queue, obtains data in the data area based on the effective length of the target data block marked as non-empty, and sets the mark of the target data block after obtaining the data to empty state.
[0011] According to a computer software data transmission method provided by the present invention, when there are multiple data queues, the sizes of data blocks of the data queues are different;
[0012] After the data queue is initialized, the method further includes:
[0013] Comparing the data length of the computer software data to be transmitted with the data length of the data blocks in each of the data queues to obtain a comparison result;
[0014] Based on the comparison result, a target queue whose data length of the data block is greater than or equal to the data length of the computer software data to be transmitted is selected from each of the data queues;
[0015] Selecting one of the target queues as a final queue;
[0016] Controlling the data sending end to detect the target data block marked as being in an empty state according to the sequence of the data blocks in the data queue, including:
[0017] The data sending end is controlled to detect the target data block marked as being in an empty state according to the sequence of the data blocks in the final queue.
[0018] According to a computer software data transmission method provided by the present invention, the step of selecting one of the target queues as a final queue comprises:
[0019] The one with the smallest data length of the data block is selected from each of the target queues as the final queue.
[0020] According to a computer software data transmission method provided by the present invention, when there are multiple data queues and there are also multiple data receiving ends which are less than the number of the data queues, the control data receiving end detects the target data block marked as a non-empty state according to the sequence of the data blocks in the data queue, including:
[0021] Based on the amount of data transmitted by each of the data queues, each of the data queues is grouped to obtain a plurality of queue groups; wherein the number of the queue groups is the same as the number of the data receiving ends;
[0022] Determining the corresponding relationship between each of the queue groups and each of the data receiving ends;
[0023] Control each of the data receiving ends to detect the target data blocks marked as being in a non-empty state in the data queues in the corresponding queue groups in sequence according to the sequence of the data blocks.
[0024] According to a computer software data transmission method provided by the present invention, the more data queues included in the queue group, the smaller the amount of data transmitted by a single data queue in the queue group;
[0025] The fewer the number of data queues included in the queue group, the larger the amount of data transmitted by a single data queue in the queue group.
[0026] According to a computer software data transmission method provided by the present invention, when there are multiple data queues and one data receiving end, the control data receiving end detects the target data block marked as a non-empty state according to the sequence of data blocks in the data queue, including:
[0027] The data receiving end is controlled to detect target data blocks marked as being in a non-empty state in each of the data queues in sequence according to the sequence of data blocks.
[0028] According to a computer software data transmission method provided by the present invention, when there are multiple data queues and multiple data receiving ends corresponding to the data queues one by one, the control data receiving end detects the target data block marked as a non-empty state according to the sequence of data blocks in the data queue, including:
[0029] Each of the data receiving ends is controlled to detect the target data blocks marked as being in a non-empty state in the corresponding data queues according to the sequence of the data blocks.
[0030] According to a computer software data transmission method provided by the present invention, the applying for memory space and establishing a data queue in the memory space further includes:
[0031] Establishing a connection between the first data block and the last data block in the data queue;
[0032] After setting the identifier of the target data block to a non-empty state, the method further includes:
[0033] Controlling the data sending end to point to the next data block;
[0034] If the next data block pointed to is the last data block, control the data sending end to point to the first data block;
[0035] After setting the identifier of the target data block after acquiring the data to an empty state, the method further includes:
[0036] Controlling the data receiving end to point to the next data block;
[0037] If the next data block pointed to is the last data block, the data receiving end is controlled to point to the first data block.
[0038] On the other hand, the present invention also provides a computer software data transmission device, comprising:
[0039] A queue creation module, used to apply for memory space and establish a data queue in the memory space; wherein the data queue includes a plurality of data blocks, each of which includes an identifier, a valid length and a data area;
[0040] An initialization module, used for initializing the data queue to determine the size and total number of data blocks in the data queue, and setting the identifier of each data block in the data queue to an empty state;
[0041] A startup module, used for starting a data sending end and a data receiving end of computer software data;
[0042] The sending module is used to control the data sending end to detect the target data block marked as empty according to the sequence of the data blocks in the data queue, write the computer software data to be transmitted into the data area of the target data block, record the actual length of the written data in the effective length, and set the mark of the target data block to a non-empty state;
[0043] The receiving module is used to control the data receiving end to detect the target data block marked as non-empty according to the sequence of data blocks in the data queue, obtain data in the data area based on the effective length of the target data block marked as non-empty, and set the mark of the target data block after obtaining the data to empty state.
[0044] On the other hand, the present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements any of the above-mentioned computer software data transmission methods.
[0045] The computer software data transmission method, device and equipment provided by the present invention establish a data queue, wherein the data queue includes multiple data blocks, control the data sending end to detect the target data block marked as empty according to the order of the data blocks in the data queue, write the computer software data to be transmitted into the data area of the target data block, record the actual length of the written data in the effective length, and set the mark of the target data block to a non-empty state, control the data receiving end to detect the target data block marked as non-empty according to the order of the data blocks in the data queue, obtain data in the data area based on the effective length of the target data block, and set the mark of the target data block after obtaining the data to an empty state. The data sending end and the data receiving end of this embodiment do not use kernel resources such as mutexes and semaphores, that is, the data transmission of this embodiment is not limited to limited kernel resources such as mutexes and semaphores, and whether it is a single large data block transmission or a small data block transmission, the same transmission efficiency can be guaranteed, which greatly reduces the delay of data transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0047] Figure 1 It is a flowchart of a method for transmitting computer software data provided by an embodiment of the present invention;
[0048] Figure 2 is a schematic diagram of the structure of a data block provided by an embodiment of the present invention;
[0049] Figure 3 is a schematic diagram of the structure of a data queue provided by an embodiment of the present invention;
[0050] Figure 4 is a schematic diagram of the structure of multiple data queues provided by an embodiment of the present invention;
[0051] Figure 5 It is a schematic diagram of the structure of a transmission device for computer software data provided by an embodiment of the present invention;
[0052] Figure 6 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0054] Figure 1 1 is a flow chart of a method for transmitting computer software data provided by an embodiment of the present invention. The execution subject of the method may be a computer, a mobile phone or a smart wearable device. Figure 1 , the computer software data transmission method may include the following steps 101 to 105.
[0055] 101. Apply for memory space and establish a data queue in the memory space; wherein the data queue includes multiple data blocks, and each data block includes an identifier, a valid length, and a data area.
[0056] In this step, the transmission of computer software data may include two situations, one of which is that the computer software data is transmitted between threads (that is, inside the computer application software), and the other is that the computer software data is transmitted between processes (that is, between different computer application software). When the software data is transmitted between threads, memory space can be directly applied for in the computer, and then the data queue is created. When the software data is transmitted between processes, the shared memory method can be used between processes to realize the creation of the data queue.
[0057] The structure of the data block can be found in Figure 2 , the data block may include three fields: "identifier", "valid length" and "data area". "Identifier" can generally occupy 1 byte (Byte), "valid length" can occupy 4 bytes (Byte), and the size of the data in the "data area" is determined by the maximum length of the data sent at a single time in the data queue. The identifier is used to indicate the state of the data in the data block. The empty state (for example, the identifier is 0) indicates that the data area is empty, or the data in the data area has been consumed by the data receiving end; the non-empty state (for example, the identifier is 1) indicates that the data in the data area is valid and has not been consumed by the data receiving end. "Valid length" is used to indicate the valid data length of the data in the data area. The maximum value of "valid length" cannot exceed the total size of the data that can be stored in the data area. The data area is used to store data. The actual valid length of the data in the data area is determined by the "valid length" field.
[0058] In the same data queue, the size of each data block is consistent. After the data sender and the data receiver complete the operation on a data block, they can offset a complete data block to reach the next data block. The consistent size of each data block can simplify the data transmission method of the data sender and the data receiver. Both the valid length and the data area are valid when the mark is in a non-empty state.
[0059] 102. Initialize the data queue to determine the size and total number of data blocks in the data queue, and set the identifier and data area of each data block in the data queue to an empty state.
[0060] In this step, when the data block in the data queue is first created, the data queue needs to be initialized. During initialization, the size and total number of data blocks can be assigned to the head of the data queue. The size of each data block in the data queue can also be called the single block size. The maximum length of data that can be transmitted by a data block at one time is "single block size minus ("identifier" + "valid length")". The total number of data blocks indicates the maximum number of data that can be cached in the data queue. The larger the "single block size", the higher the supported transmission bandwidth, the more total number of data blocks, and the stronger the jitter adaptability of the data receiving end.
[0061] 103. Start the data sending end and the data receiving end of the computer software data.
[0062] In this step, both the data sending end and the data receiving end can access the data queue in the memory space.
[0063] 104. Control the data sending end to detect the target data block marked as empty according to the sequence of data blocks in the data queue, write the computer software data to be transmitted into the data area of the target data block, record the actual length of the written data in the effective length, and set the mark of the target data block to a non-empty state.
[0064] In this embodiment, controlling the data sending end to detect the target data block marked as empty according to the order of data blocks in the data queue may specifically include: controlling the data sending end to point to the first data block according to the order of data blocks, if the mark of the first data block is in a non-empty state, indicating that the data queue is full, and the mark of the current data block (the first data block) may be detected in a non-interval and infinite polling manner until the "marker" shows an empty state, thereby obtaining the target data block. After writing the software data to the target data block, the mark of the data block may be set to a non-empty state, and then point to the next data block, and continue to detect the state of the mark of the next data block in the above non-interval and infinite polling manner.
[0065] 105. Control the data receiving end to detect the target data block marked as non-empty according to the sequence of the data blocks in the data queue, obtain data in the data area based on the effective length of the target data block marked as non-empty, and set the mark of the target data block after obtaining the data to empty.
[0066] In this step, the data receiving end is controlled to detect the target data block marked as non-empty according to the order of the data blocks in the data queue. Specifically, it may include: controlling the data receiving end to point to the first data block according to the order of the data blocks in the data queue. If the mark of the first data block is empty, it means that the data queue is empty and no new data is received. The mark of the current data block (the first data block) can be detected in a non-interval and infinite polling manner until the "marker" shows a non-empty state, and the target data block is obtained. When the non-empty state is detected, the data in the target data block is read in the above manner. After the data reading is completed, point to the next data block, and continue to detect the state of the mark of the next data block in the above non-interval and infinite polling manner.
[0067] In this embodiment, a data queue is established, wherein the data queue includes multiple data blocks, the data sending end is controlled to detect the target data block marked as empty according to the order of the data blocks in the data queue, the computer software data to be transmitted is written into the data area of the target data block, and the actual length of the written data is recorded in the effective length, and the mark of the target data block is set to a non-empty state, and the data receiving end is controlled to detect the target data block marked as non-empty according to the order of the data blocks in the data queue, and data is obtained in the data area based on the effective length of the target data block, and the mark of the target data block after the data is obtained is set to an empty state. The data sending end and the data receiving end of this embodiment do not use kernel resources such as mutexes and semaphores, that is, the data transmission of this embodiment is not limited to limited kernel resources such as mutexes and semaphores, and the same transmission efficiency can be guaranteed regardless of single large data block transmission or small data block transmission, which greatly reduces the delay of data transmission. When the data receiving end's ability to consume data is greater than the data sending end's ability to produce data and the processor time slice switching is not considered, the software data has almost zero delay from the data sending end to the data receiving end.
[0068] In an embodiment of the present specification, applying for memory space and establishing a data queue in the memory space may also include:
[0069] Establish a connection between the first data block and the last data block in the data queue;
[0070] After setting the identifier of the target data block to a non-empty state, the following may also be included:
[0071] Control the data sender to point to the next data block;
[0072] If the next data block pointed to is the last data block, the control data sending end points to the first data block;
[0073] After setting the identifier of the target data block after acquiring the data to an empty state, the following may also be included:
[0074] Control the data receiving end to point to the next data block;
[0075] If the next data block pointed to is the last data block, the control data receiving end points to the first data block.
[0076] In this embodiment, a connection is established between the first data block and the last data block in the data queue, that is, the data queue can be made into a circular data queue. Figure 3 As shown, the total number of data blocks is N, and the size of each data block is the same, for example, including data block 1, data block 2, data block 3, and so on, until data block N. Data block N is connected to data block 1 to form a loop. The data receiver can consume / read data in the data block, and the data sender can produce / write data in the data block. The circular data queue has many advantages, for example, it can save space: the circular data queue avoids frequent memory allocation and release, reducing the generation of memory fragmentation; improve efficiency: by recycling the data block space, the efficiency of the queue entry and exit operations is improved; avoid "false overflow": the circular data queue effectively utilizes the storage space through the head-to-tail loop structure, solving the "false overflow" problem of the sequential queue.
[0077] In one embodiment of the present specification, when there are multiple data queues, the sizes of data blocks of each data queue are different;
[0078] After initializing the data queue, you can also include:
[0079] Comparing the data length of the computer software data to be transmitted with the data length of the data blocks in each data queue to obtain a comparison result;
[0080] Based on the comparison result, a target queue whose data length of the data block is greater than or equal to the data length of the computer software data to be transmitted is selected from each data queue;
[0081] Select one from each target queue as the final queue;
[0082] Controlling the data sending end to detect the target data block marked as being in an empty state according to the sequence of the data blocks in the data queue may include:
[0083] The control data sending end detects the target data block marked as empty according to the sequence of the data blocks in the final queue.
[0084] In this embodiment, when there is only one data queue, it is necessary to ensure that the size of the "data area" of each data block in the data queue must be larger than the maximum data size that the data transmitter needs to send at one time, and each time the data transmitter sends data, no matter how long the data to be sent is, a complete data block will be consumed. The size of the data sent by the data transmitter each time may not be fixed. If the data block is set to be large, memory resources will be wasted when sending small data. In order to avoid the above problems, multiple data queues can be created, and the size of the data blocks of each data queue is different. The data length of the computer software data to be transmitted is compared with the data length of the data blocks in each data queue to obtain a comparison result. Based on the comparison result, a target queue whose data length of the data block is greater than or equal to the data length of the computer software data to be transmitted is selected from each data queue, and one is selected from each target queue as the final queue.
[0085] In this embodiment, the size of the data block of each data queue is different, that is, the single block size of each data queue is different. For each data queue, in addition to the single block size being different, the total number of data blocks can also be different. Each data queue can be an independent circular data queue. The single block size of the data queue can be obtained according to the size of the actual data sent at a single time, and the minimum data of the actual data sent at a single time is recorded as N. The single block size of each data queue can be set.
[0086] In this embodiment, see Figure 4 , Figure 4 It is a schematic diagram of the structure of multiple data queues provided by an embodiment of the present invention. Figure 4 In the data queue, the single block size increases from top to bottom, that is, the data queue at the top is a small block queue, and the data queue at the bottom is a large block queue. Assume that the data queue is numbered I, which means the total number of data queues. I equals 1 for the first data queue, and the size of the "data area" of the first data queue is defined as N. I equals 2 for the second data queue, and the size of the "data area" of the second data queue is N×(2×1). I equals 3 for the third data queue, and the size of the "data area" of the third data queue is N×(2×2). Similarly, the size of the "data area" of the I-th data queue is N×(2×(I-1). That is, starting from the second data queue, the single block size of the I-th data queue can be specified according to the formula N×(2×(I-1). N represents the size of the "data area" in the data block, and I represents the number of the circular data queue, or the total number of data queues. The specific value of the total number of blocks can be defined, and is not specifically limited here.
[0087] In an embodiment of the present specification, selecting one of the target queues as the final queue may include:
[0088] The one with the smallest data length of the data block is selected from each target queue as the final queue.
[0089] In this embodiment, the one with the smallest data block length is selected from each target queue as the final queue, so that the size of the data sent by the data sending end can be closest to the size of the data block of the final queue, which can minimize the occupancy of memory resources and save as much memory resources as possible.
[0090] Specifically, for example, there are currently X data queues, the data block size of the first queue is 32Byte, the data block size of the second queue is 64Byte, the data block size of the third queue is 128Byte, the data block size of the fourth queue is 256Byte, and so on, the data block size of the X-1th queue is 1Mbyte, and the data block size of the Xth queue is 2Mbyte. At this time, if you need to send 100Byte of data, select the third queue; if you need to send 150Byte of data, select the fourth queue; if you need to send 1.5Mbyte of data, select the Xth queue. When there are multiple data queues, after selecting a data queue, the way of sending data is the same as the sending method of a single data queue; similarly, when there are multiple data queues, after selecting a data queue, the way the data receiving end receives data is the same as the receiving method of a single data queue.
[0091] In an embodiment of the present specification, when there are multiple data queues and there are also multiple data receiving ends, which are less than the number of data queues, controlling the data receiving end to detect the target data block marked as a non-empty state according to the sequence of data blocks in the data queue may include:
[0092] Based on the amount of data transmitted by each data queue, each data queue is grouped to obtain a plurality of queue groups; wherein the number of queue groups is the same as the number of data receiving ends;
[0093] Determine the corresponding relationship between each queue group and each data receiving end;
[0094] Each data receiving end is controlled to detect the target data blocks marked as being in a non-empty state in the data queues in the corresponding queue groups in sequence according to the sequence of the data blocks.
[0095] In this embodiment, each queue group includes at least one data queue, that is, some queue groups include multiple data queues. For example, if there are M (M can be six) data queues, they are arranged in order from small to large according to the amount of data transmitted by each data queue, that is, the first data queue has the smallest amount of data transmitted, and the last data queue has the largest amount of data transmitted. The first to third data queues can be divided into one group, the fourth and fifth data queues can be divided into one group, and the sixth data queue can be divided into one group.
[0096] When the queue group corresponding to the data receiving end includes multiple data queues, one of the data queues can be first detected according to the order of the data blocks, and when the data of each data block of one data queue is read, the data of another data queue in the queue group is read, and so on, until the data of each data queue in the queue group is read. In addition, when the data receiving end detects that the mark of a data queue in the queue group is empty, it stops processing the data queue and directly detects the mark of the next data queue in the queue group. This embodiment can balance the data receiving capability and the central processing unit (CPU) resource occupation, while reducing the waste of CPU resources and meeting the performance requirements of the data receiving end.
[0097] In one embodiment of the present specification, the more data queues a queue group includes, the smaller the amount of data transmitted by a single data queue in the queue group;
[0098] The fewer the number of data queues included in a queue group, the larger the amount of data transmitted by a single data queue in the queue group.
[0099] In this embodiment, the amount of data transmitted by each queue group can be kept close or equal as much as possible. That is to say, the more data queues included in the queue group, the smaller the amount of data transmitted by a single data queue in the queue group, and the fewer data queues included in the queue group, the larger the amount of data transmitted by a single data queue in the queue group. In this way, it is easier to determine the balance point between data receiving capability and CPU resource occupancy, which neither wastes CPU resources nor satisfies the performance requirements of the data receiving end.
[0100] In an embodiment of the present specification, when there are multiple data queues and there is only one data receiving end, controlling the data receiving end to detect a target data block marked as being in a non-empty state according to the sequence of data blocks in the data queue may include:
[0101] The control data receiving end detects the target data blocks marked as being in a non-empty state in each data queue in turn according to the sequence of the data blocks.
[0102] In this embodiment, assuming that there are M data queues, the data receiving end can first read the data from the first data queue, detect the target data block marked as non-empty according to the order of the data blocks in the data queue, and read the data of the target data block. After all the data blocks of the first data queue are read, the data reading of the second data queue begins, and so on, until the data of the Mth data queue is read. In addition, when the data receiving end detects that the mark of a data queue is empty, the processing of the data queue is stopped, and the mark of the next data queue is directly detected. When all data queues are processed, the above steps can be continued starting from the first data queue and executed in a loop. The processing logic of the method of reading each data queue in sequence through a data receiving end is simpler.
[0103] In an embodiment of the present specification, when there are multiple data queues and multiple data receiving ends, and they correspond one-to-one with the data queues, controlling the data receiving end to detect the target data block marked as a non-empty state according to the sequence of data blocks in the data queue may include:
[0104] Each data receiving end is controlled to detect the target data block marked as being in a non-empty state in the corresponding data queue according to the sequence of the data blocks.
[0105] In this embodiment, the data receiving end corresponds to the data queue one by one, which can greatly improve the efficiency of the data receiving end in receiving data.
[0106] Based on the same general inventive concept, the present invention also protects a transmission device for computer software data, such as Figure 5 As shown. The transmission device of computer software data provided by the present invention is described below. The transmission device of computer software data described below and the transmission method of computer software data described above can be referred to each other. The device may include a queue creation module 201, an initialization module 202, a startup module 203, a sending module 204 and a receiving module 205.
[0107] The queue creation module 201 is used to apply for memory space and establish a data queue in the memory space; wherein the data queue includes a plurality of data blocks, each of which includes an identifier, a valid length and a data area.
[0108] The initialization module 202 is used to initialize the data queue to determine the size and total number of data blocks in the data queue, and to set the identifier of each data block in the data queue to an empty state.
[0109] The startup module 203 is used to start the data sending end and the data receiving end of the computer software data.
[0110] The sending module 204 is used to control the data sending end to detect the target data block marked as empty according to the order of the data blocks in the data queue, write the computer software data to be transmitted into the data area of the target data block, record the actual length of the written data in the effective length, and set the mark of the target data block to a non-empty state.
[0111] The receiving module 205 is used to control the data receiving end to detect the target data block marked as non-empty according to the order of the data blocks in the data queue, obtain data in the data area based on the effective length of the target data block marked as non-empty, and set the mark of the target data block after obtaining the data to empty state.
[0112] Figure 6 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.
[0113] like Figure 6 As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute the computer software data transmission method.
[0114] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0115] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the computer software data transmission method provided by the above-mentioned methods.
[0116] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the computer software data transmission method provided by the above methods.
[0117] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0118] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0119] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for transmitting computer software data, characterized in that: include: Applying for memory space, and establishing a data queue in the memory space; wherein the data queue includes a plurality of data blocks, each of which includes an identifier, a valid length and a data area; Initializing the data queue to determine the size and total number of data blocks in the data queue, and setting the identifier and data area of each data block in the data queue to an empty state; Start a data sending end and a data receiving end of computer software data; Control the data sending end to detect the target data block marked as empty according to the sequence of the data blocks in the data queue, write the computer software data to be transmitted into the data area of the target data block, record the actual length of the written data in the effective length, and set the mark of the target data block to a non-empty state; Control the data receiving end to detect the target data block marked as non-empty according to the sequence of the data blocks in the data queue, obtain data in the data area based on the effective length of the target data block marked as non-empty, and set the mark of the target data block after the data is obtained to empty; When there are multiple data queues, the sizes of data blocks of the data queues are different; After the data queue is initialized, the method further includes: Comparing the data length of the computer software data to be transmitted with the data length of the data blocks in each of the data queues to obtain a comparison result; Based on the comparison result, a target queue whose data length of the data block is greater than or equal to the data length of the computer software data to be transmitted is selected from each of the data queues; Selecting one of the target queues as a final queue; Controlling the data sending end to detect the target data block marked as being in an empty state according to the sequence of the data blocks in the data queue, including: The data sending end is controlled to detect the target data block marked as being in an empty state according to the sequence of the data blocks in the final queue.
2. The method for transmitting computer software data according to claim 1, characterized in that: The step of selecting one of the target queues as a final queue includes: The one with the smallest data length of the data block is selected from each of the target queues as the final queue.
3. The method for transmitting computer software data according to claim 1, characterized in that: When there are multiple data queues and there are multiple data receiving ends, which are less than the number of data queues, controlling the data receiving end to detect the target data block marked as a non-empty state according to the sequence of data blocks in the data queues includes: Based on the amount of data transmitted by each of the data queues, each of the data queues is grouped to obtain a plurality of queue groups; wherein the number of the queue groups is the same as the number of the data receiving ends; Determining the corresponding relationship between each of the queue groups and each of the data receiving ends; Control each of the data receiving ends to detect the target data blocks marked as being in a non-empty state in the data queues in the corresponding queue groups in sequence according to the sequence of the data blocks.
4. The method for transmitting computer software data according to claim 3, characterized in that: The more data queues included in the queue group, the smaller the amount of data transmitted by a single data queue in the queue group; The fewer the number of data queues included in the queue group, the larger the amount of data transmitted by a single data queue in the queue group.
5. The method for transmitting computer software data according to claim 1, characterized in that: When there are multiple data queues and one data receiving end, controlling the data receiving end to detect the target data block marked as being in a non-empty state according to the sequence of the data blocks in the data queue includes: The data receiving end is controlled to detect target data blocks marked as being in a non-empty state in each of the data queues in sequence according to the sequence of the data blocks.
6. The method for transmitting computer software data according to claim 1, characterized in that: When there are multiple data queues and multiple data receiving ends corresponding to the data queues one by one, the control data receiving end detects the target data block marked as a non-empty state according to the sequence of data blocks in the data queue, including: Each of the data receiving ends is controlled to detect the target data blocks marked as being in a non-empty state in the corresponding data queues according to the sequence of the data blocks.
7. The method for transmitting computer software data according to claim 1, characterized in that: The applying for memory space and establishing a data queue in the memory space also includes: Establishing a connection between the first data block and the last data block in the data queue; After setting the identifier of the target data block to a non-empty state, the method further includes: Controlling the data sending end to point to the next data block; If the next data block pointed to is the last data block, control the data sending end to point to the first data block; After setting the identifier of the target data block after acquiring the data to an empty state, the method further includes: Controlling the data receiving end to point to the next data block; If the next data block pointed to is the last data block, the data receiving end is controlled to point to the first data block.
8. A computer software data transmission device, characterized in that: include: A queue creation module, used to apply for memory space and establish a data queue in the memory space; wherein the data queue includes a plurality of data blocks, each of which includes an identifier, a valid length and a data area; An initialization module, used for initializing the data queue to determine the size and total number of data blocks in the data queue, and setting the identifier of each data block in the data queue to an empty state; A startup module, used for starting a data sending end and a data receiving end of computer software data; The sending module is used to control the data sending end to detect the target data block marked as empty according to the sequence of the data blocks in the data queue, write the computer software data to be transmitted into the data area of the target data block, record the actual length of the written data in the effective length, and set the mark of the target data block to a non-empty state; A receiving module, used to control the data receiving end to detect the target data block marked as non-empty according to the sequence of the data blocks in the data queue, obtain data in the data area based on the effective length of the target data block marked as non-empty, and set the mark of the target data block after the data is obtained to an empty state; When there are multiple data queues, the sizes of data blocks of the data queues are different; After initializing the data queue, the method further includes: Comparing the data length of the computer software data to be transmitted with the data length of the data blocks in each of the data queues to obtain a comparison result; Based on the comparison result, a target queue whose data length of the data block is greater than or equal to the data length of the computer software data to be transmitted is selected from each of the data queues; Selecting one of the target queues as a final queue; Controlling the data sending end to detect the target data block marked as being in an empty state according to the sequence of the data blocks in the data queue, including: The data sending end is controlled to detect the target data block marked as being in an empty state according to the sequence of the data blocks in the final queue.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method for transmitting computer software data as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Message distribution method and device and storage medium
CN116225742A
Inter-process communication method based on shared memory
CN118606069A