CN104424030A - Sharing memory multi-process operation method and device - Google Patents

Sharing memory multi-process operation method and device Download PDF

Info

Publication number
CN104424030A
CN104424030A CN201310370343.2A CN201310370343A CN104424030A CN 104424030 A CN104424030 A CN 104424030A CN 201310370343 A CN201310370343 A CN 201310370343A CN 104424030 A CN104424030 A CN 104424030A
Authority
CN
China
Prior art keywords
shared drive
data
address
node
data field
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
CN201310370343.2A
Other languages
Chinese (zh)
Other versions
CN104424030B (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201310370343.2A priority Critical patent/CN104424030B/en
Publication of CN104424030A publication Critical patent/CN104424030A/en
Application granted granted Critical
Publication of CN104424030B publication Critical patent/CN104424030B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention provides a sharing memory multi-process operation method. The sharing memory multi-process operation method comprises copying data in a first sharing memory to a pre-allocated second sharing memory when the data in the first sharing memory need to be modified through a first process, wherein the size of the first sharing memory is the same as that of the second sharing memory; modifying data in the second sharing memory through the first process; modifying a stored address of the current data area into an address of the second sharing memory from an address of the first sharing memory when the modification of the data in the second sharing memory is achieved. According to the sharing memory multi-process operation method, the concurrent execution of the reading operation and writing operation of the sharing memories can be achieved and accordingly the processing efficiency of equipment is improved. In addition, the invention also provides a sharing memory multi-process operation device and a sharing memory multi-process operation method and device.

Description

The method and apparatus of multi-process operation shared drive
Technical field
The present invention relates to field of computer technology, particularly relate to the method and apparatus of a kind of multi-process operation shared drive.
Background technology
Shared drive refer to can the internal memory shared by more process, it is described as the mapping of an internal memory region (section).Process is the running example of application program, is a Dynamic Execution of application program.Multi-process operation shared drive refers to that realization is read the data in shared drive or writes data in shared drive, and multi-process is by the communication between Sharing Memory Realization process.
In conventional art, multi-process operation shared drive is the accurate of maintenance internal storage data, need to use resource lock, that is: process in the data read in shared drive or write data to shared drive before, all need the resource lock first getting shared drive, the process only getting resource lock could carry out read operation or write operation to shared drive, and the process that can not get resource lock then can be blocked.
But inventor finds at least there is following technical matters in prior art:
Due to cannot Gains resources lock time will blocking process, when a process is when carrying out read operation (this process gets resource lock) to shared drive, then other all processes cannot carry out read operation or write operation to shared drive, when a process carries out write operation to shared drive, other all processes also cannot carry out read operation or write operation to shared drive, and this will inevitably affect the treatment effeciency of equipment.Particularly writing multi-process at one process reads in the application scenarios of (namely read operation is greatly more than the number of times of write operation), and the processing mode of this serial makes the treatment effeciency of equipment lower, thus have impact on the handling property of equipment.
Summary of the invention
Based on this, be necessary for the low technical matters for the treatment of effeciency in conventional art, provide a kind of multi-process to operate the method and apparatus of shared drive.
A method for multi-process operation shared drive, described method comprises:
When the first process need revise the data in the first shared drive, by the data Replica in described first shared drive in equal-sized second shared drive of preallocated and described first shared drive;
Data in described second shared drive of described first process amendment;
After data modification in second shared drive, the address of the active data area of storage is revised as the address of the second shared drive by the address of the first shared drive.
A device for multi-process operation shared drive, described device comprises:
Data Replica module, for when the first process need revise the data in the first shared drive, by the data Replica in described first shared drive in equal-sized second shared drive of preallocated and described first shared drive;
Data modification module, for revising the data in described second shared drive by the first process;
Address modified module, after the data modification in the second shared drive, is revised as the address of the second shared drive by the address of the first shared drive by the address of the active data area of storage.
The method and apparatus of above-mentioned multi-process operation shared drive, due to when the first process will revise the data in the first shared drive, by the data Replica in the first shared drive to preallocated with equal-sized second shared drive of the first shared drive, make the data of the first process write can carry out in the second shared drive.Like this, in the write operation implementation of the first process, the second process still can read the data before amendment, and the process thus reading data can not get clogged.Due to not for shared drive arranges resource lock, process just can to Sharing Memory Realization read operation and write operation without the need to competitive resource, and the process of read operation can not be blocked at execution write operation because of having process, and the process of write operation also can not be blocked in execution read operation because of having process, therefore, it is possible to improve the treatment effeciency of equipment, thus improve the handling property of equipment.
A method for multi-process operation shared drive, described method comprises:
When need revise the data in the first data field corresponding to the first node in chained list when the first process, by the second idle available for data write data field;
After data have write, judge whether the read operation of the second process terminates, and if so, then described chained list is set to not readable state, otherwise wait for, until the read operation of described second process terminates;
Described second data field is inserted in described chained list, makes corresponding described second data field of described first node;
Described chained list is set to readable state.
A device for multi-process operation shared drive, described device comprises:
Data, during for need revise the data in the first data field corresponding to the first node in chained list when the first process, are write the second data field with described first data field equal and opposite in direction and idle available by Data write. module;
Read operation judge module, after having write, judges whether the read operation of the second process terminates for described Data write. module data;
State setting module, at the end of the read operation of described second process, is set to not readable state by described chained list, otherwise waits for, until the read operation of described second process terminates, more described chained list is set to not readable state;
Chained list update module, for being inserted in described chained list described second data field, makes corresponding described second data field of described first node;
Described chained list also for after inserting in described chained list in described chained list update module by the second data field, is set to readable state by described state setting module.
The method and apparatus of above-mentioned multi-process operation shared drive, when need revise the data in the first data field corresponding to the first node in chained list when the first process, by in the second idle available for data write data field, because the write operation of the first process can perform in the second data field, the read operation of the second process can not be affected, the write operation of shared drive and read operation can synchronously be performed, and the process reading data can not be blocked because of the write operation of the first process.Due to not for shared drive arranges resource lock, process just can to Sharing Memory Realization read operation and write operation without the need to competitive resource, and the process of read operation can not be blocked at execution write operation because of having process, and the process of write operation also can not be blocked in execution read operation because of having process, achieve the concurrence performance of read-write operation, thus improve the treatment effeciency of equipment.
Accompanying drawing explanation
Fig. 1 is the schematic flow sheet of the method for multi-process operation shared drive in an embodiment;
Fig. 2 is the schematic diagram distributing shared drive;
Fig. 3 is the schematic diagram adopting pointed active data area;
Fig. 4 is the schematic diagram that the pointer of active data area is pointed in change;
Fig. 5 is the structured flowchart of the device of multi-process operation shared drive in an embodiment;
Fig. 6 is the structured flowchart of the device of multi-process operation shared drive in another embodiment;
Fig. 7 is the structured flowchart of the device of multi-process operation shared drive in another embodiment;
Fig. 8 is the schematic flow sheet of the method for multi-process operation shared drive in another embodiment;
Fig. 9 is the schematic diagram for the chained list of managing shared memory in an embodiment;
Figure 10 is the schematic diagram for the chained list of managing shared memory in another embodiment;
Figure 11 is the structured flowchart of the device of multi-process operation shared drive in an embodiment;
Figure 12 is the structured flowchart of the device of multi-process operation shared drive in another embodiment;
Figure 13 is the schematic flow sheet of the method for multi-process operation shared drive in another embodiment.
Embodiment
In order to make object of the present invention, technical scheme and advantage clearly understand, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein only in order to explain the present invention, be not intended to limit the present invention.
As shown in Figure 1, in one embodiment, provide the method for a kind of multi-process operation shared drive, comprising:
Step 102, when the first process need revise the data in the first shared drive, by the data Replica in the first shared drive to preallocated with equal-sized second shared drive of the first shared drive.
First shared drive and the second shared drive are pre-assigned equal-sized shared drives.In the present embodiment, when needing the shared drive of a certain size, then distribute the shared drive of twice size, wherein half shared drive is the first shared drive, and second half shared drive is then the second shared drive.
In one embodiment, before step 102, also comprise: when needing the shared drive of the first size, distribute the first shared drive of the first size and second shared drive equal-sized with the first shared drive; Create the 3rd shared drive, in the 3rd shared drive, store the address of the first shared drive, the address of the second shared drive and the address of active data area; The address of this active data area is the address of the first shared drive.
As shown in Figure 2, when being the shared drive A of X when needing size, then distribute shared drive A and B of 2*X size.The first shared drive in the embodiment of the present invention can be any one in these two shared drives, then the second shared drive is another, and namely the first shared drive and the second shared drive are relative concepts.After distributing shared drive, by in data write wherein any one shared drive, in the present embodiment, can be illustrated with the shared drive that the first shared drive is active data area, when need revise the data in active data area when the first process, then start to perform step 102.
3rd shared drive is for managing the first shared drive and the second shared drive.Further, can store three pointers in the 3rd shared drive, these three pointers point to the address of the first shared drive, the address of the second shared drive and the address of active data area respectively.Wherein the address of the first shared drive can be the reference position of the first shared drive, and the address of the second shared drive can be the reference position of the second shared drive.The present embodiment due to active data area be the first shared drive, then the address of active data area is the reference position of the first shared drive.
Concrete, in a step 102, when need revise data (data namely in the first shared drive) in active data area when the first process, obtain the address of the first shared drive and the address of the second shared drive that store in the 3rd shared drive; Read the data in the first shared drive according to the address of the first shared drive obtained, the data in the first shared drive read write in the second shared drive by the address according to the second shared drive obtained.
Step 104, the first process revises the data in the second shared drive.
When the first process need revise the data in the first shared drive, due to by the data Replica in the first shared drive in the second shared drive, the first process can be modified to the data in the second shared drive.Such as, 3 data are had in first shared drive, need amendment the 2nd data, these 3 data have been copied to after in the second shared drive, first process can directly be modified to the data of the 2nd in the second shared drive, and the information that need revise writes in the 2nd data in the second shared drive.
Step 106, after the data modification in the second shared drive, is revised as the address of the second shared drive by the address of the first shared drive by the address of the active data area of storage.
In one embodiment, before data modification in the second shared drive is complete, also comprise: the address of the active data area that the second process acquisition stores is the address of the first shared drive, reads the data in the first shared drive according to the address of the first shared drive.
Second process and the first process are also relative concepts, and the second process is one or more processes that the need different from the first process read the data in active data area.In the present embodiment, when need read the data in active data area when the second process, the address of active data area first can be obtained from the 3rd shared drive, as mentioned above, the address of active data area is the address of the first shared drive, the address of active data area that then the second process gets is the address of the first shared drive, namely may be read into the data in the first shared drive according to this address.Like this, before the data modification in the second shared drive is complete, the data (legacy data namely before amendment) remained in the first shared drive of the second process reading.
Further, after step 106, also comprise: the address of the active data area that the second process acquisition stores is the address of the second shared drive, reads the data in the second shared drive according to the address of the second shared drive.
In the present embodiment, the address of the second shared drive, after having revised the data in the second shared drive, can be revised as in the address of the active data area stored in the 3rd shared drive by the first process.As shown in Figure 3 and Figure 4, first shared drive is shared drive A, second shared drive is shared drive B, before data modification in shared drive B is complete, the pointed shared drive A(of the sensing active data area stored in the 3rd shared drive is see Fig. 3), after data modification in shared drive B, then the pointed shared drive B(of the sensing active data area stored in the 3rd shared drive is see Fig. 4), make the address change of active data area be new data address.Further, when pointing to the pointer of active data area in amendment the 3rd shared drive, can be this pointer and add protection, to prevent from causing program to go wrong during amendment pointer.
Afterwards, when need read the data in active data area when the second process, the address of active data area first can be obtained from the 3rd shared drive, address due to the active data area in now the 3rd shared drive has been revised as the address of the second shared drive, and therefore namely the second process may be read into the data in the second shared drive according to the address of the active data area got.Like this, after the data modification in the second shared drive is complete, the data (i.e. amended new data) that what the second process read is in the second shared drive.
As shown in Figure 5, in one embodiment, additionally provide the device of a kind of multi-process operation shared drive, comprising:
Data Replica module 502, for when the first process need revise the data in the first shared drive, by the data Replica in the first shared drive to preallocated with equal-sized second shared drive of the first shared drive.
Data modification module 504, for revising the data in the second shared drive by the first process.
Address modified module 506, after the data modification in the second shared drive, is revised as the address of the second shared drive by the address of the first shared drive by the address of the active data area of storage.
First shared drive and the second shared drive are pre-assigned equal-sized shared drives.When needing the shared drive of a certain size, then allocate the shared drive of twice size in advance, wherein half shared drive is the first shared drive, and second half shared drive is then the second shared drive.The present embodiment is that the first shared drive is illustrated with active data area.
In one embodiment, as shown in Figure 6, on basis embodiment illustrated in fig. 5, the device of multi-process operation shared drive, also comprises:
Memory allocating module 501, for when needing the shared drive of the first size, distributes the first shared drive of the first size and second shared drive equal-sized with the first shared drive.
3rd shared drive creation module 503, for creating the 3rd shared drive, stores the address of the first shared drive, the address of the second shared drive and the address of active data area in the 3rd shared drive; The address of this active data area is the address of the first shared drive.
In the present embodiment, the 3rd shared drive is for managing the first shared drive and the second shared drive.Further, can store three pointers in the 3rd shared drive, these three pointers point to the address of the first shared drive, the address of the second shared drive and the address of active data area respectively.Wherein the address of the first shared drive can be the reference position of the first shared drive, and the address of the second shared drive can be the reference position of the second shared drive.The present embodiment due to active data area be the first shared drive, then the address of active data area is the reference position of the first shared drive.
Further, in one embodiment, data Replica module 502 is for the address of the address and the second shared drive that obtain the first shared drive stored in the 3rd shared drive; Read the data in the first shared drive according to the address of the first shared drive obtained, the data in the first shared drive read write in the second shared drive by the address according to the second shared drive obtained.
When the first process need revise the data in the first shared drive, due to data Replica module 502 by the data Replica in the first shared drive in the second shared drive, then data modification module 504 can be modified to the data in the second shared drive by the first process.
Further, in one embodiment, as shown in Figure 7, on basis embodiment illustrated in fig. 6, the device of multi-process operation shared drive, also comprises:
Data read module 508, before complete for the data modification in the second shared drive, the address being obtained the active data area stored by the second process is the address of the first shared drive, reads the data in the first shared drive according to the address of the first shared drive; And for after the data modification in the second shared drive, the address being obtained the active data area stored by the second process is the address of the second shared drive, reads the data in the second shared drive according to the address of the second shared drive.
Second process is one or more processes that the need different from the first process read the data in active data area.In the present embodiment, when need read the data in active data area when the second process, data read module 508 first can obtain the address of active data area from the 3rd shared drive, as mentioned above, the address of active data area is the address of the first shared drive, the address of active data area that then data read module 508 is got by the second process is the address of the first shared drive, namely may be read into the data in the first shared drive according to this address.Like this, before the data modification in the second shared drive is complete, the data (legacy data namely before amendment) remained in the first shared drive of the second process reading.
Further, address modified module 506 is after data modification module 504 has revised the data in the second shared drive by the first process, can be used for the address of the address of the active data area stored in the 3rd shared drive being revised as the second shared drive, make the address change of active data area be new data address.
When need read the data in active data area when the second process, data read module 508 can be used for the address first obtaining active data area from the 3rd shared drive, address due to the active data area in now the 3rd shared drive has been revised as the address of the second shared drive, and therefore namely data read module 508 to may be read into the data in the second shared drive according to the address of the active data area got by the second process.Like this, after the data modification in the second shared drive is complete, the data (i.e. amended new data) that what the second process read is in the second shared drive.
The method and apparatus of above-mentioned multi-process operation shared drive, due to when the first process will revise the data in the first shared drive, by the data Replica in the first shared drive to preallocated with equal-sized second shared drive of the first shared drive, make the data of the first process write can carry out in the second shared drive.Like this, in the write operation implementation of the first process, the second process still can read the data before amendment, and the process thus reading data can not get clogged.And after data modification in the second shared drive, the address of the active data area of storage being revised as the address of the second shared drive by the address of the first shared drive, after data have been write, the process reading data can read new data.Therefore, the method and apparatus of above-mentioned multi-process operation shared drive can improve the treatment effeciency of equipment, thus improves the handling property of equipment.In addition, due to not for shared drive arranges resource lock, process just can to Sharing Memory Realization read operation or write operation without the need to competitive resource, and the process of read operation can not be blocked at execution write operation because of having process, and the process of write operation also can not be blocked in execution read operation because of having process, achieve the concurrence performance of read-write operation.
As shown in Figure 8, in one embodiment, provide the method for another kind of multi-process operation shared drive, comprising:
Step 802, when need revise the data in the first data field corresponding to the first node in chained list when the first process, by the second idle available for data write data field.
Step 804, after data have write, judges whether the read operation of the second process terminates, and if so, then enters step 806, otherwise waits for, returns step 804, until the read operation of the second process terminates.
Step 806, is set to not readable state by chained list.
Step 808, inserts the second data field in chained list, makes corresponding second data field of first node.
Step 810, is set to readable state by chained list.
In the present embodiment, carry out managing shared memory by chained list, a data field in the corresponding shared drive of each node in chained list, the data field composition shared drive that node is corresponding.Fig. 9 shows the schematic diagram that comprises the chained list of 3 nodes, chained list is made up of multiple nodes in gauge outfit and corresponding data district, each node comprises forwarding pointer (prev) and backwarding pointer (next), wherein, forwarding pointer points to the reference position of data field corresponding to previous node, and backwarding pointer points to the reference position of data field corresponding to a rear node.Illustrate with the node 2 in Fig. 9, the forwarding pointer of node 2 points to the reference position of the data field 1 of node 1 correspondence, the backwarding pointer of node 2 then points to the reference position of the data field 3 of node 3 correspondence, can obtain the address of data field 1 and the address of data field 2 according to the forwarding pointer in node 2 and backwarding pointer.
In the present embodiment, first node is node corresponding to data field that the first process needs amendment, when data in the first data field that the first node that the first process need be revised in chained list is corresponding, then opens up one piece of new free time available the second data field.Preferably, the second data field and the first data field equal and opposite in direction.The data of amendment are then written in the second data field by the first process.After data have write, judge whether the read operation of the second process terminates, if terminated, then chained list has been set to not readable state.Concrete, can be shared drive and arrange a zone bit, represent that current shared internal memory is not readable, like this, process cannot carry out read operation or write operation to shared drive.Further, chained list is being set to not after readable state, the second data field can be being inserted in chained list, make corresponding second data field of first node.
As shown in Figure 9, when the first process needs the data revised in the data field 2 of node 2 correspondence, the data of amendment are write in the second data field, and after data have write and after the read operation of the second process terminates, chained list is set to not readable, the pointer information of amendment node 1 and node 3, the backwarding pointer of node 1 is made to point to the reference position of the second data field, the forwarding pointer of node 3 points to the reference position of the second data field, like this, then the second data field is joined in chained list, corresponding second data field of node 2.
After nodal information in chained list has upgraded, then chained list is set to readable state.In one embodiment, when chained list is readable state, the second process obtains the address in data field corresponding to node according to the pointer information of the node in chained list, reads the data in data field corresponding to node according to the address obtained.In the present embodiment, the second process is one or more processes that the need different from the first process read the data in active data area.When chained list is readable state, then the second process reads the data in shared drive according to chained list.
In one embodiment, the method for multi-process operation shared drive also comprises: when the second process is when reading the data in data field corresponding to node, the reference count corresponding to node increases progressively; After the digital independent in the data field that the second process is corresponding to node, the reference count corresponding to node is successively decreased.In the present embodiment, each node also comprises corresponding reference count, and when the data having process to read in data field corresponding to this node, then reference count increases progressively, and after reading, then reference count increases progressively.As shown in Figure 10, this reference count can be stored in node.
Further, in one embodiment, judge whether the read operation of the second process terminates, comprise: whether reference count corresponding to decision node is the numerical value after default successively decreasing, if, then judge that the read operation of the second process to data field corresponding to this node terminates, otherwise, judge that the read operation of the second process to data field corresponding to this node does not terminate.
Preferably, the initial value that can arrange reference count corresponding to each node is 0, and when the data having process to read in data field corresponding to this node, then reference count adds 1, and after reading, then reference count subtracts 1.Like this, whether reference count corresponding to decision node is 0, if be 0, then judges that the read operation of the second process to data field corresponding to this node terminates, otherwise, do not terminate.
In one embodiment, the second data field can inserted in chained list, after making corresponding second data field of Section Point, discharge the memory headroom of the first data field.Because the second data field is inserted after chained list and chained list recover readable state, process then can read the data (namely new data) in the second data field according to chained list, and the memory headroom of the first data field can discharge, like this, can memory source be saved, more idle available memory headroom is provided.
As shown in figure 11, in one embodiment, additionally provide the device of another kind of multi-process operation shared drive, comprising:
Data, during for need revise the data in the first data field corresponding to the first node in chained list when the first process, are write the second data field with the first data field equal and opposite in direction and idle available by Data write. module 1102.
Read operation judge module 1104, after having write, judges whether the read operation of the second process terminates for Data write. module data.
State setting module 1106, at the end of the read operation of the second process, is set to not readable state by chained list, otherwise waits for, until the read operation of the second process terminates, then chained list is set to not readable state.
Chained list update module 1108, for being inserted in chained list the second data field, makes corresponding second data field of first node.
In the present embodiment, chained list also for after inserting in chained list in chained list update module by the second data field, is set to readable state by state setting module 1106.
In the present embodiment, carry out managing shared memory by chained list, a data field in the corresponding shared drive of each node in chained list, the data field composition shared drive that node is corresponding.First node is the node that the first process needs the data field of amendment corresponding, when data in the first data field that the first node that the first process need be revised in chained list is corresponding, Data write. module 1102 is for opening up one piece of new free time available the second data field.Preferably, Data write. module 1,102 second data field of opening up and the first data field equal and opposite in direction.Then the data of amendment are written in the second data field by the first process.
Read operation judge module 1104, for after the data of Data write. module 1102 have write, judges whether the read operation of the second process terminates, if terminated, then chained list is set to not readable state by state setting module 1106.Concrete, state setting module 1106 can be used for for shared drive arranges a zone bit, and represent that current shared internal memory is not readable, like this, process cannot carry out read operation or write operation to shared drive.Further, be set to by chained list not after readable state, the second data field can be inserted in chained list by chained list update module 1108, make corresponding second data field of first node.After the nodal information of state setting module 1106 in chained list has upgraded, then chained list is set to readable state.
In one embodiment, as shown in figure 12, the device of multi-process operation shared drive, also comprises:
Data read module 1107, for when chained list is readable state, is obtained the address in data field corresponding to node, reads the data in data field corresponding to node according to the address obtained according to the pointer information of the node in chained list by the second process.
Internal memory release module 1109, after inserting in chained list in chained list update module 1108 by the second data field, discharges the memory headroom of the first data field.
In one embodiment, as shown in figure 13, the device of multi-process operation shared drive, also comprises:
Reference count module 1110, for when the second process is when reading the data in data field corresponding to node, the reference count corresponding to node increases progressively; After the digital independent in the data field that the second process is corresponding to node, the reference count corresponding to node is successively decreased.
Further, whether read operation judge module 1104 is the numerical value after default successively decreasing for reference count corresponding to decision node, if, then judge that the read operation of the second process to data field corresponding to this node terminates, otherwise, judge that the read operation of the second process to data field corresponding to this node does not terminate.
Preferably, the initial value that reference count module 1110 can be used for arranging reference count corresponding to each node is 0, and when the data having process to read in data field corresponding to this node, then reference count adds 1, and after reading, then reference count subtracts 1.Like this, whether read operation judge module 1104 is 0 for the reference count that decision node is corresponding, if be 0, then judges that the read operation of the second process to data field corresponding to this node terminates, otherwise, do not terminate.
The method and apparatus of above-mentioned multi-process operation shared drive, when need revise the data in the first data field corresponding to the first node in chained list when the first process, by in the second idle available for data write data field, because the write operation of the first process can perform in the second data field, the read operation of the second process can not be affected, the write operation of shared drive and read operation can synchronously be performed, and the process reading data can not be blocked because of the write operation of the first process.Due to not for shared drive arranges resource lock, process just can to Sharing Memory Realization read operation and write operation without the need to competitive resource, and the process of read operation can not be blocked at execution write operation because of having process, and the process of write operation also can not be blocked in execution read operation because of having process, achieve the concurrence performance of read-write operation, thus improve the treatment effeciency of equipment.
After the data of the first process have write and the read operation of the second process terminates, again chained list is set to not readable state, and the second data field is inserted in chained list, make to be only can not perform the read operation of shared drive and write operation when upgrading chained list, and chained list is set to not readable state in the renewal process of chained list and can prevents from causing data read errors due to the renewal of chained list.And after chained list is inserted in the second data field, then chained list is set to readable state, make the read operation of shared drive and write operation recover to perform, and new data can be read when process reads shared drive again.Due to when the data having process need revise in shared drive, only need to open up equal-sized second data field, first data field corresponding with first node, but not open up monoblock shared drive, therefore, it is possible to save memory source.
One of ordinary skill in the art will appreciate that all or part of flow process realized in above-described embodiment method, that the hardware that can carry out instruction relevant by computer program has come, described program can be stored in a computer read/write memory medium, as in the embodiment of the present invention, this program is stored in the storage medium of terminal, and performed by least one processor in this terminal, to realize the flow process of the embodiment comprised as above-mentioned each side method.Wherein, described storage medium can be magnetic disc, CD, read-only store-memory body (Read-Only Memory, ROM) or random store-memory body (Random Access Memory, RAM) etc.
The above embodiment only have expressed several embodiment of the present invention, and it describes comparatively concrete and detailed, but therefore can not be interpreted as the restriction to the scope of the claims of the present invention.It should be pointed out that for the person of ordinary skill of the art, without departing from the inventive concept of the premise, can also make some distortion and improvement, these all belong to protection scope of the present invention.Therefore, the protection domain of patent of the present invention should be as the criterion with claims.

Claims (18)

1. a method for multi-process operation shared drive, described method comprises:
When the first process need revise the data in the first shared drive, by the data Replica in described first shared drive in equal-sized second shared drive of preallocated and described first shared drive;
Data in described second shared drive of described first process amendment;
After data modification in second shared drive, the address of the active data area of storage is revised as the address of the second shared drive by the address of the first shared drive.
2. method according to claim 1, is characterized in that, before the data modification in described second shared drive is complete, also comprises:
The address of the active data area that the second process acquisition stores is the address of the first shared drive, reads the data in the first shared drive according to the address of described first shared drive;
After data modification in described second shared drive, the address of the active data area of storage is revised as the step of the address of the second shared drive by the address of the first shared drive after, also comprise:
The address of the active data area that the second process acquisition stores is the address of the second shared drive, reads the data in the second shared drive according to the address of described second shared drive.
3. method according to claim 1, is characterized in that, described method also comprises:
When needing the shared drive of the first size, distribute the first shared drive of the first size and second shared drive equal-sized with the first shared drive;
Create the 3rd shared drive, in described 3rd shared drive, store the address of the first shared drive, the address of the second shared drive and the address of active data area;
The address of described active data area is the address of described first shared drive.
4. method according to claim 3, is characterized in that, described by the data Replica in the first shared drive in equal-sized second shared drive of preallocated and described second shared drive, comprising:
Obtain the address of the first shared drive stored in the 3rd shared drive and the address of the second shared drive;
Read the data in the first shared drive according to the address of described first shared drive obtained, the data in the first shared drive read write in described second shared drive by the address according to described second shared drive obtained.
5. a device for multi-process operation shared drive, it is characterized in that, described device comprises:
Data Replica module, for when the first process need revise the data in the first shared drive, by the data Replica in described first shared drive in equal-sized second shared drive of preallocated and described first shared drive;
Data modification module, for revising the data in described second shared drive by the first process;
Address modified module, after the data modification in the second shared drive, is revised as the address of the second shared drive by the address of the first shared drive by the address of the active data area of storage.
6. device according to claim 5, is characterized in that, described device also comprises:
Data read module, before complete for the data modification in the second shared drive, the address being obtained the active data area stored by the second process is the address of the first shared drive, reads the data in the first shared drive according to the address of described first shared drive; After data modification in the second shared drive, the address being obtained the active data area stored by the second process is the address of the second shared drive, reads the data in the second shared drive according to the address of described second shared drive.
7. device according to claim 5, is characterized in that, described device also comprises:
Memory allocating module, for when needing the shared drive of the first size, distributes the first shared drive of the first size and second shared drive equal-sized with the first shared drive;
3rd shared drive creation module, for creating the 3rd shared drive, stores the address of the first shared drive, the address of the second shared drive and the address of active data area in described 3rd shared drive;
The address of described active data area is the address of described first shared drive.
8. device according to claim 9, is characterized in that, described data Replica module is for the address of the address and the second shared drive that obtain the first shared drive stored in the 3rd shared drive; Read the data in the first shared drive according to the address of described first shared drive obtained, the data in the first shared drive read write in described second shared drive by the address according to described second shared drive obtained.
9. a method for multi-process operation shared drive, described method comprises:
When need revise the data in the first data field corresponding to the first node in chained list when the first process, by the second idle available for data write data field;
After data have write, judge whether the read operation of the second process terminates, and if so, then described chained list is set to not readable state, otherwise wait for, until the read operation of described second process terminates;
Described second data field is inserted in described chained list, makes corresponding described second data field of described first node;
Described chained list is set to readable state.
10. method according to claim 9, is characterized in that, described method also comprises:
When described chained list is readable state, the second process obtains the address in data field corresponding to node according to the pointer information of the node in described chained list, reads the data in data field corresponding to node according to the address of described acquisition.
11. methods according to claim 9, is characterized in that, described method also comprises:
When the second process is when reading the data in data field corresponding to node, the reference count corresponding to described node increases progressively;
After the digital independent in the data field that the second process is corresponding to node, the reference count corresponding to described node is successively decreased.
12. methods according to claim 11, is characterized in that, describedly judge whether the read operation of the second process terminates, and comprising:
Whether reference count corresponding to decision node is the numerical value after default successively decreasing, if, then judge that the read operation of the second process to data field corresponding to described node terminates, otherwise, judge that the read operation of the second process to data field corresponding to described node does not terminate.
13. methods according to claim 9, is characterized in that, are inserted in described chained list the second data field described, after making corresponding described second data field of described first node, also comprise:
Discharge the memory headroom of described first data field.
The device of 14. 1 kinds of multi-process operation shared drives, it is characterized in that, described device comprises:
Data, during for need revise the data in the first data field corresponding to the first node in chained list when the first process, are write the second data field with described first data field equal and opposite in direction and idle available by Data write. module;
Read operation judge module, after having write, judges whether the read operation of the second process terminates for described Data write. module data;
State setting module, at the end of the read operation of described second process, is set to not readable state by described chained list, otherwise waits for, until the read operation of described second process terminates, more described chained list is set to not readable state;
Chained list update module, for being inserted in described chained list described second data field, makes corresponding described second data field of described first node;
Described chained list also for after inserting in described chained list in described chained list update module by the second data field, is set to readable state by described state setting module.
15. devices according to claim 14, is characterized in that, described device also comprises:
Data read module, for when described chained list is readable state, is obtained the address in data field corresponding to node, reads the data in data field corresponding to node according to the address of described acquisition according to the pointer information of the node in described chained list by the second process.
16. devices according to claim 14, is characterized in that, described device also comprises:
Reference count module, for when the second process is when reading the data in data field corresponding to node, the reference count corresponding to described node increases progressively; After the digital independent in the data field that the second process is corresponding to node, the reference count corresponding to described node is successively decreased.
17. devices according to claim 16, it is characterized in that, whether described read operation judge module is used for reference count corresponding to decision node is numerical value after default successively decreasing, if, then judge that the read operation of the second process to data field corresponding to described node terminates, otherwise, judge that the read operation of the second process to data field corresponding to described node does not terminate.
18. devices according to claim 14, is characterized in that, described device also comprises:
Internal memory release module, after inserting in described chained list in described chained list update module by the second data field, discharges the memory headroom of described first data field.
CN201310370343.2A 2013-08-22 2013-08-22 Method and device for sharing memory by multi-process operation Active CN104424030B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310370343.2A CN104424030B (en) 2013-08-22 2013-08-22 Method and device for sharing memory by multi-process operation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310370343.2A CN104424030B (en) 2013-08-22 2013-08-22 Method and device for sharing memory by multi-process operation

Publications (2)

Publication Number Publication Date
CN104424030A true CN104424030A (en) 2015-03-18
CN104424030B CN104424030B (en) 2020-01-14

Family

ID=52973095

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310370343.2A Active CN104424030B (en) 2013-08-22 2013-08-22 Method and device for sharing memory by multi-process operation

Country Status (1)

Country Link
CN (1) CN104424030B (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106776145A (en) * 2016-12-29 2017-05-31 上海爱数信息技术股份有限公司 The control method of DB Backup performance, system and server
CN106980551A (en) * 2017-03-24 2017-07-25 山东浪潮商用系统有限公司 A kind of Way of Process Communication and device
CN107704325A (en) * 2016-08-08 2018-02-16 北京百度网讯科技有限公司 Method and apparatus for transmitting message between process
CN109298935A (en) * 2018-09-06 2019-02-01 华泰证券股份有限公司 A kind of method and application of the multi-process single-write and multiple-read without lock shared drive
CN110020328A (en) * 2019-04-16 2019-07-16 北京字节跳动网络技术有限公司 Data processing method, device, electronic equipment and the storage medium of online table
CN111162947A (en) * 2019-12-30 2020-05-15 北京天融信网络安全技术有限公司 PCRE hot switching method, network device and storage medium
US10884830B1 (en) 2019-07-16 2021-01-05 Advanced New Technologies Co., Ltd. Method and apparatus for multithreaded data transmission in a tee system
US10943006B2 (en) 2019-07-16 2021-03-09 Advanced New Technologies Co., Ltd. Method and apparatus for multithreaded data transmission in a TEE system
US11042642B2 (en) 2019-07-16 2021-06-22 Advanced New Technologies Co., Ltd. Method and apparatus for data transmission in a TEE system
WO2021249106A1 (en) * 2020-06-11 2021-12-16 中兴通讯股份有限公司 Memory operation control method, device, and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050278482A1 (en) * 2004-06-10 2005-12-15 Kouichi Ohtsubo Method and system for data processing for controlling a cache memory
CN1908934A (en) * 2006-08-02 2007-02-07 华为技术有限公司 Online updating control method and device of embedded database
CN101470632A (en) * 2007-12-24 2009-07-01 华为软件技术有限公司 Sharing internal memory management method and apparatus
US20110022813A1 (en) * 2007-11-28 2011-01-27 Kyoto Software Research, Inc. Data storage system and data storage program
CN103164384A (en) * 2011-12-15 2013-06-19 中国银联股份有限公司 Synchronous achieving method and system of multimachine system shared memory

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050278482A1 (en) * 2004-06-10 2005-12-15 Kouichi Ohtsubo Method and system for data processing for controlling a cache memory
CN1908934A (en) * 2006-08-02 2007-02-07 华为技术有限公司 Online updating control method and device of embedded database
US20110022813A1 (en) * 2007-11-28 2011-01-27 Kyoto Software Research, Inc. Data storage system and data storage program
CN101470632A (en) * 2007-12-24 2009-07-01 华为软件技术有限公司 Sharing internal memory management method and apparatus
CN103164384A (en) * 2011-12-15 2013-06-19 中国银联股份有限公司 Synchronous achieving method and system of multimachine system shared memory

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107704325A (en) * 2016-08-08 2018-02-16 北京百度网讯科技有限公司 Method and apparatus for transmitting message between process
CN107704325B (en) * 2016-08-08 2021-08-27 北京百度网讯科技有限公司 Method and device for transmitting messages between processes
CN106776145A (en) * 2016-12-29 2017-05-31 上海爱数信息技术股份有限公司 The control method of DB Backup performance, system and server
CN106776145B (en) * 2016-12-29 2020-04-03 上海爱数信息技术股份有限公司 Method, system and server for controlling database backup performance
CN106980551A (en) * 2017-03-24 2017-07-25 山东浪潮商用系统有限公司 A kind of Way of Process Communication and device
CN109298935A (en) * 2018-09-06 2019-02-01 华泰证券股份有限公司 A kind of method and application of the multi-process single-write and multiple-read without lock shared drive
CN110020328A (en) * 2019-04-16 2019-07-16 北京字节跳动网络技术有限公司 Data processing method, device, electronic equipment and the storage medium of online table
WO2021008111A1 (en) * 2019-07-16 2021-01-21 创新先进技术有限公司 Multi-thread data transmission method and device in tee system
US10896075B1 (en) 2019-07-16 2021-01-19 Advanced New Technologies Co., Ltd. Method and apparatus for multithreaded data transmission in a TEE system
US10884830B1 (en) 2019-07-16 2021-01-05 Advanced New Technologies Co., Ltd. Method and apparatus for multithreaded data transmission in a tee system
US10943006B2 (en) 2019-07-16 2021-03-09 Advanced New Technologies Co., Ltd. Method and apparatus for multithreaded data transmission in a TEE system
US11042642B2 (en) 2019-07-16 2021-06-22 Advanced New Technologies Co., Ltd. Method and apparatus for data transmission in a TEE system
CN111162947A (en) * 2019-12-30 2020-05-15 北京天融信网络安全技术有限公司 PCRE hot switching method, network device and storage medium
WO2021249106A1 (en) * 2020-06-11 2021-12-16 中兴通讯股份有限公司 Memory operation control method, device, and storage medium

Also Published As

Publication number Publication date
CN104424030B (en) 2020-01-14

Similar Documents

Publication Publication Date Title
CN104424030A (en) Sharing memory multi-process operation method and device
CN104423894B (en) Data memory device and method for controlling flash memory
CN102063384B (en) Method for performing read-write operation on programmable read-only memory with cache by JAVA card
CN103677884B (en) Flash subarea list file is generated and its data updating method, device
CN104350546A (en) Row hammer refresh command
CN104246727B (en) Data handling system and the method for operating data processing system
CN106557427B (en) Memory management method and device for shared memory database
CN106919517B (en) Flash memory and access method thereof
WO2014185037A1 (en) Data storage system and control method thereof
CN112840325A (en) Error checking in namespace on storage device
CN110781016B (en) Data processing method, device, equipment and medium
CN102541969A (en) File protection method and system based on file allocation table (FAT) file system, and memory
JP2010515128A (en) Method for managing data in non-volatile memory
CN110287695A (en) A kind of management method of Java card and its temporary object
CN104268097A (en) Metadata processing method and system
CN103617135B (en) The method and device of digital independent in a kind of storage device
KR100825802B1 (en) Data write method of non-volatile memory device copying data having logical pages prior to logical page of write data from data block
CN105404591A (en) Processor system and storer control method for same
CN114489487A (en) Data storage protection method and system
CN102902629A (en) Storage space mapping method and storage space mapping device
KR101465426B1 (en) Extent mapping flash device
CN110874273B (en) Data processing method and device
Chung et al. STAFF: state transition applied fast flash translation layer
US6898680B2 (en) Minimization of overhead of non-volatile memory operation
CN105868129B (en) Embedded system demarcate when working page and refer to page switching method

Legal Events

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