CN103514053A - Shared-memory-based method for conducting communication among multiple processes - Google Patents

Shared-memory-based method for conducting communication among multiple processes Download PDF

Info

Publication number
CN103514053A
CN103514053A CN201310432622.7A CN201310432622A CN103514053A CN 103514053 A CN103514053 A CN 103514053A CN 201310432622 A CN201310432622 A CN 201310432622A CN 103514053 A CN103514053 A CN 103514053A
Authority
CN
China
Prior art keywords
shared drive
storage block
data
read
reading
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
CN201310432622.7A
Other languages
Chinese (zh)
Other versions
CN103514053B (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.)
Institute of Information Engineering of CAS
Original Assignee
Institute of Information Engineering of CAS
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 Institute of Information Engineering of CAS filed Critical Institute of Information Engineering of CAS
Priority to CN201310432622.7A priority Critical patent/CN103514053B/en
Publication of CN103514053A publication Critical patent/CN103514053A/en
Application granted granted Critical
Publication of CN103514053B publication Critical patent/CN103514053B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Multi Processors (AREA)

Abstract

The invention relates to a shared-memory-based method for conducting communication among multiple processes. According to the method, a shared memory is managed in a circular queue mode, the shared memory is used for reading and writing conducted by the multiple processes in the circular queue mode, reading or writing is conducted by making a block as a unit, and the size of each block is controlled by a user; the shared memory is shared by the multiple processes, and the multiple processes comprise read-only processes and write-only processes; the multiple processes can conduct reading operation on the shared memory simultaneously, only one process can conduct writing operation on the shared memory, reading does not conflict with writing, and reading and writing can be conducted simultaneously. By means of the method, the number of times of copying conducted through a kernel when the processes exchange information is reduced greatly, throughput of a background system is improved, the overhead of the system is reduced, and performance of the system is effectively enhanced.

Description

