Movatterモバイル変換


[0]ホーム

URL:


CN104503854A - Inter-process communication method and device - Google Patents

Inter-process communication method and device
Download PDF

Info

Publication number
CN104503854A
CN104503854ACN201410837300.5ACN201410837300ACN104503854ACN 104503854 ACN104503854 ACN 104503854ACN 201410837300 ACN201410837300 ACN 201410837300ACN 104503854 ACN104503854 ACN 104503854A
Authority
CN
China
Prior art keywords
data
message queue
slice
boost
write
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.)
Pending
Application number
CN201410837300.5A
Other languages
Chinese (zh)
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.)
CHENGDU COLASOFT Co Ltd
Original Assignee
CHENGDU COLASOFT 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 CHENGDU COLASOFT Co LtdfiledCriticalCHENGDU COLASOFT Co Ltd
Priority to CN201410837300.5ApriorityCriticalpatent/CN104503854A/en
Publication of CN104503854ApublicationCriticalpatent/CN104503854A/en
Priority to CN201510907057.4Aprioritypatent/CN105573846A/en
Pendinglegal-statusCriticalCurrent

Links

Classifications

Landscapes

Abstract

The invention provides an inter-process communication method and device. The method comprises the following steps: when data are generated by a first progress, obtaining a pre-established Boost message queue; directly writing the data into the Boost message queue; when a receiving module arranged at the end of a second progress receives the Boost message queue with the written data, extracting the data and sending the extracted data to the second progress. Compared with the prior art, the data of the first progress are not directly put into a shared memory by the embodiment, and the data are written into the Boost message queue; the data are communicated to the second progress from the first progress by using the Boost message queue. Therefore, a reading-writing synchronization problem does not need to be controlled in a development process and the development process is simpler.

Description

