CN103064749B - Inter-process communication method - Google Patents

Inter-process communication method Download PDF

Info

Publication number
CN103064749B
CN103064749B CN201310008347.6A CN201310008347A CN103064749B CN 103064749 B CN103064749 B CN 103064749B CN 201310008347 A CN201310008347 A CN 201310008347A CN 103064749 B CN103064749 B CN 103064749B
Authority
CN
China
Prior art keywords
storage
file object
memory space
storage device
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
CN201310008347.6A
Other languages
Chinese (zh)
Other versions
CN103064749A (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.)
Shanghai Feixun Data Communication Technology Co Ltd
Original Assignee
Shanghai Feixun Data Communication 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 Shanghai Feixun Data Communication Technology Co Ltd filed Critical Shanghai Feixun Data Communication Technology Co Ltd
Priority to CN201310008347.6A priority Critical patent/CN103064749B/en
Publication of CN103064749A publication Critical patent/CN103064749A/en
Application granted granted Critical
Publication of CN103064749B publication Critical patent/CN103064749B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses an inter-process communication method, and belongs to the technical field of process communication mechanisms. The inter-process communication method is implemented by a calling device, a cache device, a first memory device and a second memory device, and includes steps of retrieving a message queue, a corresponding index node, a file object and a corresponding descriptor and storing the message queue, the corresponding index node, the file object and the corresponding descriptor in the cache device; establishing a corresponding relation between the message queue and the file object; initializing the index node and the file object in the cache device; enabling the calling device to rewrite the file object in the cache device according to the message queue in the cache device; reinstalling the rewritten file object into corresponding second memory space of the second memory device; reinstalling the descriptor into corresponding fourth memory space of a second indexing component; and returning the descriptor in the cache device. According to the technical scheme, the inter-process communication method has the advantages that network connection and communication on the basis of the message queue can be processed simultaneously, and the problem of low inter-process communication efficiency is solved.

Description