A kind of Inter-Process Communication method based on shared drive
Technical field
The present invention relates to computer realm, relate in particular to a kind of Inter-Process Communication method based on shared drive.
Background technology
Traditional Unix programming model moves a plurality of processes in same operating system, and each process has address space separately, information sharing between Unix process can have various ways, generally includes: pipeline, FIFO, message queue, and socket and shared drive between territory.The problem of several communication modes except shared drive is, during two process exchange messages, these information must be via kernel transmission, thereby has caused higher expense, and this requires just to become in high system in efficiency the bottleneck that affects system performance.
Utilize the communication between shared drive process no longer to relate to kernel, how to utilize shared drive, the efficient communication between implementation process, becomes a problem urgently to be resolved hurrily.
Summary of the invention
Technical matters to be solved by this invention is to provide a kind of Inter-Process Communication method based on shared drive, rationally utilizes shared drive, reduces system overhead, reaches higher performance requirement.
The technical scheme that the present invention solves the problems of the technologies described above is as follows: the means of communication between a kind of multi-process based on shared drive, comprise the steps:
Step 1: write the shared drive that process creation comprises administrative unit, round-robin queue and memory pool, and store the management information about whole shared drive in administrative unit;
Step 2: the process of writing is obtained the operating position of writing process about current from administrative unit,, according to the size of each data to be written, order is opened up the N(N=1 large with size of data to be deposited etc., 2,3 ...) storage block, data to be written are deposited in corresponding memory block;
Step 3: while opening up N storage block, record described N storage block size, reference position, end position and storage whether be partial data, the information of above-mentioned record forms N structure, and deposits the rear pointer place of round-robin queue in; Upgrade in administrative unit about the current record of writing the operating position of process simultaneously;
Step 4: in execution step 2 to 3, one or several read process can carry out read operation to shared drive;
Step 5: each team's head of reading process self-loopa queue starts, and reads successively N(N=1,2,3 ...) structure;
Step 6: judge the whether tail of the queue in round-robin queue of N structure, if tail of the queue, illustrate that the storage block that this structure is corresponding carrying out write operation, wait for, when rear pointer does not point to this structure by the time, perform step 7; If not tail of the queue, directly perform step 7;
Step 7: according in this structure about the positional information of N storage block, read the data in corresponding N storage block in memory pool;
Step 8: write process described in judgement and whether also will, to memory pool data writing, if so, return to step 2; Otherwise judge in memory pool, whether data all run through, if do not run through, return to step 5; Otherwise finish.
The invention has the beneficial effects as follows: the present invention manages shared drive with round-robin queue's form, shared drive is is sequentially read and write with queue form for a plurality of processes, reads or writes Yi Kuaiwei unit, and block size is controlled by user; Shared drive is shared by multi-process, and process is divided into read-only process and only writes process; Support a plurality of processes this shared drive to be carried out to read operation simultaneously, can only have a process to carry out write operation to this shared drive, read-write does not conflict, and can carry out simultaneously; When the method for the invention has greatly reduced exchange message between process, via the copy number of times of kernel, improve the handling capacity of background system, reduced the expense of system, effectively improved the performance of system.
On the basis of technique scheme, the present invention can also do following improvement.
Further, the management information described in described step 1 comprises:
This shared drive founder ID, queue size, memory pool size, memory pool reference position, memory pool end position, the current operating position of process, current all number of processes, Read-Write Locks and the mutual exclusion lock of reading Processes Tag, current this shared drive of use of reading this shared drive write.
Further, while opening up N storage block in step 2, also to proceed as follows,
Step 2.1: judge according to the end position of the size of the end position of N-1 storage block, data to be deposited and memory pool whether memory pool also has sufficient space to open up N storage block and store data, if there is sufficient space, performs step 2.2; If there is no sufficient space, carry out 2.3;
Step 2.2: open up the N storage block large with data to be deposited etc., deposit data to be deposited in described N storage block, generate the structure about N storage block, and the data that mark is stored in structure are partial data;
Step 2.3: open up the N storage block to the end position size of memory pool from the end position of N-1 storage block, deposit a part for data to be deposited in described N storage block, form the structure of N storage block, the data that mark is stored in structure are deficiency of data; Deposit remaining data to be deposited in memory pool head.
Adopt the beneficial effect of above-mentioned further scheme to be: can effectively solve when low memory the problem that data write.
Further, in step 2.3, before depositing remaining data to be deposited in memory pool head, to carry out following steps:
Step 2.3.1: the process of writing is according to the N(N=1 of round-robin queue, 2,3,4 ...) about reading process, read the record of N storage block in structure, judge in N storage block and whether by all processes of reading, run through, if do not run through, wait for, by the time after running through, execution step 2.3.2; If run through, directly perform step 2.3.2;
Step 2.3.2: whether the size that judges N storage block can be held is treated remaining data to be deposited, if can hold, starts to open up the storage block large with remaining data to be deposited etc. from memory pool reference position, finishes; Otherwise return to step 2.3.1.
Adopt the beneficial effect of above-mentioned further scheme to be: what said method adopted is to read preference strategy, if memory pool is full, need to cover data with existing, whether the data in the storage block that judgement needs to cover are run through, if run through, directly cover, if do not run through, wait for, wait after running through and cover again, guaranteed the integrality of data.
Further, also comprise a default stand-by period threshold value in described step 2.3.1, when described, write time that process waits for and surpass the stand-by period during threshold value, described N storage block also not all processes of reading runs through, and no longer waits for, directly performs step 2.3.2.
Adopt the beneficial effect of above-mentioned further scheme to be: said method is to catch up with while reading process in the process of writing, the situation that can prevent the process of reading from dying and occur waiting indefinitely, draft stand-by period threshold value, if exceed stand-by period threshold value, even if the process of reading does not run through, think that this process exits voluntarily, no longer wait for, the process of the writing corresponding storage block of writing direct.
Further, described in step 3, in N structure, also comprise for recording one or several and read the mark array that process reads the reading state of storage pool N storage block, when a certain, when reading process and reading N storage block, N structure is read to the mark position 1 whether process has been read to described N storage block about this.
Adopt the beneficial effect of above-mentioned further scheme to be: the reading state mark array in described N structure, can provide reference for writing into journey, especially in the process of writing, catch up with while reading process, the process of writing can judge whether the storage block that this structure is corresponding is run through by all processes of reading with reference to this mark array, and then whether judgement is write process can be to data writing in corresponding storage block.
Further, a plurality of processes of reading can be carried out read operation to shared drive simultaneously, only have one to write process shared drive is carried out to write operation, read process and write process to shared drive, to operate simultaneously.
Adopt the beneficial effect of above-mentioned further scheme to be: greatly to improve the efficiency between process.
Further, write described in process creation before shared drive, carry out authority detection according to the described control of authority ID writing in process handle, after detecting and passing through, just can in physical address, find corresponding position according to the shared drive ID in handle, and then create described shared drive.
Further, each is read process described shared drive is carried out before read-write operation, carry out authority detection according to the control of authority ID in its handle, detect pass through can carry out read operation to shared drive.
Adopt the beneficial effect of above-mentioned further scheme to be: each process is carried out authority detection before shared drive is operated, the process that does not possess operating right can not read or write, can effectively prevent shared drive described in irrelevant process, strengthen security mechanism, strengthened the security of Inter-Process Communication.
Further, described reading when process reads in the corresponding memory pool of structure that round-robin queue head pointer points to storage block need be obtained Read-Write Locks, while reading other storage blocks, needn't obtain Read-Write Locks, described writing when process is carried out write operation at every turn need to be obtained Read-Write Locks, when there being process to operate shared drive, in the time of need to revising the number of processes of current this shared drive of use of storing in administrative unit, described process need to be obtained mutual exclusion lock and just can operate.
Adopt the beneficial effect of above-mentioned further scheme to be: the present invention provides shared drive pond for the intensive message exchange of process, the interaction capabilities of raising process, the expense of bringing for reducing lock conflict, the data structure of minimum locking is used in design, and shared drive pond is managed efficiently.
Accompanying drawing explanation
Fig. 1 is the structural drawing of shared drive of the present invention;
Fig. 2 is a kind of multiprocess communication method process flow diagram based on shared drive of the present invention.
In accompanying drawing, the list of parts of each label representative is as follows:
1, administrative unit, 2, round-robin queue, 3, memory pool, 3-1, storage block.
Embodiment
Below in conjunction with accompanying drawing, principle of the present invention and feature are described, example, only for explaining the present invention, is not intended to limit scope of the present invention.
Shared drive is a kind of high efficiency interprocess communication mode, also be the fastest IPC form, two different process A, the meaning of B shared drive is, same physical memory is mapped to process A, the B process address space separately, and two processes can be seen the renewal of the other side to data in shared drive immediately, process A, between B, the transmission of data just no longer relates to kernel.Because a plurality of processes are shared same region of memory, must need certain synchronization mechanism, mutual exclusion lock and semaphore can.
No matter be Read-Write Locks or mutual exclusion lock, if a large amount of use will certainly affect system performance, so we reduce the use of lock as far as possible, avoid the overhead bringing due to lock conflict.By shared drive, the form with round-robin queue manages in the present invention, by rationally utilizing the feature of queue data structure, and the use of having locked while having avoided multi-process to read shared drive, i.e. multi-process does not need to obtain lock during from shared drive reading information.For improving the service efficiency of shared drive, shared drive can be read and write simultaneously, and synchronization supports multi-process to read, and unique process is write, but does not support multi-process to write.
As shown in Figure 1, described shared drive comprises administrative unit 1, round-robin queue 2 and storage pool 3, and wherein, the management information of administrative unit 1 storage comprises:
This shared drive founder ID, queue size, memory pool size, memory pool reference position, memory pool end position, the current operating position of process, current all number of processes, mutual exclusion lock and the Read-Write Locks of reading Processes Tag, current this shared drive of use of reading this shared drive write.Read-Write Locks guarantees that read-write safety and the memory pool synchronization of the management information of storing in administrative unit only have a process writing; If during the number of processes of current this shared drive of use that described mutual exclusion lock guarantees have process to revise stores in administrative unit, need to first obtain mutual exclusion lock, so just can not cause several processes to operate and cause data corruption simultaneously.
Shared drive described in the present invention comprises three parts, and first is administrative unit, and it has stored the management information of whole shared drive; Second portion storage Liao Yige round-robin queue; Third part is memory pool, forms several storage blocks in memory pool, for depositing data in; When depositing data in storage block, generate for recording the structure of described storage block attribute, and deposit in round-robin queue; When writing data, have a corresponding structure and join the team, the corresponding corresponding storage block of this structure, while carrying out read operation, first obtains the information of memory pool, thereby effectively accesses by this queue.
Introduce in detail three parts below.
PART1: the beginning of shared drive, this part is stored the management information of whole shared drive, and its particular content is the structure of a MESA_shm_queue_info_t type, and this structure is:
Struct?MESA_shm_queue_info{
Unsigned?int?max_queue_size;
Unsigned?int?pool_size;
Unsigned?int?pool_begin_offset;
Unsigned?int?pool_end_offset;
Unsigned?int?write_pos;
Unsigned int op_num; // current additional process number
Intower_id;
Char read_flags[32]; // mark the process that continues
Pthread_mutex_t?mutex;
Pthread_rwlock_t?rwlock;
}MESA_shm_queue_info_t;
Introduce in detail this structure below:
Max_queue_size: round-robin queue's scale.
The size of pool_size:PART3 memory pool.
Pool_begin_offset: the reference position of memory pool (distance of shared drive start address relatively).
Pool_begin_offset: the end position of memory pool (distance of shared drive start address relatively).
Write_pos: the position that the current write operation of memory pool proceeds to (distance of shared drive start address relatively).
Op_num: the number of processes of current this shared drive of use.
Ower_id: this shared drive founder's ID.
Read_flags[32]: when the process of reading appends to shared drive, the relevant position 1 of this array, represents that this process needs read data, for example the, when process of reading that id is 8 operates, read_flags[8] assignment is ' 1 '.
Mutex: this mutual exclusion lock is used for protecting op_num.
Rwlock: Read-Write Locks, protection monoblock shared drive.
PART2: save as round-robin queue in this piece, realize the control to memory pool by round-robin queue.
First this region of memory stores structure and some block_info_t type structure bodies of a circular_array_t type.
Structcircular_array_t{
Int head; // queue head pointer
Int tail; // rear of queue pointer
Block_info_t*pbase;
}
This structure is the information of queue.
Structblock_info_t{
Unsigned?int?block_size;
Unsigned?int?block_start;
Unsigned?int?block_end;
Unsigned?int?is_splits;
Char?flags[32];
}
Introduce in detail this structure below:
Block_size: the size of actual storage piece in corresponding memory pool.
Block_start: the reference position of storage block (relatively) in corresponding memory pool.
Block_end: the end position of the middle storage block of corresponding memory pool (relatively).
Is_splits: whether this blocks of data burst.When the remaining off-capacity of memory pool afterbody is to deposit monoblock data, in the time of partial data need to being put into the head of memory pool, these data are exactly the data of burst, during copy, will carry out at twice.
The structure of several block_info_t types forms round-robin queue.Thereby memory pool is effectively managed.
PART3: the memory pool of actual store data.
As shown in Figure 2, the means of communication between a kind of multi-process based on shared drive, comprise the steps:
Step 1: write the shared drive that process creation comprises administrative unit, round-robin queue and memory pool, and store the management information about whole shared drive in administrative unit;
Step 2: the process of writing is obtained the operating position of writing process about current from administrative unit,, according to the size of each data to be written, order is opened up the N(N=1 large with size of data to be deposited etc., 2,3 ...) storage block, data to be written are deposited in corresponding memory block;
Step 3: while opening up N storage block, record described N storage block size, reference position, end position and storage whether be partial data, the information of above-mentioned record forms N structure, and deposits the rear pointer place of round-robin queue in; Upgrade in administrative unit about the current record of writing the operating position of process simultaneously;
Step 4: in execution step 2 to 3, one or several read process can carry out read operation to shared drive;
Step 5: each team's head of reading process self-loopa queue starts, and reads successively N(N=1,2,3 ...) structure;
Step 6: judge the whether tail of the queue in round-robin queue of N structure, if tail of the queue, illustrate that the storage block that this structure is corresponding carrying out write operation, wait for, when rear pointer does not point to this structure by the time, perform step 7; If not tail of the queue, directly perform step 7;
Step 7: according in this structure about the positional information of N storage block, read the data in corresponding N storage block in memory pool;
Step 8: write process described in judgement and whether also will, to memory pool data writing, if so, return to step 2; Otherwise judge in memory pool, whether data all run through, if do not run through, return to step 5; Otherwise finish.
Wherein, while opening up N storage block in step 2, also to proceed as follows,
Step 2.1: judge according to the end position of the size of the end position of N-1 storage block, data to be deposited and memory pool whether memory pool also has sufficient space to open up N storage block and store data, if there is sufficient space, performs step 2.2; If there is no sufficient space, carry out 2.3;
Step 2.2: open up the N storage block large with data to be deposited etc., deposit data to be deposited in described N storage block, generate the structure about N storage block, and the data that mark is stored in structure are partial data;
Step 2.3: open up the N storage block to the end position size of memory pool from the end position of N-1 storage block, deposit a part for data to be deposited in described N storage block, form the structure of N storage block, the data that mark is stored in structure are deficiency of data; Deposit remaining data to be deposited in memory pool head.
Wherein, in step 2.3, before depositing remaining data to be deposited in memory pool head, to carry out following steps:
Step 2.3.1: the process of writing is according to the N(N=1 of round-robin queue, 2,3,4 ...) about reading process, read the record of N storage block in structure, judge in N storage block and whether by all processes of reading, run through, if do not run through, wait for, by the time after running through, execution step 2.3.2; If run through, directly perform step 2.3.2;
Step 2.3.2: whether the size that judges N storage block can be held is treated remaining data to be deposited, if can hold, starts to open up the storage block large with remaining data to be deposited etc. from memory pool reference position, finishes; Otherwise return to step 2.3.1.
Wherein, also comprise a default stand-by period threshold value in described step 2.3.1, when described, write time that process waits for and surpass the stand-by period during threshold value, described N storage block also not all processes of reading runs through, and no longer waits for, directly performs step 2.3.2.
In described each structure, also comprise for recording one or several and read the mark array that process reads the reading state of the corresponding storage block of storage pool.
A plurality of processes of reading can be carried out read operation to shared drive simultaneously, only have one to write process shared drive is carried out to write operation, read process and write process to shared drive, to operate simultaneously.
For preventing irrelevant process use shared drive, the present invention carries out authority detection when process is carried out read-write operation to shared drive, and the process of lack of competence can not operate shared drive.Write described in process creation before shared drive, carry out authority detection according to the described control of authority ID writing in process handle, after detecting and passing through, just can in physical address, find corresponding position according to the shared drive ID in handle, and then create described shared drive.Each is read process described shared drive is carried out before read-write operation, carry out authority detection according to the control of authority ID in its handle, detect pass through can carry out read operation to shared drive.
Shared drive queue is shared by multi-process, and process can order be carried out read-write operation to shared drive.Support a plurality ofly to enter this shared drive to be carried out to read operation, synchronization can only have a process to carry out write operation to this internal memory simultaneously.Read-write does not conflict, and can carry out simultaneously.Before each process operates shared drive, can carry out authority detection, the process that does not possess operating right can not read or write.
Described reading when process reads in the corresponding memory pool of structure that round-robin queue head pointer points to storage block need be obtained Read-Write Locks, while reading other storage blocks, needn't obtain Read-Write Locks, described writing when process is carried out write operation at every turn need to be obtained Read-Write Locks, when there being process to operate shared drive, in the time of need to revising the number of processes of current this shared drive of use of storing in administrative unit, described process need to be obtained mutual exclusion lock and just can operate.Such as when having process will use this shared drive, need to revise the number of processes of current this shared drive of use, or have when process operation is complete to be exited, also need to revise the number of current this shared drive of use, the process operating this time need to be obtained mutual exclusion lock, could revise the number of current this shared drive of use, can effectively prevent like this that several processes from operating simultaneously and cause data corruption.
Due to each process in reality system may existence itself problem, such as certain process may be died or the too low shared drive Data Update that affects of reading efficiency in reading process, in the face of these problems, the present invention, for user provides selectable superseded mechanism, can carry out the wait of special time or eliminate above-mentioned process.Specifically comprise following two kinds of situations.
1. when read operation catch up with write operation, how to solve stationary problem.
Solution: all can judge whether to read the tail of the queue of queue while at every turn carrying out read operation, if tail of the queue does not read the data in corresponding memory block in the memory pool that this tail of the queue place structure is corresponding, in order to avoid read dirty data.The worst situation of this scheme is that this blocks of data reads in upper once read operation.
Because if what read is the structure that rear pointer points to, its corresponding storage block may directly not read if just also write in write state, and the data of reading may be dirty datas.
2. when write operation catch up with read operation, how to solve stationary problem.
We have designed two kinds of strategies: read preference strategy and write preference strategy.
Paper is read preference strategy.Read preference strategy and can guarantee that each reads process and read complete data, if write operation catch up with read operation, wait for read operation, wait read operation to read data and write again.Meanwhile, for preventing that the process of reading from dying, there is the situation of waiting indefinitely, propose and determine stand-by period threshold value WAIT_TIME, if the stand-by period surpasses WAIT_TIME, think that this process exits voluntarily, no longer wait for.
Then introduce and write preferentially, write in preferential situation and generally do not advise adopting, write and under preferential pattern, write process and to reading process, be not responsible for, no matter whether run through, if the process of writing catch up with the process of reading, the process of the writing data of writing direct, the data before covering, but can add up respectively reading the data volume that therefore process override.
The foregoing is only preferred embodiment of the present invention, in order to limit the present invention, within the spirit and principles in the present invention not all, any modification of doing, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.