A kind of inter-process communication methods and device
Technical field
The present invention relates to communication technical field, especially a kind of inter-process communication methods and device.
Background technology
Need to communicate between different process, such as a process sends data to another process, or receives the data of another process transmission.In prior art, communication mode between different process is the mode of shared drive, namely in internal memory, arranges shared region, when a process needs to send data to another process, these data are write in this shared drive region, after write, send notice, to inform that this another process can read shared drive region to another process, or, amendment memory features value, after another monitoring the process is modified to memory features value, can read shared drive region.
But the above-mentioned process communication mode based on shared drive, need the read-write between control process synchronous, performance history is comparatively complicated.
Summary of the invention
In view of this, the invention provides a kind of inter-process communication methods and device, in order to solve the technical matters of inter-process communication methods performance history complexity in prior art.For realizing described object, technical scheme provided by the invention is as follows:
A kind of inter-process communication methods, comprising:
When the first process generates data, obtain the Boost message queue be pre-created;
Described data are write described Boost message queue;
When receiving the described Boost message queue with data, the Data Concurrent extracted wherein delivers to the second process.
Alternatively, describedly described data are write described Boost message queue and comprise:
Determine the length of described data and default single message-length of described Boost message queue;
When the length of described data is greater than described default single message-length, in units of described default single message-length, described data is cut into slices, obtains multiple slice of data;
Described multiple slice of data is write described Boost message queue.
Alternatively, describedly described multiple slice of data write described Boost message queue comprise:
According to section order, described multiple slice of data is write described Boost message queue.
Alternatively, described data are being cut into slices, after obtaining multiple slice of data, are also comprising:
Add up the number of described slice of data, and the described number of statistics is write described Boost message queue.
Alternatively, described when receiving the described Boost message queue with data, the Data Concurrent extracted wherein is delivered to the second process and is comprised:
When receiving the described Boost message queue with data, extract slice of data wherein, until the number of the slice of data extracted equals the described number of adding up;
Splice the slice of data extracted, and the data that splicing obtains are sent to the second process.
This application provides a kind of interprocess communication device, comprising:
Message queue acquisition module, for when the first process generates data, obtains the Boost message queue be pre-created;
Message queue writing module, for writing described Boost message queue by described data;
Process data extraction module, for when receiving the described Boost message queue with data, the Data Concurrent extracted wherein delivers to the second process.
Alternatively, described message queue writing module comprises:
Length determination submodule, for default single message-length of the length and described Boost message queue of determining described data;
Data slicer submodule, for when the length of described data is greater than described default single message-length, in units of described default single message-length, cuts into slices to described data, obtains multiple slice of data;
Data write submodule, for writing described Boost message queue by described multiple slice of data.
Alternatively, described data write submodule comprises:
Be sequentially written in unit, for according to section order, described multiple slice of data write described Boost message queue.
Alternatively, described message queue writing module also comprises:
Number write submodule, for cutting into slices to described data, after obtaining multiple slice of data, is adding up the number of described slice of data, and the described number of statistics is being write described Boost message queue.
Alternatively, described process data extraction module comprises:
Data extract submodule, for when receiving the described Boost message queue with data, extract slice of data wherein, until the number of the slice of data extracted equals the described number of adding up;
The data that splicing obtains for splicing the slice of data extracted, and are sent to the second process by data splicing submodule.
From above scheme, the beneficial effect of the application is:
The invention provides a kind of inter-process communication methods and device, the method comprises: when the first process generates data, obtain the Boost message queue be pre-created, write direct data Boost message queue, when the receiver module that the second process end is arranged receives the Boost message queue with data, extract data wherein, and the data of extraction are sent to the second process.Compared with prior art, the data of the first process are not directly put into shared drive by the embodiment of the present invention, but data are write in Boost message queue, utilize Boost message queue to realize the first process by data communication to the second process.Thus do not need on stream to control read-write stationary problem, performance history is simpler.
Accompanying drawing explanation
In order to be illustrated more clearly in the embodiment of the present invention or technical scheme of the prior art, be briefly described to the accompanying drawing used required in embodiment or description of the prior art below, apparently, accompanying drawing in the following describes is only embodiments of the invention, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to the accompanying drawing provided.
The process flow diagram of the inter-process communication methods that Fig. 1 provides for the embodiment of the present invention;
The schematic diagram of the sending module that Fig. 2 provides for the embodiment of the present invention and receiver module;
The partial process view of the inter-process communication methods that Fig. 3 provides for another embodiment of the present invention;
The structured flowchart of the interprocess communication device that Fig. 4 provides for the embodiment of the present invention;
The part-structure block diagram of the interprocess communication device that Fig. 5 provides for another embodiment of the present invention.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, be clearly and completely described the technical scheme in the embodiment of the present invention, obviously, described embodiment is only the present invention's part embodiment, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, belong to the scope of protection of the invention.
With reference to Fig. 1, it has disclosed the flow process of the inter-process communication methods that the embodiment of the present invention provides, and specifically comprises following flow process:
Step S101: when the first process generates data, obtain the Boost message queue be pre-created.
Wherein, when the first process generates data and needs these data to be sent to the second process, then the Boost message queue be pre-created is obtained.Boost message queue is used for sending data to the second process.
Step S102: described data are write described Boost message queue.
In the present embodiment, write direct data Boost message queue, and self can the realizing of Boost message queue sends data to the second process end, and wherein, the second process end is previously provided with receiver module, for performing next step.
Step S103: when receiving the described Boost message queue with data, the Data Concurrent extracted wherein delivers to the second process.
Wherein, when the receiver module of the second process end receives the Boost message queue with data, receiver module extracts data wherein, and the data extracted are sent to the second process, thus first process that completes sends the process of data to the second process.As shown in Figure 2, the first process end is provided with sending module, Boost message queue calls the transmission that sending module realizes data, and the second process end is provided with receiver module, and receiver module realizes the reception of data, thus completes the communication of different process.
In the present embodiment, whether receiver module can have message queue to be sent to self by Real-Time Monitoring, or receiver module is not monitored, but message queue triggers receiver module after arriving, then the receiver module be triggered extracts data wherein.
From above technical scheme, the inter-process communication methods that the present embodiment provides comprises: when the first process generates data, obtain the Boost message queue be pre-created, directly data are write in Boost message queue, the mechanism of Boost message queue self is utilized to realize data to mail to the second process end, when the receiver module that the second process end is arranged receives the Boost message queue with data, extract data wherein, and the data of extraction are sent to the second process.
Briefly, the embodiment of the present invention creates Boost message queue at the first process end with WriteMode, opens this message queue in a read mode at the second process end.First process end writes data in Boost message queue, and the second process end reads data wherein.Compared with prior art, the data of the first process are not directly put into shared drive by the embodiment of the present invention, but utilize Boost message queue to send data to the second process.Like this, the embodiment of the present invention does not need read-write synchronous operation when accessing shared drive between control process on stream, and performance history is simpler.
It should be noted that, two processes are in same equipment, and do not limit the Platform Type of equipment use, can be Linux platform, also can be windows platforms.In addition, the first process can be calling data to the process data that the second process sends, and this calling data triggers the second process and sends process data to the first process, thus realizes the first process calling the second process.Certainly, the mode that the second process sends process data to the first process can be the inter-process communication methods that the embodiment of the present invention provides.
When creating message queue, need to arrange the length of single message in message queue.When memory amount is less and performance requirement is lower, can arrange less message-length value, need to illustrate, the concrete numerical value of message-length can be determined according to the process interaction size of data of reality, and in the present invention, each embodiment does not limit.When the message-length arranged is less, and when data volume to be sent is larger, need data to cut into slices.Also namely, as shown in Figure 3, in above-described embodiment, specific implementation data being write Boost message queue can be:
Step S201: determine the length of described data and default single message-length of described Boost message queue.
Wherein, when creating Boost message queue, the length value of single message is pre-set, in order to the size of message each in restriction of message queue.
Step S202: when the length of described data is greater than described default single message-length, in units of described default single message-length, cuts into slices to described data, obtains multiple slice of data.
That is, when the length of data is larger, in units of default single message-length, be multiple data by data cutting.Such as, single message-length is 10K, and data are 200K size, be then the slice of data of 20 10K sizes by data cutting.
It should be noted that, even if when the last part data of cutting are less than single message-length, also using this partial data as a slice of data.Such as, single message-length is 10K, and process message is 205K size, be then 21 slice of datas by data cutting, comprising the slice of data of a 5K.
Step S203: described multiple slice of data is write described Boost message queue.
Wherein, corresponding sequence identification can be set for each slice of data, by multiple slice of data write Boost message queue being provided with sequence identification.Or direct basis section order, by multiple slice of data write Boost message queue.Multiple section processes in same message queue have identical process identification (PID), and this process identification (PID) is mark i.e. first process identification (PID) of transmission process.
In this kind of implementation, in message queue, comprise multiple slice of data.After second process end receiver module receives message queue, need to extract multiple slice of data successively, and be spliced into complete data.In order to ensure that receiver module accurately extracts whole slice of datas, the number of slice of data can be write in Boost message queue.That is:
Described data are being cut into slices, after obtaining multiple slice of data, is adding up the number of described slice of data, and the described number of statistics is being write described Boost message queue.
Therefore, the number of slice of data is included in the Boost message queue of encapsulation.When the second process termination receives Boost message queue, according to the number of the slice of data extracted, the extraction of data can be carried out.Particularly:
When receiving the described Boost message queue with data, extract slice of data wherein, until the number of the slice of data extracted equals the described number of adding up; Splice the slice of data extracted, and the data that splicing obtains are sent to the second process.
If slice of data has sequence identification, then the slice of data extracted is identified in order and splice; If slice of data there is no mark, but when being sequentially written in Boost message queue according to section, can extract successively and splice successively, the data that splicing obtains be complete data.
Below the interprocess communication device that the embodiment of the present invention provides is described, it should be noted that, below can be cross-referenced with inter-process communication methods above to the introduction of the interprocess communication device that the embodiment of the present invention provides.
With reference to Fig. 4, it illustrates the structure of the interprocess communication device that the embodiment of the present invention provides, specifically comprise: message queue acquisition module 100, message queue writing module 200 and process data extraction module 300; Wherein:
Message queue acquisition module 100, for when the first process generates data, obtains the Boost message queue be pre-created;
Message queue writing module 200, for writing described Boost message queue by described data;
Process data extraction module 300, for when receiving the described Boost message queue with data, the Data Concurrent extracted wherein delivers to the second process.
From above technical scheme, in the interprocess communication device that the present embodiment provides, when the first process generates data, message queue acquisition module 100 obtains the Boost message queue be pre-created, data directly write in Boost message queue by message queue writing module 200, when receiving the Boost message queue with data, process data extraction module 300 extracts data wherein, and the data of extraction are sent to the second process.Compared with prior art, the data of the first process are not put into shared drive by the embodiment of the present invention, but utilize Boost message queue directly to send data to the second process.Like this, the embodiment of the present invention does not need read-write synchronous operation when accessing shared drive between process, and development scheme is simpler.
Need explanation, message queue acquisition module 100 in the present embodiment, message queue writing module 200 can think the sending module in said method embodiment, be integrated in the first process end, for sending the data that the first process generates, process data extraction module 300 can think the receiver module in said method embodiment, be integrated in the second process end, for receiving data.Certainly, the first process end and the second process end can all arrange sending module and receiver module, then each process both can send data, also can receive data.
As shown in Figure 5, wherein, the message queue writing module 200 in above-mentioned interprocess communication device can comprise: length determination submodule 201, data slicer submodule 202 and data write submodule 203.Wherein:
Length determination submodule 201, for default single message-length of the length and described Boost message queue of determining described data;
Data slicer submodule 202, for when the length of described data is greater than described default single message-length, in units of described default single message-length, cuts into slices to described data, obtains multiple slice of data;
Data write submodule 203, for writing described Boost message queue by described multiple slice of data.
Wherein, the data write submodule 203 in above-mentioned interprocess communication device can comprise:
Be sequentially written in unit, for according to section order, described multiple slice of data write described Boost message queue.
As shown in Figure 5, alternatively, the message queue writing module 200 in above-mentioned interprocess communication device can also comprise:
Number write submodule 204, for cutting into slices to described data, after obtaining multiple slice of data, is adding up the number of described slice of data, and the described number of statistics is being write described Boost message queue.
Alternatively, the process data extraction module 300 in above-mentioned interprocess communication device can comprise:
Data extract submodule, for when receiving the described Boost message queue with data, extract slice of data wherein, until the number of the slice of data extracted equals the described number of adding up;
The data that splicing obtains for splicing the slice of data extracted, and are sent to the second process by data splicing submodule.
It should be noted that, each embodiment in this instructions all adopts the mode of going forward one by one to describe, and what each embodiment stressed is the difference with other embodiments, between each embodiment identical similar part mutually see.
Also it should be noted that, in this article, the such as relational terms of first and second grades and so on is only used for an entity or operation to separate with another entity or operational zone, and not necessarily requires or imply the relation that there is any this reality between these entities or operation or sequentially.And, term " comprises ", " comprising " or its any other variant are intended to contain comprising of nonexcludability, thus make to comprise the process of a series of key element, method, article or equipment and not only comprise those key elements, but also comprise other key elements clearly do not listed, or also comprise by the intrinsic key element of this process, method, article or equipment.When not more restrictions, the key element limited by statement " comprising ... ", and be not precluded within process, method, article or the equipment comprising above-mentioned key element and also there is other identical element.
To the above-mentioned explanation of the disclosed embodiments, professional and technical personnel in the field are realized or uses the present invention.To be apparent for those skilled in the art to the multiple amendment of these embodiments, General Principle as defined herein can without departing from the spirit or scope of the present invention, realize in other embodiments.Therefore, the present invention can not be restricted to these embodiments shown in this article, but will meet the widest scope consistent with principle disclosed herein and features of novelty.