A kind of inter-process communication methods
Technical field
The present invention relates to Interprocess Communication Mechanism technical field, more particularly to a kind of inter-process communication methods.
Background technology
Gateway device is complex due to its function, and interaction more frequently, sets in the gateway developed between each functional module In standby, there is such a management program:It should process the network connecting request from network side, at the same again with various journeys The interprocess communication based on message queue is carried out between sequence, a function for configuration management program is reached.Due to based on socket (socket) network connection uses descriptor, thus can easily use select/poll functions, and message team Row are identified by respective identifier, and this means that can not directly use select/poll functions on message queue.
For above mentioned problem, existing solution:Allow service end first to create a pipeline, then derive from a son and enter Journey, is blocked in during msgrcv calls by subprocess.When there is a message to be ready to processed, msgrcv functions are returned to, son enters Journey then reads the message from specified queue, and the message is write pipeline.Service end parent process at that time may be at this Select on pipeline and some network connections.But in this method, message is processed three times:It is once to make in subprocess When being read with msgrcv, it, when subprocess writes pipeline, is for the last time when parent process reads from the pipeline to be once.When So, for these extra treatment, while increased extra overhead, efficiency is also lower.Corresponding solution is: An anonymous shared section key is created, a subprocess is derived from, allows the subprocess to be blocked in during msgrcv calls, message is read Enter in the anonymous shared section key, parent process creates two pipelines again, one of pipeline is used for parent process from subprocess What a message is notice prepare in shared section key, and another pipeline is then used for being notified in shared to subprocess from parent process Area is deposited to have can use.This allows for parent process to the reading end readable conditions of select of previous pipeline, while wanting selection to it Other descriptors select read-write condition.Even however, this solution, same or relatively complicated, additionally increasing Overhead, also greatly increases encoding amount.
The content of the invention
The defect according to present in prior art, now provides a kind of technical scheme of inter-process communication methods, specifically includes:
A kind of inter-process communication methods, it is adaptable to which the process in system is in communication with each other, wherein, including calling device, caching Device, first storage device, and the second storage device, the calling device connect the buffer storage, first storage respectively Device and second storage device;The message queue that the first storage device, is used for needed for depositing the interprocess communication; Second storage device is used to deposit the file object in the system;Content is transferred and write to the calling device described in First storage device, and second storage device, and the content that will be transferred is temporarily stored in the buffer storage;
The first storage device, includes multiple the first independent memory spaces, is deposited in each described first memory space It is placed with a message queue;Second storage device includes multiple the second independent memory spaces, and each described second is deposited Storage has an independent file object in storage space;
Also include the first index part in the first storage device, the first index part is connected described in multiple respectively First memory space;The first index part includes multiple the 3rd independent memory spaces, and each described 3rd storage is empty Between it is middle storage have an index node, each described index node respectively correspond to and first memory space of unique mark one In message queue;Each index node includes the handling function of the message queue;
Also include the second index part in second storage device, the second index part is connected described in multiple respectively Second memory space, the second index part includes multiple the 4th independent memory spaces, each described 4th memory space Middle storage has a descriptor, and each described descriptor is corresponded to and the text in second memory space of unique mark one respectively Part object;Each descriptor includes the handling function of the file object;
The inter-process communication methods are specifically included:
Step a, one is transferred by the calling device in first memory space of the first storage device, The message queue is simultaneously stored in the buffer storage;
Step b, correspondence is transferred by the calling device in the 3rd memory space of the described first index part The index node of the message queue is simultaneously stored in the buffer storage;
Step c, one is transferred by the calling device in the 4th memory space of the described second index part The descriptor is simultaneously stored in buffer storage;
Step d, correspondence is transferred by the calling device in second memory space of second storage device The file object of the descriptor is simultaneously stored in buffer storage;The message team in the buffer storage is stored in Corresponding relation is set up between row and the file object;
Step e, initializes the index node and the file object in the buffer storage;
Step f, the message queue of the calling device in the buffer storage is rewritten using default method The file object in the buffer storage;
Step g, the writing file object is reinstalled back the correspondence described second of second storage device In memory space;By the descriptor reinstall back it is described second index part correspondence the 4th memory space in;
Step h, returns to the descriptor in the buffer storage.
Preferably, the inter-process communication methods, wherein, including the first independent storage in each described first memory space Block, the first memory block internal memory is placed with the parameter value of the correspondence message queue.
Preferably, the inter-process communication methods, wherein, including the second independent storage in each described second memory space Block, the second memory block internal memory is placed with the parameter value of the correspondence file object.
Preferably, the inter-process communication methods, wherein, in the step f, the default method is:
The parameter value of the message queue in the buffer storage is write into the file pair in the buffer storage With the parameter value of the replacement file object as in;
By the handling function of the file object in the buffer storage be set in the buffer storage described in disappear Cease the handling function of queue;
The writing file object is reinstalled back correspondence second storage in second storage device In space.
The beneficial effect of above-mentioned technical proposal is:Network connection and the communication based on message queue can be simultaneously processed, and Solve the problems, such as interprocess communication inefficiency;It is add file descriptor mark in message queue, such that it is able to support it Select/poll, and then more efficiently treatment network connection and the demand of interprocess communication.
Brief description of the drawings
Fig. 1 is the foundation structure schematic diagram to interprocess communication in embodiments of the invention;
Fig. 2 is the schematic flow sheet of inter-process communication methods in embodiments of the invention.
Specific embodiment
The invention will be further described with specific embodiment below in conjunction with the accompanying drawings, but not as limiting to the invention.
As shown in figure 1, inter-process communication methods depend on the foundation structure to include:Calling device, buffer storage, the first storage Device and the second storage device, calling device difference Connection Cache device, first storage device, and the second storage device;First deposits The message queue that storage device is used for needed for depositing interprocess communication;The file object that second storage device is used in storage system; Content from first storage device, and the second storage device is transferred and write to calling device, and the content that will be transferred be temporarily stored in it is slow In cryopreservation device.
First storage device, includes multiple independent the first memory spaces (one of them is only shown in figure), and each first Storage has a message queue in memory space;Second storage device includes multiple the second independent memory spaces (in figure only One of them is shown), storage has an independent file object in each second memory space.
Also include the first index part in first storage device, it is empty that the first index part connects multiple first storages respectively Between;First index part includes multiple the 3rd independent memory spaces (one of them is only shown in figure), each the 3rd storage Storage has an index node in space, and each index node is corresponded to and disappearing in one the first memory space of unique mark respectively Breath queue.
Also include the second index part in second storage device, it is empty that the second index part connects multiple second storages respectively Between, the second index part includes multiple the 4th independent memory spaces (one of them is only shown in figure), each the 4th storage Storage has a descriptor in space, and each descriptor is corresponded to and the file pair in one the second memory space of unique mark respectively As.
Include independent first memory block in each first memory space, first memory block internal memory is placed with correspondence message queue Parameter value.
Include the second independent memory block in each second memory space, the second memory block internal memory is placed with respective file object Parameter value.
Can be while processing network connection and server program based on message queue communication, it is necessary to disappear in order to write one Add file descriptor mark in breath queue, so that it supports select/poll functions, and then more efficiently processes net simultaneously Network connection and the demand of interprocess communication.
Message queue is set to support select/poll functions, it is therefore necessary to first to understand the mode of operation of select functions: Select functions are to rely on filec descriptor and carry out work, and this filec descriptor is defined in a file structure (the second index part i.e. mentioned above), in this document structure, there is a collection of functions for being called file_operations (handling function that filec descriptor i.e. mentioned above includes), in the structure function of this file_operations, There is a function for being called poll.Select functions are exactly to obtain the text corresponding to filec descriptor by calling poll functions The state of part, therefore message queue is supported select functions, it is necessary to the add file descriptor mark in message queue, Specific method is as shown in Figure 2:
First, register a new system and call " _ NR_msgqtofd ", in the system is called, by calling device Msgqid functions transfer a new message queue in first storage device, while being obtained in the corresponding first index part The index node inode of the message queue, above-mentioned message queue and index node are stored in buffer storage with pending;With A new filec descriptor is obtained in the second index part by calling device afterwards, the get_ of calling device is then used Empty_filp functions obtain corresponding file object file_structure in the second storage device, by the description of above-mentioned file Symbol and file object are also stored in buffer storage with pending;Set up between message queue and file object in buffer storage Corresponding relation, and the index node inode of initial message queue and corresponding file object file_structure;With The handling function file_ of file object is set using the handling function msgq_file_ops of message queue in index node afterwards Operations, the corresponding parameter value of file object is set using the related parameter values in message queue.Finally will be by setting The file object of filec descriptor install back correspondence position in the second storage device, and return to this document descriptor.
In order to realize the poll functions of message queue handling function, select functions finally need for entering into file pair Poll functions are called in the handling function of elephant to obtain the correlation behavior of file.Therefore, it is determined that during message queue, can basis The correlation behavior of message queue is necessarily set:If being empty in message queue, corresponding flag bit is set to writeable;If Message queue is not sky, then be set to the flag bit read-only, is then back to the flag bit.
In order to be supported to poll functions, the structure of existing message queue can be modified, in the message team A waiting list head (poll_wait) is added on the structure of row;When message queue is created, it is necessary to simultaneously to the wait Queue heads are initialized.Message queue structure is defined as follows:
The present invention can simultaneously process network connection and the communication based on message queue, and it is low to solve interprocess communication efficiency Under problem;It is add file descriptor mark in message queue, it is such that it is able to make it support select/poll and then higher Effect ground treatment network connection and the demand of interprocess communication.
Preferred embodiments of the present invention are the foregoing is only, embodiments of the present invention and protection model is not thereby limited Enclose, to those skilled in the art, should can appreciate that done by all utilization description of the invention and diagramatic content Scheme obtained by equivalent and obvious change, should be included in protection scope of the present invention.

