WO2015089839A1 - Method and device for processing messages in shared queue and receiving core - Google Patents

Method and device for processing messages in shared queue and receiving core Download PDF

Info

Publication number
WO2015089839A1
WO2015089839A1 PCT/CN2013/090139 CN2013090139W WO2015089839A1 WO 2015089839 A1 WO2015089839 A1 WO 2015089839A1 CN 2013090139 W CN2013090139 W CN 2013090139W WO 2015089839 A1 WO2015089839 A1 WO 2015089839A1
Authority
WO
WIPO (PCT)
Prior art keywords
msg
num
shared queue
messages
rsv
Prior art date
Application number
PCT/CN2013/090139
Other languages
French (fr)
Chinese (zh)
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 华为技术有限公司
Priority to CN201380003405.4A priority Critical patent/CN105264499B/en
Priority to PCT/CN2013/090139 priority patent/WO2015089839A1/en
Publication of WO2015089839A1 publication Critical patent/WO2015089839A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4812Task transfer initiation or dispatching by interrupt, e.g. masked

Definitions

  • the present invention belongs to the field of message processing technologies, and in particular, to a message processing method, apparatus, and receiving core in a shared queue.
  • Shared messages are typically used in multi-threaded multicore to speed up thread or inter-core communication.
  • One of the widely used scenarios is a sender and multiple receivers.
  • the message data can be received by any one of the cores, and there is a competition relationship between the plurality of receiving cores.
  • FIG. 1 is a shared queue message processing scenario of multiple receiving ends.
  • the general processing procedure is as follows. The scenario assumes two receiving cores:
  • Step 1 The sending core writes the message data to the shared queue
  • Step 2 The shared queue generates an event interrupt to notify all relevant receiving cores
  • Step 3 The interrupt handler in the receiving core processes the interrupt, judges according to the information such as the queue number, and schedules the corresponding service thread 0 or 1 to read the message data from the shared queue;
  • Step 4 Both service threads 0 and 1 competingly read messages from the shared queue. In this way, one business thread can read the message, and another business thread can not read the message. Business threads that do not read the message will exit without doing anything.
  • the object of the present invention is to provide a message processing method, device and receiving core in a shared queue, which aims to solve the problem of message sharing in the prior art, and there is an invalid service thread wake-up in the whole process, when the message is compared.
  • the core is running very inefficiently; in addition, the business thread cannot handle more than 1 fixed message per wake-up. For example, if two messages are fixedly processed after each wakeup, each of the two messages in the shared queue generates an interrupt. When one message is read, there is a possibility that another message is read by another thread.
  • the present invention is implemented as a message processing method in a shared queue, the method comprising the following steps:
  • the interrupt handler in the receiving core receives the interrupt notification message sent by the shared queue
  • the interrupt handler reads the number of subscription messages
  • the interrupt handler determines the number of subscribed subscription messages
  • the message is considered to have been preempted by other receiving cores, and the service thread is not woken up, and the interrupt processing program directly exits;
  • the message subscription is considered successful, the service thread is woken up, and the service thread reads the message from the shared queue.
  • Another object of the present invention is to provide a message processing apparatus in a shared queue, the apparatus comprising:
  • a receiving module configured to receive an interrupt notification message sent by the shared queue
  • a reading module for reading the number of subscription messages
  • a judging module configured to determine the number of read subscription messages
  • the wake-up control module is configured to: if it is determined that the number of subscription messages is 0, the message is considered to have been preempted by other receiving cores, and the service thread is not awake, the interrupt processing program directly exits; if it is determined that the number of subscription messages is non-zero, The message subscription is considered successful, waking up the business thread, and the business thread reads the message from the shared queue.
  • Another object of the present invention is to provide a receiving core including the message processing apparatus in the shared queue described above.
  • whether the corresponding task is activated is determined by whether the message subscription is successful.
  • the service thread can process a fixed number of messages greater than 1 in the shared queue message processing scenario of the multiple receiving ends.
  • FIG. 1 is a schematic diagram of a process flow of a shared queue message provided by the prior art.
  • FIG. 2 is a schematic flowchart of an implementation process of a message processing method in a shared queue according to an embodiment of the present invention.
  • FIG. 3 is a schematic structural diagram of a message processing apparatus in a shared queue according to an embodiment of the present invention.
  • an implementation flow of a message processing method in a shared queue includes the following steps:
  • step S101 the interrupt handler in the receiving core receives the interrupt notification message sent by the shared queue
  • the method before step S101, the method further includes the following steps:
  • a counter that presets the number of subscribed messages in the shared queue is a counter that presets the number of subscribed messages in the shared queue.
  • step S102 the interrupt handler reads the number of subscription messages
  • the interrupt handler reads the number of subscription messages from the counter.
  • step S103 the interrupt processing program determines the number of read subscription messages
  • step S104 if it is determined that the number of subscription messages is 0, the message is considered to have been preempted by other receiving cores, and the service thread is not awake, and the interrupt processing program directly exits;
  • step S105 if it is determined that the number of subscription messages is non-zero, the message subscription is considered successful, the service thread is woken up, and the service thread reads the message from the shared queue.
  • the total number of messages in the shared queue is total_num
  • the threshold of the number of messages that trigger the interruption is msg_threshold
  • the number of the reserved messages is msg_rsv_num
  • Embodiments of the present invention can be applied to LTE In CoMP, the sRIO data reception completion message can be sent to the shared queue; other cores receive the shared message at the lowest priority (higher priority than the IDLE task). After the interrupt of the core is triggered, whether the corresponding task is activated is determined by whether the message subscription is successful.
  • FIG. 3 is a message processing device in a shared queue according to an embodiment of the present invention.
  • the message processing device in the shared queue includes: a receiving module 101, a reading module 102, a determining module 103, and a wakeup control module 104.
  • the message processing device in the shared queue may be a software unit, a hardware unit, or a combination of software and hardware built in the receiving core.
  • the receiving module 101 is configured to receive an interrupt notification message sent by the shared queue.
  • the reading module 102 is configured to read the number of subscription messages
  • the determining module 103 is configured to determine the number of the read subscription messages
  • the wake-up control module 104 is configured to: if it is determined that the number of subscription messages is 0, the message is considered to have been preempted by other receiving cores, and the service thread is not awake, the interrupt processing program directly exits; if it is determined that the number of subscription messages is non-zero , the message subscription is considered successful, the business thread is woken up, and the business thread reads the message from the shared queue.
  • the apparatus further includes: a setting module.
  • a setup module that sets a counter for the number of subscription messages in the shared queue.
  • the reading module 102 is specifically configured to read the number of subscription messages from the counter.
  • the apparatus further includes: a subscription message number reading module, a numerical judgment module, a calculation module, a control module, and an update module.
  • a subscription number reading module for reading the number of subscription messages in the shared queue msg_rsv_num;
  • the value judging module is configured to determine whether the total number of messages total_num-the number of messages triggering the interrupt threshold msg_threshold-the number of the reserved message number msg_rsv_num is greater than or equal to 0,
  • the control module is configured to control the shared queue to return the calculated value of msg_rsv_num to the service thread; if less than 0, the value of the number of subscription messages in the counter is unchanged, and the control shared queue returns a value of 0 to the service thread.
  • whether the corresponding task is activated is determined by whether the message subscription is successful.
  • the service thread can process a fixed number of messages greater than 1 in the shared queue message processing scenario of the multiple receiving ends.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Telephonic Communication Services (AREA)

