Disclosure of Invention
The application provides a data transmission method, a data transmission device, an electronic device and a storage medium, which are used for overcoming the defects of large data transmission delay and the like in the prior art.
A first aspect of the present application provides a data transmission method applied to a communication device, where the communication device includes a multi-core processor, and includes:
acquiring data to be transmitted and operation information of each kernel of the multi-core processor;
judging whether an idle core exists in the multi-core processor or not according to the running information of each core;
and when determining that an idle kernel exists in the multi-core processor, sending the data to be transmitted to the idle kernel so as to process the data to be transmitted by utilizing the idle kernel.
Optionally, the method further includes:
when determining that no idle kernel exists in the multi-core processor, acquiring identity authentication information of a data sender of the data to be transmitted;
determining a target kernel according to the identity authentication information of the data sender of the data to be transmitted;
and sending the data to be transmitted to the target kernel.
Optionally, the determining a target kernel according to the identity authentication information of the data sender of the to-be-transmitted data includes:
acquiring identity attribute information of data in each non-idle core;
and determining a target kernel according to the matching relationship between the identity authentication information and the identity attribute information of the data in each non-idle kernel.
Optionally, the method further includes:
when determining that no idle core exists in the multi-core processor, acquiring the residual resources of each non-idle core;
determining the non-idle core with the most residual resources as a target core;
and sending the data to be transmitted to the target kernel.
Optionally, before sending the data to be transmitted to the target kernel, the method further includes:
acquiring the data volume of the data to be transmitted;
and when the residual resources of the target kernel are not enough to process the data volume of the data to be transmitted, returning to the step of acquiring the residual resources of each non-idle kernel.
Optionally, the method further includes:
monitoring the number of started threads of each non-idle kernel;
when the number of threads started by any non-idle kernel reaches a preset upper limit value, setting the non-idle kernel to be in a busy state; wherein the kernel in the busy state does not receive the data to be transmitted.
Optionally, after sending the data to be transmitted to the idle kernel or the target kernel, the method further includes:
acquiring processing demand information corresponding to the data to be transmitted;
determining a target thread according to the processing demand information;
and controlling the idle kernel or the target kernel to start the target thread so as to process the data to be transmitted.
A second aspect of the present application provides a data transmission apparatus, including:
the acquisition module is used for acquiring data to be transmitted and the operation information of each kernel of the multi-core processor;
the judging module is used for judging whether an idle kernel exists in the multi-core processor according to the running information of each kernel;
and the transmission module is used for sending the data to be transmitted to an idle kernel when the idle kernel in the multi-core processor is determined to exist so as to process the data to be transmitted by utilizing the idle kernel.
Optionally, the apparatus further comprises:
the determining module is used for acquiring the identity authentication information of the data sender of the data to be transmitted when the idle kernel does not exist in the multi-core processor; determining a target kernel according to the identity authentication information of the data sender of the data to be transmitted; and sending the data to be transmitted to the target kernel.
Optionally, the determining module is specifically configured to:
acquiring identity attribute information of data in each non-idle core;
and determining a target kernel according to the matching relationship between the identity authentication information and the identity attribute information of the data in each non-idle kernel.
Optionally, the determining module is further configured to:
when determining that no idle core exists in the multi-core processor, acquiring the residual resources of each non-idle core;
determining the non-idle core with the most residual resources as a target core;
and sending the data to be transmitted to the target kernel.
Optionally, the determining module is further configured to:
acquiring the data volume of the data to be transmitted;
and when the residual resources of the target kernel are not enough to process the data volume of the data to be transmitted, returning to the step of acquiring the residual resources of each non-idle kernel.
Optionally, the determining module is further configured to:
monitoring the number of started threads of each non-idle kernel;
when the number of threads started by any non-idle kernel reaches a preset upper limit value, setting the non-idle kernel to be in a busy state; wherein the kernel in the busy state does not receive the data to be transmitted.
Optionally, the apparatus further comprises:
the processing module is used for acquiring processing demand information corresponding to the data to be transmitted; determining a target thread according to the processing demand information; and controlling the idle kernel or the target kernel to start the target thread so as to process the data to be transmitted.
A third aspect of the present application provides an electronic device, comprising: at least one processor and memory;
the memory stores computer-executable instructions;
the at least one processor executes computer-executable instructions stored by the memory to cause the at least one processor to perform the method as set forth in the first aspect above and in various possible designs of the first aspect.
A fourth aspect of the present application provides a computer-readable storage medium having stored thereon computer-executable instructions that, when executed by a processor, implement a method as set forth in the first aspect and various possible designs of the first aspect.
This application technical scheme has following advantage:
according to the data transmission method, the data transmission device, the electronic equipment and the storage medium, the data to be transmitted and the operation information of each kernel of the multi-core processor are acquired; judging whether an idle core exists in the multi-core processor or not according to the operation information of each core; and when determining that the idle cores exist in the multi-core processor, sending the data to be transmitted to any idle core so as to process the data to be transmitted by utilizing the idle cores. According to the data transmission method provided by the scheme, the data to be transmitted is directly transmitted to the idle kernel without waiting for the operation right of the processor, so that the data transmission delay is reduced, and the data transmission efficiency is improved.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Furthermore, the terms "first", "second", etc. are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. In the description of the following examples, "plurality" means two or more unless specifically limited otherwise.
In the prior art, data packet transmission is generally performed in a concurrent manner, that is, a plurality of data packets simultaneously preempt processor resources of a client. However, when a large amount of data packets occupy the processor resources of the client, only the link which occupies the processor resources can process the corresponding data packets preferentially, and other links can continue to occupy the operation right of the processor only by waiting for the transmission completion of the current link. The operation of the processor is divided into a plurality of time slices, and different time slices are used for processing data of different links, so that the data transmission delay is large.
In order to solve the above problems, in the data transmission method, the data transmission device, the electronic device, and the storage medium provided in the embodiments of the present application, the data to be transmitted and the operation information of each core of the multi-core processor are acquired; judging whether an idle core exists in the multi-core processor or not according to the operation information of each core; and when determining that the idle cores exist in the multi-core processor, sending the data to be transmitted to any idle core so as to process the data to be transmitted by utilizing the idle cores. According to the data transmission method provided by the scheme, the data to be transmitted is directly transmitted to the idle kernel without waiting for the operation right of the processor, so that the data transmission delay is reduced, and the data transmission efficiency is improved.
The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present invention will be described below with reference to the accompanying drawings.
First, a structure of a data transmission system based on the present application will be explained:
the data transmission method, the data transmission device, the electronic equipment and the storage medium are suitable for transmitting data to a processor so as to enable the processor to process the data. As shown in fig. 1, which is a schematic structural diagram of a data transmission system based on the embodiment of the present application, the data transmission system mainly includes a data sender, a multi-core processor, and a data transmission device for transmitting data. Specifically, the data transmission device receives data to be transmitted sent by a data sender, and transmits the received data to be transmitted to the multi-core processor.
The embodiment of the application provides a data transmission method, which is applied to communication equipment, wherein the communication equipment comprises a multi-core processor and is used for transmitting data to a processor so as to enable the processor to process the data. The execution subject of the embodiment of the present application is an electronic device, such as a server, a desktop computer, a notebook computer, a tablet computer, and other electronic devices that can be used for data transmission.
As shown in fig. 2, a schematic flow chart of a data transmission method provided in the embodiment of the present application is shown, where the method includes:
step 201, acquiring data to be transmitted and operation information of each core of the multi-core processor.
It should be noted that each core of the multi-core processor operates independently, and each core generates corresponding operation information in the operation process. The running information may include a start time and an end time of the data processing thread, and the like.
Step 202, judging whether an idle core exists in the multi-core processor according to the running information of each core.
It should be noted that the idle core may refer to a core that does not start any thread, and also includes a core in an inactive state such as hibernation or sleep.
Specifically, whether each core is currently in an occupied state (at least one thread is started) can be judged according to the running information of each core, and then an idle core in the current multi-core processor is screened out.
And 203, when the idle core exists in the multi-core processor, sending the data to be transmitted to the idle core so as to process the data to be transmitted by using the idle core.
Specifically, when it is determined that there are multiple idle cores, one of the idle cores may be randomly selected as a target core, and data to be transmitted is sent to the target core (idle core).
Each core in the multi-core processor provided by the embodiment of the application is a multi-thread core, when a plurality of data to be transmitted are obtained simultaneously and the number of the current idle cores is less than that of the data to be transmitted, the obtained data to be transmitted can be equally distributed to each idle core, and each core starts a corresponding thread after receiving the data, namely, a plurality of threads in the cores run in parallel.
Specifically, in an embodiment, after the data to be transmitted is sent to the idle kernel or the target kernel, processing requirement information corresponding to the data to be transmitted may be obtained; determining a target thread according to the processing demand information; and controlling the idle kernel or the target kernel to start the target thread so as to process data to be transmitted.
Specifically, after the kernel receives the data, a data processing thread (target thread) corresponding to the data is started to perform decryption, encryption, transcoding, redundancy removal and other processing on the data, and finally, the processed data is forwarded to a target storage unit or other communication devices.
On the basis of the above embodiments, since each core in the multi-core processor will be occupied when the number of data transmission is large, in order to reduce the data transmission delay in this case, as an implementable manner, in one embodiment, the method includes:
step 301, when determining that no idle kernel exists in the multi-core processor, acquiring identity authentication information of a data sender of data to be transmitted;
step 302, determining a target kernel according to the identity authentication information of a data sender of data to be transmitted;
step 303, sending the data to be transmitted to the target kernel.
It should be noted that the data sending party provided in the embodiment of the present application may be a router, a server, another client terminal, or a base station.
It should be further noted that the identity authentication information may include operator information for providing communication service for the data sender, a device type, an IP address of the data sender, and/or interface information of a communication interface of the data sender, etc.
For example, taking the current data sender as a wireless router as an example, the corresponding identity authentication information may be operator information. When the SIM card is inserted into the 4G/5G module interface of the wireless router, the data to be transmitted sent by the SIM card carries operator information. After receiving data to be transmitted sent by the wireless router, searching a kernel corresponding to the data to be transmitted in the multi-core processing according to operator information carried by the data to be transmitted, and determining the kernel as a target kernel.
Before data transmission, a matching relationship between each core in the multi-core processor and an operator may be configured. Taking the example that the multi-core processor includes four cores, three cores may be selected to be respectively responsible for the first operator data, the second operator data and the third operator data, and the other core is responsible for the ethernet data, that is, each core provides services for the corresponding operator link.
Specifically, in an embodiment, identity attribute information of data in each non-idle kernel may also be obtained; and determining the target kernel according to the matching relationship between the identity authentication information and the identity attribute information of the data in each non-idle kernel.
It should be explained that the identity attribute information and the identity authentication information have the same information content, taking the identity authentication information as the operator information as an example, the identity attribute information of the data in the non-idle kernel also includes the corresponding operator information.
Specifically, under the condition that each kernel in the multi-core processor is occupied, data with identity attribute information matched with identity authentication information of current data to be transmitted is selected, and the kernel to which the data belongs is determined as a target kernel.
Further, the current data to be transmitted is sent to the target kernel, and the target kernel is triggered to start a corresponding thread, so that the data parallel processing of the same operator is realized.
On the basis of the above embodiment, if the same data sender or the data senders with the same identity authentication information send a large amount of data to be transmitted at the same time, load imbalance among the cores will be caused, which is not beneficial to ensuring data transmission efficiency.
Therefore, in view of the above problem, as an implementable manner, in an embodiment, the method further includes:
step 401, when determining that no idle core exists in the multi-core processor, acquiring the residual resources of each non-idle core;
step 402, determining the non-idle core with the most residual resources as a target core;
and step 403, sending the data to be transmitted to the target kernel.
It should be noted that, there is an upper limit to the amount of data that can be processed by one core, and a difference between the upper limit of the amount of core data and the total amount of data of the currently stored (currently processed) data is the amount of data that can be processed by the above-mentioned remaining resources.
Specifically, the core with the most residual resources is selected from the multi-core processor as the target core, so that the load among the cores is balanced, and the data transmission efficiency is further guaranteed.
Further, in an embodiment, if the kernel runs in an overload state, the kernel data may be jammed, and the service life of the kernel may be shortened, so that, in order to avoid the overload operation of the kernel, before sending the data to be transmitted to the target kernel, the data amount of the data to be transmitted may be acquired; and when the residual resources of the target kernel are not enough to process the data volume of the data to be transmitted, returning to the step of acquiring the residual resources of each non-idle kernel.
Specifically, while returning to the step of obtaining the remaining resources of each non-idle core, adding the data to be transmitted currently to the waiting queue, and waiting for the core with sufficient remaining resources to provide services for the core.
On the basis of the above embodiment, because the threads in each kernel run in parallel, and the computational resources of the kernels are limited, that is, each time the parallel running of a fixed number of threads can only be satisfied, if new data is received under the condition that the number of threads running in parallel has reached a preset fixed number, the threads corresponding to the data can only be restarted after a certain thread is finished, and the data transmission delay is increased.
Therefore, in view of the above problem, as an implementable manner, in an embodiment, the method further includes:
step 501, monitoring the number of threads started by each non-idle kernel;
step 502, when the number of threads started by any non-idle kernel reaches a preset upper limit value, the non-idle kernel is set to be in a busy state.
Wherein the kernel in the busy state does not receive the data to be transmitted.
It should be noted that, in the process of selecting the target kernel based on the above embodiment, the kernels in the busy state are removed from the candidate kernels, that is, the kernels in the busy state are not determined as the target kernels.
Specifically, in an embodiment, if all the current cores are in a busy state, the current data to be transmitted is added to the wait queue, the current state of each core is monitored, and if any core is out of the busy state, the core is taken as a target core.
To help those skilled in the art to better understand the data transmission method provided by the embodiments of the present application, the following is an exemplary implementation manner provided for the embodiments of the present application:
for comparison, as shown in fig. 3, which is a schematic structural diagram of an existing data transmission network, in a conventional manner, 7 links respectively preempt a time slice of one core of a processor (CPU), the links that preempt data transmit processing data, and other links wait for the completion of processing, and continue to preempt the CPU, and links that do not preempt CPU resources can only wait.
Fig. 4 is a schematic structural diagram of an exemplary data transmission network provided in an embodiment of the present application. When a single 4G module of any operator communicates, a core in the CPU is selected at will to start a new thread at the moment, and data of the single 4G module is processed.
Fig. 5 is a schematic structural diagram of another exemplary data transmission network provided in the embodiment of the present application. When the 4G modules of any two operators are used simultaneously, firstly, which two operators are respectively (assuming mobile and connected) is judged according to an interface (identity authentication information), then, the CPU uses two idle kernels, and each kernel respectively starts a thread to be responsible for processing data of the 4G module.
Fig. 6 is a schematic structural diagram of another exemplary data transmission network provided in the embodiment of the present application. When two 4G modules of any two operators are used simultaneously, firstly, which two operators are respectively judged according to the interfaces (2 mobile and 2 intercommunicating are assumed), then the CPU uses two idle kernels, and each kernel respectively starts two threads to be responsible for processing data of the 4G module of the same operator.
Fig. 7 is a schematic structural diagram of another exemplary data transmission network provided in the embodiment of the present application. When two 4G modules of the same operator are used simultaneously, if the data volume transmission of one 4G module is large, according to the previous rule, if a single core is used for starting two threads, the CPU occupation is possibly too high, at the moment, two kernels can be started to be respectively responsible for the data transmission of the two 4G modules, the parallel transmission is realized, the load of the CPU is reduced, and the data transmission efficiency is improved.
Fig. 8 is a schematic structural diagram of another exemplary data transmission network provided in the embodiment of the present application. When there are 6 4G modules (assuming 2 mobile, 2 connected, 2 telecom) and ethernet ports used simultaneously, three cores are first used and each core opens two threads responsible for processing data of 4G modules of the same operator. In addition, the other core is used for processing data transmitted by the Ethernet port through an interface (such as a PCIE interface), so that the parallel processing of the data is realized.
According to the data transmission method provided by the embodiment of the application, the data to be transmitted and the operation information of each kernel of the multi-core processor are acquired; judging whether an idle core exists in the multi-core processor or not according to the operation information of each core; and when determining that the idle cores exist in the multi-core processor, sending the data to be transmitted to any idle core so as to process the data to be transmitted by utilizing the idle cores. According to the data transmission method provided by the scheme, the data to be transmitted is directly transmitted to the idle kernel without waiting for the operation right of the processor, so that the data transmission delay is reduced, and the data transmission efficiency is improved. And moreover, the data transmission efficiency is further improved by fully and reasonably utilizing the resources of the multi-core processor.
The embodiment of the application provides a data transmission device, which is used for executing the data transmission method provided by the embodiment.
Fig. 9 is a schematic structural diagram of a data transmission device according to an embodiment of the present application. The data transmission device 90 includes an obtaining module 901, a judging module 902 and a transmitting module 903.
The device comprises an acquisition module, a data transmission module and a data transmission module, wherein the acquisition module is used for acquiring data to be transmitted and operation information of each kernel of the multi-core processor; the judging module is used for judging whether an idle kernel exists in the multi-core processor according to the operation information of each kernel; and the transmission module is used for sending the data to be transmitted to the idle kernel when the idle kernel in the multi-core processor is determined to exist so as to process the data to be transmitted by utilizing the idle kernel.
Specifically, in an embodiment, the apparatus further comprises:
the determining module is used for acquiring the identity authentication information of a data sender of the data to be transmitted when the idle kernel does not exist in the multi-core processor; determining a target kernel according to the identity authentication information of a data sender of data to be transmitted; and sending the data to be transmitted to the target kernel.
Specifically, in an embodiment, the determining module is specifically configured to:
acquiring identity attribute information of data in each non-idle core;
and determining the target kernel according to the matching relationship between the identity authentication information and the identity attribute information of the data in each non-idle kernel.
Specifically, in an embodiment, the determining module is further configured to:
when determining that no idle core exists in the multi-core processor, acquiring the residual resources of each non-idle core;
determining the non-idle core with the most residual resources as a target core;
and sending the data to be transmitted to the target kernel.
Specifically, in an embodiment, the determining module is further configured to:
acquiring the data volume of data to be transmitted;
and when the residual resources of the target kernel are not enough to process the data volume of the data to be transmitted, returning to the step of acquiring the residual resources of each non-idle kernel.
Specifically, in an embodiment, the determining module is further configured to:
monitoring the number of started threads of each non-idle kernel;
when the number of the threads started by any non-idle kernel reaches a preset upper limit value, setting the non-idle kernel to be in a busy state; wherein the kernel in the busy state does not receive the data to be transmitted.
Specifically, in an embodiment, the apparatus further comprises:
the processing module is used for acquiring processing demand information corresponding to the data to be transmitted; determining a target thread according to the processing demand information; and controlling the idle kernel or the target kernel to start the target thread so as to process data to be transmitted.
With regard to the data transmission apparatus in the present embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
The data transmission device provided in the embodiment of the present application is configured to execute the data transmission method provided in the above embodiment, and an implementation manner and a principle thereof are the same and are not described again.
The embodiment of the application provides electronic equipment for executing the data transmission method provided by the embodiment.
Fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present application. The electronic device 100 includes: at least one processor 1001 and memory 1002;
the memory stores computer-executable instructions; the at least one processor executes the computer-executable instructions stored by the memory to cause the at least one processor to perform the data transfer method provided by the above embodiments.
The electronic device provided in the embodiment of the present application is configured to execute the data transmission method provided in the above embodiment, and an implementation manner and a principle of the electronic device are the same and are not described again.
The embodiment of the present application provides a computer-readable storage medium, where a computer executing instruction is stored in the computer-readable storage medium, and when a processor executes the computer executing instruction, the data transmission method provided in any of the above embodiments is implemented.
The storage medium including the computer-executable instructions of the embodiments of the present application may be used to store the computer-executable instructions of the data transmission method provided in the foregoing embodiments, and the implementation manner and the principle thereof are the same and are not described again.
It is obvious to those skilled in the art that, for convenience and simplicity of description, the foregoing division of the functional modules is merely used as an example, and in practical applications, the above function distribution may be performed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to perform all or part of the above described functions. For the specific working process of the device described above, reference may be made to the corresponding process in the foregoing method embodiment, which is not described herein again.
Finally, it should be noted that: the above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.