Claims (4)

1. a kind of inter-process communication methods, it is adaptable to which the process in system is in communication with each other, it is characterised in that including calling device, Buffer storage, first storage device, and the second storage device, the calling device connect the buffer storage, described first respectively Storage device and second storage device;The message team that the first storage device, is used for needed for depositing the interprocess communication Row;Second storage device is used to deposit the file object in the system;Content is transferred and write to the calling device certainly The first storage device, and second storage device, and the content that will be transferred is temporarily stored in the buffer storage;
The first storage device, includes multiple the first independent memory spaces, and being deposited in each described first memory space has One message queue;Second storage device includes multiple the second independent memory spaces, and each described second storage is empty Between it is middle storage have an independent file object;
Also include the first index part in the first storage device, the first index part connects multiple described first respectively Memory space;The first index part includes multiple the 3rd independent memory spaces, in each described 3rd memory space Storage has an index node, and each described index node is corresponded to and in first memory space of unique mark one respectively Message queue;Each index node includes the handling function of the message queue;
Also include the second index part in second storage device, the second index part connects multiple described second respectively Memory space, the second index part includes multiple the 4th independent memory spaces, is deposited in each described 4th memory space A descriptor is placed with, each described descriptor is corresponded to and the file pair in second memory space of unique mark one respectively As;Each descriptor includes the handling function of the file object;
The inter-process communication methods are specifically included:
Step a, is transferred described in one by the calling device in first memory space of the first storage device, Message queue is simultaneously stored in the buffer storage;
Step b, is transferred described in correspondence by the calling device in the 3rd memory space of the described first index part The index node of message queue is simultaneously stored in the buffer storage;
Step c, is transferred described in one by the calling device in the 4th memory space of the described second index part Descriptor is simultaneously stored in buffer storage;
Step d, transfers correspondence described by the calling device in second memory space of second storage device The file object of descriptor is simultaneously stored in buffer storage;The message queue in the buffer storage is stored in and Corresponding relation is set up between the file object;
Step e, initializes the index node and the file object in the buffer storage;
Step f, the message queue of the calling device in the buffer storage is rewritten described using default method The file object in buffer storage;
Step g, correspondence second storage that the writing file object is reinstalled into back second storage device In space;By the descriptor reinstall back it is described second index part correspondence the 4th memory space in;
Step h, returns to the descriptor in the buffer storage.
2. inter-process communication methods as claimed in claim 1, it is characterised in that include in each described first memory space only Vertical first memory block, the first memory block internal memory is placed with the parameter value of the correspondence message queue.
3. inter-process communication methods as claimed in claim 2, it is characterised in that include in each described second memory space only The second vertical memory block, the second memory block internal memory is placed with the parameter value of the correspondence file object.
4. inter-process communication methods as described in claim 3, it is characterised in that in the step f, the default method For:
By in the file object in the parameter value write-in buffer storage of the message queue in the buffer storage To replace the parameter value of the file object;
The handling function of the file object in the buffer storage is set to the message team in the buffer storage The handling function of row;
The writing file object is reinstalled back correspondence second memory space in second storage device In.
CN201310008347.6A 2013-01-09 2013-01-09 Inter-process communication method Active CN103064749B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310008347.6A CN103064749B (en) 2013-01-09 2013-01-09 Inter-process communication method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310008347.6A CN103064749B (en) 2013-01-09 2013-01-09 Inter-process communication method

