CN112486702B - Global message queue implementation method based on multi-core multi-processor parallel system - Google Patents
Global message queue implementation method based on multi-core multi-processor parallel system Download PDFInfo
- Publication number
- CN112486702B CN112486702B CN202011360414.7A CN202011360414A CN112486702B CN 112486702 B CN112486702 B CN 112486702B CN 202011360414 A CN202011360414 A CN 202011360414A CN 112486702 B CN112486702 B CN 112486702B
- Authority
- CN
- China
- Prior art keywords
- global
- message
- queue
- message queue
- semaphore
- Prior art date
- Legal status (The legal status 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 status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 24
- 238000012545 processing Methods 0.000 claims abstract description 55
- 230000005540 biological transmission Effects 0.000 claims abstract description 5
- 238000004891 communication Methods 0.000 abstract description 9
- 238000012546 transfer Methods 0.000 abstract description 3
- 238000011161 development Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000009977 dual effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F5/00—Methods or arrangements for data conversion without changing the order or content of the data handled
- G06F5/06—Methods or arrangements for data conversion without changing the order or content of the data handled for changing the speed of data flow, i.e. speed regularising or timing, e.g. delay lines, FIFO buffers; over- or underrun control therefor
- G06F5/065—Partitioned buffers, e.g. allowing multiple independent queues, bidirectional FIFO's
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F9/526—Mutual exclusion algorithms
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/544—Buffers; Shared memory; Pipes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/54—Indexing scheme relating to G06F9/54
- G06F2209/548—Queue
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Multi Processors (AREA)
Abstract
Description
技术领域Technical field
本发明涉及一种全局消息队列的实现方法,具体为一种基于多核多处理器并行系统的全局消息队列实现方法,属于嵌入式计算机领域。The invention relates to a global message queue implementation method, specifically a global message queue implementation method based on a multi-core multi-processor parallel system, and belongs to the field of embedded computers.
背景技术Background technique
随着计算机系统的发展以及领域应用对实时性、并行性需求的日益增长,多核多处理器并行系统己成为嵌入式计算机系统发展的重要趋势。With the development of computer systems and the increasing demand for real-time and parallelism in field applications, multi-core and multi-processor parallel systems have become an important trend in the development of embedded computer systems.
随着多核多处理器并行系统核心数和处理器节点的增多,与传统的多核处理器消息通信方式相比,多核多处理器并行系统的消息通信方式更复杂,其不仅需要实现多核处理器片内处理核心间通信,还需要实现多处理器片间的通信。换言之,消息通信成为影响多核多处理器并行系统性能的瓶颈之一。因此,处理核心之间、处理器之间的高效通信成为多核多处理器并行系统的关键问题。As the number of cores and processor nodes in multi-core and multi-processor parallel systems increases, compared with the traditional multi-core processor message communication method, the message communication method of multi-core and multi-processor parallel systems is more complex. It not only requires the implementation of multi-core processor chip In addition to inter-core communication, it is also necessary to implement multi-processor inter-chip communication. In other words, message communication has become one of the bottlenecks affecting the performance of multi-core and multi-processor parallel systems. Therefore, efficient communication between processing cores and processors has become a key issue in multi-core and multi-processor parallel systems.
此外,处理核心之间、处理器之间进行通信时,其线程必须互斥地访问多核处理器上的硬件资源,否则会造成因资源争用导致的访问数据错误等问题,进而导致处理核心之间、处理器之间的通信失败。In addition, when communicating between processing cores and between processors, their threads must mutually access hardware resources on the multi-core processor. Otherwise, problems such as access data errors due to resource contention will occur, which will lead to inter-processing cores. Communication between processors failed.
发明内容Contents of the invention
本发明的目的就在于为了解决上述问题而提供一种基于多核多处理器并行系统的全局消息队列实现方法,该方法利用全局信号量与共享存储区,将线程之间的消息传递交由全局信号量控制,任何使用全局消息队列的线程获取全局信号量后,才能进行全局消息队列的相关操作,满足多核多处理器间的高速通信需求,具有快速、高效、安全的特点,能在极大程度上简化应用开发人员的工作。The purpose of the present invention is to provide a global message queue implementation method based on a multi-core multi-processor parallel system in order to solve the above problems. This method uses global semaphores and shared storage areas to transfer messages between threads to global signals. Volume control. Any thread that uses the global message queue can perform operations related to the global message queue only after acquiring the global semaphore. This meets the high-speed communication needs between multi-core and multi-processors. It is fast, efficient, and safe, and can be used to a great extent. Simplify the work of application developers.
本发明通过以下技术方案来实现上述目的:一种基于多核多处理器并行系统的全局消息队列实现方法,该全局消息队列实现方法包括:The present invention achieves the above objects through the following technical solutions: a global message queue implementation method based on a multi-core multi-processor parallel system. The global message queue implementation method includes:
S1)多核多处理器并行系统的各处理核心进行系统初始化,通过SRIO映射一段共享存储空间用于存储全局消息队列与全局消息队列名表;S1) Each processing core of the multi-core multi-processor parallel system initializes the system, and maps a shared storage space through SRIO to store the global message queue and global message queue name table;
S2)从线程所属的处理核心对应的全局消息队列缓冲池中创建并初始化全局消息队列,将全局消息队列信息填入全局消息队列名表;S2) Create and initialize the global message queue from the global message queue buffer pool corresponding to the processing core to which the thread belongs, and fill in the global message queue information into the global message queue name table;
S3)当线程向全局消息队列发送消息或从全局消息队列接收消息时,通过全局信号量对全局消息队列资源进行管理与控制,实现消息的传输。S3) When a thread sends a message to or receives a message from the global message queue, the global message queue resources are managed and controlled through the global semaphore to realize message transmission.
优选地,所述多核多处理器并行系统的处理器节点数至少有1个;所述处理器节点的处理核心至少有1个;并且所述处理器节点间或处理核心支持SRIO总线互连。Preferably, the multi-core multi-processor parallel system has at least one processor node; the processor node has at least one processing core; and the processor nodes or processing cores support SRIO bus interconnection.
优选地,步骤S1)中,所述系统初始化的过程包括:Preferably, in step S1), the system initialization process includes:
S11)各处理核心初始化SRIO,通过SRIO映射一段共享存储空间用于存储全局消息队列与全局消息队列名表;S11) Each processing core initializes SRIO, and maps a shared storage space through SRIO to store the global message queue and global message queue name table;
S12)选取任一处理核心为主处理核心,创建并初始化一张共享的全局消息队列名表,用于记录所有已创建的全局消息队列;S12) Select any processing core as the main processing core, create and initialize a shared global message queue name table, which is used to record all created global message queues;
S13)在各处理核心映射出的共享存储空间中,创建全局消息队列缓冲池和消息缓冲池。S13) Create a global message queue buffer pool and a message buffer pool in the shared storage space mapped by each processing core.
优选地,步骤S12)中,所述全局消息队列名表的内容包括控制名表互斥访问的全局信号量、名表中所有已创建的全局消息队列数目,以及所有已创建的全局消息队列信息;Preferably, in step S12), the content of the global message queue name table includes a global semaphore that controls mutually exclusive access to the name table, the number of all created global message queues in the name table, and all created global message queue information;
所述全局消息队列信息包括名称、类型、所属处理核心、消息属性、打开次数、数据队列、空闲队列、全局信号量;The global message queue information includes name, type, processing core, message attributes, number of opens, data queue, idle queue, and global semaphore;
其中,消息属性包括最大消息数目、消息大小、消息标识和当前消息数目,全局信号量包括用于控制数据队列访问的全局信号量和用于控制空闲队列访问的全局信号量。Among them, the message attributes include the maximum number of messages, message size, message identification and the current number of messages. The global semaphore includes a global semaphore used to control data queue access and a global semaphore used to control idle queue access.
优选地,步骤S13)中,所述全局消息队列缓冲池用于分配全局消息队列,所述消息缓冲池用于分配全局消息队列的空闲队列;Preferably, in step S13), the global message queue buffer pool is used to allocate a global message queue, and the message buffer pool is used to allocate an idle queue of the global message queue;
其中,全局消息队列缓冲池和消息缓冲池,为带表头指针的双向链表,链表表头均放置在各自所属的处理核心上,可用自旋锁或者全局信号量管理互斥访问。Among them, the global message queue buffer pool and the message buffer pool are two-way linked lists with header pointers. The linked list headers are placed on their respective processing cores, and mutually exclusive access can be managed with spin locks or global semaphores.
优选地,步骤S2)中,所述全局消息队列初始化时,控制数据队列的全局信号量的值初始化为0,控制空闲队列的全局信号量的值初始化为消息队列允许承载的最大消息个数。Preferably, in step S2), when the global message queue is initialized, the value of the global semaphore controlling the data queue is initialized to 0, and the value of the global semaphore controlling the idle queue is initialized to the maximum number of messages the message queue is allowed to carry.
优选地,步骤S3)中,所述线程向全局消息队列发送消息的操作具体包括:Preferably, in step S3), the operation of the thread sending messages to the global message queue specifically includes:
S31)获取消息队列内控制空闲队列的全局信号量;S31) Obtain the global semaphore that controls the idle queue in the message queue;
S32)若控制空闲队列的全局信号量为0,表明消息队列已达到最大消息个数,全局消息队列已满,则通过全局信号量将该线程阻塞;S32) If the global semaphore controlling the idle queue is 0, indicating that the message queue has reached the maximum number of messages and the global message queue is full, the thread will be blocked through the global semaphore;
S33)若控制空闲队列的全局信号量不为0,则从空闲队列中取下一块空闲区,将消息复制到空闲区,然后按消息优先级加入数据队列,修改消息属性,释放控制数据队列的全局信号量。S33) If the global semaphore controlling the idle queue is not 0, remove a piece of free area from the idle queue, copy the message to the free area, then join the data queue according to the message priority, modify the message attributes, and release the control data queue Global semaphore.
优选地,步骤S3)中,所述线程从消息队列接收消息的操作具体包括:Preferably, in step S3), the operation of the thread receiving messages from the message queue specifically includes:
S34)获取消息队列内控制数据队列的全局信号量;S34) Obtain the global semaphore that controls the data queue in the message queue;
S35)若控制数据队列的全局信号量为0,表明消息队列为空,则通过全局信号量将该线程阻塞;S35) If the global semaphore controlling the data queue is 0, indicating that the message queue is empty, the thread will be blocked through the global semaphore;
S36)若控制数据队列的全局信号量不为0,则根据消息优先级,按照“FIFO”原则,从数据队列中取下一个消息,修改消息属性,然后复制消息,将消息加入空闲队列,释放控制空闲队列的全局信号量。S36) If the global semaphore controlling the data queue is not 0, according to the message priority and the "FIFO" principle, remove a message from the data queue, modify the message attributes, then copy the message, add the message to the idle queue, and release it Global semaphore that controls the idle queue.
本发明的有益效果是:该基于多核多处理器并行系统的全局消息队列实现方法,利用全局信号量与共享存储区,将线程之间的消息传递交由全局信号量控制,满足多核多处理器间的高速通信需求,具有快速、高效的特点,能在极大程度上简化应用开发人员的工作。The beneficial effects of the present invention are: the global message queue implementation method based on a multi-core multi-processor parallel system uses global semaphores and shared storage areas to control the message transfer between threads by global semaphores, which satisfies the needs of multi-core and multi-processors. It is fast and efficient, which can greatly simplify the work of application developers.
附图说明Description of the drawings
图1为本发明实施例应用的一种多核多处理器并行系统结构框图;Figure 1 is a structural block diagram of a multi-core multi-processor parallel system applied in an embodiment of the present invention;
图2为本发明实施例应用的一种多核多处理器并行系统全局消息队列实现方法原理;Figure 2 shows the principle of a global message queue implementation method for a multi-core multi-processor parallel system applied in the embodiment of the present invention;
图3为本发明实施例应用的系统初始化流程图;Figure 3 is a system initialization flow chart applied in the embodiment of the present invention;
图4为本发明实施例应用的全局消息队列名表结构;Figure 4 is a global message queue name table structure applied in the embodiment of the present invention;
图5为本发明实施例应用的全局消息队列发送消息流程图;Figure 5 is a flow chart of sending messages through the global message queue applied in the embodiment of the present invention;
图6为本发明实施例应用的全局消息队列接收消息流程图。Figure 6 is a flow chart of global message queue receiving messages applied in the embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present invention.
一种基于多核多处理器并行系统的全局消息队列实现方法,该全局消息队列实现方法包括:A global message queue implementation method based on a multi-core multi-processor parallel system. The global message queue implementation method includes:
S1)多核多处理器并行系统的各处理核心进行系统初始化,通过SRIO映射一段共享存储空间用于存储全局消息队列与全局消息队列名表。S1) Each processing core of the multi-core multi-processor parallel system initializes the system, and maps a shared storage space through SRIO to store the global message queue and global message queue name table.
步骤S1)中,所述系统初始化的过程包括:In step S1), the system initialization process includes:
S11)各处理核心初始化SRIO,通过SRIO映射一段共享存储空间用于存储全局消息队列与全局消息队列名表;S11) Each processing core initializes SRIO, and maps a shared storage space through SRIO to store the global message queue and global message queue name table;
S12)选取任一处理核心为主处理核心,创建并初始化一张共享的全局消息队列名表,用于记录所有已创建的全局消息队列;S12) Select any processing core as the main processing core, create and initialize a shared global message queue name table, which is used to record all created global message queues;
所述全局消息队列名表的内容包括控制名表互斥访问的全局信号量、名表中所有已创建的全局消息队列数目,以及所有已创建的全局消息队列信息;The content of the global message queue name table includes a global semaphore that controls mutually exclusive access to the name table, the number of all created global message queues in the name table, and all created global message queue information;
所述全局消息队列信息包括名称、类型、所属处理核心、消息属性、打开次数、数据队列、空闲队列、全局信号量;The global message queue information includes name, type, processing core, message attributes, number of opens, data queue, idle queue, and global semaphore;
其中,消息属性包括最大消息数目、消息大小、消息标识和当前消息数目,全局信号量包括用于控制数据队列访问的全局信号量和用于控制空闲队列访问的全局信号量。Among them, the message attributes include the maximum number of messages, message size, message identification and the current number of messages. The global semaphore includes a global semaphore used to control data queue access and a global semaphore used to control idle queue access.
S13)在各处理核心映射出的共享存储空间中,创建全局消息队列缓冲池和消息缓冲池。S13) Create a global message queue buffer pool and a message buffer pool in the shared storage space mapped by each processing core.
所述全局消息队列缓冲池用于分配全局消息队列,所述消息缓冲池用于分配全局消息队列的空闲队列;The global message queue buffer pool is used to allocate the global message queue, and the message buffer pool is used to allocate the idle queue of the global message queue;
其中,全局消息队列缓冲池和消息缓冲池,为带表头指针的双向链表,链表表头均放置在各自所属的处理核心上,可用自旋锁或者全局信号量管理互斥访问。Among them, the global message queue buffer pool and the message buffer pool are two-way linked lists with header pointers. The linked list headers are placed on their respective processing cores, and mutually exclusive access can be managed with spin locks or global semaphores.
S2)从线程所属的处理核心对应的全局消息队列缓冲池中创建并初始化全局消息队列,将全局消息队列信息填入全局消息队列名表。S2) Create and initialize the global message queue from the global message queue buffer pool corresponding to the processing core to which the thread belongs, and fill the global message queue information into the global message queue name table.
所述全局消息队列初始化时,控制数据队列的全局信号量的值初始化为0,控制空闲队列的全局信号量的值初始化为消息队列允许承载的最大消息个数。When the global message queue is initialized, the value of the global semaphore that controls the data queue is initialized to 0, and the value of the global semaphore that controls the idle queue is initialized to the maximum number of messages that the message queue is allowed to carry.
S3)当线程向全局消息队列发送消息或从全局消息队列接收消息时,通过全局信号量对全局消息队列资源进行管理与控制,实现消息的传输。S3) When a thread sends a message to or receives a message from the global message queue, the global message queue resources are managed and controlled through the global semaphore to realize message transmission.
其中,所述线程向全局消息队列发送消息的操作具体包括:Among them, the operation of the thread sending messages to the global message queue specifically includes:
S31)获取消息队列内控制空闲队列的全局信号量;S31) Obtain the global semaphore that controls the idle queue in the message queue;
S32)若控制空闲队列的全局信号量为0,表明消息队列已达到最大消息个数,全局消息队列已满,则通过全局信号量将该线程阻塞;S32) If the global semaphore controlling the idle queue is 0, indicating that the message queue has reached the maximum number of messages and the global message queue is full, the thread will be blocked through the global semaphore;
S33)若控制空闲队列的全局信号量不为0,则从空闲队列中取下一块空闲区,将消息复制到空闲区,然后按消息优先级加入数据队列,修改消息属性,释放控制数据队列的全局信号量。S33) If the global semaphore controlling the idle queue is not 0, remove a piece of free area from the idle queue, copy the message to the free area, then join the data queue according to the message priority, modify the message attributes, and release the control data queue Global semaphore.
所述线程从消息队列接收消息的操作具体包括:The operation of the thread receiving messages from the message queue specifically includes:
S34)获取消息队列内控制数据队列的全局信号量;S34) Obtain the global semaphore that controls the data queue in the message queue;
S35)若控制数据队列的全局信号量为0,表明消息队列为空,则通过全局信号量将该线程阻塞;S35) If the global semaphore controlling the data queue is 0, indicating that the message queue is empty, the thread will be blocked through the global semaphore;
S36)若控制数据队列的全局信号量不为0,则根据消息优先级,按照“FIFO”原则,从数据队列中取下一个消息,修改消息属性,然后复制消息,将消息加入空闲队列,释放控制空闲队列的全局信号量。S36) If the global semaphore controlling the data queue is not 0, according to the message priority and the "FIFO" principle, remove a message from the data queue, modify the message attributes, then copy the message, add the message to the idle queue, and release it Global semaphore that controls the idle queue.
所述多核多处理器并行系统的处理器节点数至少有1个;所述处理器节点的处理核心至少有1个;并且所述处理器节点间或处理核心支持SRIO总线互连。The multi-core multi-processor parallel system has at least one processor node; the processor node has at least one processing core; and the processor nodes or processing cores support SRIO bus interconnection.
实施例Example
需要说明的是:It should be noted:
1)如图1所示,本实施例是在一个嵌入式多核多处理器并行系统上实施的实施例;1) As shown in Figure 1, this embodiment is implemented on an embedded multi-core multi-processor parallel system;
2)本实施例应用的嵌入式多核多处理器并行系统,包含四块处理板,分别为S0,S1,S2,S3,其中处理板S0、S1、S2包含两片MPC8641D双核处理器和一个SRIO交换设备,处理板S3包含一片MPC8641D双核处理器和一个SRIO交换设备,其中每片MPC8641D处理器包含两个e600处理核心,处理核心分别为C0,C1,……,Ci,……,C13,选定处理核心C0为主处理核心;2) The embedded multi-core multi-processor parallel system used in this embodiment includes four processing boards, namely S 0 , S 1 , S 2 , and S 3 . Among them, the processing boards S0, S1, and S 2 include two MPC8641D dual cores. processor and an SRIO switching device. The processing board S 3 contains an MPC8641D dual-core processor and an SRIO switching device. Each MPC8641D processor contains two e600 processing cores. The processing cores are C 0 , C 1 ,..., C i ,..., C 13 , the processing core C 0 is selected as the main processing core;
3)处理核心C0上有一个线程A,用于发送消息;处理核心C13上有一个线程B,用于接收消息;3) There is a thread A on the processing core C 0 for sending messages; there is a thread B on the processing core C 13 for receiving messages;
4)本实施例应用的MPC8641D处理器均支持SRIO总线互连,每片MPC8641D双核处理器之间通过SRIO交换设备连接;4) The MPC8641D processors used in this embodiment all support SRIO bus interconnection, and each MPC8641D dual-core processor is connected through an SRIO switching device;
5)本实施例是基于SRIO的多核多处理器并行系统。5) This embodiment is a multi-core multi-processor parallel system based on SRIO.
如图2所示,本实施例中一种多核多处理器并行系统全局消息队列实现方法,包括以下步骤:As shown in Figure 2, a method for implementing a global message queue in a multi-core multi-processor parallel system in this embodiment includes the following steps:
S1)MPC8641D多核多处理器并行系统各e600处理核心进行系统初始化,通过SRIO映射一段共享存储空间用于存储全局消息队列与全局消息队列名表。S1) Each e600 processing core of the MPC8641D multi-core multi-processor parallel system performs system initialization and maps a shared storage space through SRIO to store the global message queue and global message queue name table.
S2)各e600处理核心从线程所属处理核心对应的全局消息队列缓冲池中创建并初始化全局消息队列,将全局消息队列信息填入全局消息队列名表。S2) Each e600 processing core creates and initializes a global message queue from the global message queue buffer pool corresponding to the processing core to which the thread belongs, and fills the global message queue information into the global message queue name table.
S3)当线程向全局消息队列发送消息或从全局消息队列接收消息时,通过全局信号量对全局消息队列资源进行管理与控制,实现消息的传输。S3) When a thread sends a message to or receives a message from the global message queue, the global message queue resources are managed and controlled through the global semaphore to realize message transmission.
如图3所示,步骤S1中,所述系统初始化过程具体包括:As shown in Figure 3, in step S1, the system initialization process specifically includes:
S11)各e600处理核心初始化SRIO,通过SRIO映射一段共享存储空间用于存储全局消息队列与全局消息队列名表;S11) Each e600 processing core initializes SRIO, and maps a shared storage space through SRIO to store the global message queue and global message queue name table;
S12)选取处理核心C0为主处理核心,创建并初始化一张共享的全局消息队列名表,用于记录所有已创建的全局消息队列;S12) Select the processing core C 0 as the main processing core, create and initialize a shared global message queue name table, which is used to record all created global message queues;
S13)在各e600处理核心映射出的共享存储空间中,创建全局消息队列缓冲池和消息缓冲池。S13) Create a global message queue buffer pool and a message buffer pool in the shared storage space mapped by each e600 processing core.
其中,步骤S11中各e600处理核心均从本地地址空间映射长度为4M字节的空间到SRIO地址空间作为共享内存,供MPC8641D多核多处理器并行系统所有处理核心访问,共享内存的空间首地址依次为0xA4000000,0xA4400000,……,0xA4000000+i*0x400000,……,0xA4000000+13*0x400000。Among them, in step S11, each e600 processing core maps a space with a length of 4M bytes from the local address space to the SRIO address space as a shared memory for all processing cores of the MPC8641D multi-core multi-processor parallel system to access. The first address of the shared memory space is in sequence. It is 0xA4000000, 0xA4400000,…, 0xA4000000+i*0x400000,…, 0xA4000000+13*0x400000.
如图4所示,步骤S12中,所述全局消息队列名表的内容包括控制名表互斥访问的全局信号量、名表中所有已创建的全局消息队列数目,以及所有已创建的全局消息队列信息。其中,全局消息队列信息主要包括名称、类型、所属处理核心、消息属性、打开次数、数据队列、空闲队列、全局信号量等,消息属性包括最大消息数目、消息大小、消息标识和当前消息数目,全局信号量主要包括用于控制数据队列访问的全局信号量和用于控制空闲队列访问的全局信号量。As shown in Figure 4, in step S12, the contents of the global message queue name table include the global semaphore that controls mutually exclusive access to the name table, the number of all created global message queues in the name table, and all created global message queue information. Among them, the global message queue information mainly includes name, type, processing core, message attributes, open times, data queue, idle queue, global semaphore, etc. The message attributes include the maximum number of messages, message size, message identifier and current number of messages. Global semaphores mainly include global semaphores used to control data queue access and global semaphores used to control idle queue access.
其中,步骤S13中,所述全局消息队列缓冲池用于分配全局消息队列,所述消息缓冲池用于分配全局消息队列的空闲队列。其中,全局消息队列缓冲池和消息缓冲池,为带表头指针的双向链表,链表表头均放置在各自所属的处理核心上,可用自旋锁或者全局信号量管理互斥访问。In step S13, the global message queue buffer pool is used to allocate a global message queue, and the message buffer pool is used to allocate an idle queue of the global message queue. Among them, the global message queue buffer pool and the message buffer pool are two-way linked lists with header pointers. The linked list headers are placed on their respective processing cores, and mutually exclusive access can be managed with spin locks or global semaphores.
其中,步骤S2中,所述全局消息队列初始化时,控制数据队列的全局信号量的值初始化为0,控制空闲队列的全局信号量的值初始化为消息队列允许承载的最大消息个数。In step S2, when the global message queue is initialized, the value of the global semaphore controlling the data queue is initialized to 0, and the value of the global semaphore controlling the idle queue is initialized to the maximum number of messages the message queue is allowed to carry.
如图5所示,步骤S3中,线程A向全局消息队列发送消息的操作具体包括:As shown in Figure 5, in step S3, the operation of thread A to send a message to the global message queue specifically includes:
S31)获取消息队列内控制空闲队列的全局信号量;S31) Obtain the global semaphore that controls the idle queue in the message queue;
S32)若控制空闲队列的全局信号量为0,表明消息队列已达到最大消息个数,全局消息队列已满,则通过全局信号量将该线程阻塞;S32) If the global semaphore controlling the idle queue is 0, indicating that the message queue has reached the maximum number of messages and the global message queue is full, the thread will be blocked through the global semaphore;
S33)若控制空闲队列的全局信号量不为0,则从空闲队列中取下一块空闲区,将消息复制到空闲区,然后按消息优先级加入数据队列,修改消息属性,释放控制数据队列的全局信号量。S33) If the global semaphore controlling the idle queue is not 0, remove a piece of free area from the idle queue, copy the message to the free area, then join the data queue according to the message priority, modify the message attributes, and release the control data queue Global semaphore.
如图6所示,步骤S3中,线程B从消息队列接收消息的操作具体包括:As shown in Figure 6, in step S3, the operation of thread B to receive messages from the message queue specifically includes:
S34)获取消息队列内控制数据队列的全局信号量;S34) Obtain the global semaphore that controls the data queue in the message queue;
S35)若控制数据队列的全局信号量为0,表明消息队列为空,则通过全局信号量将该线程阻塞;S35) If the global semaphore controlling the data queue is 0, indicating that the message queue is empty, the thread will be blocked through the global semaphore;
S36)若控制数据队列的全局信号量不为0,则根据消息优先级,按照“FIFO”或其他原则,从数据队列中取下一个消息,修改消息属性,然后复制消息,将消息加入空闲队列,释放控制空闲队列的全局信号量。S36) If the global semaphore controlling the data queue is not 0, according to the message priority and "FIFO" or other principles, remove a message from the data queue, modify the message attributes, then copy the message, and add the message to the idle queue , release the global semaphore controlling the idle queue.
对于本领域技术人员而言,显然本发明不限于上述示范性实施例的细节,而且在不背离本发明的精神或基本特征的情况下,能够以其他的具体形式实现本发明。因此,无论从哪一点来看,均应将实施例看作是示范性的,而且是非限制性的,本发明的范围由所附权利要求而不是上述说明限定,因此旨在将落在权利要求的等同要件的含义和范围内的所有变化囊括在本发明内。不应将权利要求中的任何附图标记视为限制所涉及的权利要求。It is obvious to those skilled in the art that the present invention is not limited to the details of the above-described exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention. Therefore, the embodiments should be regarded as illustrative and non-restrictive from any point of view, and the scope of the present invention is defined by the appended claims rather than the above description, and it is therefore intended that all claims falling within the claims All changes within the meaning and scope of equivalent elements are included in the present invention. Any reference signs in the claims shall not be construed as limiting the claim in question.
此外,应当理解,虽然本说明书按照实施方式加以描述,但并非每个实施方式仅包含一个独立的技术方案,说明书的这种叙述方式仅仅是为清楚起见,本领域技术人员应当将说明书作为一个整体,各实施例中的技术方案也可以经适当组合,形成本领域技术人员可以理解的其他实施方式。In addition, it should be understood that although this specification is described in terms of implementations, not each implementation only contains an independent technical solution. This description of the specification is only for the sake of clarity, and those skilled in the art should take the specification as a whole. , the technical solutions in each embodiment can also be appropriately combined to form other implementations that can be understood by those skilled in the art.
Claims (2)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011360414.7A CN112486702B (en) | 2020-11-27 | 2020-11-27 | Global message queue implementation method based on multi-core multi-processor parallel system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011360414.7A CN112486702B (en) | 2020-11-27 | 2020-11-27 | Global message queue implementation method based on multi-core multi-processor parallel system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112486702A CN112486702A (en) | 2021-03-12 |
CN112486702B true CN112486702B (en) | 2024-02-13 |
Family
ID=74936028
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011360414.7A Active CN112486702B (en) | 2020-11-27 | 2020-11-27 | Global message queue implementation method based on multi-core multi-processor parallel system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112486702B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113300946B (en) * | 2021-05-24 | 2022-05-10 | 北京理工大学 | A multi-core multi-communication protocol gateway and its management and scheduling method |
CN113672364B (en) * | 2021-08-02 | 2023-09-01 | 北京奇艺世纪科技有限公司 | Task scheduling method and device, electronic equipment and storage medium |
CN114090290A (en) * | 2021-11-18 | 2022-02-25 | 哈尔滨航天恒星数据系统科技有限公司 | A spatiotemporal data automation service publishing method based on message pool flow mode |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102841810A (en) * | 2011-05-14 | 2012-12-26 | 国际商业机器公司 | Techniques for executing threads in a computing environment |
CN108595282A (en) * | 2018-05-02 | 2018-09-28 | 广州市巨硅信息科技有限公司 | A kind of implementation method of high concurrent message queue |
CN109144749A (en) * | 2018-08-14 | 2019-01-04 | 苏州硅岛信息科技有限公司 | A method of it is communicated between realizing multiprocessor using processor |
CN111722942A (en) * | 2020-05-29 | 2020-09-29 | 天津大学 | A kind of transformation method of distributed real-time operating system |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080148280A1 (en) * | 2006-12-13 | 2008-06-19 | Stillwell Joseph W | Apparatus, system, and method for autonomically managing multiple queues |
US7937532B2 (en) * | 2007-03-30 | 2011-05-03 | Intel Corporation | Method and apparatus for speculative prefetching in a multi-processor/multi-core message-passing machine |
-
2020
- 2020-11-27 CN CN202011360414.7A patent/CN112486702B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102841810A (en) * | 2011-05-14 | 2012-12-26 | 国际商业机器公司 | Techniques for executing threads in a computing environment |
CN108595282A (en) * | 2018-05-02 | 2018-09-28 | 广州市巨硅信息科技有限公司 | A kind of implementation method of high concurrent message queue |
CN109144749A (en) * | 2018-08-14 | 2019-01-04 | 苏州硅岛信息科技有限公司 | A method of it is communicated between realizing multiprocessor using processor |
CN111722942A (en) * | 2020-05-29 | 2020-09-29 | 天津大学 | A kind of transformation method of distributed real-time operating system |
Non-Patent Citations (2)
Title |
---|
一种嵌入式系统多处理器间通信协议的应用实验;陈金忠;耿锐;;单片机与嵌入式系统应用(05);全文 * |
嵌入式并行计算管理中间件技术研究;弓静;中国优秀硕士学位论文全文数据库 信息科技辑(第12期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN112486702A (en) | 2021-03-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP3776162B1 (en) | Group-based data replication in multi-tenant storage systems | |
CN110892380B (en) | Data processing unit for stream processing | |
CN112486702B (en) | Global message queue implementation method based on multi-core multi-processor parallel system | |
US7738443B2 (en) | Asynchronous broadcast for ordered delivery between compute nodes in a parallel computing system where packet header space is limited | |
US8094560B2 (en) | Multi-stage multi-core processing of network packets | |
US8655962B2 (en) | Shared address collectives using counter mechanisms | |
US10693787B2 (en) | Throttling for bandwidth imbalanced data transfers | |
US11403247B2 (en) | Methods and apparatus for network interface fabric send/receive operations | |
US20150067695A1 (en) | Information processing system and graph processing method | |
US9311044B2 (en) | System and method for supporting efficient buffer usage with a single external memory interface | |
US20230100935A1 (en) | Microservice deployments using accelerators | |
US20160004445A1 (en) | Devices and methods for interconnecting server nodes | |
CN101866326A (en) | A message-passing interface supports the bus communication framework | |
US9304706B2 (en) | Efficient complex network traffic management in a non-uniform memory system | |
WO2022142562A1 (en) | Rdma-based communication method, node, system, and medium | |
CN111797497B (en) | Communication method and system for electromagnetic transient parallel simulation | |
US8898353B1 (en) | System and method for supporting virtual host bus adaptor (VHBA) over infiniband (IB) using a single external memory interface | |
CN104769553A (en) | System and method for supporting work sharing muxing in a cluster | |
CN112463716B (en) | Global semaphore implementation method based on multi-core multi-processor parallel system | |
US9104637B2 (en) | System and method for managing host bus adaptor (HBA) over infiniband (IB) using a single external memory interface | |
CN112486703B (en) | Global data memory management method based on multi-core multi-processor parallel system | |
US20240388546A1 (en) | System and method for an optimized staging buffer for broadcast/multicast operations | |
WO2024041140A1 (en) | Data processing method, accelerator, and computing device | |
CN118101612A (en) | Message distribution method, device, equipment and readable storage medium | |
CN115801877A (en) | Data transmission platform and method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CP03 | Change of name, title or address |
Address after: No. 718, Luoyu Road, Hongshan District, Wuhan City, Hubei Province 430000 Patentee after: China Shipbuilding Lingjiu Electronics (Wuhan) Co.,Ltd. Country or region after: China Address before: No. 718, Luoyu Road, Hongshan District, Wuhan City, Hubei Province 430000 Patentee before: CSIC (WUHAN) LINCOM ELECTRONICS Co.,Ltd. Country or region before: China |
|
CP03 | Change of name, title or address |