Claims (10)

1. means of communication between the multi-process based on shared drive, is characterized in that, comprise the steps:
Step 1: write the shared drive that process creation comprises administrative unit, round-robin queue and memory pool, and store the management information about whole shared drive in administrative unit;
Step 2: the process of writing is obtained the operating position of writing process about current from administrative unit, according to the size of each data to be written, order is opened up the N(N=1 large with size of data to be deposited etc., 2,3 ...) storage block, data to be written are deposited in corresponding memory block;
Step 3: while opening up N storage block, record described N storage block size, reference position, end position and storage whether be partial data, the information of above-mentioned record forms N structure, and deposits the rear pointer place of round-robin queue in; Upgrade in administrative unit about the current record of writing the operating position of process simultaneously;
Step 4: in execution step 2 to 3, one or several read process can carry out read operation to shared drive;
Step 5: each team's head of reading process self-loopa queue starts, and reads successively N(N=1,2,3 ...) structure;
Step 6: judge the whether tail of the queue in round-robin queue of N structure, if tail of the queue, illustrate that the storage block that this structure is corresponding carrying out write operation, wait for, when rear pointer does not point to this structure by the time, perform step 7; If not tail of the queue, directly perform step 7;
Step 7: according in this structure about the positional information of N storage block, read the data in corresponding N storage block in memory pool;
Step 8: write process described in judgement and whether also will, to memory pool data writing, if so, return to step 2; Otherwise judge in memory pool, whether data all run through, if do not run through, return to step 5; Otherwise finish.
2. the means of communication between a kind of multi-process based on shared drive according to claim 1, is characterized in that, the management information described in step 1 comprises:
This shared drive founder ID, queue size, memory pool size, memory pool reference position, memory pool end position, the current operating position of process, current all number of processes, Read-Write Locks and the mutual exclusion lock of reading Processes Tag, current this shared drive of use of reading this shared drive write.
3. the means of communication between a kind of multi-process based on shared drive according to claim 1, is characterized in that, while opening up N storage block in step 2, also to proceed as follows,
Step 2.1: judge according to the end position of the size of the end position of N-1 storage block, data to be deposited and memory pool whether memory pool also has sufficient space to open up N storage block and store data, if there is sufficient space, performs step 2.2; If there is no sufficient space, carry out 2.3;
Step 2.2: open up the N storage block large with data to be deposited etc., deposit data to be deposited in described N storage block, generate the structure about N storage block, and the data that mark is stored in structure are partial data;
Step 2.3: open up the N storage block to the end position size of memory pool from the end position of N-1 storage block, deposit a part for data to be deposited in described N storage block, form the structure of N storage block, the data that mark is stored in structure are deficiency of data; Deposit remaining data to be deposited in memory pool head.
4. the means of communication between a kind of multi-process based on shared drive according to claim 3, is characterized in that, in step 2.3, before depositing remaining data to be deposited in memory pool head, will carry out following steps:
Step 2.3.1: the process of writing is according to the N(N=1 of round-robin queue, 2,3,4 ...) about reading process, read the record of N storage block in structure, judge in N storage block and whether by all processes of reading, run through, if do not run through, wait for, by the time after running through, execution step 2.3.2; If run through, directly perform step 2.3.2;
Step 2.3.2: whether the size that judges N storage block can hold remaining data to be deposited, if can hold, starts to open up the storage block large with remaining data to be deposited etc. from memory pool reference position, finishes; Otherwise return to step 2.3.1.
5. the means of communication between a kind of multi-process based on shared drive according to claim 4, it is characterized in that, in described step 2.3.1, also comprise a default stand-by period threshold value, when described, write time that process waits for and surpass the stand-by period during threshold value, described N storage block is not also run through by all processes of reading, no longer wait for, directly perform step 2.3.2.
6. a kind of Inter-Process Communication method based on shared drive according to claim 1, it is characterized in that, described in step 3, in N structure, also comprise for recording one or several and read the mark array that process reads the reading state of storage pool N storage block, when a certain, when reading process and reading N storage block, N structure is read to the mark position 1 whether process has been read to described N storage block about this.
7. the means of communication between a kind of multi-process based on shared drive according to claim 1, it is characterized in that, a plurality of processes of reading can be carried out read operation to shared drive simultaneously, only have one to write process shared drive is carried out to write operation, read process and write process to shared drive, to operate simultaneously.
8. a kind of Inter-Process Communication method based on shared drive according to claim 1, it is characterized in that, write described in process creation before shared drive, to carry out authority detection according to the described control of authority ID writing in process handle, after detection is passed through, just can in physical address, find corresponding position according to the shared drive ID in handle, and then create described shared drive.
9. a kind of Inter-Process Communication method based on shared drive according to claim 1, it is characterized in that, each is read process described shared drive is carried out before read operation, carry out authority detection according to the control of authority ID in its handle, detect pass through can carry out read operation to shared drive.
10. a kind of Inter-Process Communication method based on shared drive according to claim 2, it is characterized in that, described reading when process reads in the corresponding memory pool of structure that round-robin queue head pointer points to storage block need be obtained Read-Write Locks, while reading other storage blocks, needn't obtain Read-Write Locks, described writing when process is carried out write operation at every turn need to be obtained Read-Write Locks, when there being process to operate shared drive, in the time of need to revising the number of processes of current this shared drive of use of storing in administrative unit, described process need to be obtained mutual exclusion lock and just can operate.
CN201310432622.7A 2013-09-22 2013-09-22 Shared-memory-based method for conducting communication among multiple processes Active CN103514053B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310432622.7A CN103514053B (en) 2013-09-22 2013-09-22 Shared-memory-based method for conducting communication among multiple processes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310432622.7A CN103514053B (en) 2013-09-22 2013-09-22 Shared-memory-based method for conducting communication among multiple processes