Claims (10)

CN201410837300.5A2014-12-292014-12-29Inter-process communication method and devicePendingCN104503854A (en)

Priority Applications (2)

Application NumberPriority DateFiling DateTitle
CN201410837300.5ACN104503854A (en)2014-12-292014-12-29Inter-process communication method and device
CN201510907057.4ACN105573846A (en)2014-12-292015-12-09Inter-process communication method and inter-process communication device

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201410837300.5ACN104503854A (en)2014-12-292014-12-29Inter-process communication method and device

Publications (1)

Publication NumberPublication Date
CN104503854Atrue CN104503854A (en)2015-04-08

Family

ID=52945254

Family Applications (2)

Application NumberTitlePriority DateFiling Date
CN201410837300.5APendingCN104503854A (en)2014-12-292014-12-29Inter-process communication method and device
CN201510907057.4APendingCN105573846A (en)2014-12-292015-12-09Inter-process communication method and inter-process communication device

Family Applications After (1)

Application NumberTitlePriority DateFiling Date
CN201510907057.4APendingCN105573846A (en)2014-12-292015-12-09Inter-process communication method and inter-process communication device

Country Status (1)

CountryLink
CN (2)CN104503854A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN106338931A (en)*2015-07-062017-01-18天津九洲云物联科技有限公司Central control information scheduling algorithm
CN112445631A (en)*2020-12-022021-03-05广东博智林机器人有限公司RTPS process communication method, device, electronic equipment and storage medium
CN117931485A (en)*2024-03-222024-04-26摩尔线程智能科技(北京)有限责任公司 Data transmission system and method, electronic device and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
WO2009122390A2 (en)*2008-03-302009-10-08Correlsense Ltd.Apparatus and method for tracking requests in a multi threaded multi tier computerized environment
US20110246763A1 (en)*2010-04-032011-10-06Jason Wayne KarnesParallel method, machine, and computer program product for data transmission and reception over a network
CN102457442A (en)*2010-10-292012-05-16金蝶软件(中国)有限公司Message sending and reading method, device and middleware system
CN103176856B (en)*2013-04-022017-05-03浪潮电子信息产业股份有限公司Timing communication method between courses based on pipelines
CN103677988B (en)*2013-12-112018-04-20北京爱唯光石信息技术有限公司The multi-process means of communication and system for software systems