Publications (2)

Publication Number Publication Date
CN103064749A CN103064749A (en) 2013-04-24
CN103064749B true CN103064749B (en) 2017-05-24

Family

ID=48107382

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310008347.6A Active CN103064749B (en) 2013-01-09 2013-01-09 Inter-process communication method

Country Status (1)

Country Link
CN (1) CN103064749B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104516740B (en) * 2013-09-26 2019-07-16 腾讯科技(深圳)有限公司 A kind of function calling method, device and mobile terminal
CN105512151A (en) * 2014-10-16 2016-04-20 安一恒通(北京)科技有限公司 Method and device for relieving document occupation
CN107038075B (en) * 2015-07-14 2020-12-25 阿里巴巴集团控股有限公司 Message queue system and method for realizing message communication
CN105912410A (en) * 2015-12-15 2016-08-31 乐视网信息技术(北京)股份有限公司 Method for communication among a plurality of processes, and client
CN109358974B (en) * 2018-10-17 2021-05-28 武汉斗鱼网络科技有限公司 Inter-process communication method and related device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101448018A (en) * 2008-12-26 2009-06-03 中兴通讯股份有限公司 Interprocess communication method and device thereof
CN101515241A (en) * 2009-02-19 2009-08-26 北京安高科技有限公司 Intertask data communication control method and system
CN101996097A (en) * 2009-08-26 2011-03-30 鸿富锦精密工业(深圳)有限公司 Process management system

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1116111A1 (en) * 1998-09-01 2001-07-18 Lernout & Hauspie Speech Products N.V. Interface between a control process and a target process
US7376957B1 (en) * 2002-12-16 2008-05-20 At&T Delaware Intellectual Property, Inc. Method and system for recovering stranded outbound messages
US7373647B2 (en) * 2003-04-30 2008-05-13 International Business Machines Corporation Method and system for optimizing file table usage

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101448018A (en) * 2008-12-26 2009-06-03 中兴通讯股份有限公司 Interprocess communication method and device thereof
CN101515241A (en) * 2009-02-19 2009-08-26 北京安高科技有限公司 Intertask data communication control method and system
CN101996097A (en) * 2009-08-26 2011-03-30 鸿富锦精密工业(深圳)有限公司 Process management system