Publications (2)

Publication Number Publication Date
CN103514053A true CN103514053A (en) 2014-01-15
CN103514053B CN103514053B (en) 2017-01-25

Family

ID=49896822

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310432622.7A Active CN103514053B (en) 2013-09-22 2013-09-22 Shared-memory-based method for conducting communication among multiple processes

Country Status (1)

Country Link
CN (1) CN103514053B (en)

Cited By (34)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104980454A (en) * 2014-04-02 2015-10-14 腾讯科技(深圳)有限公司 Method, server and system for sharing resource data
CN105760217A (en) * 2016-03-23 2016-07-13 深圳森格瑞通信有限公司 Method for accessing shared memory
CN105912478A (en) * 2016-04-06 2016-08-31 中国航空无线电电子研究所 Dual-buffer mechanism based real-time system multi-task data sharing method
CN105955971A (en) * 2015-11-30 2016-09-21 中国银联股份有限公司 Key value buffer memory implementation method and device
CN106020962A (en) * 2016-05-31 2016-10-12 广东欧珀移动通信有限公司 Progress control method and terminal equipment
CN106293973A (en) * 2016-08-17 2017-01-04 深圳市金证科技股份有限公司 Lock-free message queue communication means and system
CN106372183A (en) * 2016-08-31 2017-02-01 北京小米移动软件有限公司 File write-in method and device
CN106598736A (en) * 2016-12-13 2017-04-26 深圳中科讯联科技股份有限公司 Memory block calling method and memory block releasing method for memory pool and server
CN106648939A (en) * 2016-12-30 2017-05-10 上海寰视网络科技有限公司 Method and equipment for inter-process resource sharing
CN106708631A (en) * 2016-11-30 2017-05-24 福建省天奕网络科技有限公司 Shared memory property modification method and system
CN106980551A (en) * 2017-03-24 2017-07-25 山东浪潮商用系统有限公司 A kind of Way of Process Communication and device
CN107562639A (en) * 2016-07-01 2018-01-09 北京忆恒创源科技有限公司 Wipe block read request processing method and device
CN107577539A (en) * 2016-07-05 2018-01-12 阿里巴巴集团控股有限公司 The shared drive structure communicated for kernel state and User space and its application
CN107589915A (en) * 2017-09-25 2018-01-16 郑州云海信息技术有限公司 Capacity information monitoring method, device and the equipment of a kind of distributed memory system
CN107643942A (en) * 2016-07-21 2018-01-30 杭州海康威视数字技术股份有限公司 The storage method and device of a kind of status information
CN108021339A (en) * 2017-11-03 2018-05-11 网宿科技股份有限公司 A kind of method of disk read-write, equipment and computer-readable recording medium
CN108062252A (en) * 2016-11-08 2018-05-22 阿里巴巴集团控股有限公司 A kind of information interacting method, method for managing object and device and system
CN108255622A (en) * 2018-01-17 2018-07-06 郑州云海信息技术有限公司 The method and system that a kind of SMASH CLP functions are realized
CN108304269A (en) * 2017-01-13 2018-07-20 阿里巴巴集团控股有限公司 A kind of sending, receiving method of data, device and communications framework
CN108614740A (en) * 2016-12-12 2018-10-02 上海美桔网络科技有限公司 The method and system of unique ID are generated based on shared drive mode between process
CN108694152A (en) * 2017-04-11 2018-10-23 上海福赛特机器人有限公司 Communication system between multinuclear, communication control method and server based on the system
CN109032798A (en) * 2018-07-25 2018-12-18 天津凯发电气股份有限公司 A kind of Power quality management system shared drive lock control method
CN110287044A (en) * 2019-07-02 2019-09-27 广州虎牙科技有限公司 Without lock shared drive processing method, device, electronic equipment and readable storage medium storing program for executing
CN110399229A (en) * 2018-04-25 2019-11-01 清华大学 Communication means, device, system, medium and terminal between process
WO2019227724A1 (en) * 2018-05-28 2019-12-05 深圳市道通智能航空技术有限公司 Data read/write method and device, and circular queue
CN110750372A (en) * 2019-10-16 2020-02-04 深圳技威时代科技有限公司 Log system based on shared memory and log management method
CN111699479A (en) * 2019-06-20 2020-09-22 深圳市大疆创新科技有限公司 Log processing method, log processing device and computer-readable storage medium
CN112702550A (en) * 2020-12-21 2021-04-23 上海商米科技集团股份有限公司 NVR multi-process audio and video stream sharing system and implementation method
CN112860458A (en) * 2021-02-22 2021-05-28 北京睿芯高通量科技有限公司 Inter-process communication method and system based on shared memory
CN113032162A (en) * 2021-03-23 2021-06-25 重庆智行者信息科技有限公司 Multi-process communication method based on shared memory backup mechanism
CN113779545A (en) * 2021-08-27 2021-12-10 深圳市优必选科技股份有限公司 Data cross-process sharing method, terminal equipment and computer readable storage medium
CN114297109A (en) * 2021-12-28 2022-04-08 中汽创智科技有限公司 Data processing method and device based on subscription and publishing mode, electronic equipment and storage medium
CN115269392A (en) * 2022-07-20 2022-11-01 北京斯年智驾科技有限公司 Visual debugging method, equipment and medium for fusion perception
CN116668985A (en) * 2023-06-25 2023-08-29 成都飞机工业(集团)有限责任公司 Low bit error rate method for wireless transmission of multi-source multi-node acquisition sensing data

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6629152B2 (en) * 1998-06-29 2003-09-30 International Business Machines Corporation Message passing using shared memory of a computer
CN101448018A (en) * 2008-12-26 2009-06-03 中兴通讯股份有限公司 Interprocess communication method and device thereof
CN102255794A (en) * 2010-05-17 2011-11-23 塔塔咨询服务有限公司 Remote message transmit-receive handling capacity and waiting time shortening system and method
CN102915276A (en) * 2012-09-25 2013-02-06 武汉邮电科学研究院 Memory control method for embedded systems
CN103150220A (en) * 2011-12-07 2013-06-12 腾讯科技(深圳)有限公司 Method and system for interprocess communications

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6629152B2 (en) * 1998-06-29 2003-09-30 International Business Machines Corporation Message passing using shared memory of a computer
CN101448018A (en) * 2008-12-26 2009-06-03 中兴通讯股份有限公司 Interprocess communication method and device thereof
CN102255794A (en) * 2010-05-17 2011-11-23 塔塔咨询服务有限公司 Remote message transmit-receive handling capacity and waiting time shortening system and method
CN103150220A (en) * 2011-12-07 2013-06-12 腾讯科技(深圳)有限公司 Method and system for interprocess communications
CN102915276A (en) * 2012-09-25 2013-02-06 武汉邮电科学研究院 Memory control method for embedded systems

