WO2013086847A1 - 核间通信的方法及核处理器 - Google Patents

核间通信的方法及核处理器 Download PDF

Info

Publication number
WO2013086847A1
WO2013086847A1 PCT/CN2012/077544 CN2012077544W WO2013086847A1 WO 2013086847 A1 WO2013086847 A1 WO 2013086847A1 CN 2012077544 W CN2012077544 W CN 2012077544W WO 2013086847 A1 WO2013086847 A1 WO 2013086847A1
Authority
WO
WIPO (PCT)
Prior art keywords
queue
bytes
read
write
identifier
Prior art date
Application number
PCT/CN2012/077544
Other languages
English (en)
French (fr)
Inventor
马书宇
陈诗军
陆海涛
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2013086847A1 publication Critical patent/WO2013086847A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus

Definitions

  • the present invention relates to the field of communications technologies, and in particular, to a method and a core processor for inter-core communication. Background technique
  • the existing inter-core communication method is to send a data packet to a shared queue, and then unpack the data packet and copy the data into the shared queue.
  • the inter-core communication method has low communication efficiency, so how to improve the inter-core communication Communication efficiency is an urgent problem to be solved. Summary of the invention
  • Embodiments of the present invention provide a method for inter-core communication and a core processor to solve the problem of low efficiency of communication between existing cores.
  • the embodiment of the invention provides a method for communication between cores, the method comprising:
  • the data transmitting core writes data to the shared queue between the data transmitting core and the data receiving core in units of bytes;
  • the data receiving core reads data from the shared queue in units of the number of bytes of the data packet.
  • the shared queue is a circular queue, and the circular queue includes a write identifier indicating a total number of bytes written in the circular queue and a read identifier indicating a total number of bytes read from the circular queue. .
  • the method before the data sending core writes data to the shared queue in units of bytes, the method further includes:
  • the data sending core determines whether the shared queue is a full queue.
  • the step of determining, by the data sending core, whether the shared queue is a full queue includes: The data sending core obtains a write pointer, a write identifier, a read pointer, and a read identifier of the circular queue;
  • the ring The queue is a full queue, and if the read pointer is not equal to the write pointer or the total number of bytes written to the circular queue is equal to the total number of bytes read from the circular queue, the circular queue is not a full queue Or the data sending core determines whether the length of the ring queue for the write byte is smaller than the number of bytes to be written by the current write operation, and the readout identifier is read from the ring queue.
  • Readout identifier The total number of bytes represented is not equal to the total number of bytes represented by the write identifier, and the circular queue is full queue ⁇ J, if the length of the write queue for the circular queue is not less than the current write operation.
  • the number of bytes written, or the total number of bytes represented by the read identifier is equal to the total number of bytes represented by the write identifier, and the circular queue is not a full queue;
  • the step of the data sending core writing data to the shared queue in units of bytes includes: the data sending core determining that the circular queue is not a full queue, and writing data to the shared queue in units of bytes .
  • the method before the data receiving core reads data from the shared queue, the method further includes:
  • the data receiving core determines whether the shared queue is an empty queue.
  • the step of determining, by the data receiving core, whether the shared queue is an empty queue comprises: obtaining, by the data receiving core, a write pointer, a write identifier, a read pointer, and a read identifier of the circular queue;
  • Determining, by the data receiving core, whether the read pointer is equal to the write pointer, and whether the total number of bytes written to the circular queue represented by the write identifier is equal to the circular queue represented by the read identifier The total number of bytes read, if the read pointer is equal to the write pointer, and the write identifier The total number of bytes represented is equal to the total number of bytes represented by the readout identifier, and the circular queue is an empty queue, if the read pointer is not equal to the write pointer, or the write identifier indicates If the total number of bytes is not equal to the total number of bytes indicated by the read identifier, the circular queue is not an empty queue; or the data receiving core determines whether the length of the byte written to the circular queue is smaller than the current The number of bytes of the data packet, and whether the total number of bytes read from the circular queue indicated by the read identifier is equal to the total number of bytes written by the write identifier to the circular queue, if The length of
  • the embodiment of the invention further provides a core processor, the core processor comprising:
  • Write to the module which is set to: write data to the shared queue between the core processors in units of bytes;
  • a read module is configured to: read data from the shared queue in units of the number of bytes of the packet.
  • the shared queue is a circular queue
  • the circular queue includes a write identifier indicating a total number of bytes written in the circular queue and a read identifier indicating a total number of bytes read from the circular queue.
  • the core processor further includes a determining module
  • the determining module is configured to determine whether the circular queue is a full queue or an empty queue J
  • the writing module is configured to, after the determining module determines that the circular queue is not a full queue, write data to a shared queue between the core processors in units of bytes;
  • the reading module is configured to read data from the shared queue in units of the number of bytes of the data packet after the determining module determines that the circular queue is not an empty queue.
  • the determining module is configured to determine whether the circular queue is a full queue in the following manner:
  • the circular queue is not a full queue; or, Whether the length of the write byte for the circular queue is smaller than the number of bytes to be written by the current write operation, and whether the total number of bytes read from the circular queue indicated by the read identifier is equal to the write.
  • the total number of bytes written to the circular queue indicated by the identifier if the length of the write byte of the circular queue is smaller than the number of bytes to be written by the current write operation, and the read identifier indicates the total number of bytes
  • the number of bytes is not equal to the write identifier
  • the total number of bytes, the circular queue is a full queue, if the length of the write byte of the circular queue is not less than the number of bytes to be written by the current write operation, or the read identifier indicates The total number of bytes is equal to the total number of bytes represented by the
  • the circular queue is an empty queue, if If the read pointer is not equal to the write pointer, or the total number of bytes represented by the write identifier is not equal to the total number of bytes represented by the read identifier, the circular queue is not an empty queue; or, the judgment is written.
  • the total number of bytes into the circular queue if the length of the bytes written to the circular queue is less than the number of bytes of the current data packet, and the total number of bytes represented by the read identifier is not equal to the write represented by the write identifier.
  • the total number of bytes into the circular queue if the length of the bytes written to the circular queue is less than the number of bytes of the current data packet, and the total number of bytes represented by the read identifier is not equal to the write
  • the total word represented by the identification The number of bytes is an empty queue, if the length of the byte that has been written to the circular queue is not less than the number of bytes of the current data packet, or the total number of bytes represented by the read identifier is equal to the write If the total number of bytes represented by the identifier is entered, the circular queue is not an empty queue.
  • the above method for inter-core communication and the core processor do not need to perform data packet when transmitting data.
  • the packet operation realizes zero copy; when the data is received, the queue unit is set to the corresponding data packet, which facilitates the modular operation of the inter-core communication; thereby improving the communication efficiency.
  • FIG. 1 is a schematic diagram of inter-core communication according to an embodiment of the present invention.
  • FIG. 2 is a flowchart of an embodiment of an inter-core communication method according to an embodiment of the present invention
  • FIG. 3 is a schematic diagram of a state in which an inter-core shared queue is full according to an embodiment of the present invention
  • 4a is a schematic diagram 1 showing a state in which an inter-core shared queue is empty according to an embodiment of the present invention
  • FIG. 4b is a second schematic diagram of a state in which an inter-core shared queue is empty according to an embodiment of the present invention.
  • FIG. 5 is a flowchart of operation of reading and writing inter-core shared queues according to an embodiment of the present invention
  • FIG. 6 is a schematic structural diagram of an embodiment of a core processor according to an embodiment of the present invention.
  • FIG. 1 it is a schematic diagram of inter-core communication according to an embodiment of the present invention.
  • the data cores are divided into two types, one is a data transmission core, and the other is a data reception core.
  • the two cores exchange data through a shared queue between the cores.
  • the data sending core writes the data to the shared queue, and the data receiving core reads the data from the shared queue.
  • the inter-core shared queue uses a circular queue. The advantage of the circular queue is that it can be read and written continuously. Because it is a ring, it can be written down all the time. As long as the data can be read out in time, the data will not be overwritten.
  • the ring queue used in the embodiment of the present invention is not a standard ring queue, it is necessary to increase the write identifier indicating the total number of bytes written in the ring queue and the total number of bytes read from the ring queue. Read the identifier to ensure the correctness of the queue read and write by judging the queue empty, thus ensuring correct communication between the sending core and the receiving core.
  • Step 201 A data sending core sends a core and a data receiving core to the data in units of bytes. Write data between shared queues;
  • the shared queue is a circular queue, and the circular queue includes a write identifier indicating a total number of bytes written in the circular queue and a read identifier indicating a total number of bytes read from the circular queue.
  • the method further includes: the data sending core determining whether the shared queue is a full queue J
  • the foregoing data sending core determines whether the shared queue is a full queue, including:
  • the data sending core obtains a write pointer, a write identifier, a read pointer, and a read identifier of the circular queue;
  • the data sending core determines whether the read pointer is equal to the write pointer, and whether the total number of bytes written in the circular queue indicated by the write identifier is equal to the read from the circular queue indicated by the read identifier
  • the data transmission core determines whether the length of the write byte of the circular queue is smaller than the number of bytes to be written by the current write operation, and the read identifier indicates that the read queue is read from the circular queue.
  • the circular queue is a full queue, as shown in FIG. 3, if the length of the write queue for the circular queue is not less than the current write operation.
  • the number of bytes to be written, or the total number of bytes represented by the read identifier is equal to the total number of bytes represented by the write identifier, and the circular queue is not a full queue.
  • Step 202 The data receiving core reads data from the shared queue in units of the number of bytes of the data packet.
  • the method further includes: determining whether the shared queue is an empty queue, and reading data from the shared queue only after confirming that the shared queue is not an empty queue.
  • the data receiving core determining whether the shared queue is an empty queue includes: The data receiving core obtains a write pointer, a write identifier, a read pointer, and a read identifier of the circular queue;
  • the ring The queue is not an empty queue; or, the data receiving core determines whether the length of the byte that has been written into the circular queue is smaller than the number of bytes of the current data packet, and the read identifier indicates that the readout is from the circular queue Whether the total number of bytes is equal to the total number of bytes written to the circular queue represented by the write identifier, if the length of the byte that has been written into the circular queue is less than the number of bytes of the current data packet, and Read the total word indicated by the logo If the number is not equal to the total number of bytes represented by the write identifier, the circular queue is an empty queue, as shown in FIG.
  • the above data transmission core writes data in units of bytes, eliminating the grouping process of the data packet, that is, realizing zero-copy inter-core communication; the above data receiving core only needs to be in the read queue for data packets of different formats and sizes. It can be read according to different basic queue units, which facilitates the modular operation of inter-core communication; thus improving communication efficiency.
  • the above shared queue is a queue, but the queue structure is different from the view of the sending core and the receiving core.
  • the sending core writes data to the shared queue, it writes in bytes. Incoming, the number of bytes written per time is not fixed. From the perspective of the queue unit, the basic queue unit is byte. Each time the queue is written, how many bytes are copied into the queue; when the receiving core is in the read queue, its basic queue unit is the data packet, that is, the data of one packet is read at a time. In order to maintain consistency with the write pointer operation, its unit is also a byte. Each time a packet is read, the read pointer is offset by the number of bytes of a packet.
  • FIG. 6 is a schematic structural diagram of an embodiment of a core processor according to the present invention.
  • the core processor includes a write module 61 and a read module 62, where:
  • the write module 61 is arranged to write data to the shared queue between the core processors in units of bytes; the read module 62 is arranged to read data from the shared queue in units of the number of bytes of the data packet.
  • the shared queue is preferably a circular queue comprising a write identifier indicating the total number of bytes written to the ring queue and a read identifier indicating the total number of bytes read from the circular queue.
  • the core processor further includes a determining module 63.
  • the determining module 63 is configured to determine whether the circular queue is a full queue or an empty queue.
  • the writing module 61 is configured to be in the determining module. Determining that the circular queue is not a full queue, and writing data to the shared queue between the core processors in units of bytes; the reading module 62 is configured to determine, in the determining module, that the circular queue is not empty After the queue, data is read from the shared queue in units of the number of bytes of the packet.
  • the determining module 63 is configured to determine whether the circular queue is a full queue in the following manner:
  • the read pointer Determining whether the read pointer is equal to the write pointer, whether the total number of bytes written in the circular queue indicated by the write identifier is equal to the total bytes read from the circular queue indicated by the read identifier a number, if the read pointer is equal to the write pointer, and the total number of bytes written to the circular queue is not equal to the total number of bytes read from the circular queue, the circular queue is a full queue, if The read pointer is not equal to the write pointer, or the total number of bytes written to the circular queue is equal to the total number of bytes read from the circular queue, and the circular queue is not a full queue; or, Whether the length of the write byte of the circular queue is smaller than the number of bytes to be written by the current write operation, and whether the total number of bytes read from the circular queue indicated by the read identifier is equal to the write identifier The total number of bytes written to the circular queue, if the length of the write byte of the circular queue is smaller than
  • the determining module 63 is configured to determine whether the circular queue is an empty queue in the following manner: obtaining a write pointer, a write identifier, a read pointer, and a read identifier of the circular queue;
  • the read pointer Determining whether the read pointer is equal to the write pointer, whether the total number of bytes written in the circular queue indicated by the write identifier is equal to the total bytes read from the circular queue indicated by the read identifier a number, if the read pointer is equal to the write pointer, and the total number of bytes represented by the write identifier is equal to the total number of bytes represented by the read identifier, the circular queue is an empty queue, if The read pointer is not equal to the write pointer, or the total number of bytes represented by the write identifier is not equal to the total number of bytes represented by the read identifier, and the circular queue is not an empty queue; or, the judgment is written.
  • the total number of bytes of the circular queue if the length of the byte that has been written into the circular queue is less than the number of bytes of the current data packet, and the total number of bytes represented by the read identifier is not equal to the write identifier The total number of bytes represented, then The circular queue is an empty queue.
  • the circular queue is not an empty queue.
  • the core processor When the core processor sends data as a data transmission core, it does not need to perform packet packing operation on the transmitting side, and can implement zero copy; when receiving data as the data receiving core, the queue unit is set as a corresponding data packet, which facilitates implementation of the core. Modular operation of inter-communication; thereby improving the efficiency of communication.
  • the above-mentioned inter-core communication method and the core processor do not need to perform packet packing operation when transmitting data, and realize zero copy; when the data is received, the queue unit is set as a corresponding data packet, which facilitates implementation of the inter-core space. Modular operation of communication; thereby improving the efficiency of communication.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Communication Control (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Information Transfer Systems (AREA)

Abstract

本发明提供了一种核间通信的方法及核处理器,其中,该核间通信的方法包括:数据发送核以字节为单位向所述数据发送核和数据接收核之间的共享队列写入数据;所述数据接收核以数据包的字节数为单位从所述共享队列读出数据。上述核间通信的方法及核处理器,在发送数据时不需要进行数据包的打包操作,实现了零拷贝;在接收数据时把队列单元设置为相应的数据包,便于实现核间通信的模块化操作;从而提高了通信的效率。

Description

核间通信的方法及核处理器
技术领域
本发明涉及通信技术领域, 尤其涉及一种核间通信的方法及核处理器。 背景技术
随着无线通信技术的发展, 无线通信系统中有些设备, 尤其是一些实时 进行无线信道仿真的设备, 经常要求进行大数据量的计算, 这些设备通常釆 用多个核处理器, 多个核进行信道仿真计算。
现有的核间通信方法是将数据包发送到共享队列后, 对该数据包进行解 包后将数据拷入共享队列中, 该种核间通信方法通信效率较低, 因此, 如何 提高核间通信效率是一个急需解决的问题。 发明内容
本发明实施例提供了一种核间通信的方法及核处理器, 以解决现有的核 间通信效率低的问题。
本发明实施例提供了一种核间通信的方法, 该方法包括:
数据发送核以字节为单位向所述数据发送核和数据接收核之间的共享队 列写入数据; 以及
所述数据接收核以数据包的字节数为单位从所述共享队列读出数据。 优选地, 所述共享队列为环形队列, 所述环形队列包含表示写入所述环 形队列的总字节数的写入标识和表示从所述环形队列读出的总字节数的读出 标识。
优选地, 所述数据发送核以字节为单位向所述共享队列写入数据之前, 所述方法还包括:
所述数据发送核判断所述共享队列是否为满队列。
优选地, 所述数据发送核判断所述共享队列是否为满队列的步骤包括: 所述数据发送核获得所述环形队列的写指针、 写入标识、 读指针和读出 标识;
所述数据发送核判断所述读指针是否等于所述写指针, 以及所述写入标 识表示的写入所述环形队列的总字节数是否等于所述读出标识表示的从所述 环形队列读出的总字节数, 若所述读指针等于所述写指针, 且写入所述环形 队列的总字节数不等于从所述环形队列读出的总字节数, 则所述环形队列是 满队列, 若所述读指针不等于所述写指针或者写入所述环形队列的总字节数 等于从所述环形队列读出的总字节数, 则所述环形队列不是满队列; 或者, 所述数据发送核判断所述环形队列供写入字节的长度是否小于当前写入操作 欲写入的字节数, 以及所述读出标识表示的从所述环形队列读出的总字节数 是否等于所述写入标识表示的写入所述环形队列的总字节数, 若所述环形队 列供写入字节的长度小于当前写入操作欲写入的字节数, 且所述读出标识表 示的总字节数不等于所述写入标识表示的总字节数, 则所述环形队列是满队 歹J ,若所述环形队列供写入字节的长度不小于当前写入操作欲写入的字节数, 或所述读出标识表示的总字节数等于所述写入标识表示的总字节数, 则所述 环形队列不是满队列;
所述数据发送核以字节为单位向所述共享队列写入数据的步骤包括: 所述数据发送核确定所述环形队列不是满队列后, 以字节为单位向所述 共享队列写入数据。
优选地, 所述数据接收核从所述共享队列读出数据之前, 所述方法还包 括:
所述数据接收核判断所述共享队列是否为空队列。
优选地, 所述数据接收核判断所述共享队列是否为空队列的步骤包括: 所述数据接收核获得所述环形队列的写指针、 写入标识、 读指针和读出 标识;
所述数据接收核判断所述读指针是否等于所述写指针, 以及所述写入标 识表示的写入所述环形队列的总字节数是否等于所述读出标识表示的从所述 环形队列读出的总字节数, 若所述读指针等于所述写指针, 且所述写入标识 表示的总字节数等于所述读出标识表示的总字节数, 则所述环形队列是空队 歹 lj , 若所述读指针不等于所述写指针, 或所述写入标识表示的总字节数不等 于所述读出标识表示的总字节数, 则所述环形队列不是空队列; 或者, 所述 数据接收核判断已写入所述环形队列的字节的长度是否小于当前数据包的字 节数, 以及所述读出标识表示的从所述环形队列读出的总字节数是否等于所 述写入标识表示的写入所述环形队列的总字节数, 若已写入所述环形队列的 字节的长度小于当前数据包的字节数, 且所述读出标识表示的总字节数不等 于所述写入标识表示的总字节数, 则所述环形队列是空队列, 若已写入所述 环形队列的字节的长度不小于当前数据包的字节数, 或所述读出标识表示的 总字节数等于所述写入标识表示的总字节数, 则所述环形队列不是空队列。
本发明实施例还提供了一种核处理器, 该核处理器包括:
写入模块, 其设置为: 以字节为单位向核处理器之间的共享队列写入数 据;
读出模块, 其设置为: 以数据包的字节数为单位从所述共享队列读出数 据。
优选地, 所述共享队列为环形队列, 所述环形队列包含表示写入所述环 形队列的总字节数的写入标识和表示从所述环形队列读出的总字节数的读出 标识。
优选地, 该核处理器还包括判断模块;
所述判断模块, 其设置为判断所述环形队列是否为满队列或是否为空队 歹 |J ;
所述写入模块是设置为在所述判断模块确定所述环形队列不是满队列 后, 以字节为单位向核处理器之间的共享队列写入数据;
所述读出模块是设置为在所述判断模块确定所述环形队列不是空队列 后, 以数据包的字节数为单位从所述共享队列读出数据。
优选地, 所述判断模块是设置为以如下方式判断所述环形队列是否为满 队列:
获得所述环形队列的写指针、 写入标识、 读指针和读出标识; 判断所述读指针是否等于所述写指针, 以及所述写入标识表示的写入所 述环形队列的总字节数是否等于所述读出标识表示的从所述环形队列读出的 总字节数, 若所述读指针等于所述写指针, 且写入所述环形队列的总字节数 不等于从所述环形队列读出的总字节数, 则所述环形队列是满队列, 若所述 读指针不等于所述写指针, 或写入所述环形队列的总字节数等于从所述环形 队列读出的总字节数, 则所述环形队列不是满队列; 或者, 判断所述环形队 列供写入字节的长度是否小于当前写入操作欲写入的字节数, 以及所述读出 标识表示的从所述环形队列读出的总字节数是否等于所述写入标识表示的写 入所述环形队列的总字节数, 若所述环形队列供写入字节的长度小于当前写 入操作欲写入的字节数, 且所述读出标识表示的总字节数不等于所述写入标 识表示的总字节数, 则所述环形队列是满队列, 若所述环形队列供写入字节 的长度不小于当前写入操作欲写入的字节数, 或所述读出标识表示的总字节 数等于所述写入标识表示的总字节数, 则所述环形队列不是满队列; 或者 所述判断模块是设置为以如下方式判断所述环形队列是否为空队列: 获得所述环形队列的写指针、 写入标识、 读指针和读出标识;
判断所述读指针是否等于所述写指针, 以及所述写入标识表示的写入所 述环形队列的总字节数是否等于所述读出标识表示的从所述环形队列读出的 总字节数, 若所述读指针等于所述写指针, 且所述写入标识表示的总字节数 等于所述读出标识表示的总字节数, 则所述环形队列是空队列, 若所述读指 针不等于所述写指针, 或所述写入标识表示的总字节数不等于所述读出标识 表示的总字节数, 则所述环形队列不是空队列; 或者, 判断已写入所述环形 队列的字节的长度是否小于当前数据包的字节数, 以及所述读出标识表示的 从所述环形队列读出的总字节数是否等于所述写入标识表示的写入所述环形 队列的总字节数, 若已写入所述环形队列的字节的长度小于当前数据包的字 节数,且所述读出标识表示的总字节数不等于所述写入标识表示的总字节数, 则所述环形队列是空队列, 若已写入所述环形队列的字节的长度不小于当前 数据包的字节数, 或所述读出标识表示的总字节数等于所述写入标识表示的 总字节数, 则所述环形队列不是空队列。
上述核间通信的方法及核处理器, 在发送数据时不需要进行数据包的打 包操作, 实现了零拷贝; 在接收数据时把队列单元设置为相应的数据包, 便 于实现核间通信的模块化操作; 从而提高了通信的效率。 附图概述
图 1是本发明实施例的核间通信示意图;
图 2是本发明实施例的核间通信方法实施例的流程图;
图 3是本发明实施例的核间共享队列为满的状态示意图;
图 4a是本发明实施例的核间共享队列为空的状态示意图一;
图 4b是本发明实施例的核间共享队列为空的状态示意图二;
图 5是本发明实施例的读写核间共享队列操作流程图;
图 6是本发明实施例的核处理器实施例的结构示意图。
本发明的较佳实施方式
下文中将结合附图对本发明的实施例进行详细说明。 需要说明的是, 在 不冲突的情况下, 本申请中的实施例及实施例中的特征可以相互任意组合。
如图 1所示, 是本发明实施例的核间通信示意图, 根据核间通信时数据 的流向, 将数据核分成两种, 一种是数据发送核, 一种是数据接收核。 两个 核通过核间的共享队列, 进行数据交互。 数据发送核将数据写入共享队列, 数据接收核从共享队列读出数据。 核间共享队列使用环形队列, 环形队列的 好处是可以不停地读写, 因为是一个环, 可以一直写下去, 只要保证数据能 及时读出, 数据不会被覆盖即可。 由于本发明实施例釆用的环形队列不是标 准的环形队列, 所以需要增加表示写入所述环形队列的总字节数的写入标识 和表示从所述环形队列读出的总字节数的读出标识,以通过队列空满的判断, 确保队列读写的正确性, 从而确保发送核和接收核之间的正确通信。
如图 2所示, 是本发明核间通信方法实施例的流程图, 该方法包括: 步骤 201、 数据发送核以字节为单位向所述数据发送核和数据接收核之 间的共享队列写入数据;
其中, 所述共享队列为环形队列, 所述环形队列包含表示写入所述环形 队列的总字节数的写入标识和表示从所述环形队列读出的总字节数的读出标 识。
在该步骤之前, 还可以包括: 数据发送核判断所述共享队列是否为满队 歹 |J , 只有在确定该共享队列不是满队列后, 才可以向共享队列中写入数据。
上述数据发送核判断所述共享队列是否为满队列包括:
所述数据发送核获得所述环形队列的写指针、 写入标识、 读指针和读出 标识;
所述数据发送核判断所述读指针是否等于所述写指针, 所述写入标识表 示的写入所述环形队列的总字节数是否等于所述读出标识表示的从所述环形 队列读出的总字节数, 若所述读指针等于所述写指针, 且写入所述环形队列 的总字节数不等于从所述环形队列读出的总字节数, 则所述环形队列是满队 歹J , 若所述读指针不等于所述写指针, 或写入所述环形队列的总字节数等于 从所述环形队列读出的总字节数, 则所述环形队列不是满队列; 或者, 所述 数据发送核判断所述环形队列供写入字节的长度是否小于当前写入操作欲写 入的字节数, 所述读出标识表示的从所述环形队列读出的总字节数是否等于 所述写入标识表示的写入所述环形队列的总字节数, 若所述环形队列供写入 字节的长度小于当前写入操作欲写入的字节数, 且所述读出标识表示的总字 节数不等于所述写入标识表示的总字节数, 则所述环形队列是满队列, 如图 3 所示, 若所述环形队列供写入字节的长度不小于当前写入操作欲写入的字 节数, 或所述读出标识表示的总字节数等于所述写入标识表示的总字节数, 则所述环形队列不是满队列。
步骤 202、 所述数据接收核以数据包的字节数为单位从所述共享队列读 出数据。
在该步骤之前, 还可以包括: 判断所述共享队列是否为空队列, 只有在 确认该共享队列不是空队列之后, 才可以从该共享队列中读数据。
所述数据接收核判断所述共享队列是否为空队列包括: 所述数据接收核获得所述环形队列的写指针、 写入标识、 读指针和读出 标识;
所述数据接收核判断所述读指针是否等于所述写指针, 所述写入标识表 示的写入所述环形队列的总字节数是否等于所述读出标识表示的从所述环形 队列读出的总字节数, 若所述读指针等于所述写指针, 且所述写入标识表示 的总字节数等于所述读出标识表示的总字节数, 则所述环形队列是空队列, 如图 4a所示, 若所述读指针不等于所述写指针, 或所述写入标识表示的总字 节数不等于所述读出标识表示的总字节数, 则所述环形队列不是空队列; 或 者, 所述数据接收核判断已写入所述环形队列的字节的长度是否小于当前数 据包的字节数, 所述读出标识表示的从所述环形队列读出的总字节数是否等 于所述写入标识表示的写入所述环形队列的总字节数, 若已写入所述环形队 列的字节的长度小于当前数据包的字节数, 且所述读出标识表示的总字节数 不等于所述写入标识表示的总字节数, 则所述环形队列是空队列, 如图 4b所 示, 若已写入所述环形队列的字节的长度不小于当前数据包的字节数, 或所 述读出标识表示的总字节数等于所述写入标识表示的总字节数, 则所述环形 队列不是空队列。
上述数据发送核以字节为单位写入数据, 省去了对数据包的组包过程, 即实现了零拷贝的核间通信; 上述数据接收核对于不同格式和大小的数据包 只需要在读队列时按不同的基本队列单元读取即可, 便于实现核间通信的模 块化操作; 从而提高了通信效率。
上述共享队列是一个队列, 但从发送核看和从接收核看, 其队列结构是 不同的, 如图 5所示, 发送核在向共享队列写入数据时, 是以字节为单位进 行写入的, 每次写入的字节数不固定, 从队列单元的角度看, 其基本的队列 单元即为字节。 每次写队列, 即往队列中拷入多少字节; 接收核在读队列时, 其基本的队列单元是数据包, 即每次读取一个数据包的数据。 为了保持和写 指针操作的一致性, 其单位也是字节。 每读取一个数据包, 读指针就偏移一 个数据包的字节数。 这样针对不同的数据包操作, 不需要在发送侧进行数据 包的打包操作, 可以实现零拷贝, 只需在接收核侧, 把队列单元设置为相应 的数据包即可, 这样便于实现核间通信的模块化操作。 如图 6所示, 是本发明核处理器实施例的结构示意图, 该核处理器包括 写入模块 61和读出模块 62, 其中:
写入模块 61 ,设置为以字节为单位向核处理器之间的共享队列写入数据; 读出模块 62 ,设置为以数据包的字节数为单位从所述共享队列读出数据。 上述共享队列优选为环形队列, 所述环形队列包含表示写入所述环形队 列的总字节数的写入标识和表示从所述环形队列读出的总字节数的读出标 识。
另外, 该核处理器还包括判断模块 63; 所述判断模块 63 , 设置为判断所 述环形队列是否为满队列或是否为空队列; 所述写入模块 61 , 是设置为在所 述判断模块确定所述环形队列不是满队列后, 以字节为单位向核处理器之间 的共享队列写入数据; 所述读出模块 62, 是设置为在所述判断模块确定所述 环形队列不是空队列后,以数据包的字节数为单位从所述共享队列读出数据。
其中,所述判断模块 63是设置为以如下方式判断所述环形队列是否为满 队列:
获得所述环形队列的写指针、 写入标识、 读指针和读出标识;
判断所述读指针是否等于所述写指针, 所述写入标识表示的写入所述环 形队列的总字节数是否等于所述读出标识表示的从所述环形队列读出的总字 节数, 若所述读指针等于所述写指针, 且写入所述环形队列的总字节数不等 于从所述环形队列读出的总字节数, 则所述环形队列是满队列, 若所述读指 针不等于所述写指针, 或写入所述环形队列的总字节数等于从所述环形队列 读出的总字节数, 则所述环形队列不是满队列; 或者, 判断所述环形队列供 写入字节的长度是否小于当前写入操作欲写入的字节数, 所述读出标识表示 的从所述环形队列读出的总字节数是否等于所述写入标识表示的写入所述环 形队列的总字节数, 若所述环形队列供写入字节的长度小于当前写入操作欲 写入的字节数, 且所述读出标识表示的总字节数不等于所述写入标识表示的 总字节数, 则所述环形队列为满队列, 若所述环形队列供写入字节的长度不 小于当前写入操作欲写入的字节数, 或所述读出标识表示的总字节数等于所 述写入标识表示的总字节数, 则所述环形队列为非满队列。
所述判断模块 63是设置为以如下方式判断所述环形队列是否为空队列: 获得所述环形队列的写指针、 写入标识、 读指针和读出标识;
判断所述读指针是否等于所述写指针, 所述写入标识表示的写入所述环 形队列的总字节数是否等于所述读出标识表示的从所述环形队列读出的总字 节数, 若所述读指针等于所述写指针, 且所述写入标识表示的总字节数等于 所述读出标识表示的总字节数, 则所述环形队列是空队列, 若所述读指针不 等于所述写指针, 或所述写入标识表示的总字节数不等于所述读出标识表示 的总字节数, 则所述环形队列不是空队列; 或者, 判断已写入所述环形队列 的字节的长度是否小于当前数据包的字节数, 所述读出标识表示的从所述环 形队列读出的总字节数是否等于所述写入标识表示的写入所述环形队列的总 字节数, 若已写入所述环形队列的字节的长度小于当前数据包的字节数, 且 所述读出标识表示的总字节数不等于所述写入标识表示的总字节数, 则所述 环形队列是空队列, 若已写入所述环形队列的字节的长度不小于当前数据包 的字节数, 或所述读出标识表示的总字节数等于所述写入标识表示的总字节 数, 则所述环形队列不是空队列。
上述核处理器作为数据发送核发送数据时, 不需要在发送侧进行数据包 的打包操作, 可以实现零拷贝; 作为数据接收核接收数据时, 把队列单元设 置为相应的数据包, 便于实现核间通信的模块化操作; 从而提高通信的效率。
本领域普通技术人员可以理解上述方法中的全部或部分步骤可通过程序 来指令相关硬件完成, 上述程序可以存储于计算机可读存储介质中, 如只读 存储器、 磁盘或光盘等。 可选地, 上述实施例的全部或部分步骤也可以使用 一个或多个集成电路来实现。 相应地, 上述实施例中的各模块 /单元可以釆用 硬件的形式实现, 也可以釆用软件功能模块的形式实现。 本发明不限制于任 何特定形式的硬件和软件的结合。
以上实施例仅用以说明本发明的技术方案而非限制, 仅仅参照较佳实施 例对本发明进行了详细说明。 本领域的普通技术人员应当理解, 可以对本发 明的技术方案进行修改或者等同替换, 而不脱离本发明技术方案的精神和范 围, 均应涵盖在本发明的权利要求范围当中。
工业实用性 上述核间通信的方法及核处理器, 在发送数据时不需要进行数据包的打 包操作, 实现了零拷贝; 在接收数据时把队列单元设置为相应的数据包, 便 于实现核间通信的模块化操作; 从而提高了通信的效率。

Claims

权 利 要 求 书
1、 一种核间通信的方法, 该方法包括:
数据发送核以字节为单位向所述数据发送核和数据接收核之间的共享队 列写入数据; 以及
所述数据接收核以数据包的字节数为单位从所述共享队列读出数据。
2、 根据权利要求 1所述的方法, 其中:
所述共享队列为环形队列, 所述环形队列包含表示写入所述环形队列的 总字节数的写入标识和表示从所述环形队列读出的总字节数的读出标识。
3、 根据权利要求 2所述的方法, 其中:
所述数据发送核以字节为单位向所述共享队列写入数据之前, 所述方法 还包括:
所述数据发送核判断所述共享队列是否为满队列。
4、 根据权利要求 3所述的方法, 其中:
所述数据发送核判断所述共享队列是否为满队列的步骤包括:
所述数据发送核获得所述环形队列的写指针、 写入标识、 读指针和读出 标识;
所述数据发送核判断所述读指针是否等于所述写指针, 以及所述写入标 识表示的写入所述环形队列的总字节数是否等于所述读出标识表示的从所述 环形队列读出的总字节数, 若所述读指针等于所述写指针, 且写入所述环形 队列的总字节数不等于从所述环形队列读出的总字节数, 则所述环形队列是 满队列, 若所述读指针不等于所述写指针或者写入所述环形队列的总字节数 等于从所述环形队列读出的总字节数, 则所述环形队列不是满队列; 或者, 所述数据发送核判断所述环形队列供写入字节的长度是否小于当前写入操作 欲写入的字节数, 以及所述读出标识表示的从所述环形队列读出的总字节数 是否等于所述写入标识表示的写入所述环形队列的总字节数, 若所述环形队 列供写入字节的长度小于当前写入操作欲写入的字节数, 且所述读出标识表 示的总字节数不等于所述写入标识表示的总字节数, 则所述环形队列是满队 歹 lj ,若所述环形队列供写入字节的长度不小于当前写入操作欲写入的字节数, 或所述读出标识表示的总字节数等于所述写入标识表示的总字节数, 则所述 环形队列不是满队列;
所述数据发送核以字节为单位向所述共享队列写入数据的步骤包括: 所述数据发送核确定所述环形队列不是满队列后, 以字节为单位向所述 共享队列写入数据。
5、 根据权利要求 2所述的方法, 其中:
所述数据接收核从所述共享队列读出数据之前, 所述方法还包括: 所述数据接收核判断所述共享队列是否为空队列。
6、 根据权利要求 5所述的方法, 其中:
所述数据接收核判断所述共享队列是否为空队列的步骤包括:
所述数据接收核获得所述环形队列的写指针、 写入标识、 读指针和读出 标识;
所述数据接收核判断所述读指针是否等于所述写指针, 以及所述写入标 识表示的写入所述环形队列的总字节数是否等于所述读出标识表示的从所述 环形队列读出的总字节数, 若所述读指针等于所述写指针, 且所述写入标识 表示的总字节数等于所述读出标识表示的总字节数, 则所述环形队列是空队 歹 ij , 若所述读指针不等于所述写指针, 或所述写入标识表示的总字节数不等 于所述读出标识表示的总字节数, 则所述环形队列不是空队列; 或者, 所述 数据接收核判断已写入所述环形队列的字节的长度是否小于当前数据包的字 节数, 以及所述读出标识表示的从所述环形队列读出的总字节数是否等于所 述写入标识表示的写入所述环形队列的总字节数, 若已写入所述环形队列的 字节的长度小于当前数据包的字节数, 且所述读出标识表示的总字节数不等 于所述写入标识表示的总字节数, 则所述环形队列是空队列, 若已写入所述 环形队列的字节的长度不小于当前数据包的字节数, 或所述读出标识表示的 总字节数等于所述写入标识表示的总字节数, 则所述环形队列不是空队列。
7、 一种核处理器, 该核处理器包括:
写入模块, 其设置为: 以字节为单位向核处理器之间的共享队列写入数 据;
读出模块, 其设置为: 以数据包的字节数为单位从所述共享队列读出数 据。
8、 根据权利要求 7所述的核处理器, 其中:
所述共享队列为环形队列, 所述环形队列包含表示写入所述环形队列的 总字节数的写入标识和表示从所述环形队列读出的总字节数的读出标识。
9、 根据权利要求 8所述的核处理器, 该核处理器还包括判断模块; 所述判断模块设置为判断所述环形队列是否为满队列或是否为空队列; 所述写入模块是设置为在所述判断模块确定所述环形队列不是满队列 后, 以字节为单位向核处理器之间的共享队列写入数据;
所述读出模块是设置为在所述判断模块确定所述环形队列不是空队列 后, 以数据包的字节数为单位从所述共享队列读出数据。
10、 根据权利要求 9所述的核处理器, 其中,
所述判断模块是设置为以如下方式判断所述环形队列是否为满队列: 获得所述环形队列的写指针、 写入标识、 读指针和读出标识;
判断所述读指针是否等于所述写指针, 以及所述写入标识表示的写入所 述环形队列的总字节数是否等于所述读出标识表示的从所述环形队列读出的 总字节数, 若所述读指针等于所述写指针, 且写入所述环形队列的总字节数 不等于从所述环形队列读出的总字节数, 则所述环形队列是满队列, 若所述 读指针不等于所述写指针, 或写入所述环形队列的总字节数等于从所述环形 队列读出的总字节数, 则所述环形队列不是满队列; 或者, 判断所述环形队 列供写入字节的长度是否小于当前写入操作欲写入的字节数, 以及所述读出 标识表示的从所述环形队列读出的总字节数是否等于所述写入标识表示的写 入所述环形队列的总字节数, 若所述环形队列供写入字节的长度小于当前写 入操作欲写入的字节数, 且所述读出标识表示的总字节数不等于所述写入标 识表示的总字节数, 则所述环形队列是满队列, 若所述环形队列供写入字节 的长度不小于当前写入操作欲写入的字节数, 或所述读出标识表示的总字节 数等于所述写入标识表示的总字节数, 则所述环形队列不是满队列; 或者 所述判断模块是设置为以如下方式判断所述环形队列是否为空队列: 获得所述环形队列的写指针、 写入标识、 读指针和读出标识;
判断所述读指针是否等于所述写指针, 以及所述写入标识表示的写入所 述环形队列的总字节数是否等于所述读出标识表示的从所述环形队列读出的 总字节数, 若所述读指针等于所述写指针, 且所述写入标识表示的总字节数 等于所述读出标识表示的总字节数, 则所述环形队列是空队列, 若所述读指 针不等于所述写指针, 或所述写入标识表示的总字节数不等于所述读出标识 表示的总字节数, 则所述环形队列不是空队列; 或者, 判断已写入所述环形 队列的字节的长度是否小于当前数据包的字节数, 所述读出标识表示的从所 述环形队列读出的总字节数是否等于所述写入标识表示的写入所述环形队列 的总字节数,若已写入所述环形队列的字节的长度小于当前数据包的字节数, 且所述读出标识表示的总字节数不等于所述写入标识表示的总字节数, 则所 述环形队列是空队列, 若已写入所述环形队列的字节的长度不小于当前数据 包的字节数, 或所述读出标识表示的总字节数等于所述写入标识表示的总字 节数, 则所述环形队列不是空队列。
PCT/CN2012/077544 2011-12-12 2012-06-26 核间通信的方法及核处理器 WO2013086847A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201110411232.2A CN103166873B (zh) 2011-12-12 2011-12-12 核间通信的方法及核处理器
CN201110411232.2 2011-12-12

Publications (1)

Publication Number Publication Date
WO2013086847A1 true WO2013086847A1 (zh) 2013-06-20

Family

ID=48589623

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/077544 WO2013086847A1 (zh) 2011-12-12 2012-06-26 核间通信的方法及核处理器

Country Status (2)

Country Link
CN (1) CN103166873B (zh)
WO (1) WO2013086847A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110764924A (zh) * 2018-07-27 2020-02-07 普天信息技术有限公司 一种多核处理器的核间通信方法及装置
CN112214444A (zh) * 2020-09-24 2021-01-12 深圳云天励飞技术股份有限公司 一种核间通信方法、arm、dsp及终端
CN114490127A (zh) * 2022-01-20 2022-05-13 Oppo广东移动通信有限公司 核间通信方法、装置、电子设备及存储介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1540523A (zh) * 2003-10-30 2004-10-27 中兴通讯股份有限公司 单任务快速缓冲读写方法
CN101013383A (zh) * 2007-02-13 2007-08-08 杭州华为三康技术有限公司 实现多核cpu进行报文联合处理的系统及方法
CN101631327A (zh) * 2009-08-04 2010-01-20 华为技术有限公司 微波业务数据发送、接收方法及装置、收发系统

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5313582A (en) * 1991-04-30 1994-05-17 Standard Microsystems Corporation Method and apparatus for buffering data within stations of a communication network
CN1238788C (zh) * 2003-10-08 2006-01-25 复旦大学 可处理变长数据的先进先出寄存器队列装置及控制方法
CN100362839C (zh) * 2003-12-29 2008-01-16 中兴通讯股份有限公司 基于流水线的多队列顺序化缓冲管理电路及方法
CN1829129B (zh) * 2005-03-04 2010-12-22 Ut斯达康通讯有限公司 消除多路同步数据传输中的传输延时差异的方法和装置
CN101034346A (zh) * 2006-03-10 2007-09-12 北京佳讯飞鸿电气有限责任公司 一种循环队列的数据存储方法
CN100517294C (zh) * 2006-07-14 2009-07-22 中兴通讯股份有限公司 一种基于共享存储器的双cpu通信方法
CN101771554B (zh) * 2008-12-31 2012-01-11 中国航空工业第一集团公司第六三一研究所 一种余度管理电路及其管理方法
CN102023961A (zh) * 2009-09-10 2011-04-20 中兴通讯股份有限公司 一种基于共享内存的通信方法及装置
CN101753439A (zh) * 2009-12-18 2010-06-23 深圳市融创天下科技发展有限公司 一种流媒体分发传输方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1540523A (zh) * 2003-10-30 2004-10-27 中兴通讯股份有限公司 单任务快速缓冲读写方法
CN101013383A (zh) * 2007-02-13 2007-08-08 杭州华为三康技术有限公司 实现多核cpu进行报文联合处理的系统及方法
CN101631327A (zh) * 2009-08-04 2010-01-20 华为技术有限公司 微波业务数据发送、接收方法及装置、收发系统

Also Published As

Publication number Publication date
CN103166873A (zh) 2013-06-19
CN103166873B (zh) 2018-02-27

Similar Documents

Publication Publication Date Title
US11500810B2 (en) Techniques for command validation for access to a storage device by a remote client
US11023411B2 (en) Programmed input/output mode
KR102532173B1 (ko) 메모리 액세스 기술 및 컴퓨터 시스템
US9411775B2 (en) iWARP send with immediate data operations
US10789110B2 (en) Methods and apparatus for correcting out-of-order data transactions between processors
CN111930676B (zh) 多处理器间的通信方法、装置、系统及存储介质
US8732360B2 (en) System and method for accessing memory
US20140068134A1 (en) Data transmission apparatus, system, and method
RU2559727C2 (ru) Способ и устройство для обеспечения потоков на основе идентификатора через шину pci express
WO2014169860A1 (zh) 一种数据传输方法及设备
US9846657B2 (en) Electronic device for packing multiple commands in one compound command frame and electronic device for decoding and executing multiple commands packed in one compound command frame
JP6189898B2 (ja) アクティブメッセージによるrmaapiのサポート
US20100185811A1 (en) Data processing system and method
WO2018041074A1 (zh) 一种内存设备的访问方法、装置和系统
US20200034186A1 (en) Methods and apparatus for verifying completion of groups of data transactions between processors
US10489322B2 (en) Apparatus and method to improve performance in DMA transfer of data
WO2013086847A1 (zh) 核间通信的方法及核处理器
WO2022110387A1 (zh) 路由装置及片上网络的路由设备
US9817784B2 (en) Multi-port transmitter device for transmitting at least partly redundant data, an associated control system, an associated method and an associated computer program product
US9338219B2 (en) Direct push operations and gather operations
US9311225B2 (en) DMA channels
KR101486547B1 (ko) Ldma방법을 이용한 ipc장치
KR20160007859A (ko) 컴퓨팅 시스템 및 이의 동작 방법.
CN114641035A (zh) 无线数据包聚合发送方法及其电子设备、介质
JP2013191202A (ja) マルチコアプロセッサ

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 12857735

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 12857735

Country of ref document: EP

Kind code of ref document: A1