Also Published As

Publication number Publication date
CN103064749A (en) 2013-04-24

Similar Documents

Publication Publication Date Title
CN103064749B (en) Inter-process communication method
CN109085997A (en) Memory-efficient for nonvolatile memory continues key assignments storage
CN104809247B (en) The distribution of database connection and recovery method
CN104881466B (en) The processing of data fragmentation and the delet method of garbage files and device
CN103092927B (en) File rapid read-write method under a kind of distributed environment
CN102810116B (en) Automatic routing and load balancing method and system based on database connection
CN106843773A (en) Storage method and distributed storage system
CN110275840A (en) Distributed process on memory interface executes and file system
CN110109868A (en) Method, apparatus and computer program product for index file
CN106909516A (en) Storage system and its operating method
CN103985393A (en) Method and device for parallel management of multi-optical-disc data
CN104598161B (en) Digital independent, wiring method and device and data store organisation
CN104484131A (en) Device and corresponding method for processing data of multi-disk servers
CN102999441B (en) Fine granularity memory access method
US20200394085A1 (en) Smart contract information redirect to updated version of smart contract
CN104252416B (en) A kind of accelerator and data processing method
CN102650972B (en) Date storage method, Apparatus and system
EP2606429A2 (en) Systems and methods for efficient sequential logging on caching-enabled storage devices
CN101783814A (en) Metadata storing method for mass storage system
CN104050189B (en) The page shares processing method and processing device
CN107250995A (en) Memory management apparatus
CN104407811B (en) A kind of merging I/O device based on cloud computing
CN109408505A (en) A kind of generation method of Bloom filter
CN109522240A (en) A kind of data processing method and device
CN105095111B (en) A kind of method and memory virtual equipment improving Storage Virtualization safety

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
PP01 Preservation of patent right

Effective date of registration: 20180313

Granted publication date: 20170524

PP01 Preservation of patent right
PD01 Discharge of preservation of patent

Date of cancellation: 20210313

Granted publication date: 20170524

PD01 Discharge of preservation of patent
PP01 Preservation of patent right

Effective date of registration: 20210313

Granted publication date: 20170524

PP01 Preservation of patent right
PD01 Discharge of preservation of patent

Date of cancellation: 20240313

Granted publication date: 20170524