Abstract

The invention is applicable in the technical field of message processing, and provides a method and a device for processing messages in a shared queue and a receiving core. The method comprises the following steps: an interrupt handler in the receiving core receiving an interrupt notification message transmitted by the shared queue; the interrupt handler reading a reserved message number; the interrupt handler judging the read reserved message number; if the reserved message number is 0, messages having been occupied by other receiving core, a service thread being not awakened, and the interrupt handler directly exiting; if the reserved message number is non-0, messages being reserved successfully, the service thread being awakened, and the service thread reading the messages from the shared queue. The invention avoids awakening of invalid service threads when a plurality of receiving cores share a queue so as to reduce time delay, and the service thread can process the messages of a fixed number more than 1 under a shared queue message processing scenario of multiple receiving ends.

Description

一种共享队列中的消息处理方法、装置及接收核  Message processing method, device and receiving core in shared queue 技术领域Technical field
本发明属于消息处理技术领域,尤其涉及一种共享队列中的消息处理方法、装置及接收核。The present invention belongs to the field of message processing technologies, and in particular, to a message processing method, apparatus, and receiving core in a shared queue.
背景技术Background technique
一般在多线程多核中使用共享消息来加快线程或核间通信的效率。其中一种广泛使用的场景是一个发送端,多个接收端。消息数据可以被其中任一个核接收,多个接收核之间存在竞争关系。Shared messages are typically used in multi-threaded multicore to speed up thread or inter-core communication. One of the widely used scenarios is a sender and multiple receivers. The message data can be received by any one of the cores, and there is a competition relationship between the plurality of receiving cores.
请参阅图1,为多接收端的共享队列消息处理场景,一般的处理流程示例如下,场景中假定2个接收核:Please refer to FIG. 1 , which is a shared queue message processing scenario of multiple receiving ends. The general processing procedure is as follows. The scenario assumes two receiving cores:
步骤1:发送核将消息数据写入到共享队列中;Step 1: The sending core writes the message data to the shared queue;
步骤2:共享队列产生事件中断,通知所有的相关的接收核;Step 2: The shared queue generates an event interrupt to notify all relevant receiving cores;
步骤3:接收核中的中断处理程序处理中断,根据队列序号等信息进行判断,调度相应的业务线程0或1来从共享队列中读取消息数据;Step 3: The interrupt handler in the receiving core processes the interrupt, judges according to the information such as the queue number, and schedules the corresponding service thread 0 or 1 to read the message data from the shared queue;
步骤4:业务线程0和1都从共享队列中竞争式地读取消息。这样,一个业务线程能读取到消息,另外一个业务线程则读取不到消息。读取不到消息的业务线程会不执行任何操作而退出。Step 4: Both service threads 0 and 1 competingly read messages from the shared queue. In this way, one business thread can read the message, and another business thread can not read the message. Business threads that do not read the message will exit without doing anything.
由上可知,由于消息共享的原因,整个流程中会有无效业务线程的唤醒,当消息比较多的时候导致核的运行效率非常低;另外,业务线程在每次唤醒时无法处理大于1的固定消息个数。比如,如果每次唤醒后固定处理2个消息,共享队列里面每来2个消息产生一个中断,当一个消息被读取时,有可能另外一个消息被其他线程读取了。It can be seen from the above that due to the reason of message sharing, there will be wake-up of invalid business threads in the whole process. When the number of messages is relatively large, the efficiency of the core is very low. In addition, the business thread cannot handle the fixed more than 1 each time it wakes up. The number of messages. For example, if two messages are fixedly processed after each wakeup, each of the two messages in the shared queue generates an interrupt. When one message is read, another message may be read by another thread.
技术问题technical problem
本发明的目的在于提供一种共享队列中的消息处理方法、装置及接收核,旨在解决现有技术中存在的由于消息共享的原因,整个流程中会有无效业务线程的唤醒,当消息比较多的时候导致核的运行效率非常低;另外,业务线程在每次唤醒时无法处理大于1的固定消息个数。比如,如果每次唤醒后固定处理2个消息,共享队列里面每来2个消息产生一个中断,当一个消息被读取时,有可能另外一个消息被其他线程读取了的问题。The object of the present invention is to provide a message processing method, device and receiving core in a shared queue, which aims to solve the problem of message sharing in the prior art, and there is an invalid service thread wake-up in the whole process, when the message is compared. Many times, the core is running very inefficiently; in addition, the business thread cannot handle more than 1 fixed message per wake-up. For example, if two messages are fixedly processed after each wakeup, each of the two messages in the shared queue generates an interrupt. When one message is read, there is a possibility that another message is read by another thread.
技术解决方案Technical solution
本发明是这样实现的,一种共享队列中的消息处理方法,所述方法包括以下步骤:The present invention is implemented as a message processing method in a shared queue, the method comprising the following steps:
接收核中的中断处理程序接收共享队列发送的中断通知消息;The interrupt handler in the receiving core receives the interrupt notification message sent by the shared queue;
所述中断处理程序读取预订消息个数;The interrupt handler reads the number of subscription messages;
所述中断处理程序判断读取到的预订消息个数;The interrupt handler determines the number of subscribed subscription messages;
如果判断出预订消息个数为0,则认为消息已被其他接收核抢占,不唤醒业务线程,所述中断处理程序直接退出;If it is determined that the number of subscription messages is 0, the message is considered to have been preempted by other receiving cores, and the service thread is not woken up, and the interrupt processing program directly exits;
如果判断出预订消息个数为非0,则认为消息预订成功,唤醒业务线程,所述业务线程从共享队列中读取消息。If it is determined that the number of subscription messages is non-zero, the message subscription is considered successful, the service thread is woken up, and the service thread reads the message from the shared queue.
本发明的另一目的在于提供一种共享队列中的消息处理装置,所述装置包括:Another object of the present invention is to provide a message processing apparatus in a shared queue, the apparatus comprising:
接收模块,用于接收共享队列发送的中断通知消息;a receiving module, configured to receive an interrupt notification message sent by the shared queue;
读取模块,用于读取预订消息个数;a reading module for reading the number of subscription messages;
判断模块,用于判断读取到的预订消息个数;a judging module, configured to determine the number of read subscription messages;
唤醒控制模块,用于如果判断出预订消息个数为0,则认为消息已被其他接收核抢占,不唤醒业务线程,所述中断处理程序直接退出;如果判断出预订消息个数为非0,则认为消息预订成功,唤醒业务线程,所述业务线程从共享队列中读取消息。The wake-up control module is configured to: if it is determined that the number of subscription messages is 0, the message is considered to have been preempted by other receiving cores, and the service thread is not awake, the interrupt processing program directly exits; if it is determined that the number of subscription messages is non-zero, The message subscription is considered successful, waking up the business thread, and the business thread reads the message from the shared queue.
本发明的另一目的在于提供一种包括上面所述的共享队列中的消息处理装置的接收核。Another object of the present invention is to provide a receiving core including the message processing apparatus in the shared queue described above.
有益效果Beneficial effect
在本发明中,当核的中断被触发后,通过消息预订是否成功决定是否激活对应的任务。使得在多个接收核共享一个队列时避免无效业务线程的唤醒,减少时延,另外可以使业务线程在多接收端的共享队列消息处理场景下处理大于1的固定个数的消息。In the present invention, after the interrupt of the core is triggered, whether the corresponding task is activated is determined by whether the message subscription is successful. When a plurality of receiving cores share a queue, the waking of the invalid service thread is avoided, and the delay is reduced. In addition, the service thread can process a fixed number of messages greater than 1 in the shared queue message processing scenario of the multiple receiving ends.
附图说明DRAWINGS
图1是现有技术提供的共享队列消息处理流程示意图。FIG. 1 is a schematic diagram of a process flow of a shared queue message provided by the prior art.
图2是本发明实施例提供的共享队列中的消息处理方法的实现流程示意图。2 is a schematic flowchart of an implementation process of a message processing method in a shared queue according to an embodiment of the present invention.
图3是本发明实施例提供的共享队列中的消息处理装置的结构示意图。FIG. 3 is a schematic structural diagram of a message processing apparatus in a shared queue according to an embodiment of the present invention.
本发明的实施方式Embodiments of the invention
为了使本发明的目的、技术方案及有益效果更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
请参阅图2,为本发明实施例提供的共享队列中的消息处理方法的实现流程,其包括以下步骤:Referring to FIG. 2, an implementation flow of a message processing method in a shared queue according to an embodiment of the present invention includes the following steps:
在步骤S101中,接收核中的中断处理程序接收共享队列发送的中断通知消息;In step S101, the interrupt handler in the receiving core receives the interrupt notification message sent by the shared queue;
作为本发明一实施例,在步骤S101之前,还包括以下步骤:As an embodiment of the present invention, before step S101, the method further includes the following steps:
在共享队列中预先设置预订消息个数的计数器。A counter that presets the number of subscribed messages in the shared queue.
在步骤S102中,所述中断处理程序读取预订消息个数;In step S102, the interrupt handler reads the number of subscription messages;
在本发明实施例中,所述中断处理程序从计数器中读取预订消息个数。In an embodiment of the invention, the interrupt handler reads the number of subscription messages from the counter.
在步骤S103中,所述中断处理程序判断读取到的预订消息个数;In step S103, the interrupt processing program determines the number of read subscription messages;
在步骤S104中,如果判断出预订消息个数为0,则认为消息已被其他接收核抢占,不唤醒业务线程,所述中断处理程序直接退出;In step S104, if it is determined that the number of subscription messages is 0, the message is considered to have been preempted by other receiving cores, and the service thread is not awake, and the interrupt processing program directly exits;
在步骤S105中,如果判断出预订消息个数为非0,则认为消息预订成功,唤醒业务线程,所述业务线程从共享队列中读取消息。In step S105, if it is determined that the number of subscription messages is non-zero, the message subscription is considered successful, the service thread is woken up, and the service thread reads the message from the shared queue.
在本发明实施例中,假定共享队列里的总消息个数为total_num,触发中断的消息个数阈值为msg_threshold,预订消息个数为msg_rsv_num,预订消息个数的计算步骤,具体为:In the embodiment of the present invention, it is assumed that the total number of messages in the shared queue is total_num, the threshold of the number of messages that trigger the interruption is msg_threshold, and the number of the reserved messages is msg_rsv_num, and the calculation steps of the number of reserved messages are specifically:
在步骤S201中,业务线程读取共享队列中的预订消息个数msg_rsv_num,共享队列判断总消息个数total_num-触发中断的消息个数阈值msg_threshold-预订消息个数msg_rsv_num的值是否大于等于0,如果大于等于0,则计算msg_rsv_num的值,msg_rsv_num=msg_rsv_num+msg_threshold,共享队列向业务线程返回计算得到的msg_rsv_num的值;进入步骤S202。如果小于0,则计数器中的预订消息个数的值不变,共享队列向业务线程返回0值。In step S201, the service thread reads the number of reservation messages in the shared queue, msg_rsv_num, and the shared queue determines the total number of messages total_num-the number of messages that trigger the interruption, the number of msg_threshold-the number of subscription messages, msg_rsv_num, is greater than or equal to 0, if If it is greater than or equal to 0, the value of msg_rsv_num is calculated, msg_rsv_num=msg_rsv_num+msg_threshold, and the shared queue returns the calculated value of msg_rsv_num to the service thread; and the process proceeds to step S202. If less than 0, the value of the number of subscribed messages in the counter is unchanged, and the shared queue returns a value of 0 to the business thread.
在步骤S202中,业务线程读取共享队列中的消息,共享队列判断msg_rsv_num是否大于0,如果大于0,则更新msg_rsv_num的值,msg_rsv_num=msg_rsv_num-1。In step S202, the service thread reads the message in the shared queue, and the shared queue determines whether msg_rsv_num is greater than 0. If it is greater than 0, the value of msg_rsv_num is updated, msg_rsv_num=msg_rsv_num-1.
本发明实施例可以应用在LTE CoMP中,可以将sRIO数据接收完成消息发到共享队列;其它核在最低优先级(比IDLE任务优先级高)接收共享消息。当核的中断被触发后,通过消息预订是否成功决定是否激活对应的任务。Embodiments of the present invention can be applied to LTE In CoMP, the sRIO data reception completion message can be sent to the shared queue; other cores receive the shared message at the lowest priority (higher priority than the IDLE task). After the interrupt of the core is triggered, whether the corresponding task is activated is determined by whether the message subscription is successful.
请参阅图3,为本发明实施例提供的共享队列中的消息处理装置,为了便于说明,仅示出了与本发明实施例相关的部分。所述共享队列中的消息处理装置包括:接收模块101、读取模块102、判断模块103、唤醒控制模块104。所述共享队列中的消息处理装置可以是内置于接收核中的软件单元、硬件单元或者是软硬件结合的单元。Please refer to FIG. 3, which is a message processing device in a shared queue according to an embodiment of the present invention. For convenience of description, only parts related to the embodiment of the present invention are shown. The message processing device in the shared queue includes: a receiving module 101, a reading module 102, a determining module 103, and a wakeup control module 104. The message processing device in the shared queue may be a software unit, a hardware unit, or a combination of software and hardware built in the receiving core.
接收模块101,用于接收共享队列发送的中断通知消息;The receiving module 101 is configured to receive an interrupt notification message sent by the shared queue.
读取模块102,用于读取预订消息个数;The reading module 102 is configured to read the number of subscription messages;
判断模块103,用于判断读取到的预订消息个数;The determining module 103 is configured to determine the number of the read subscription messages;
唤醒控制模块104,用于如果判断出预订消息个数为0,则认为消息已被其他接收核抢占,不唤醒业务线程,所述中断处理程序直接退出;如果判断出预订消息个数为非0,则认为消息预订成功,唤醒业务线程,所述业务线程从共享队列中读取消息。The wake-up control module 104 is configured to: if it is determined that the number of subscription messages is 0, the message is considered to have been preempted by other receiving cores, and the service thread is not awake, the interrupt processing program directly exits; if it is determined that the number of subscription messages is non-zero , the message subscription is considered successful, the business thread is woken up, and the business thread reads the message from the shared queue.
作为本发明一实施例,所述装置还包括:设置模块。In an embodiment of the invention, the apparatus further includes: a setting module.
设置模块,用于在共享队列中设置预订消息个数的计数器。A setup module that sets a counter for the number of subscription messages in the shared queue.
在本发明实施例中,In the embodiment of the present invention,
读取模块102,具体用于从计数器中读取预订消息个数。The reading module 102 is specifically configured to read the number of subscription messages from the counter.
作为本发明一实施例,所述装置还包括:预订消息个数读取模块、数值判断模块、计算模块、控制模块以及更新模块。In an embodiment of the invention, the apparatus further includes: a subscription message number reading module, a numerical judgment module, a calculation module, a control module, and an update module.
预订消息个数读取模块,用于读取共享队列中的预订消息个数msg_rsv_num;a subscription number reading module for reading the number of subscription messages in the shared queue msg_rsv_num;
数值判断模块,用于判断总消息个数total_num-触发中断的消息个数阈值msg_threshold-预订消息个数msg_rsv_num的值是否大于等于0,The value judging module is configured to determine whether the total number of messages total_num-the number of messages triggering the interrupt threshold msg_threshold-the number of the reserved message number msg_rsv_num is greater than or equal to 0,
计算模块,用于如果判断出大于等于0,则计算msg_rsv_num的值,msg_rsv_num=msg_rsv_num+msg_threshold;a calculation module, configured to calculate a value of msg_rsv_num if it is judged to be greater than or equal to 0, msg_rsv_num=msg_rsv_num+msg_threshold;
控制模块,用于控制共享队列向业务线程返回计算得到的msg_rsv_num的值;如果小于0,则计数器中的预订消息个数的值不变,控制共享队列向业务线程返回0值。The control module is configured to control the shared queue to return the calculated value of msg_rsv_num to the service thread; if less than 0, the value of the number of subscription messages in the counter is unchanged, and the control shared queue returns a value of 0 to the service thread.
更新模块,用于读取共享队列中的消息,共享队列判断msg_rsv_num是否大于0,如果大于0,则更新msg_rsv_num的值,msg_rsv_num=msg_rsv_num-1。The update module is configured to read the message in the shared queue, and the shared queue determines whether msg_rsv_num is greater than 0. If greater than 0, the value of msg_rsv_num is updated, msg_rsv_num=msg_rsv_num-1.
综上所述,本发明实施例当核的中断被触发后,通过消息预订是否成功决定是否激活对应的任务。使得在多个接收核共享一个队列时避免无效业务线程的唤醒,减少时延,另外可以使业务线程在多接收端的共享队列消息处理场景下处理大于1的固定个数的消息。In summary, in the embodiment of the present invention, after the interrupt of the core is triggered, whether the corresponding task is activated is determined by whether the message subscription is successful. When a plurality of receiving cores share a queue, the waking of the invalid service thread is avoided, and the delay is reduced. In addition, the service thread can process a fixed number of messages greater than 1 in the shared queue message processing scenario of the multiple receiving ends.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,所述的程序可以存储于一计算机可读取存储介质中,所述的存储介质,如ROM/RAM、磁盘、光盘等。One of ordinary skill in the art can understand that all or part of the steps of implementing the above embodiments may be completed by a program instructing related hardware, and the program may be stored in a computer readable storage medium, the storage. Media, such as ROM/RAM, disk, CD, etc.
以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。The above is only the preferred embodiment of the present invention, and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection of the present invention. Within the scope.

