An inter-core data communication method for a multi-core operating system
By allocating inter-core sockets for each core in a multi-core operating system and establishing a shared storage receiving queue, efficient, reliable and orderly data communication between multiple cores is achieved, and the problem of high transmission rate but low reliability in the prior art is solved.
Patent Information
- Application Number
- CN202311832308.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-27
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2043-12-27
AI Technical Summary
The prior art is difficult to achieve efficient, reliable and orderly data communication between multi-core processors.
After the multi-core operating system is powered on, a socket descriptor pool is created for each core, and inter-core sockets are allocated and bound to each core, a receive queue is created in a shared storage area, a communication link is established through interrupts between the sending and receiving cores, and a new inter-core socket is used for data transmission.
It realizes the reliability and orderliness of data transmission between multiple cores, and solves the problem of low reliability and disorderly reception of data in the absence of connection.
Smart Images

Figure CN117851333B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer system software, and particularly relates to an inter-core data communication method for a multi-core operating system. Background Art
[0002] A multi-core processor refers to a processor that integrates multiple complete computing engines. Each computing engine serves as a core, and each computing engine can support a processor on the system bus, enabling the multi-core processor to support multiple processors on the system bus at this time. The bus control provides all bus control signals and command signals.
[0003] Currently, there are two types of real-time operating systems that support multi-core processors: the symmetric multi-processing (SMP) architecture and the asymmetric multi-processing (AMP) architecture. The data communication between multi-cores has low requirements for real-time performance, but it is often accompanied by a large amount of data. Currently, there is no relatively effective way to achieve data communication between multi-cores. Summary of the Invention
[0004] The purpose of the present invention is to disclose an inter-core data communication method for a multi-core operating system to solve the technical problem that it is difficult to achieve data communication between multi-cores of a multi-core processor by existing methods.
[0005] The technical solution for achieving the invention purpose is as follows: An inter-core data communication method for a multi-core operating system includes:
[0006] Step 1: After the multi-core operating system is powered on, each core creates a socket descriptor pool, allocates and binds an inter-core socket for each core from the socket descriptor pool, and creates a receive queue in the shared storage area for each inter-core socket. Herein, the core that needs to send data is defined as the sending core, and the core that needs to receive data is defined as the receiving core;
[0007] Step 2: The sending core packs the connection request event into a first data packet and stores the first data packet in the receive queue of the receiving core;
[0008] Step 3: The receiving core receives the first data packet according to the inter-core interrupt sent by the sending core, allocates a new inter-core socket for the receiving core according to the connection request event in the first data packet, and establishes a communication link with the sending core using the new inter-core socket;
[0009] Step 4: The sending core packs the processing data event and the data to be sent into a second data packet and stores the second data packet in the receive queue of the receiving core;
[0010] Step 5: The receiving core receives the second data packet according to the inter-core interrupt sent by the sending core, and receives and processes the data to be sent according to the processing data event in the second data packet;
[0011] Step 6: After the receiving core receives and processes the data to be sent, it releases the new inter-core socket and disconnects the communication link with the sending core.
[0012] Further, in the above Step 1, after the multi-core operating system is powered on, it further includes:
[0013] Step 11: The starting address of the shared storage area, the shared memory size, and the maximum number of nodes, ports, maximum number of socket sockets, and interrupt number in the bus list.
[0014] Further, in the above Step 1, when each core creates a socket descriptor pool and allocates and binds an inter-core socket for each core from the socket descriptor pool, it includes:
[0015] Step 12: Each core in the multi-core operating system creates a socket descriptor pool locally, and allocates and binds an inter-core socket for each core from the socket descriptor pool;
[0016] Step 13: Write the address information of each core into the inter-core socket allocated to it and bind it to the inter-core socket, where the address information includes address cluster, bus number, node number, and port number.
[0017] Further, in the above Step 3, when allocating a new inter-core socket for the receiving core according to the connection request event in the first data packet and establishing a communication link with the sending core using the new inter-core socket, it includes:
[0018] Step 31: When the receiving core receives and parses the event in the first data packet as the connection request event, it allocates a new inter-core socket for the receiving core from the socket descriptor pool;
[0019] Step 32: The receiving core uses the new inter-core socket to send an ACK message to the sending core according to the node number and port number of the sending core in the connection request event;
[0020] Step 33: The sending core establishes a communication link with the new inter-core socket according to the received ACK message and communicates with the sending core.
[0021] Even further, in the above Step 31, the address structures of the inter-core socket and the new inter-core socket both include address cluster, bus number, node number, and port number.
[0022] Further, in the above step 5, receiving and processing the data to be sent according to the processing data event in the second data packet includes:
[0023] The receiving core extracts the data to be sent according to the event pool offset, event offset, and event index in the processing data event, and processes the data to be sent according to the event instruction in the processing data event.
[0024] Compared with the prior art, the beneficial effects that can be achieved by at least one of the above technical solutions adopted in the embodiments of this specification at least include: The inter-core data communication method of the multi-core operating system disclosed in the present invention can allocate an inter-core socket (i.e., socket) for each core from the socket descriptor pool created by it through the established shared storage area. By allocating a new inter-core socket to the receiving core and using the new inter-core socket to communicate and transfer data with the sending core, it has the advantages of high reliability in data transmission and the transmitted data being in order. The method of the present invention solves the technical problems that the existing connectionless-oriented method has the advantages of high transmission rate, but has the disadvantages of low reliability in receiving data and the possibility of being disordered. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required to be used in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0026] Figure 1 It is a flowchart of the inter-core data communication method of the multi-core operating system disclosed in the embodiments of the present invention;
[0027] Figure 2 It is a schematic diagram of communication between two cores of the multi-core operating system disclosed in the embodiments of the present invention;
[0028] Figure 3 It is a schematic diagram of establishing a communication link between two cores of the multi-core operating system disclosed in the embodiments of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0029] The embodiments of the present application will be described in detail below with reference to the drawings.
[0030] The following describes the implementation manners of the present application through specific examples. Those skilled in the art can easily understand other advantages and effects of the present application from the content disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all embodiments. The present application can also be implemented or applied through other different specific implementation manners. Various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that, without conflict, the following embodiments and the features of the embodiments can be combined with each other. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts fall within the protection scope of the present application.
[0031] An embodiment of the present invention provides a method for inter-core data communication in a multi-core operating system. Refer to Figure 1 and Figure 2 as shown, which includes:
[0032] Step 1: After the multi-core operating system is powered on, each core creates a socket descriptor pool, allocates and binds an inter-core socket for each core from the socket descriptor pool, and creates a receive queue in the shared storage area for each inter-core socket. Herein, the core that needs to send data is defined as the sending core, and the core that needs to receive data is defined as the receiving core;
[0033] Step 2: The sending core packs the connection request event into a first data packet and stores the first data packet in the receive queue of the receiving core;
[0034] Step 3: The receiving core receives the first data packet according to the inter-core interrupt sent by the sending core, allocates a new inter-core socket for the receiving core according to the connection request event in the first data packet, and establishes a communication link with the sending core using the new inter-core socket;
[0035] Step 4: The sending core packs the processing data event and the data to be sent into a second data packet and stores the second data packet in the receive queue of the receiving core;
[0036] Step 5: The receiving core receives the second data packet according to the inter-core interrupt sent by the sending core, and receives and processes the data to be sent according to the processing data event in the second data packet;
[0037] Step 6: After the receiving core receives and processes the data to be sent, it releases the new inter-core socket and disconnects the communication link with the sending core.
[0038] Further, in the above step 1, after the multi-core operating system is powered on, it further includes:
[0039] Step 11, the starting address of the shared storage area, the size of the shared memory, and the maximum number of nodes, ports, maximum number of socket descriptors, and interrupt number in the bus list.
[0040] Further, in the above step 1, each core creates a socket descriptor pool, and allocates and binds an inter-core socket for each core from the socket descriptor pool, including:
[0041] Step 12, each core in the multi-core operating system creates a socket descriptor pool locally, and allocates and binds an inter-core socket for each core from the socket descriptor pool;
[0042] Step 13, write the address information of each core into the inter-core socket allocated to it and bind it to the inter-core socket, where the address information includes an address cluster, a bus number, a node number, and a port number.
[0043] Further, in the above step 3, according to the connection request event in the first data packet, allocate a new inter-core socket for the receiving core, and establish a communication link with the sending core using the new inter-core socket, including:
[0044] Step 31, when the receiving core receives and parses the event in the first data packet as the connection request event, allocate a new inter-core socket for the receiving core from the socket descriptor pool;
[0045] Step 32, the receiving core uses the new inter-core socket to send an ACK message to the sending core according to the node number and port number of the sending core in the connection request event;
[0046] Step 33, the sending core establishes a communication link with the new inter-core socket according to the received ACK message and communicates with the sending core.
[0047] Even further, in the above step 31, the address structures of the inter-core socket and the new inter-core socket both include an address cluster, a bus number, a node number, and a port number.
[0048] In specific implementation, the receiving core (such as socket2) keeps listening. When it listens to the inter-core interrupt and data packet sent by the receiving core (such as socket1) to its receiving queue, it starts to establish a link and communicate. The process of establishing a communication link between the two can be seen in Figure 3 as shown.
[0049] Further, in the above step 5, according to the processing data event in the second data packet, receive and process the data to be sent, including:
[0050] The receiving core extracts the data to be sent according to the event pool offset, event offset, and event index in the processing data event, and processes the data to be sent according to the event instruction in the processing data event.
[0051] The embodiments of the present invention achieve the following technical effects: In the inter-core data communication method of the multi-core operating system disclosed in the present invention, through the established shared storage area, an inter-core socket (i.e., socket) can be allocated for each core from the socket descriptor pool created by it. By allocating a new inter-core socket to the receiving core and using the new inter-core socket to communicate and transfer data with the sending core, it has the advantages of high reliability in data transmission and orderly data transmission. The method of the present invention solves the technical problems that the existing connectionless-oriented method has the advantage of high transmission rate, but has the disadvantages of low reliability in receiving data and possible disorder.
[0052] Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the embodiments of the present invention can be implemented by a general computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. Optionally, they can be implemented by program codes executable by the computing device. Thus, they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a different order from here, or they can be separately made into individual integrated circuit modules, or multiple modules or steps among them can be made into a single integrated circuit module to implement. In this way, the embodiments of the present invention are not limited to any specific combination of hardware and software.
[0053] The above are only the preferred embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, the embodiments of the present invention can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for inter-core data communication in a multi-core operating system, characterized in that Including: After the multi-core operating system is powered on, each core creates a socket descriptor pool, allocates and binds an inter-core socket for each core from the socket descriptor pool, and creates a receive queue in the shared storage area for each inter-core socket. Wherein, the core that needs to send data is defined as the sending core, and the core that needs to receive data is defined as the receiving core, including: each core in the multi-core operating system creates a socket descriptor pool locally, and allocates and binds an inter-core socket for each core from the socket descriptor pool; writes the address information of each core into the allocated inter-core socket and binds it to the inter-core socket, where the address information includes address cluster, bus number, node number, and port number. The sending core packs the connection request event into a first data packet and stores the first data packet in the receive queue of the receiving core. The receiving core receives the first data packet according to the inter-core interrupt sent by the sending core, and allocates a new inter-core socket for the receiving core according to the connection request event in the first data packet, and establishes a communication link with the sending core using the new inter-core socket, including: when the receiving core receives and parses the event in the first data packet as the connection request event, allocates a new inter-core socket for the receiving core from the socket descriptor pool; the receiving core uses the new inter-core socket and sends an ACK message to the sending core according to the node number and port number of the sending core in the connection request event; the sending core establishes a communication link with the new inter-core socket according to the received ACK message and communicates with the sending core. The sending core packs the processing data event and the data to be sent into a second data packet and stores the second data packet in the receive queue of the receiving core. The receiving core receives the second data packet according to the inter-core interrupt sent by the sending core, and receives and processes the data to be sent according to the processing data event in the second data packet, including: the receiving core extracts the data to be sent according to the event pool offset, event offset, and event index in the processing data event, and processes the data to be sent according to the event instruction in the processing data event. After the receiving core receives and processes the data to be sent, it releases the new inter-core socket and disconnects the communication link with the sending core.
2. The method for inter-core data communication in a multi-core operating system according to claim 1, wherein After the multi-core operating system is powered on, it further includes: Initializing the shared storage area for multi-core communication in the multi-core operating system, including initializing the starting address of the shared storage area, the shared memory size, and the maximum number of nodes, port numbers, the maximum number of socket sockets, and interrupt numbers in the bus list.
3. The method for inter-core data communication of a multi-core operating system according to claim 1, characterized in that, The address structures of the inter-core socket and the new inter-core socket both include address cluster, bus number, node number, and port number.
Citation Information
Patent Citations
Inter-core interaction method of multi-core system
CN108228524A
Communication apparatus, computer, and communication program
JP2015170947A