CN107704325A - Method and apparatus for transmitting message between process - Google Patents

Method and apparatus for transmitting message between process Download PDF

Info

Publication number
CN107704325A
CN107704325A CN201610640978.3A CN201610640978A CN107704325A CN 107704325 A CN107704325 A CN 107704325A CN 201610640978 A CN201610640978 A CN 201610640978A CN 107704325 A CN107704325 A CN 107704325A
Authority
CN
China
Prior art keywords
memory block
written
read
currently
message
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.)
Granted
Application number
CN201610640978.3A
Other languages
Chinese (zh)
Other versions
CN107704325B (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 Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and 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 Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201610640978.3A priority Critical patent/CN107704325B/en
Publication of CN107704325A publication Critical patent/CN107704325A/en
Application granted granted Critical
Publication of CN107704325B publication Critical patent/CN107704325B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes
    • 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/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multi Processors (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

This application discloses the method and apparatus for transmitting message between process.One embodiment of methods described includes:According to the size of message to be transmitted, the shared drive that operating system is distributed is divided into multiple memory blocks;In the multiple memory block, determine a memory block being currently not written into as memory block to be written;Monitor whether the memory block to be written is currently read;Currently it is read in response to the memory block to be written, the memory block to be written is performed and locks operation;End is read in response to the memory block to be written, unblock operation is performed to the memory block to be written, and the message to be transmitted is write into the memory block to be written.The embodiment has efficiently controlled the speed that message is write into shared drive, to avoid transmission process from sending the excessive velocities of message, prevent the message that receiving process is sent from receiving transmission process in real time, ensure that the synchronism of Message Processing, so as to improve the reliability of message transmission.

Description

Method and apparatus for transmitting message between process
Technical field
The application is related to field of computer technology, and in particular to Computer Applied Technology field, more particularly to one kind are used for The method and apparatus that message is transmitted between process.
Background technology
Inter-process data interaction is needed by modes such as message queue, shared drive, pipelines, is using message queue or pipe During road, send the process of message and write message in message queue according to the transmission frequency of itself, receive the process of message from disappearing Message is obtained in breath queue.The drawbacks of this method is present is when the processing frequency for the process for receiving message is less than transmission message When the transmission frequency and message queue of process are full, the process for sending message continues to write message into message queue and can cause message The spilling of queue, i.e. a part can be deleted also by the message that the process of reception message receives, and cause the loss of message.
The method of the usually used interprocess communication based on shared drive, it is impossible to ensure to send process and the reception of message Synchronism between the process of message so that the reliability of message transmission is poor.
The content of the invention
The purpose of the application is to propose a kind of method and apparatus for transmitting message between process, to solve background above The technical problem that technology segment is mentioned.
In a first aspect, this application provides a kind of method for being used between process transmit message, methods described includes:According to treating The size of message is transmitted, the shared drive that operating system is distributed is divided into multiple memory blocks;In the multiple memory block, really A fixed memory block being currently not written into is as memory block to be written;Monitor whether the memory block to be written is currently read Take;Currently it is read in response to the memory block to be written, the memory block to be written is performed and locks operation;In response to described Memory block to be written is read end, and unblock operation is performed to the memory block to be written, and into the memory block to be written Write the message to be transmitted.
In certain embodiments, it is described to determine a memory block being currently not written into as memory block to be written, including: For the multiple memory block, continuous sequence number is set;The write-in quantitative value being pre-stored in the shared drive is incremented by;It is determined that pass The sequence number of first memory block corresponding to said write quantitative value after increasing, said write quantitative value and the multiple memory block are one by one It is corresponding;Monitor whether first memory block is currently written into;Currently it is not written into response to first memory block, by described in First memory block is as the memory block to be written.
In certain embodiments, the sequence number for determining the first memory block corresponding to the said write quantitative value after being incremented by, Including:Determine the quantity of the multiple memory block;Quantity by the write-in quantitative value after described be incremented by the multiple memory block Complementation;Sequence number using complementation value as first memory block.
In certain embodiments, methods described also includes:Currently it is written into response to first memory block, according to described The numeric order of multiple memory blocks, inquires about whether other memory blocks are currently written into;It is current in response to inquiring other memory blocks It is not written into, using the memory block being currently not written into as the memory block to be written.
In certain embodiments, methods described also includes:Currently it is written into, then presses in response to inquiring other memory blocks Inquire about according to the sequence number cycle of the multiple memory block, be currently not written into until inquiring a memory block, will be current not written The memory block entered is as the memory block to be written.
In certain embodiments, whether the monitoring memory block to be written is currently read, including:Monitoring is pre-stored in Whether the reading quantitative value in the memory block to be written is equal to preset value;When the reading quantitative value is equal to the preset value When, determine that the memory block to be written is not read currently;When the reading quantitative value is not equal to the preset value, institute is determined Memory block to be written is stated currently to be read.
In certain embodiments, methods described also includes:The message to be transmitted is write into the memory block to be written When, the write-in being pre-stored in the memory block to be written mark is arranged to true value, the true value corresponds to the internal memory to be written Block is currently written into;Completed in response to writing the message to be transmitted into the memory block to be written, said write is identified Falsity is arranged to, the falsity corresponds to the memory block to be written and is currently not written into.
Second aspect, this application provides a kind of method for being used between process transmit message, methods described includes:Will operation The address of cache of the shared drive of system is in the address space of itself;From multiple memory blocks of the shared drive, it is determined that The memory block of message is newly written as memory block to be read;Monitor whether the memory block to be read is currently written into;Response Currently it is written into the memory block to be read, into process wait state;Knot is written into response to the memory block to be read Beam, read the message stored in the memory block to be read.
In certain embodiments, it is described to determine to be newly written the memory block of message as memory block to be read, including:Read The sequence number of each memory block and the write-in quantitative value to prestore in the shared drive;By said write quantitative value and the multiple internal memory The quantity complementation of block;Sequence number is equal to the memory block of complementation value as the memory block to be read.
In certain embodiments, whether the monitoring memory block to be read is currently written into, including:Treated described in monitoring Whether the value for reading the write-in mark that memory block prestores is true value, and the true value corresponds to the memory block to be read and currently write Enter;Or whether the value for writing mark that the monitoring memory block to be read prestores is falsity, the falsity corresponds to described to be read Memory block is currently not written into.
In certain embodiments, methods described also includes:Currently it is not written into, reads in response to the memory block to be read The message stored in the memory block to be read.
In certain embodiments, methods described also includes:Read in the message process stored in the memory block to be read, The reading quantitative value being pre-stored in the memory block to be read is incremented by;In response to reading what is stored in the memory block to be read Message is completed, and the reading quantitative value being pre-stored in the memory block to be read is successively decreased.
In certain embodiments, methods described also includes:In response to reading the message stored in the memory block to be read Complete, using other memory blocks as new memory block to be read;Compare the complementation value and the new memory block to be read The size of sequence number;Be less than the complementation value in response to the sequence number of the new memory block to be read, read newly to be read The message stored in memory block;Be equal to the complementation value in response to the sequence number of the new memory block to be read, into it is described enter Journey wait state.
The third aspect, this application provides a kind of device for being used between process transmit message, described device includes:Division is single Member, for the size according to message to be transmitted, the shared drive that operating system is distributed is divided into multiple memory blocks;First determines Unit, in the multiple memory block, determining a memory block being currently not written into as memory block to be written;First Monitoring unit, for monitoring whether the memory block to be written is currently read;Lock cell, in response to described to be written Memory block is currently read, and the memory block to be written is performed and locks operation;Writing unit, in response to described to be written Memory block is read end, performs unblock operation to the memory block to be written, and write institute into the memory block to be written State message to be transmitted.
In certain embodiments, first determining unit includes:Setup module, for being set for the multiple memory block Continuous sequence number;Assignment module, for the write-in being pre-stored in shared drive quantitative value to be incremented by;First determining module, For determine be incremented by after said write quantitative value corresponding to the first memory block sequence number, said write quantitative value with it is the multiple Memory block corresponds;Monitoring modular, for monitoring whether first memory block is currently written into;Second determining module, use Currently it is not written into response to first memory block, using first memory block as the memory block to be written.
In certain embodiments, first determining module is further used for:Determine the quantity of the multiple memory block;Will It is described be incremented by after quantity complementation of the write-in quantitative value to the multiple memory block;Using complementation value as first memory block Sequence number.
In certain embodiments, first determining unit also includes:Enquiry module, in response to first internal memory Block is currently written into, and according to the numeric order of the multiple memory block, inquires about whether other memory blocks are currently written into;3rd is true Cover half block, for being currently not written into response to inquiring other memory blocks, using the memory block being currently not written into as described in Memory block to be written.
In certain embodiments, first determining unit also includes:4th determining module, in response to inquiring it Its memory block is currently written into, then is inquired about according to the sequence number cycle of the multiple memory block, until inquiring a memory block Currently it is not written into, using the memory block being currently not written into as the memory block to be written.
In certain embodiments, first monitoring unit includes:Monitoring modular, it is pre-stored in for monitoring described to be written Whether the reading quantitative value in memory block is equal to preset value;5th determining module, described in being equal to when the reading quantitative value During preset value, determine that the memory block to be written is not read currently;6th determining module, for reading quantitative value not when described During equal to the preset value, determine that the memory block to be written is currently read.
In certain embodiments, described device also includes:First mark unit, for being write into the memory block to be written When entering the message to be transmitted, the write-in being pre-stored in the memory block to be written mark is arranged to true value, the true value pair The memory block to be written is answered currently to be written into;Second mark unit, in response to being write into the memory block to be written The message to be transmitted is completed, and said write mark is arranged into falsity, it is current that the falsity corresponds to the memory block to be written It is not written into.
Fourth aspect, this application provides a kind of device for being used between process transmit message, described device includes:Internal memory reflects Unit is penetrated, for by the address of cache of the shared drive of operating system to the address space of itself;3rd determining unit, is used for From multiple memory blocks of the shared drive, it is determined that being newly written the memory block of message as memory block to be read;Second prison Unit is surveyed, for monitoring whether the memory block to be read is currently written into;First waits unit, for being continued in response to described Memory block is taken currently to be written into, into process wait state;First reading unit, in response to the memory block quilt to be read Write-in terminates, and reads the message stored in the memory block to be read.
In certain embodiments, the 3rd determining unit is further used for:Read each memory block in the shared drive Sequence number and the write-in quantitative value that prestores;By the quantity complementation of said write quantitative value and the multiple memory block;By sequence number etc. In complementation value memory block as the memory block to be read.
In certain embodiments, second monitoring unit is further used for:Monitor what the memory block to be read prestored Whether the value of write-in mark is true value, and the true value corresponds to the memory block to be read and is currently written into;Or continued described in monitoring Whether the value that the write-in for taking memory block to prestore identifies is falsity, and it is currently not written that the falsity corresponds to the memory block to be read Enter.
In certain embodiments, described device also includes:Second reading unit, in response to the memory block to be read Currently it is not written into, reads the message stored in the memory block to be read.
In certain embodiments, described device also includes:First assignment unit, for reading in the memory block to be read In the message process of storage, the reading quantitative value being pre-stored in the memory block to be read is incremented by;Second assignment unit, is used for Completed in response to reading the message stored in the memory block to be read, the reading number in the memory block to be read will be pre-stored in Value successively decreases.
In certain embodiments, described device also includes:Comparing unit, in response to reading the memory block to be read The message of middle storage is completed, using other memory blocks as new memory block to be read;Compare the complementation value to treat with described new Read the size of the sequence number of memory block;3rd reading unit, for being less than in response to the sequence number of the new memory block to be read The complementation value, read the message stored in the new memory block to be read;Second waits unit, in response to described new The sequence number of memory block to be read be equal to the complementation value, into the process wait state.
The method and apparatus that message is transmitted between process that what the application provided be used for, first according to the size of message to be transmitted, Shared drive is divided into multiple memory blocks, an internal memory being currently not written into then is chosen in multiple memory blocks of division Block is not read out in above-mentioned memory block to be written, write into above-mentioned memory block to be written to be passed as memory block to be written Defeated message.When reading message, first by the address of cache of shared drive into the address space of itself, and by shared drive The memory block for being newly written message in multiple memory blocks is and not written in above-mentioned memory block to be read as memory block to be read It is fashionable, read the message wherein stored.The speed of message is write so as to efficiently control transmission process into shared drive, with Transmission process is avoided to send the excessive velocities of message so that receiving process can not receive the message of transmission process transmission in real time, The process that the message that the process for sending message is sent is read message in time is read, and ensure that the synchronization of Message Processing Property, so as to improve the reliability of message transmission.
Brief description of the drawings
By reading the detailed description made to non-limiting example made with reference to the following drawings, the application's is other Feature, objects and advantages will become more apparent upon:
Fig. 1 is the flow chart for being used between process transmit one embodiment of the method for message according to the application;
Fig. 2 is the flow chart for being used between process transmit another embodiment of the method for message according to the application;
Fig. 3 is the flow chart for being used between process transmit one embodiment of the method for message according to the application;
Fig. 4 is the flow chart for being used between process transmit another embodiment of the method for message according to the application;
Fig. 5 is the schematic diagram for being used between process transmit an application scenarios of the method for message according to the application;
Fig. 6 is the structural representation for being used between process transmit one embodiment of the device of message according to the application;
Fig. 7 is the structural representation for being used between process transmit one embodiment of the device of message according to the application;
Fig. 8 is adapted for the computer system for being used between process transmit the device of message for realizing the embodiment of the present application Structural representation.
Embodiment
The application is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched The specific embodiment stated is used only for explaining related invention, rather than the restriction to the invention.It also should be noted that in order to Be easy to describe, illustrate only in accompanying drawing to about the related part of invention.
It should be noted that in the case where not conflicting, the feature in embodiment and embodiment in the application can phase Mutually combination.Describe the application in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
Fig. 1 shows the flow 100 for being used between process transmit one embodiment of the method for message according to the application.This The method for transmitting message between process of embodiment, comprises the following steps:
Step 101, according to the size of message to be transmitted, the shared drive that operating system is distributed is divided into multiple internal memories Block.
In the present embodiment, the process for sending message to be transmitted is referred to as transmission process, by entering for the message for reading transmission Journey is referred to as receiving process.Transmission process sends message to be transmitted to receiving process, and above-mentioned message to be transmitted can be various processes Between the message that can transmit, such as can be traffic information of the emulator of autonomous driving vehicle in simulation run.Aforesaid operations System can be various operating systems, such as can be linux system, robot operating system (Robot Operating System, ROS) etc..Shared drive refers in the computer system of multi-process, the internal memory that can be accessed by different processes.Can With understanding, above-mentioned shared drive is that transmission process obtains to operating system application.
Transmission process be able to will be shared after the shared drive of operating system distribution is obtained according to the size of message to be transmitted Internal memory is divided into multiple memory blocks.For example, the size of message to be transmitted is 8M, the size of the memory block of division can with it is to be transmitted The size of message is identical or can be with N times of the size of message to be transmitted, and N is preset constant (such as N=2.5).By in N times that is dimensioned to message to be transmitted of counterfoil, it is ensured that in ensuing message back is come, make an internal memory as far as possible The space size of block can store the message of transmission.For example, in ROS, each process can serve as a node, between node When transmitting message, can it is organized by message deposit in one or more topics.The size of message is poor in each topic Few.Therefore, in the present embodiment, can by the size for being sized slightly larger than message to be transmitted of the memory block of division so that its Transmission process and the message next to be transmitted of receiving process can be stored.
Step 102, in above-mentioned multiple memory blocks, determine a memory block being currently not written into as internal memory to be written Block.
, can be by setting a write-in mark to determine that a memory block is current in each memory block in the present embodiment Whether it is written into.For example, when the write-in of memory block is identified as true, it is believed that this memory block is currently written into, that is, other hairs be present It is sent into journey and writes message into this memory block.It is understood that the present embodiment can also cause otherwise Transmission process determines whether memory block is currently written into, such as can carry out table by setting bitmap in shared drive with bitmap Show which memory block is currently being written into shared drive.
In the present embodiment, transmission process can choose one and currently be not written into when choosing memory block to write message Memory block, to avoid multiple processes while write message into same memory block, cause the chaotic phenomenon of message.
Step 103, monitor whether memory block to be written is currently read.
In the present embodiment, transmission process is determining a memory block being currently not written into as memory block to be written Afterwards, it can monitor whether above-mentioned memory block to be written is currently read by various modes, for example, can be by being set in memory block Put a mark amount to be designated as reading quantitative value, to mark whether above-mentioned memory block to be written is currently read;Can also by One control bit is set in the message of transmission, the quantity of the process of the message is currently read with record.
In some optional implementations of the present embodiment, above-mentioned steps 103 can be by following not shown in Fig. 1 Step is realized:
Monitor whether the reading quantitative value being pre-stored in memory block to be written is equal to preset value;It is equal in advance when reading quantitative value If during value, determine that memory block to be written is not read currently;When reading quantitative value is not equal to preset value, internal memory to be written is determined Block is currently read.
In the present embodiment, quantitative value can be read by being prestored in each memory block one, and an initial value is set (such as it is 0 to set initial value), when reading the message stored in memory block per more receiving process, just makes reading quantitative value Add one;When often lacking the message stored in a receiving process reading memory block, reading quantitative value is just set to subtract one.So when above-mentioned reading When access value is equal to initial value, it is possible to think that memory block is not read currently.
Step 104, currently it is read in response to memory block to be written, memory block to be written is performed and locks operation.
In the present embodiment, if above-mentioned memory block to be written is currently received into journey reading, transmission process can lock this Memory block to be written, to avoid other transmission processes from equally wanting to write message into the memory block to be written.Sending process lock During fixed memory block to be written, operation can be locked by being performed to memory block to be written, or it is distributed to operating system application The mode of lock realizes the locking to memory block to be written.
Step 105, end is read in response to memory block to be written, performing unblock to memory block to be written operates, and to Message to be transmitted is write in memory block to be written.
No longer it is read out in memory block to be written, unblock behaviour can be performed to above-mentioned memory block to be written by sending process Make, to release the locking to it, and write message to be transmitted thereto., can be with when writing message to the memory block to be written Since the original position of the memory block to be written, message to be transmitted is write.
The method for transmitting message between process that above-described embodiment of the application provides, first according to message to be transmitted Size, shared drive is divided into multiple memory blocks, then choosing one in multiple memory blocks of division is currently not written into Memory block as memory block to be written, be not read out in above-mentioned memory block to be written, write into above-mentioned memory block to be written Enter message to be transmitted, efficiently controlled the speed that transmission process writes message into shared drive, to avoid transmission process from sending out Send the excessive velocities of message so that receiving process can not receive the message of transmission process transmission in real time, ensure that message is transmitted Synchronism, so as to improve message transmission reliability.
Fig. 2 shows the flow chart for being used between process transmit another embodiment of the method for message according to the application 200.As shown in Fig. 2 the method for transmitting message between process of the present embodiment comprises the following steps:
Step 201, according to the size of message to be transmitted, the shared drive that operating system is distributed is divided into multiple internal memories Block.
Step 202, continuous sequence number is set for multiple memory blocks.
In the present embodiment, continuous sequence number can be set to multiple memory blocks of division by sending process, for example, the process of transmission N number of memory block has been divided altogether, then above-mentioned continuous sequence number can terminate since 1 to N.
Step 203, the write-in quantitative value being pre-stored in shared drive is incremented by.
In the present embodiment, by setting a write-in quantitative value to be used as scalar value in shared drive, to show newest write Enter the position of the memory block of message, while the entry of memory block is chosen as transmission process.Above-mentioned write-in quantitative value can be opened from 0 Begin cumulative, can also be added up since other preset values.Above-mentioned write-in quantitative value exists with the sequence number in each memory block to be corresponded Relation, therefore, transmission process search out corresponding memory block according to the value can of write-in quantity.Whenever transmission process need to When message is write in memory block, just write-in quantitative value is incremented by, to point to a new memory block.
Step 204, it is determined that be incremented by after write-in quantitative value corresponding to the first memory block sequence number.
Because the sequence number of write-in quantitative value and each memory block is one-to-one, so the process of transmission is accessing shared drive When, write-in quantitative value is incrementally assured that a new memory block.In the present embodiment, by the write-in quantitative value pair after being incremented by The memory block answered is referred to as the first memory block.
In some optional implementations of the present embodiment, above-mentioned steps 204 can pass through the following step not shown in Fig. 2 It is rapid to realize:
Determine the quantity of multiple memory blocks;By quantity complementation of the write-in quantitative value after being incremented by multiple memory blocks;It will ask Sequence number of the residual value as the first memory block.
Because the quantity of memory block is limited, and it is ever-increasing to write quantitative value, it is possible that multiple write-in numbers Value corresponds to same memory block.In the present embodiment, quantity complementation of the quantitative value to memory block can will be write, and complementation value is made For the sequence number of memory block, thus write-in quantitative value and memory block are corresponded.For example, transmission process is drawn altogether 3 memory blocks are divided, the write-in quantitative value after being incremented by is 7, then 7 divided by 3 remainder is 1, then writes in corresponding to quantitative value 7 Counterfoil serial number 1.
Step 205, judge whether the first memory block is currently written into.
In the present embodiment, it can prestore one to write to identify in each memory block and work as mark amount to identify memory block It is preceding whether to be written into.For example, when can set the write-in to be identified as true, mark memory block is currently written into;Write-in is identified as fictitious time, Mark memory block is currently not written into.When the first memory block is currently written into, step 206 is performed ';When the first memory block is current When being not written into, step 206 is performed.
Step 206, using the first memory block as memory block to be written.
If memory block is currently not written into, preparation writes message to be transmitted in the memory block, and by this memory block As memory block to be written.
Step 207, judge whether memory block to be written is not read currently.
In the present embodiment, when memory block is currently read out, message will not be write into it by sending process, to avoid causing The confusion of message.Transmission process can judge that memory block to be written is current by reading the reading quantitative value being stored in memory block Whether it is read.
In some optional implementations of the present embodiment, above-mentioned steps 207 specifically can be by not shown in Fig. 2 Following steps are realized:
Monitor whether the reading quantitative value being pre-stored in memory block to be written is equal to preset value;It is equal in advance when reading quantitative value If during value, determine that memory block to be written is not read currently;When reading quantitative value is not equal to preset value, internal memory to be written is determined Block is currently read.
For example, the initial value that the reading quantitative value in each memory block can be set is 0, being read per more receiving process should During the message stored in memory block, it will just read quantitative value and add 1, then transmission process just understands have when knowing and reading quantitative value The message that " reading quantitative value " individual receiving process stores in the memory block is read.Process is read whenever one and reads message completion When, quantitative value will be read and subtract 1, then when all receiving process, which read message, to be completed, read quantitative value and be changed into initial value 0, Show that the memory block is not read currently.
Memory block to be written is not read out currently, performs step 208, otherwise performs step 219.
Step 208, memory block to be written is set currently to be written into.
In the present embodiment, memory block to be written is not read out, is shown that transmission process can write into the memory block and is treated Transmit message.Now, it is written into memory block to be arranged to currently be written into, other transmission processes can be allowed clearly to know that this is interior The current state of counterfoil.The write-in that transmission process can be pre-stored in memory block by setting identifies, to show memory block to be written Current state.Such as write-in mark is arranged to true value, then it represents that memory block to be written is currently written into.
Step 209, message to be transmitted is write into memory block to be written.
Also it is not read out when memory block is currently not written into, transmission process can write message into the memory block.
Step 210, judge whether to write to memory block to be written and complete.
Step 211 is performed after the completion of write-in, otherwise continues executing with step 209.
Step 211, memory block to be written is set currently to be not written into.
After the completion of transmission process writes message, the write-in mark that can be written into memory block is set to false as, to show The memory block is currently not written into.
Determine to perform step 206 when the first memory block is currently written into step 205 '.
Step 206 ', according to the sequence number of memory block, inquire about whether other memory blocks are currently written into.
When the first memory block is currently written into, then it is current other memory blocks to be inquired about successively according to the sequence number of memory block Whether it is written into.For example, 5 memory blocks have been divided in shared drive altogether, the serial number 1 of the first memory block, then according to 0,1,2, 3rd, the other memory blocks of 4 sequential query.
Step 207 ', judge whether other memory blocks are currently not written into.
When inquiring other memory blocks and being currently not written into, then step 208 is performed ', otherwise return and perform step 206 ', after Continuous inquiry.
In the present embodiment, still can be currently to judge other memory blocks by the write-in mark being arranged in memory block It is no to be written into.
Step 208 ', using the memory block being currently not written into as memory block to be written.
Transmission process according to 0,1,2,3,4 the other memory blocks of sequential query, if in query process, a certain memory block Currently it is not written into, then using this memory block as memory block to be written, prepares to write message to be transmitted into this memory block.
Step 208 is completed performing ' after, perform step 207.Determine that memory block to be written is currently read in step 207 When taking, step 209 is performed '.
Step 209 ', memory block to be written is performed and locks operation.
In the present embodiment, if above-mentioned memory block to be written is currently received into journey reading, transmission process can lock this Memory block to be written, to avoid other transmission processes from equally wanting to write message into the memory block to be written.Sending process lock During fixed memory block to be written, operation can be locked by being performed to memory block to be written, or it is distributed to operating system application The mode of lock realizes the locking to memory block to be written.
Step 210 ', into process wait state.
After transmission process locks memory block to be written, then into wait state, until memory block to be written is written into end.
Step 211 ', judge whether memory block to be written is read completion.
When memory block to be written is read completion, step 212 is performed ';Otherwise return and perform step 210 ', continue Treat.
Step 212 ', unblock operation is performed to memory block to be written.
After the completion of memory block to be written is read, memory block to be written is unlocked, and perform step 208.
The method that message is transmitted between process that what above-described embodiment of the application provided be used for, by set write-in quantitative value, Reading quantitative value and write-in three mark amounts of mark can make the process of transmission message rapidly determine to work as one in shared drive Before the memory block that is not written into and reads write memory block as memory block to be written, and by message, improve message write-in Efficiency;Meanwhile before message is write, the process of reading message is preferentially read completion message, also further ensure message The reliability of transmission, avoid the chaotic phenomenon of message transmission.
Fig. 3 shows the flow 300 for being used between process transmit one embodiment of the method for message according to the application.Such as Shown in Fig. 3, the method for transmitting message between process of the present embodiment comprises the following steps:
Step 301, by the address of cache of the shared drive of operating system to the address space of itself.
When the process of reading message reads message from shared drive, first have to the address of the shared drive of operating system It is mapped in the address space of itself, the process for so allowing for receiving message is accessed as the internal memory for accessing itself in shared Deposit.Operating system can be various operating systems, such as can be linux system, robot operating system (Robot Operating System, ROS) etc..
In the present embodiment, the process for reading message is referred to as receiving process, the process for sending message is referred to as transmission process. Above-mentioned receiving process can be the various processes that can receive message, such as can be each in the emulator of autonomous driving vehicle Process where emulation module.
Step 302, from multiple memory blocks of shared drive, it is determined that being newly written the memory block of message as to be read interior Counterfoil.
In order to ensure that receiving process can read newest message, receiving process accesses first when accessing shared drive The memory block of message is newly written, and as memory block to be read.
Step 303, monitor whether memory block to be read is currently written into.
After memory block to be read is determined, it is first determined whether the memory block is currently written into, if the process of transmission is just Message is being write into the memory block, then receiving process can not read the message in the memory block.
In the present embodiment, reading process can be identified by reading the write-in in memory block, to determine that memory block to be read is worked as It is preceding whether to be written into.Certainly, reading process can also determine above mentioned problem, such as the side for passing through bitmap by another way Formula.
Step 304, currently it is written into response to memory block to be read, into process wait state.
If memory block to be read is currently written into, receiving process needs just be read out after it is written into end, Therefore, process wait state is entered.
Step 305, end is written into response to memory block to be read, reads the message stored in memory block to be read.
Memory block to be read is written into end, shows transmission process so that message to be transmitted is all write into memory block to be read In, now, receiving process can read the message stored in memory block to be read.
It is understood that receiving process can equally identify to determine memory block to be read according to the write-in in memory block Whether end is written into.
The method for transmitting message between process that above-described embodiment of the application provides, first by the address of shared drive It is mapped in the address space of itself, and using the memory block for being newly written message in multiple memory blocks of shared drive as treating Memory block is read, and when above-mentioned memory block to be read is not written into, reads the message wherein stored, it is newest so as to read The message of write-in, ensure the synchronism of Message Processing.
Fig. 4 shows the flow chart for being used between process transmit another embodiment of the method for message according to the application 400.As shown in figure 4, the method for transmitting message between process of the present embodiment comprises the following steps:
Step 401, by the address of cache of the shared drive of operating system to the address space of itself.
Step 402, from multiple memory blocks of shared drive, it is determined that being newly written the memory block of message as to be read interior Counterfoil.
In some optional implementations of the present embodiment, above-mentioned steps 402 can be by following not shown in Fig. 4 Step:
Read the sequence number of each memory block and the write-in quantitative value to prestore in shared drive;Will write-in quantitative value and multiple internal memories The quantity complementation of block;Sequence number is equal to the memory block of complementation value as the memory block to be read.
, can be by writing quantitative value and memory block sequence number in shared drive when it is determined that being newly written the memory block of message One-to-one relationship determines.Quantitative value divided by the quantity of multiple memory blocks will be write, memory block sequence number is equal to remainder Memory block is as the memory block for being newly written message.
Step 403, judge whether memory block to be read is currently written into.
Receiving process can judge whether memory block to be read is currently written into by various modes, such as be marked by writing The mode of knowledge, mode of bitmap etc..
In some optional implementations of the present embodiment, above-mentioned steps 403 can pass through the following step not shown in Fig. 4 It is rapid to realize:
Whether the value for monitoring the write-in mark that memory block to be read prestores is true value, and it is current that true value corresponds to memory block to be read It is written into;Or
Whether the value for monitoring the write-in mark that memory block to be read prestores is falsity, and it is current that falsity corresponds to memory block to be read It is not written into.
The value that receiving process can be identified by the write-in monitored in memory block to be read, to determine whether it is currently write Enter.When monitoring that write-in is identified as true value, assert that memory block to be read is currently written into;When monitoring that write-in is identified as falsity When, assert that memory block to be read is currently not written into.
When memory block to be read is currently written into, step 404 is performed ';Otherwise step 404 is performed.
Step 404, the reading quantitative value of memory block to be read is incremented by.
When reading message, the reading quantitative value of memory block to be read is incremented by, to cause transmission process sending message When, the reading state of this memory block can be apparent from.
Step 405, the message stored in memory block to be read is read.
When memory block to be read is not written into, the message stored in memory block to be read can be read in receiving process.
Step 406, judge whether memory block to be read is read completion.
If it is, performing step 407, otherwise return and perform step 405.
Step 407, the reading quantitative value of memory block to be read is successively decreased.
After the completion of reading, quantitative value will be read and successively decreased, make it that transmission process, can be clear when sending message Solve the reading state of this memory block.
When determining that memory block to be read is currently written into step 403, step 404 is performed '.
Step 404 ', into process wait state.
If memory block to be read is currently written into, after the completion of the process write-ins to be sent such as receiving process needs, then read Take the message of its memory storage.
Step 405 ', judge whether memory block to be read is written into completion.
If it is step 404 is performed, otherwise returns and performs step 404 '.
In some optional implementations of the present embodiment, the above method also includes the following steps not shown in Fig. 4:
Completed in response to reading the message stored in memory block to be read, using other memory blocks as new internal memory to be read Block;Compare the size of complementation value and the sequence number of new memory block to be read.
When the sequence number of new memory block to be read is less than complementation value, disappearing of being stored in new memory block to be read is read Breath.
When the sequence number of new memory block to be read is equal to complementation value, into process wait state.
Receiving process can read in other memory blocks and store after the message for completing to be stored in memory block to be read is read Message, and using other memory blocks as new memory block to be read.Before reading, it is necessary to by new memory block to be read Sequence number, if the two is equal, illustrates transmission process compared with the remainder that the quantity of write-in quantitative value divided by memory block obtains Message is write into the memory block, then receiving process enters process wait state;If the sequence of new memory block to be read Number it is less than above-mentioned remainder, illustrates that journey write-in has been sent into the memory block to be completed, receiving process can be read.
The method for transmitting message between process that above-described embodiment of the application provides, by writing quantitative value, write-in Mark and quantitative value these three mark amounts are read, can rapidly determine to be newly written the memory block of message, and determine the internal memory The state of block, while quantitative value is read by changing, also transmission process can be made to be expressly understood that the reading state of memory block, carried The high efficiency of Message Processing;Receiving process introduces process wait state, ensured in the message in reading memory block to be read Receiving process can always read the message being newly written, and ensure that the synchronism of message transmission;So as to locate in real time The message read is managed, improves the reliability of message transmission.
With continued reference to Fig. 5, Fig. 5 is one for the application scenarios of the method for transmission message between process according to the present embodiment Individual schematic diagram.In Fig. 5 application scenarios, send process 501 shared drive 502 7 memory blocks (sequence number is respectively 0, 1 ... 6) in choose a memory block being currently not written into as memory block to be written, looked into from the internal memory BOB(beginning of block) of serial number 0 Ask, it is found that the write-in mark of memory block 0 and memory block 1 is true (being flag mark be present in figure), the memory block of serial number 2 is write Inlet identity is false, then using memory block 2 as memory block to be written.It is 2 now to monitor the reading quantitative value in memory block 2, Memory block 2 is locked.When the reading quantitative value of locked memory block 2 (as shown at 503) is changed into 0, transmission process 501 solves to it Lock and write message wherein, now its write-in is identified as true (as shown by 504).Receiving process 506 accesses memory block at this moment 2, it is found that it is true its write-in is identified as, into wait state, is identified as fictitious time (as shown in 505) in write-in, reads in memory block 2 and deposit The message of storage.
With further reference to Fig. 6, as the realization to method shown in above-mentioned each figure, this application provides one kind to be used between process One embodiment of the device of message is transmitted, the device embodiment is corresponding with the embodiment of the method shown in Fig. 1, and the device is specific It can apply in various electronic equipments.As shown in fig. 6, the device 600 for transmitting message between process of the present embodiment includes: Division unit 601, the first determining unit 602, the first monitoring unit 603, lock cell 604 and writing unit 605.
Wherein, division unit 601, for the size according to message to be transmitted, the shared drive of operating system distribution is drawn It is divided into multiple memory blocks.
First determining unit 602, in multiple memory blocks for being divided in division unit 601, determine one it is current not by The memory block of write-in is as memory block to be written.
In some optional implementations of the present embodiment, above-mentioned first determining unit 602 may further include Fig. 6 Not shown in setup module, assignment module, the first determining module, monitoring modular and the second determining module.
Wherein, setup module, multiple memory blocks for being divided for division unit 601 set continuous sequence number.
Assignment module, for the write-in being pre-stored in shared drive quantitative value to be incremented by.
First determining module, for determining the sequence number of the first memory block corresponding to the write-in quantitative value after being incremented by.Wherein, write Enter quantitative value to correspond with multiple memory blocks.
Monitoring modular, currently whether it is written into for monitoring the first memory block that the first determining module determines.
Second determining module, for being currently not written into the first memory block in response to monitoring module monitors, in first Counterfoil is as memory block to be written.
In some optional implementations of the present embodiment, above-mentioned first determining module can be further used for:
Determine the quantity of multiple memory blocks;By quantity complementation of the write-in quantitative value after being incremented by multiple memory blocks;It will ask Sequence number of the residual value as the first memory block.
In some optional implementations of the present embodiment, above-mentioned first determining unit 602 can further include Enquiry module, the 3rd determining module and the 4th determining module not shown in Fig. 6.
Wherein, enquiry module, for being currently written into the first memory block in response to monitoring module monitors, according to multiple interior The numeric order of counterfoil, inquires about whether other memory blocks are currently written into.
3rd determining module, currently it is not written into for inquiring other memory blocks in response to enquiry module, will currently not The memory block being written into is as memory block to be written.
4th determining module, currently it is written into for inquiring other memory blocks in response to enquiry module, then according to more The sequence number cycle inquiry of individual memory block, is currently not written into, the internal memory that will be currently not written into until inquiring a memory block Block is as memory block to be written.
First monitoring unit 603, currently whether read for monitoring the memory block to be written that the first determining unit 602 determines Take.
In some optional implementations of the present embodiment, above-mentioned first monitoring unit 603 may further include Fig. 6 Not shown in monitoring modular, the 5th determining module and the 6th determining module.
Wherein, monitoring modular, for monitoring whether the reading quantitative value being pre-stored in memory block to be written is equal to preset value.
5th determining module, for when monitoring module monitors are equal to preset value to reading quantitative value, determining in be written Counterfoil is not read currently.
6th determining module, for when monitoring module monitors are not equal to preset value to reading quantitative value, determining to be written Memory block is currently read.
Lock cell 604, it is right for monitoring that memory block to be written is currently read in response to the first monitoring unit 603 Memory block to be written, which performs, locks operation.
Writing unit 605, for being read end in response to memory block to be written, unblock behaviour is performed to memory block to be written Make, and the message to be transmitted is write into memory block to be written.
In some optional implementations of the present embodiment, the above-mentioned device 600 for transmitting message between process may be used also With including the first mark unit not shown in Fig. 6 and the second mark unit.
Wherein, the first mark unit, during for writing message to be transmitted into memory block to be written, will be pre-stored in be written Write-in mark in memory block is arranged to true value, and true value corresponds to memory block to be written and is currently written into.
Second mark unit, for being completed in response to writing message to be transmitted into memory block to be written, write-in is identified Falsity is arranged to, falsity corresponds to memory block to be written and is currently not written into.
The device for transmitting message between process that above-described embodiment of the application provides, has efficiently controlled transmission process The speed of message is write into shared drive, to avoid transmission process from sending the excessive velocities of message so that receiving process can not The message that transmission process is sent is received in real time, ensure that the synchronism of message transmission, so as to improve the reliable of message transmission Property.
Fig. 7 shows the structural representation for being used between process transmit one embodiment of the device of message according to the application Figure.As shown in fig. 7, the device 700 for transmitting message between process of the present embodiment includes:Internal memory map unit the 701, the 3rd is true Order member 702, the second monitoring unit 703, first wait the reading unit 705 of unit 704 and first.
Wherein, internal memory map unit 701, for the address of cache of the shared drive of operating system is empty to the address of itself In.
3rd determining unit 702, for from multiple memory blocks of shared drive, it is determined that being newly written the memory block of message As memory block to be read.
In some optional implementations of the present embodiment, above-mentioned 3rd determining unit 702 can also be further used for:
Read the sequence number of each memory block and the write-in quantitative value to prestore in shared drive;Will write-in quantitative value and multiple internal memories The quantity complementation of block;Sequence number is equal to the memory block of complementation value as memory block to be read.
Second monitoring unit 703, currently whether it is written into for monitoring memory block to be read.
In some optional implementations of the present embodiment, above-mentioned second monitoring unit 703 can also be further used for:
Whether the value for monitoring the write-in mark that memory block to be read prestores is true value, and it is current that true value corresponds to memory block to be read It is written into;Or whether the value for writing mark that monitoring memory block to be read prestores is falsity, falsity corresponds to memory block to be read and worked as Before be not written into.
First waits unit 704, for being currently written into response to memory block to be read, into process wait state.
First reading unit 705, for being written into end in response to memory block to be read, read in memory block to be read and deposit The message of storage.
In some optional implementations of the present embodiment, the above-mentioned device 700 for transmitting message between process may be used also Including the second reading unit not shown in Fig. 7, for being currently not written into response to memory block to be read, to read to be read The message stored in memory block.
In some optional implementations of the present embodiment, the above-mentioned device 700 for transmitting message between process may be used also With including the first assignment unit and the second assignment unit not shown in Fig. 7.
First assignment unit, for reading in the message process stored in memory block to be read, it will be pre-stored in be read Reading quantitative value in counterfoil is incremented by.
Second assignment unit, for being completed in response to reading the message stored in memory block to be read, continued being pre-stored in The reading quantitative value in memory block is taken to successively decrease.
In some optional implementations of the present embodiment, the above-mentioned device 700 for transmitting message between process may be used also To wait unit including the comparing unit not shown in Fig. 7, the 3rd reading unit and second.
Comparing unit, for being completed in response to reading the message stored in memory block to be read, using other memory blocks as New memory block to be read;Compare the size of complementation value and the sequence number of new memory block to be read.
3rd reading unit, for determining that the sequence number of new memory block to be read is less than complementation value in response to comparing unit, Read the message stored in new memory block to be read.
Second waits unit, for determining that the sequence number of new memory block to be read is equal to complementation value in response to comparing unit, Into process wait state.
The device of message is transmitted between process that what above-described embodiment of the application provided be used for, disappearing of being newly written can be read Breath, ensure the synchronism of Message Processing.
Below with reference to Fig. 8, it illustrates suitable for for realizing the dress for being used between process transmit message of the embodiment of the present application The structural representation for the computer system 800 put.
As shown in figure 8, computer system 800 includes CPU (CPU) 801, it can be read-only according to being stored in Program in memory (ROM) 802 or be loaded into program in random access storage device (RAM) 803 from storage part 808 and Perform various appropriate actions and processing.In RAM 803, also it is stored with system 800 and operates required various programs and data. CPU 801, ROM 802 and RAM 803 are connected with each other by bus 804.Input/output (I/O) interface 805 is also connected to always Line 804.
I/O interfaces 805 are connected to lower component:Importation 806 including keyboard, mouse etc.;Penetrated including such as negative electrode The output par, c 807 of spool (CRT), liquid crystal display (LCD) etc. and loudspeaker etc.;Storage part 808 including hard disk etc.; And the communications portion 809 of the NIC including LAN card, modem etc..Communications portion 809 via such as because The network of spy's net performs communication process.Driver 810 is also according to needing to be connected to I/O interfaces 805.Detachable media 811, such as Disk, CD, magneto-optic disk, semiconductor memory etc., it is arranged on as needed on driver 810, in order to read from it Computer program be mounted into as needed storage part 808.
Especially, in accordance with an embodiment of the present disclosure, it may be implemented as computer above with reference to the process of flow chart description Software program.For example, embodiment of the disclosure includes a kind of computer program product, it includes being tangibly embodied in machine readable Computer program on medium, the computer program include the program code for being used for the method shown in execution flow chart.At this In the embodiment of sample, the computer program can be downloaded and installed by communications portion 809 from network, and/or from removable Medium 811 is unloaded to be mounted.When the computer program is performed by CPU (CPU) 801, perform in the present processes The above-mentioned function of limiting.
Flow chart and block diagram in accompanying drawing, it is illustrated that according to the system of the various embodiments of the application, method and computer journey Architectural framework in the cards, function and the operation of sequence product.At this point, each square frame in flow chart or block diagram can generation The part of one module of table, program segment or code, a part for the module, program segment or code include one or more For realizing the executable instruction of defined logic function.It should also be noted that some as replace realization in, institute in square frame The function of mark can also be with different from the order marked in accompanying drawing generation.For example, two square frames succeedingly represented are actual On can perform substantially in parallel, they can also be performed in the opposite order sometimes, and this is depending on involved function.Also It is noted that the combination of each square frame and block diagram in block diagram and/or flow chart and/or the square frame in flow chart, Ke Yiyong Function as defined in execution or the special hardware based system of operation are realized, or can be referred to specialized hardware and computer The combination of order is realized.
Being described in unit involved in the embodiment of the present application can be realized by way of software, can also be by hard The mode of part is realized.Described unit can also be set within a processor, for example, can be described as:A kind of processor bag Include division unit, the first determining unit, the first monitoring unit, lock cell and writing unit.Wherein, the title of these units The restriction to the unit in itself is not formed under certain conditions, for example, the first monitoring unit is also described as " monitoring institute State the unit whether memory block to be written is currently read ".
As on the other hand, present invention also provides a kind of nonvolatile computer storage media, the non-volatile calculating Machine storage medium can be the nonvolatile computer storage media included in device described in above-described embodiment;Can also be Individualism, without the nonvolatile computer storage media in supplying terminal.Above-mentioned nonvolatile computer storage media is deposited One or more program is contained, when one or more of programs are performed by an equipment so that the equipment:According to The size of message to be transmitted, the shared drive that operating system is distributed is divided into multiple memory blocks;In the multiple memory block, Determine a memory block being currently not written into as memory block to be written;Monitor whether the memory block to be written is currently read Take;Currently it is read in response to the memory block to be written, the memory block to be written is performed and locks operation;In response to described Memory block to be written is read end, and unblock operation is performed to the memory block to be written, and into the memory block to be written Write the message to be transmitted.Or by the address of cache of the shared drive of operating system to the address space of itself;From described In multiple memory blocks of shared drive, it is determined that being newly written the memory block of message as memory block to be read;Continued described in monitoring Take whether memory block is currently written into;Currently it is written into response to the memory block to be read, into process wait state;Response End is written into the memory block to be read, reads the message stored in the memory block to be read.
Above description is only the preferred embodiment of the application and the explanation to institute's application technology principle.People in the art Member should be appreciated that invention scope involved in the application, however it is not limited to the technology that the particular combination of above-mentioned technical characteristic forms Scheme, while should also cover in the case where not departing from the inventive concept, carried out by above-mentioned technical characteristic or its equivalent feature The other technical schemes for being combined and being formed.Such as features described above has similar work(with (but not limited to) disclosed herein The technical scheme that the technical characteristic of energy is replaced mutually and formed.

Claims (26)

  1. A kind of 1. method for transmitting message between process, it is characterised in that methods described includes:
    According to the size of message to be transmitted, the shared drive that operating system is distributed is divided into multiple memory blocks;
    In the multiple memory block, determine a memory block being currently not written into as memory block to be written;
    Monitor whether the memory block to be written is currently read;
    Currently it is read in response to the memory block to be written, the memory block to be written is performed and locks operation;
    End is read in response to the memory block to be written, performs unblock operation to the memory block to be written, and to described The message to be transmitted is write in memory block to be written.
  2. 2. according to the method for claim 1, it is characterised in that one memory block conduct being currently not written into of the determination Memory block to be written, including:
    For the multiple memory block, continuous sequence number is set;
    The write-in quantitative value being pre-stored in the shared drive is incremented by;
    It is determined that be incremented by after said write quantitative value corresponding to the first memory block sequence number, said write quantitative value with it is the multiple Memory block corresponds;
    Monitor whether first memory block is currently written into;
    Currently it is not written into response to first memory block, using first memory block as the memory block to be written.
  3. 3. according to the method for claim 2, it is characterised in that described to determine corresponding to the said write quantitative value after being incremented by The sequence number of first memory block, including:
    Determine the quantity of the multiple memory block;
    By quantity complementation of the write-in quantitative value after described be incremented by the multiple memory block;
    Sequence number using complementation value as first memory block.
  4. 4. according to the method for claim 2, it is characterised in that methods described also includes:
    Currently it is written into response to first memory block, according to the numeric order of the multiple memory block, inquires about other internal memories Whether block is currently written into;
    Currently it is not written into response to inquiring other memory blocks, using the memory block being currently not written into as described to be written interior Counterfoil.
  5. 5. according to the method for claim 4, it is characterised in that methods described also includes:
    Currently it is written into, then is inquired about according to the sequence number cycle of the multiple memory block, directly in response to inquiring other memory blocks Currently it is not written into a memory block is inquired, using the memory block being currently not written into as the memory block to be written.
  6. 6. according to the method described in claim any one of 1-5, it is characterised in that the monitoring memory block to be written is current Whether it is read, including:
    Monitor whether the reading quantitative value being pre-stored in the memory block to be written is equal to preset value;
    When the reading quantitative value is equal to the preset value, determine that the memory block to be written is not read currently;
    When the reading quantitative value is not equal to the preset value, determine that the memory block to be written is currently read.
  7. 7. according to the method for claim 1, it is characterised in that methods described also includes:
    When writing the message to be transmitted into the memory block to be written, the write-in in the memory block to be written will be pre-stored in Mark is arranged to true value, and the true value corresponds to the memory block to be written and is currently written into;
    Completed in response to writing the message to be transmitted into the memory block to be written, said write mark is set to false as Value, the falsity correspond to the memory block to be written and are currently not written into.
  8. A kind of 8. method for transmitting message between process, it is characterised in that methods described includes:
    By in the address of cache of the shared drive of operating system to the address space of itself;
    From multiple memory blocks of the shared drive, it is determined that being newly written the memory block of message as memory block to be read;
    Monitor whether the memory block to be read is currently written into;
    Currently it is written into response to the memory block to be read, into process wait state;
    End is written into response to the memory block to be read, reads the message stored in the memory block to be read.
  9. 9. according to the method for claim 8, it is characterised in that described to determine that the memory block conduct for being newly written message is continued Memory block is taken, including:
    Read the sequence number of each memory block in the shared drive and the write-in quantitative value to prestore;
    By the quantity complementation of said write quantitative value and the multiple memory block;
    Sequence number is equal to the memory block of complementation value as the memory block to be read.
  10. 10. according to the method for claim 8, it is characterised in that the monitoring memory block to be read it is current whether by Write-in, including:
    Whether the value for monitoring the write-in mark that the memory block to be read prestores is true value, and the true value corresponds to described to be read interior Counterfoil is currently written into;Or
    Whether the value for monitoring the write-in mark that the memory block to be read prestores is falsity, and the falsity corresponds to described to be read interior Counterfoil is currently not written into.
  11. 11. according to the method for claim 8, it is characterised in that methods described also includes:
    Currently it is not written into response to the memory block to be read, reads the message stored in the memory block to be read.
  12. 12. the method according to claim 8 or 11, it is characterised in that methods described also includes:
    Read in the message process stored in the memory block to be read, the reading number in the memory block to be read will be pre-stored in Value is incremented by;
    Completed in response to reading the message stored in the memory block to be read, the reading in the memory block to be read will be pre-stored in Access value successively decreases.
  13. 13. according to the method for claim 9, it is characterised in that methods described also includes:
    Completed in response to reading the message stored in the memory block to be read, using other memory blocks as new internal memory to be read Block;Compare the size of the complementation value and the sequence number of the new memory block to be read;
    It is less than the complementation value in response to the sequence number of the new memory block to be read, reads in the new memory block to be read The message of storage;
    It is equal to the complementation value in response to the sequence number of the new memory block to be read, into the process wait state.
  14. 14. a kind of device for transmitting message between process, it is characterised in that described device includes:
    Division unit, for the size according to message to be transmitted, the shared drive that operating system is distributed is divided into multiple internal memories Block;
    First determining unit, in the multiple memory block, determining a memory block being currently not written into as to be written Enter memory block;
    First monitoring unit, for monitoring whether the memory block to be written is currently read;
    Lock cell, for being currently read in response to the memory block to be written, locking is performed to the memory block to be written Operation;
    Writing unit, for being read end in response to the memory block to be written, unblock is performed to the memory block to be written Operation, and the message to be transmitted is write into the memory block to be written.
  15. 15. device according to claim 14, it is characterised in that first determining unit includes:
    Setup module, for setting continuous sequence number for the multiple memory block;
    Assignment module, for the write-in being pre-stored in shared drive quantitative value to be incremented by;
    First determining module, it is described to write for determining the sequence number of the first memory block corresponding to the said write quantitative value after being incremented by Enter quantitative value to correspond with the multiple memory block;
    Monitoring modular, for monitoring whether first memory block is currently written into;
    Second determining module, for being currently not written into response to first memory block, using first memory block as institute State memory block to be written.
  16. 16. device according to claim 15, it is characterised in that first determining module is further used for:
    Determine the quantity of the multiple memory block;
    By quantity complementation of the write-in quantitative value after described be incremented by the multiple memory block;
    Sequence number using complementation value as first memory block.
  17. 17. device according to claim 15, it is characterised in that first determining unit also includes:
    Enquiry module, for being currently written into response to first memory block, according to the numeric order of the multiple memory block, Inquire about whether other memory blocks are currently written into;
    3rd determining module, for being currently not written into response to inquiring other memory blocks, the internal memory that will be currently not written into Block is as the memory block to be written.
  18. 18. device according to claim 17, it is characterised in that first determining unit also includes:
    4th determining module, for being currently written into response to inquiring other memory blocks, then according to the multiple memory block Sequence number cycle inquiry, until inquiring a memory block and being currently not written into, using the memory block being currently not written into as institute State memory block to be written.
  19. 19. according to the device described in claim any one of 14-18, it is characterised in that first monitoring unit includes:
    Monitoring modular, for monitoring whether the reading quantitative value being pre-stored in the memory block to be written is equal to preset value;
    5th determining module, for when the reading quantitative value is equal to the preset value, determining that the memory block to be written is worked as It is preceding not to be read;
    6th determining module, for when the reading quantitative value is not equal to the preset value, determining the memory block to be written Currently it is read.
  20. 20. device according to claim 14, it is characterised in that described device also includes:
    First mark unit, during for writing the message to be transmitted into the memory block to be written, described treat will be pre-stored in Write-in mark in write-in memory block is arranged to true value, and the true value corresponds to the memory block to be written and is currently written into;
    Second mark unit, for being completed in response to writing the message to be transmitted into the memory block to be written, by described in Write-in mark is arranged to falsity, and the falsity corresponds to the memory block to be written and is currently not written into.
  21. 21. a kind of device for transmitting message between process, it is characterised in that described device includes:
    Internal memory map unit, for by the address of cache of the shared drive of operating system to the address space of itself;
    3rd determining unit, for from multiple memory blocks of the shared drive, it is determined that the memory block for being newly written message is made For memory block to be read;
    Second monitoring unit, for monitoring whether the memory block to be read is currently written into;
    First waits unit, for being currently written into response to the memory block to be read, into process wait state;
    First reading unit, for being written into end in response to the memory block to be read, read in the memory block to be read The message of storage.
  22. 22. device according to claim 21, it is characterised in that the 3rd determining unit is further used for:
    Read the sequence number of each memory block in the shared drive and the write-in quantitative value to prestore;
    By the quantity complementation of said write quantitative value and the multiple memory block;
    Sequence number is equal to the memory block of complementation value as the memory block to be read.
  23. 23. device according to claim 21, it is characterised in that second monitoring unit is further used for:
    Whether the value for monitoring the write-in mark that the memory block to be read prestores is true value, and the true value corresponds to described to be read interior Counterfoil is currently written into;Or
    Whether the value for monitoring the write-in mark that the memory block to be read prestores is falsity, and the falsity corresponds to described to be read interior Counterfoil is currently not written into.
  24. 24. device according to claim 21, it is characterised in that described device also includes:
    Second reading unit, for being currently not written into response to the memory block to be read, read the memory block to be read The message of middle storage.
  25. 25. the device according to claim 21 or 24, it is characterised in that described device also includes:
    First assignment unit, for reading in the message process stored in the memory block to be read, described continue will be pre-stored in The reading quantitative value in memory block is taken to be incremented by;
    Second assignment unit, for being completed in response to reading the message stored in the memory block to be read, it will be pre-stored in described Reading quantitative value in memory block to be read is successively decreased.
  26. 26. device according to claim 21, it is characterised in that described device also includes:
    Comparing unit, for being completed in response to reading the message stored in the memory block to be read, using other memory blocks as New memory block to be read;Compare the size of the complementation value and the sequence number of the new memory block to be read;
    3rd reading unit, for being less than the complementation value in response to the sequence number of the new memory block to be read, described in reading The message stored in new memory block to be read;
    Second waits unit, for being equal to the complementation value in response to the sequence number of the new memory block to be read, into described Process wait state.
CN201610640978.3A 2016-08-08 2016-08-08 Method and device for transmitting messages between processes Active CN107704325B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610640978.3A CN107704325B (en) 2016-08-08 2016-08-08 Method and device for transmitting messages between processes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610640978.3A CN107704325B (en) 2016-08-08 2016-08-08 Method and device for transmitting messages between processes

Publications (2)

Publication Number Publication Date
CN107704325A true CN107704325A (en) 2018-02-16
CN107704325B CN107704325B (en) 2021-08-27

Family

ID=61168475

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610640978.3A Active CN107704325B (en) 2016-08-08 2016-08-08 Method and device for transmitting messages between processes

Country Status (1)

Country Link
CN (1) CN107704325B (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108833477A (en) * 2018-05-16 2018-11-16 百度在线网络技术(北京)有限公司 Method for message transmission, system and device based on shared drive
CN109656730A (en) * 2018-12-20 2019-04-19 东软集团股份有限公司 A kind of method and apparatus of access cache
CN110515868A (en) * 2019-08-09 2019-11-29 苏州浪潮智能科技有限公司 The method and apparatus for showing image
CN111506436A (en) * 2020-03-25 2020-08-07 炬星科技(深圳)有限公司 Method for realizing memory sharing, electronic equipment and shared memory data management library
CN112749025A (en) * 2020-12-30 2021-05-04 深兰人工智能(深圳)有限公司 Data distribution method and device based on shared memory
WO2023051591A1 (en) * 2021-09-29 2023-04-06 华为技术有限公司 Interprocess communication method and related apparatus

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001013229A2 (en) * 1999-08-19 2001-02-22 Venturcom, Inc. System and method for data exchange
CN1740978A (en) * 2004-08-23 2006-03-01 华为技术有限公司 Method for realing sharing internal stored data base and internal stored data base system
CN1787588A (en) * 2005-12-01 2006-06-14 大唐软件技术有限责任公司 Method for processing multiprogress message and method for processing multiprogress talk ticket
CN1920780A (en) * 2006-08-15 2007-02-28 杭州华为三康技术有限公司 Method and system for accessing critical region
CN102693162A (en) * 2011-12-29 2012-09-26 中国科学技术大学苏州研究院 Method for process communication among multiple virtual machines on multi-core platform based on shared memory and intercore interruption
CN102750187A (en) * 2012-07-11 2012-10-24 北京联时空网络通信设备有限公司 Out-of-process interaction method and device
CN103197958A (en) * 2013-04-01 2013-07-10 天脉聚源(北京)传媒科技有限公司 Data transmission method and system and transponder device
CN104424030A (en) * 2013-08-22 2015-03-18 腾讯科技(深圳)有限公司 Sharing memory multi-process operation method and device

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001013229A2 (en) * 1999-08-19 2001-02-22 Venturcom, Inc. System and method for data exchange
CN1740978A (en) * 2004-08-23 2006-03-01 华为技术有限公司 Method for realing sharing internal stored data base and internal stored data base system
CN1787588A (en) * 2005-12-01 2006-06-14 大唐软件技术有限责任公司 Method for processing multiprogress message and method for processing multiprogress talk ticket
CN1920780A (en) * 2006-08-15 2007-02-28 杭州华为三康技术有限公司 Method and system for accessing critical region
CN102693162A (en) * 2011-12-29 2012-09-26 中国科学技术大学苏州研究院 Method for process communication among multiple virtual machines on multi-core platform based on shared memory and intercore interruption
CN102750187A (en) * 2012-07-11 2012-10-24 北京联时空网络通信设备有限公司 Out-of-process interaction method and device
CN103197958A (en) * 2013-04-01 2013-07-10 天脉聚源(北京)传媒科技有限公司 Data transmission method and system and transponder device
CN104424030A (en) * 2013-08-22 2015-03-18 腾讯科技(深圳)有限公司 Sharing memory multi-process operation method and device

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108833477A (en) * 2018-05-16 2018-11-16 百度在线网络技术(北京)有限公司 Method for message transmission, system and device based on shared drive
CN108833477B (en) * 2018-05-16 2020-09-29 百度在线网络技术(北京)有限公司 Message transmission method, system and device based on shared memory
CN109656730A (en) * 2018-12-20 2019-04-19 东软集团股份有限公司 A kind of method and apparatus of access cache
CN110515868A (en) * 2019-08-09 2019-11-29 苏州浪潮智能科技有限公司 The method and apparatus for showing image
CN111506436A (en) * 2020-03-25 2020-08-07 炬星科技(深圳)有限公司 Method for realizing memory sharing, electronic equipment and shared memory data management library
CN111506436B (en) * 2020-03-25 2024-05-14 炬星科技(深圳)有限公司 Method for realizing memory sharing, electronic equipment and shared memory data management library
CN112749025A (en) * 2020-12-30 2021-05-04 深兰人工智能(深圳)有限公司 Data distribution method and device based on shared memory
WO2023051591A1 (en) * 2021-09-29 2023-04-06 华为技术有限公司 Interprocess communication method and related apparatus

Also Published As

Publication number Publication date
CN107704325B (en) 2021-08-27

Similar Documents

Publication Publication Date Title
CN107704325A (en) Method and apparatus for transmitting message between process
CN106484383B (en) Page rendering method, device and equipment
CN104462127B (en) A kind of record data-updating method and device
CN106021000A (en) Shared memory management method and device for robot operating system
CN105527881B (en) A kind of command processing method and device
CN106055454B (en) A kind of monitoring method of server master board
CN109491928A (en) Buffer control method, device, terminal and storage medium
CN106294233A (en) The transfer control method of a kind of direct memory access and device
CN106354546B (en) Virtual machine remote control method and system
CN108572876A (en) A kind of implementation method and device of Read-Write Locks
CN111625497A (en) Deployment method, device, equipment and storage medium of distributed file system
CN107765991A (en) Method and apparatus for transmitting message
CN105530153B (en) Slave equipment communication means, communication network, main equipment in network and from equipment
CN105389096B (en) Data interactive method based on browser and device
CN107544751B (en) Method and device for remotely accessing disk
CN104536884B (en) Code test method and device
CN109978380A (en) A kind of workflow processing method and device
CN107391278A (en) A kind of front and back end communication means based on shared drive
CN107506184A (en) The treating method and apparatus of system application message
CN108595244A (en) Communication means, virtual machine, physical host and virtual machine system inside and outside virtual machine
CN105677456B (en) A kind of write method and user equipment of progress information
CN106933646B (en) Method and device for creating virtual machine
CN107239689A (en) A kind of recognition methods of checking information based on mass-rent and system
CN105897841A (en) Scheduling method, device and system for network resource processing and sub scheduler
CN106357764B (en) The method of data synchronization and server of mobile terminal

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