Claims (9)

  1. 一种共享队列中的消息处理方法,其特征在于,所述方法包括以下步骤:A message processing method in a shared queue, characterized in that the method comprises the following steps:
    接收核中的中断处理程序接收共享队列发送的中断通知消息;The interrupt handler in the receiving core receives the interrupt notification message sent by the shared queue;
    所述中断处理程序读取预订消息个数;The interrupt handler reads the number of subscription messages;
    所述中断处理程序判断读取到的预订消息个数;The interrupt handler determines the number of subscribed subscription messages;
    如果判断出预订消息个数为0,则认为消息已被其他接收核抢占,不唤醒业务线程,所述中断处理程序直接退出;If it is determined that the number of subscription messages is 0, the message is considered to have been preempted by other receiving cores, and the service thread is not woken up, and the interrupt processing program directly exits;
    如果判断出预订消息个数为非0,则认为消息预订成功,唤醒业务线程,所述业务线程从共享队列中读取消息。If it is determined that the number of subscription messages is non-zero, the message subscription is considered successful, the service thread is woken up, and the service thread reads the message from the shared queue.
  2. 如权利要求1所述的方法,其特征在于,在所述接收核中的中断处理程序接收共享队列发送的中断通知消息的步骤S101前,还包括以下步骤:The method according to claim 1, wherein before the step S101 of receiving the interrupt notification message sent by the shared queue by the interrupt handler in the receiving core, the method further comprises the following steps:
    在共享队列中预先设置预订消息个数的计数器。A counter that presets the number of subscribed messages in the shared queue.
  3. 如权利要求2所述的方法,其特征在于,所述中断处理程序读取预订消息个数的步骤,具体为:The method of claim 2, wherein the step of the interrupt handler reading the number of subscription messages is specifically:
    所述中断处理程序从计数器中读取预订消息个数。The interrupt handler reads the number of subscription messages from the counter.
  4. 如权利要求1所述的方法,其特征在于,所述预订消息个数的计算步骤,具体为:The method of claim 1, wherein the calculating step of the number of subscription messages is specifically:
    业务线程读取共享队列中的预订消息个数msg_rsv_num,共享队列判断总消息个数total_num-触发中断的消息个数阈值msg_threshold-预订消息个数msg_rsv_num的值是否大于等于0,如果大于等于0,则计算msg_rsv_num的值,msg_rsv_num=msg_rsv_num+msg_threshold,共享队列向业务线程返回计算得到的msg_rsv_num的值;业务线程读取共享队列中的消息,共享队列判断msg_rsv_num是否大于0,如果大于0,则更新msg_rsv_num的值,msg_rsv_num=msg_rsv_num-1;The service thread reads the number of subscription messages in the shared queue msg_rsv_num, the shared queue determines the total number of messages total_num-the number of messages that trigger the interrupt threshold msg_threshold- whether the value of the number of subscription messages msg_rsv_num is greater than or equal to 0, if greater than or equal to 0, then Calculate the value of msg_rsv_num, msg_rsv_num=msg_rsv_num+msg_threshold, the shared queue returns the calculated value of msg_rsv_num to the business thread; the business thread reads the message in the shared queue, and the shared queue determines whether msg_rsv_num is greater than 0. If it is greater than 0, the msg_rsv_num is updated. Value, msg_rsv_num=msg_rsv_num-1;
    如果总消息个数total_num-触发中断的消息个数阈值msg_threshold-预订消息个数msg_rsv_num的值小于0,则计数器中的预订消息个数的值不变,共享队列向业务线程返回0值。If the total number of messages total_num-triggered message threshold threshold msg_threshold-the number of subscription messages msg_rsv_num is less than 0, the value of the number of subscription messages in the counter is unchanged, and the shared queue returns a value of 0 to the service thread.
  5. 一种共享队列中的消息处理装置,其特征在于,所述装置包括:A message processing device in a shared queue, the device comprising:
    接收模块,用于接收共享队列发送的中断通知消息;a receiving module, configured to receive an interrupt notification message sent by the shared queue;
    读取模块,用于读取预订消息个数;a reading module for reading the number of subscription messages;
    判断模块,用于判断读取到的预订消息个数;a judging module, configured to determine the number of read subscription messages;
    唤醒控制模块,用于如果判断出预订消息个数为0,则认为消息已被其他接收核抢占,不唤醒业务线程,所述中断处理程序直接退出;如果判断出预订消息个数为非0,则认为消息预订成功,唤醒业务线程,所述业务线程从共享队列中读取消息。The wake-up control module is configured to: if it is determined that the number of subscription messages is 0, the message is considered to have been preempted by other receiving cores, and the service thread is not awake, the interrupt processing program directly exits; if it is determined that the number of subscription messages is non-zero, The message subscription is considered successful, waking up the business thread, and the business thread reads the message from the shared queue.
  6. 如权利要求5所述的装置,其特征在于,所述装置还包括: The device of claim 5, wherein the device further comprises:
    设置模块,用于在共享队列中设置预订消息个数的计数器。A setup module that sets a counter for the number of subscription messages in the shared queue.
  7. 如权利要求6所述的装置,其特征在于,The device of claim 6 wherein:
    读取模块,具体用于从计数器中读取预订消息个数。The reading module is specifically configured to read the number of subscription messages from the counter.
  8. 如权利要求5所述的装置,其特征在于,所述装置还包括:The device of claim 5, wherein the device further comprises:
    预订消息个数读取模块,用于读取共享队列中的预订消息个数msg_rsv_num;a subscription number reading module for reading the number of subscription messages in the shared queue msg_rsv_num;
    数值判断模块,用于判断总消息个数total_num-触发中断的消息个数阈值msg_threshold-预订消息个数msg_rsv_num的值是否大于等于0,The value judging module is configured to determine whether the total number of messages total_num-the number of messages triggering the interrupt threshold msg_threshold-the number of the reserved message number msg_rsv_num is greater than or equal to 0,
    计算模块,用于如果判断出大于等于0,则计算msg_rsv_num的值,msg_rsv_num=msg_rsv_num+msg_threshold;a calculation module, configured to calculate a value of msg_rsv_num if it is judged to be greater than or equal to 0, msg_rsv_num=msg_rsv_num+msg_threshold;
    控制模块,用于控制共享队列向业务线程返回计算得到的msg_rsv_num的值;如果小于0,则计数器中的预订消息个数的值不变,控制共享队列向业务线程返回0值。The control module is configured to control the shared queue to return the calculated value of msg_rsv_num to the service thread; if less than 0, the value of the number of subscription messages in the counter is unchanged, and the control shared queue returns a value of 0 to the service thread.
    更新模块,用于读取共享队列中的消息,共享队列判断msg_rsv_num是否大于0,如果大于0,则更新msg_rsv_num的值,msg_rsv_num=msg_rsv_num-1。The update module is configured to read the message in the shared queue, and the shared queue determines whether msg_rsv_num is greater than 0. If greater than 0, the value of msg_rsv_num is updated, msg_rsv_num=msg_rsv_num-1.
  9. 一种包括权利要求5至8任一项所述的共享队列中的消息处理装置的接收核。 A receiving core comprising the message processing apparatus in the shared queue of any one of claims 5 to 8.
