CN111314244B - Data receiving and transmitting method based on message queue - Google Patents

Data receiving and transmitting method based on message queue Download PDF

Info

Publication number
CN111314244B
CN111314244B CN202010091810.8A CN202010091810A CN111314244B CN 111314244 B CN111314244 B CN 111314244B CN 202010091810 A CN202010091810 A CN 202010091810A CN 111314244 B CN111314244 B CN 111314244B
Authority
CN
China
Prior art keywords
queue
sending
defining
interface
message queue
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
Application number
CN202010091810.8A
Other languages
Chinese (zh)
Other versions
CN111314244A (en
Inventor
杨更新
吴浩峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Tiantuo Zhiling Technology Co ltd
Original Assignee
Beijing Tiantuo Zhiling Technology Co ltd
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 Beijing Tiantuo Zhiling Technology Co ltd filed Critical Beijing Tiantuo Zhiling Technology Co ltd
Priority to CN202010091810.8A priority Critical patent/CN111314244B/en
Publication of CN111314244A publication Critical patent/CN111314244A/en
Application granted granted Critical
Publication of CN111314244B publication Critical patent/CN111314244B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/50Queue scheduling
    • H04L47/62Queue scheduling characterised by scheduling criteria
    • H04L47/6245Modifications to standard FIFO or LIFO
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Abstract

The invention discloses a data receiving and transmitting method based on a message queue, which belongs to the field of data receiving and transmitting and comprises the following steps: s1: defining a queue structure and a node structure, defining a series of API interfaces for message queue operations based on the two structures, S2: defining a free queue and a work queue, defining specific elements of the node object, S3: defining enqueue and dequeue interfaces for free queues and work queues, S4: and data receiving and sending are realized by mutual leading-in and leading-out of the idle queue and the work queue. The invention aims at the data receiving and transmitting method based on the message queue, the method can stabilize the interface of the message queue frame, and a third party user does not need to modify the interface of the message queue frame; the transceiving task is separated from the hardware transceiving interface, so that the coupling degree of codes is greatly reduced; the expansibility is strong, and the method can be used in any occasions needing to receive and transmit the cache; the coupling degree is low, and the deadlock of resources is avoided.

Description

Data receiving and transmitting method based on message queue
Technical Field
The invention relates to the field of data receiving and transmitting, in particular to a data receiving and transmitting method based on a message queue.
Background
When the industrial field uses the bus protocol to collect the data of the sensing equipment and control the equipment to execute actions, the problems of receiving and sending multiple pieces of data through the protocol are all involved. The conventional method is that a receiving data linked list and a sending data linked list are established, when a receiving task receives data of the industrial field equipment, the data is added into the receiving data linked list, and then a piece of protocol data is taken out from the receiving data linked list for analysis; when the sending task sends data to the industrial field equipment, the sending data is added into the sending data linked list, then the protocol data is taken out from the sending data linked list, and the hardware sending interface is called to send the protocol data to the equipment. The disadvantages of this are: in a sending example, a sending task and a hardware sending interface call the same sending data linked list, so that resource deadlock is easily caused; in addition, the sending task and the hardware sending interface are in the same task, and the separation of the multi-task sending and the hardware sending interface cannot be achieved.
From the above, it can be seen that the data transceiving method of the prior art has some defects: in the conventional scheme, because the sending task and the hardware sending interface call the same sending data linked list or the hardware receiving interface and the receiving task call the same receiving data linked list, resource deadlock is easily caused; the conventional scheme cannot separate the multi-sending task from the hardware sending interface.
Therefore, a data transceiving method based on the message queue is provided.
Disclosure of Invention
The present invention is directed to a data transceiving method based on a message queue, so as to solve the problems in the background art.
In order to achieve the purpose, the invention provides the following technical scheme: a data receiving and sending method based on a message queue comprises the following steps:
s1: defining a queue structure body and a node structure body, and defining a series of API interfaces of message queue operation based on the two structure bodies;
s2: defining an idle queue and a work queue, and defining specific elements of a node object;
s3: defining enqueue and dequeue interfaces of an idle queue and a work queue;
s4: and data receiving and sending are realized by mutual leading-in and leading-out of the idle queue and the work queue.
Preferably, in S2, the size of the queue can be either statically allocated before operation or dynamically applied according to the sending protocol packet during operation.
Preferably, in S2, the number of elements and the type of elements of the node in the queue may be freely and flexibly expanded according to actual needs, that is, the number of elements and the type of elements may be increased, deleted, modified and checked, and the code may have strong expandability.
Preferably, in S3, the application sending task and the hardware sending interface are separated, so that multiple sending tasks can send the protocol data to the hardware sending interface at the same time.
Preferably, in S3, the application receiving task is separated from the hardware receiving interface, so that the hardware receiving interface can send data to multiple receiving tasks simultaneously.
Preferably, in S4, the sending task interacts only with the idle queue, and the hardware sending interface interacts only with the work queue; the receiving task only interacts with the work queue, and the hardware receiving interface only interacts with the idle queue; this avoids the problem of deadlocks on resources.
Compared with the prior art, the invention has the beneficial effects that:
1. the message queue frame interface is stable, and a third party user does not need to modify the message queue frame interface.
2. The transceiving task is separated from the hardware transceiving interface, so that the coupling degree of codes is greatly reduced; the tracking and debugging of problems is easier to locate and modify.
3. The user only needs to create the work queue and the idle queue of the user, and the use is simple and quick. The threshold of the door is low.
4. The expansibility is strong, and the method can be used in any occasions needing transceiving cache.
5. The coupling degree is low, and the deadlock of resources is avoided.
Drawings
FIG. 1 is an overall flow chart of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The invention provides a technical scheme that: a data receiving and sending method based on a message queue comprises the following steps:
s1: defining a queue structure body and a node structure body, and defining a series of API (application program interface) interfaces of message queue operation based on the two structure bodies;
s2: defining an idle queue and a work queue, and defining specific elements of a node object, wherein the size of the queues can be statically allocated before operation, and can also be dynamically applied according to a sending protocol data packet during operation; the number and the types of the elements of the nodes in the queue can be freely and flexibly expanded according to actual needs, namely, the number, the deletion, the modification and the check are increased, and the code expandability is strong;
s3: defining enqueue and dequeue interfaces of an idle queue and a work queue, wherein an application sending task is separated from a hardware sending interface, so that a plurality of sending tasks can send protocol data to the hardware sending interface at the same time; the application receiving task is separated from the hardware receiving interface, so that the hardware receiving interface can send data to a plurality of receiving tasks at the same time;
s4: data receiving and sending are achieved through mutual leading-in and leading-out of the idle queue and the work queue, wherein a sending task only interacts with the idle queue, and a hardware sending interface only interacts with the work queue; the receiving task only interacts with the work queue, and the hardware receiving interface only interacts with the idle queue; this avoids the problem of deadlocks on resources.
The invention aims at the data receiving and transmitting method based on the message queue, the method can stabilize the interface of the message queue frame, and a third party user does not need to modify the interface of the message queue frame; the transceiving task is separated from the hardware transceiving interface, so that the coupling degree of codes is greatly reduced; the problem tracking and debugging are easier to locate and modify; the user only needs to create the own work queue and the idle queue, and the use is simple and quick. The threshold of the door is low; the expansibility is strong, and the method can be used in any occasions needing to receive and transmit the cache; the coupling degree is low, and the deadlock of resources is avoided.
Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that changes, modifications, substitutions and alterations can be made in these embodiments without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents, and the invention is not limited to the embodiments described above, and various modifications and changes may be made without departing from the spirit and scope of the invention, and it is intended that all changes and modifications that fall within the scope of the invention are embraced in the appended claims.

Claims (3)

1. A data receiving and sending method based on a message queue is characterized by comprising the following steps:
s1: defining a queue structure body and a node structure body, and defining a series of API (application program interface) interfaces of message queue operation based on the two structure bodies;
s2: defining an idle queue and a work queue, and defining specific elements of a node object;
s3: defining enqueue and dequeue interfaces of an idle queue and a work queue;
wherein, the application sending task is separated from the hardware sending interface; the application receiving task is separated from the hardware receiving interface;
s4: data receiving and sending are realized through mutual leading-in and leading-out of the idle queue and the work queue;
wherein, the sending task only interacts with the idle queue, and the hardware sending interface only interacts with the work queue; the receiving task only interacts with the work queue, and the hardware receiving interface only interacts with the idle queue.
2. The message queue-based data transceiving method according to claim 1, wherein: in S2, the size of the queue may be statically allocated before operation, or dynamically applied according to the sending protocol packet during operation.
3. The message queue-based data transceiving method according to claim 1, wherein: in S2, the number and type of the elements of the nodes in the queue can be freely and flexibly expanded according to actual needs, i.e., the number, the type, the number, and the type of the elements can be increased, decreased, modified and checked.
CN202010091810.8A 2020-02-13 2020-02-13 Data receiving and transmitting method based on message queue Active CN111314244B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010091810.8A CN111314244B (en) 2020-02-13 2020-02-13 Data receiving and transmitting method based on message queue

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010091810.8A CN111314244B (en) 2020-02-13 2020-02-13 Data receiving and transmitting method based on message queue

Publications (2)

Publication Number Publication Date
CN111314244A CN111314244A (en) 2020-06-19
CN111314244B true CN111314244B (en) 2022-09-13

Family

ID=71158277

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010091810.8A Active CN111314244B (en) 2020-02-13 2020-02-13 Data receiving and transmitting method based on message queue

Country Status (1)

Country Link
CN (1) CN111314244B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO1997000533A1 (en) * 1995-06-15 1997-01-03 Intel Corporation A method and apparatus for transporting messages between processors in a multiple processor system
CN1713138A (en) * 2004-06-15 2005-12-28 中兴通讯股份有限公司 Deadlock solution in multi-task operating system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO1997000533A1 (en) * 1995-06-15 1997-01-03 Intel Corporation A method and apparatus for transporting messages between processors in a multiple processor system
CN1713138A (en) * 2004-06-15 2005-12-28 中兴通讯股份有限公司 Deadlock solution in multi-task operating system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于众核架构的入侵检测系统结构研究;陆遥;《中国优秀博硕士学位论文全文数据库(硕士)信息科技辑》;20190115(第1期);第25-27页 *

Also Published As

Publication number Publication date
CN111314244A (en) 2020-06-19

Similar Documents

Publication Publication Date Title
US10365957B2 (en) Multicasting of event notifications using extended socket for inter-process communication
CN107992370B (en) VxWorks platform multitask software framework implementation method
US8270299B2 (en) Communicator-based token/buffer management for eager protocol support in collective communication operations
US20160253213A1 (en) Method and system for dedicating processors for desired tasks
Kitayama et al. RT-IPC: An IPC Extension for Real-Time Mach.
US20060143616A1 (en) System and method for performing multi-task processing
WO2013144876A1 (en) Communication transport protocol for distributed information technology architectures
CN108255621A (en) A kind of MySQL incremental message analytic methods based on binlog
CN115794313B (en) Virtual machine debugging method, system, electronic device and storage medium
CN111314244B (en) Data receiving and transmitting method based on message queue
CN111666167A (en) Input event reading processing optimization method, nonvolatile memory and terminal equipment
CN105049372A (en) Method of expanding message middleware throughput and system thereof
CN104063285A (en) Message broadcast communication method based on vehicle-mounted software among modules in platform process
CN100426241C (en) Message level soft interrupt processing method in service system structure
US7216349B2 (en) System and method for triggering message queue applications
CN109639795B (en) Service management method and device based on AcitveMQ message queue
CN110442442B (en) Nuclear power plant DCS platform engineer station software maintenance network communication method
CN102117261A (en) Communication method between inner processors of chip
US20120317586A1 (en) Methods of reference counting across multiple processes
US20030041115A1 (en) Managing memory resident queues to control resources of the systems using the queues
CN106293884B (en) The detection method of invalid time exceeded message in a kind of message-driven system
CN110380991A (en) A kind of IOCP mechanism and the Internet of Things Network Communication acceleration system based on eFPGA and IOCP
CN117278505B (en) Message transmission method, system, equipment and medium between RAID card nodes
CN110620778B (en) Method for simultaneously supporting synchronous and asynchronous communication modes of socket
CN108604192B (en) System, method, and medium for performing one or more tasks while waiting for an event to be recorded

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