Cited By (57)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104980454A (en) * 2014-04-02 2015-10-14 腾讯科技(深圳)有限公司 Method, server and system for sharing resource data
US10455003B2 (en) 2014-04-02 2019-10-22 Tencent Technology (Shenzhen) Company Limited Method, server, and system for sharing resource data
CN104980454B (en) * 2014-04-02 2019-08-06 腾讯科技(深圳)有限公司 A kind of resource data sharing method, server and system
CN105955971B (en) * 2015-11-30 2019-09-17 中国银联股份有限公司 A kind of implementation method and device of key assignments caching
CN105955971A (en) * 2015-11-30 2016-09-21 中国银联股份有限公司 Key value buffer memory implementation method and device
CN105760217A (en) * 2016-03-23 2016-07-13 深圳森格瑞通信有限公司 Method for accessing shared memory
CN105912478B (en) * 2016-04-06 2018-11-27 中国航空无线电电子研究所 Real-time system Multitask Data sharing method based on pair buffers
CN105912478A (en) * 2016-04-06 2016-08-31 中国航空无线电电子研究所 Dual-buffer mechanism based real-time system multi-task data sharing method
CN106020962A (en) * 2016-05-31 2016-10-12 广东欧珀移动通信有限公司 Progress control method and terminal equipment
CN106020962B (en) * 2016-05-31 2019-05-21 Oppo广东移动通信有限公司 A kind of course control method and terminal device
US10754684B2 (en) 2016-05-31 2020-08-25 Guangdong Oppo Mobile Telecommunications Corp., Ltd. Method for controlling process and related device
US10719351B2 (en) 2016-05-31 2020-07-21 Guangdong Oppo Mobile Telecommunications Corp., Ltd. Method for controlling states of processes and related device
CN107562639B (en) * 2016-07-01 2020-08-11 北京忆恒创源科技有限公司 Erase block read request processing method and device
CN107562639A (en) * 2016-07-01 2018-01-09 北京忆恒创源科技有限公司 Wipe block read request processing method and device
CN107577539A (en) * 2016-07-05 2018-01-12 阿里巴巴集团控股有限公司 The shared drive structure communicated for kernel state and User space and its application
CN107577539B (en) * 2016-07-05 2021-03-16 阿里巴巴集团控股有限公司 Shared memory structure for communication between kernel mode and user mode and application thereof
CN107643942A (en) * 2016-07-21 2018-01-30 杭州海康威视数字技术股份有限公司 The storage method and device of a kind of status information
CN107643942B (en) * 2016-07-21 2020-11-03 杭州海康威视数字技术股份有限公司 State information storage method and device
CN106293973B (en) * 2016-08-17 2019-12-13 深圳市金证科技股份有限公司 lock-free message queue communication method and system
CN106293973A (en) * 2016-08-17 2017-01-04 深圳市金证科技股份有限公司 Lock-free message queue communication means and system
CN106372183B (en) * 2016-08-31 2020-02-07 北京小米移动软件有限公司 File writing method and device
CN106372183A (en) * 2016-08-31 2017-02-01 北京小米移动软件有限公司 File write-in method and device
CN108062252A (en) * 2016-11-08 2018-05-22 阿里巴巴集团控股有限公司 A kind of information interacting method, method for managing object and device and system
CN108062252B (en) * 2016-11-08 2022-02-01 斑马智行网络(香港)有限公司 Information interaction method, object management method, device and system
CN106708631A (en) * 2016-11-30 2017-05-24 福建省天奕网络科技有限公司 Shared memory property modification method and system
CN106708631B (en) * 2016-11-30 2020-06-09 福建省天奕网络科技有限公司 Shared memory attribute modifying method and system
CN108614740A (en) * 2016-12-12 2018-10-02 上海美桔网络科技有限公司 The method and system of unique ID are generated based on shared drive mode between process
CN106598736A (en) * 2016-12-13 2017-04-26 深圳中科讯联科技股份有限公司 Memory block calling method and memory block releasing method for memory pool and server
CN106648939A (en) * 2016-12-30 2017-05-10 上海寰视网络科技有限公司 Method and equipment for inter-process resource sharing
CN108304269A (en) * 2017-01-13 2018-07-20 阿里巴巴集团控股有限公司 A kind of sending, receiving method of data, device and communications framework
CN106980551A (en) * 2017-03-24 2017-07-25 山东浪潮商用系统有限公司 A kind of Way of Process Communication and device
CN108694152A (en) * 2017-04-11 2018-10-23 上海福赛特机器人有限公司 Communication system between multinuclear, communication control method and server based on the system
CN108694152B (en) * 2017-04-11 2021-07-13 实时侠智能控制技术有限公司 Communication system among multiple cores, communication control method based on system and server
CN107589915A (en) * 2017-09-25 2018-01-16 郑州云海信息技术有限公司 Capacity information monitoring method, device and the equipment of a kind of distributed memory system
CN107589915B (en) * 2017-09-25 2020-05-29 郑州云海信息技术有限公司 Capacity information monitoring method, device and equipment of distributed storage system
CN108021339A (en) * 2017-11-03 2018-05-11 网宿科技股份有限公司 A kind of method of disk read-write, equipment and computer-readable recording medium
CN108021339B (en) * 2017-11-03 2021-05-04 网宿科技股份有限公司 Method and device for reading and writing magnetic disk and computer readable storage medium
CN108255622A (en) * 2018-01-17 2018-07-06 郑州云海信息技术有限公司 The method and system that a kind of SMASH CLP functions are realized
CN110399229A (en) * 2018-04-25 2019-11-01 清华大学 Communication means, device, system, medium and terminal between process
WO2019227724A1 (en) * 2018-05-28 2019-12-05 深圳市道通智能航空技术有限公司 Data read/write method and device, and circular queue
US11500586B2 (en) 2018-05-28 2022-11-15 Autel Robotics Co., Ltd. Data read-write method and apparatus and circular queue
CN109032798A (en) * 2018-07-25 2018-12-18 天津凯发电气股份有限公司 A kind of Power quality management system shared drive lock control method
CN109032798B (en) * 2018-07-25 2022-03-18 天津凯发电气股份有限公司 Control method for shared memory lock of power quality management system
CN111699479A (en) * 2019-06-20 2020-09-22 深圳市大疆创新科技有限公司 Log processing method, log processing device and computer-readable storage medium
CN110287044A (en) * 2019-07-02 2019-09-27 广州虎牙科技有限公司 Without lock shared drive processing method, device, electronic equipment and readable storage medium storing program for executing
CN110750372A (en) * 2019-10-16 2020-02-04 深圳技威时代科技有限公司 Log system based on shared memory and log management method
CN110750372B (en) * 2019-10-16 2024-05-14 深圳技威时代科技有限公司 Log system and log management method based on shared memory
CN112702550A (en) * 2020-12-21 2021-04-23 上海商米科技集团股份有限公司 NVR multi-process audio and video stream sharing system and implementation method
CN112860458A (en) * 2021-02-22 2021-05-28 北京睿芯高通量科技有限公司 Inter-process communication method and system based on shared memory
CN113032162A (en) * 2021-03-23 2021-06-25 重庆智行者信息科技有限公司 Multi-process communication method based on shared memory backup mechanism
CN113032162B (en) * 2021-03-23 2023-10-24 重庆兰德适普信息科技有限公司 Multi-process communication method based on shared memory backup mechanism
CN113779545A (en) * 2021-08-27 2021-12-10 深圳市优必选科技股份有限公司 Data cross-process sharing method, terminal equipment and computer readable storage medium
CN114297109A (en) * 2021-12-28 2022-04-08 中汽创智科技有限公司 Data processing method and device based on subscription and publishing mode, electronic equipment and storage medium
CN114297109B (en) * 2021-12-28 2024-05-24 中汽创智科技有限公司 Data processing method and device based on subscription and release modes, electronic equipment and storage medium
CN115269392A (en) * 2022-07-20 2022-11-01 北京斯年智驾科技有限公司 Visual debugging method, equipment and medium for fusion perception
CN115269392B (en) * 2022-07-20 2023-11-14 北京斯年智驾科技有限公司 Visual debugging method, device and medium for fusion perception
CN116668985A (en) * 2023-06-25 2023-08-29 成都飞机工业(集团)有限责任公司 Low bit error rate method for wireless transmission of multi-source multi-node acquisition sensing data