Cited By (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN106338931A (en)*2015-07-062017-01-18天津九洲云物联科技有限公司Central control information scheduling algorithm
CN112445631A (en)*2020-12-022021-03-05广东博智林机器人有限公司RTPS process communication method, device, electronic equipment and storage medium
CN117931485A (en)*2024-03-222024-04-26摩尔线程智能科技(北京)有限责任公司 Data transmission system and method, electronic device and storage medium
CN117931485B (en)*2024-03-222024-06-07摩尔线程智能科技(北京)有限责任公司 A data transmission system and method, electronic device and storage medium

Also Published As

Publication numberPublication date
CN105573846A (en)2016-05-11

Similar Documents

PublicationPublication DateTitle
US9471412B2 (en)Encoding diagnostic data in an error message for a computer program
US10289472B2 (en)Resource leak detection method, apparatus, and system
CN111159600A (en)Method and device for reporting information of elements on page, electronic equipment and storage medium
EP2434390A3 (en)Method of adding value to print data, a value-adding device, and a recording medium
CN106156165A (en)Method of data synchronization between heterogeneous data source and device
DE602004008801D1 (en) MANAGEMENT OF TRANSMISSIONS BETWEEN FACILITIES
CN110908707B (en)Resource packaging method, device, server and storage medium
CN105573846A (en)Inter-process communication method and inter-process communication device
CN104461716A (en)Access method of multi-nucleus heterogeneous system and multi-nucleus heterogeneous system
CN105183585B (en)Data backup method and device
EP2838037A3 (en)Information processing system, information processing method, and information processing program
CN104410671A (en)Snapshot capturing method and data monitoring tool
CN103914286B (en)Management method and manager for tab page in user interface
CN113495825A (en)Line alarm processing method and device, electronic equipment and readable storage medium
CN103501247A (en)Method and device for processing high concurrency request
CN105515933A (en)Management method for realizing network function of VMware based on OpenStack
CN109697281A (en)The online method, apparatus and electronic equipment for merging document
CN106844184A (en)A kind of distributed system metadata performance test methods, script and instrument
CN105844255A (en)Subjective question marking method and subjective question marking device
CN104426761A (en)Message processing method and device
CN103714291A (en)Information processing method and electronic equipment
US9705833B2 (en)Event driven dynamic multi-purpose internet mail extensions (MIME) parser
CN114007077A (en)Multimedia resource processing method and device, electronic equipment and storage medium
CN114416560A (en)Program crash analysis aggregation method and system
CN101442363B (en)Method and apparatus for revealing light path design graph

Legal Events

DateCodeTitleDescription
C06Publication
PB01Publication
C10Entry into substantive examination
SE01Entry into force of request for substantive examination
C02Deemed withdrawal of patent application after publication (patent law 2001)
WD01Invention patent application deemed withdrawn after publication

Application publication date:20150408


[8]ページ先頭

©2009-2025 Movatter.jp