PCT/CN2013/090139 2013-12-20 2013-12-20 Method and device for processing messages in shared queue and receiving core WO2015089839A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201380003405.4A CN105264499B (en) 2013-12-20 2013-12-20 Message treatment method, device and reception core in a kind of shared queue
PCT/CN2013/090139 WO2015089839A1 (en) 2013-12-20 2013-12-20 Method and device for processing messages in shared queue and receiving core

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2013/090139 WO2015089839A1 (en) 2013-12-20 2013-12-20 Method and device for processing messages in shared queue and receiving core

Publications (1)

Publication Number Publication Date
WO2015089839A1 true WO2015089839A1 (en) 2015-06-25

Family

ID=53402006

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/090139 WO2015089839A1 (en) 2013-12-20 2013-12-20 Method and device for processing messages in shared queue and receiving core

Country Status (2)

Country Link
CN (1) CN105264499B (en)
WO (1) WO2015089839A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108681467B (en) * 2018-03-27 2021-07-06 维沃移动通信有限公司 System awakening method and terminal
CN111858095B (en) * 2020-07-17 2022-06-10 山东云海国创云计算装备产业创新中心有限公司 Hardware queue multithreading sharing method, device, equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0602773A1 (en) * 1992-12-18 1994-06-22 Fujitsu Limited Data communication between processors in multiprocessor systems
CN101086712A (en) * 2006-06-07 2007-12-12 国际商业机器公司 Method and system for sharing kernel services among kernels
CN102117261A (en) * 2009-12-30 2011-07-06 重庆重邮信科通信技术有限公司 Communication method between inner processors of chip
CN102566979A (en) * 2011-12-02 2012-07-11 华为技术有限公司 Method, device and multi-core processor system for realizing self-adaptive lock

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0602773A1 (en) * 1992-12-18 1994-06-22 Fujitsu Limited Data communication between processors in multiprocessor systems
CN101086712A (en) * 2006-06-07 2007-12-12 国际商业机器公司 Method and system for sharing kernel services among kernels
CN102117261A (en) * 2009-12-30 2011-07-06 重庆重邮信科通信技术有限公司 Communication method between inner processors of chip
CN102566979A (en) * 2011-12-02 2012-07-11 华为技术有限公司 Method, device and multi-core processor system for realizing self-adaptive lock

Also Published As

Publication number Publication date
CN105264499B (en) 2018-03-13
CN105264499A (en) 2016-01-20

Similar Documents

Publication Publication Date Title
EP2966913A1 (en) Wake-up control method, device and terminal equipment
US10324513B2 (en) Control of peripheral device data exchange based on CPU power state
WO2011021318A1 (en) Multi-core system, control method of multi-core system, and multiprocessor
CN103729329A (en) ICN device and method
CN101442513A (en) Method for implementing various service treatment function and multi-nuclear processor equipment
CN104102548A (en) Task resource scheduling processing method and task resource scheduling processing system
WO2014142610A1 (en) Terminal and method for synchronizing application thereof
WO2015089839A1 (en) Method and device for processing messages in shared queue and receiving core
WO2022040847A1 (en) Communication data processing method and apparatus
CN101470636A (en) Message read-write method and apparatus
CN103842979B (en) System and method for performing isochronous data buffering
CN107645455A (en) A kind of message transmission dispatching method of CAN
CN114697194A (en) Blocking type event notification method and device
CN114095901A (en) Communication data processing method and device
CN107276909A (en) Port flow management method and device
CN104636206A (en) Optimization method and device for system performance
CN114691312A (en) Circuit, method and system for inter-chip communication
US8195846B2 (en) Direct memory access controller for improving data transmission efficiency in MMoIP and method therefor
EP3293896B1 (en) Intra-body communication device, intra-body communication method, and program
CN106998508B (en) ONU (optical network unit) state transition method and ONU
CN104753830A (en) Baseband chip and data processing method thereof
JPH04256246A (en) Bus priority occupancy system and communication network connector using the system
WO2022143917A1 (en) Inter-chip communication circuit, method and system
JPH07219887A (en) Dma transfer controller
CN107239417B (en) System and method for processing low-speed peripheral access based on asynchronous event framework mechanism

Legal Events

Date Code Title Description
WWE Wipo information: entry into national phase

Ref document number: 201380003405.4

Country of ref document: CN

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

Ref document number: 13899653

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: 13899653

Country of ref document: EP

Kind code of ref document: A1