Also Published As

Publication number Publication date
CN103514053B (en) 2017-01-25

Similar Documents

Publication Publication Date Title
CN103514053A (en) Shared-memory-based method for conducting communication among multiple processes
Turon et al. GPS: Navigating weak memory with ghosts, protocols, and separation
CN103842959B (en) Maintaining operand liveness information in a computer system
US5355457A (en) Data processor for performing simultaneous instruction retirement and backtracking
KR20200056430A (en) Cache-based trace history using cache coherence protocol data
CN100570564C (en) User mode threads is configured to method and system near disabled interrupt priority
CN104424158A (en) General unit-based high-performance processor system and method
CN105051682B (en) software interface for hardware device
CN102629221B (en) Task synchronization method, device and system for distributed shared memory structure
CN102855121A (en) Branching processing method and system
CN110888727A (en) Method, device and storage medium for realizing concurrent lock-free queue
CN103279428A (en) Explicit multi-core Cache consistency active management method facing flow application
CN106293894A (en) Perform hardware device and the method for transactional power management
CN101359321A (en) Method and apparatus for implementing intercommunication of processors
CN103020003A (en) Multi-core program determinacy replay-facing memory competition recording device and control method thereof
CN102681937A (en) Correctness verifying method of cache consistency protocol
KR20200002932A (en) Apparatus and method for managing entitlement metadata
CN106294169A (en) The detection of a kind of data contention based on semiology analysis virtual machine and playback method
CN109634672A (en) A kind of multi-core processor loading method based on intercore communication
CN102141955B (en) Linux-based kernel log system and realization method thereof
CN101719116B (en) Method and system for realizing transaction memory access mechanism based on exception handling
CN109885489B (en) Data race detection method and device in driver
CN103036947A (en) Virtual machine transferring method based on kernel-based virtual machine (KVM) and virtual machine transferring method based on KVM
US20160092182A1 (en) Methods and systems for optimizing execution of a program in a parallel processing environment
CN101164035A (en) Power saving methods and apparatus to selectively enable comparators in a cam renaming register file based on known processor state

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant