CN106648939A - Method and equipment for inter-process resource sharing - Google Patents
Method and equipment for inter-process resource sharing Download PDFInfo
- Publication number
- CN106648939A CN106648939A CN201611261263.3A CN201611261263A CN106648939A CN 106648939 A CN106648939 A CN 106648939A CN 201611261263 A CN201611261263 A CN 201611261263A CN 106648939 A CN106648939 A CN 106648939A
- Authority
- CN
- China
- Prior art keywords
- shared
- shared drive
- synchronization control
- access
- processes
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/544—Buffers; Shared memory; Pipes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5016—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention provides method and equipment for inter-process resource sharing. Compared with the prior art, the method is characterized in that a first process creates or opens a file-mapping kernel object corresponding to a shared memory so that the shared memory is accessed through the file-mapping kernel object; the first process determines access state of the shared memory according to synchronous control marks corresponding to all the shared processes; when the shared memory is in an accessible state, the first process accesses the shared memory to write data into the shared memory or read data written in by the other shared processes from the shared memory; thus, multiple two-way corrective communications among multiple processes are realized and resource sharing efficiency is improved.
Description
Technical field
The application is related to field of computer technology, more particularly to a kind of technology for resource-sharing between process.
Background technology
Shared drive refers to the shared same internal memory of permission two or more processes, for example, by by this block internal memory pair
The address of cache answered is to the independent address space of each process oneself, so that these processes can be in communication with each other, and it is existing
In technology, for the resource-sharing between process, the unidirectional correct communication issue of single is solve only, or solve only sharing not
There is synchronization, otherwise solve synchronously do not share, therefore, resource-sharing is less efficient, also there is limitation, it is impossible to give full play to altogether
Enjoy the effect of internal memory.
The content of the invention
The purpose of the application is to provide a kind of method and apparatus for resource-sharing between process.
According to the one side of the application, there is provided a kind of method for resource-sharing between process, wherein, the method bag
Include:
First process creation opens File Mapping kernel objects corresponding with shared drive, with by the File Mapping
Kernel objects access the shared drive;
First process determines the access of the shared drive according to the corresponding Synchronization Control mark of all shared processes
State;
When the access state of the shared drive is to may have access to, first process accesses the shared drive, with to
The shared drive write data read the data of other shared process writes from the shared drive.
Further, wherein, the first process creation or open corresponding with shared drive File Mapping kernel objects, wrap
Include:
When the File Mapping kernel objects that there are no other shared process creations, text described in first process creation
Part maps kernel objects, so that other shared processes open the File Mapping kernel objects;
Or when there are other File Mapping kernel objects described in shared process creation, first process opens the text
Part maps kernel objects.
Further, wherein, it is described may have access to include it is writeable and readable, wherein, it is described when the access of the shared drive
When state is to may have access to, first process accesses the shared drive, to write data or from institute to the shared drive
Stating shared drive and reading the data of other shared processes writes includes:
When the access state of the shared drive is writeable, first process to the shared drive writes data.
Further, wherein, first process is according to the corresponding Synchronization Control mark of all shared processes determines
The access state of shared drive includes:
When the corresponding Synchronization Control mark of all shared processes is all writeable value, the access shape of the shared drive is determined
State for writeable,
First process also includes to after shared drive write data:
By first process corresponding Synchronization Control mark be set to can readings so that other shared processes are according to all common
Enjoy the corresponding Synchronization Control mark of process and determine that the access state of the shared drive is readable.
Further, wherein, it is described may have access to include it is writeable and readable, wherein, it is described when the access of the shared drive
When state is to may have access to, first process accesses the shared drive, to write data or from institute to the shared drive
The data that shared drive reads other shared process writes are stated, including:
When the access state of the shared drive is readable, first process is read by second from the shared drive
The data of shared process write.
Further, wherein, first process is according to the corresponding Synchronization Control mark of all shared processes determines
The access state of shared drive includes:
When exist the corresponding Synchronization Control of arbitrary other shared processes be labeled as can readings, determine the visit of the shared drive
Ask that state is readable;
First process is read after data from the shared drive, is also included:
Change described second and share the corresponding Synchronization Control mark of process, wherein, when the institute in addition to the second shared process
There is shared process to read after data from the shared drive, the Synchronization Control mark is modified to writeable value.
Further, wherein, the method also includes:
First process obtains the state of cue mark;
First process determines the access of the shared drive according to the corresponding Synchronization Control mark of all shared processes
State includes:
When cue mark is in triggering state, first process is according to the corresponding Synchronization Control mark of all shared processes
Determine the access state of the shared drive.
Further, wherein, the cue mark is to trigger first process corresponding same according to all shared processes
After the access state of the step control mark determination shared drive, non-triggering state is reduced to;
And first process is accessed after the shared drive, is also included:
The cue mark is set to triggering state by first process.
Further, wherein, when the access state when the shared drive is to may have access to, first process is accessed
The shared drive, to write data to the shared drive or read other shared process writes from the shared drive
Data include:
When there is the corresponding Synchronization Control of arbitrary other shared processes and being labeled as non-zero, first process is from described common
Enjoy internal memory to read by the data of the second shared process write, and the value for sharing the corresponding Synchronization Control mark of process by described second
Subtract one, while will be prompted to mark is set to triggering state;
When the corresponding Synchronization Control of all shared processes is labeled as zero, first process writes to the shared drive
Data, and the corresponding Synchronization Control mark of first process is set to preset value, while the cue mark is set to into triggering
State, wherein, the preset value is that the quantity of all shared processes subtracts one.
Further, wherein, the cue mark includes event kernel objects or semaphore.
According to the another aspect of the application, a kind of equipment for resource-sharing between process is additionally provided, wherein, the equipment
Including:
First device, for controlling the first process creation or opening File Mapping kernel objects corresponding with shared drive,
To access the shared drive by the File Mapping kernel objects;
Second device, institute is determined for controlling first process according to the corresponding Synchronization Control mark of all shared processes
State the access state of shared drive;
3rd device, for when the access state of the shared drive is to may have access to, controlling first process and accessing
The shared drive, to write data to the shared drive or read other shared process writes from the shared drive
Data.
Further, wherein, the first device is used for:
When the File Mapping kernel objects that there are no other shared process creations, the first process creation institute is controlled
File Mapping kernel objects are stated, so that other shared processes open the File Mapping kernel objects;
Or when there are other File Mapping kernel objects described in shared process creation, controlling first process and opening institute
State File Mapping kernel objects.
Further, wherein, it is described may have access to include it is writeable and readable, wherein, the 3rd device is used for:
When the access state of the shared drive is writeable, controls first process and write number to the shared drive
According to.
Further, wherein, the second device is used for:
When the corresponding Synchronization Control mark of all shared processes is all writeable value, the access shape of the shared drive is determined
State for writeable,
The 3rd device controls first process and is additionally operable to after shared drive write data:
By first process corresponding Synchronization Control mark be set to can readings so that other shared processes are according to all common
Enjoy the corresponding Synchronization Control mark of process and determine that the access state of the shared drive is readable.
Further, wherein, it is described may have access to include it is writeable and readable, wherein, the 3rd device is used for:When described common
When the access state for enjoying internal memory is readable, first process is read by the number of the second shared process write from the shared drive
According to.
Further, wherein, the second device is used for:
When exist the corresponding Synchronization Control of arbitrary other shared processes be labeled as can readings, determine the visit of the shared drive
Ask that state is readable;
The 3rd device controls first process and is additionally operable to from after shared drive reading data:
Change described second and share the corresponding Synchronization Control mark of process, wherein, when the institute in addition to the second shared process
There is shared process to read after data from the shared drive, the Synchronization Control mark is modified to writeable value.
Further, wherein, the equipment also includes:
4th device, for controlling the state that first process obtains cue mark;
The second device is used for:
When cue mark is in triggering state, first process is controlled according to the corresponding Synchronization Control of all shared processes
Mark determines the access state of the shared drive.
Further, wherein, the cue mark is to trigger first process corresponding same according to all shared processes
After the access state of the step control mark determination shared drive, non-triggering state is reduced to;
And first process is accessed after the shared drive, is also included:
5th device, triggering state is set to for controlling first process by the cue mark.
Further, wherein, the 3rd device is used for:
When there is the corresponding Synchronization Control of arbitrary other shared processes and being labeled as non-zero, first process is from described common
Enjoy internal memory to read by the data of the second shared process write, and the value for sharing the corresponding Synchronization Control mark of process by described second
Subtract one, while will be prompted to mark is set to triggering state;
When the corresponding Synchronization Control of all shared processes is labeled as zero, first process writes to the shared drive
Data, and the corresponding Synchronization Control mark of first process is set to preset value, while the cue mark is set to into triggering
State, wherein, the preset value is that the quantity of all shared processes subtracts one.
Further, wherein, the cue mark includes event kernel objects or semaphore.
Compared with prior art, the application is by the first process creation or opens in File Mapping corresponding with shared drive
Verification is as to access the shared drive by the File Mapping kernel objects, then first process is according to all common
The access state that the corresponding Synchronization Control mark of process determines the shared drive is enjoyed, when the access state of the shared drive is
When addressable, first process accesses the shared drive, to write data to the shared drive or share from described
Internal memory reads the data of other shared process writes, realizes in this way multiple two-way correct between multiple processes
Communication, improves the sharing efficiency of resource.
Description of the drawings
By reading the detailed description made to non-limiting example made with reference to the following drawings, other of the invention
Feature, objects and advantages will become more apparent upon:
Fig. 1 illustrates a kind of method flow diagram for resource-sharing between process according to the application one side;
Fig. 2 is illustrated and illustrated according to a kind of interaction for being used for resource-sharing between two processes of one preferred embodiment of the application
Figure;
Fig. 3 illustrates a kind of equipment schematic diagram for resource-sharing between process according to the application other side.
Same or analogous reference represents same or analogous part in accompanying drawing.
Specific embodiment
The present invention is described in further detail below in conjunction with the accompanying drawings.
In one typical configuration of the application, terminal, the equipment of service network and trusted party include one or more
Processor (CPU), input/output interface, network interface and internal memory.
Internal memory potentially includes the volatile memory in computer-readable medium, random access memory (RAM) and/or
The forms such as Nonvolatile memory, such as read-only storage (ROM) or flash memory (flash RAM).Internal memory is computer-readable medium
Example.
Computer-readable medium includes that permanent and non-permanent, removable and non-removable media can be by any method
Or technology is realizing information Store.Information can be computer-readable instruction, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase transition internal memory (PRAM), static RAM (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only storage (ROM), electric erasable
Programmable read only memory (EEPROM), fast flash memory bank or other memory techniques, read-only optical disc read-only storage (CD-ROM),
Digital versatile disc (DVD) or other optical storages, magnetic cassette tape, magnetic disk storage or other magnetic storage apparatus or
Any other non-transmission medium, can be used to store the information that can be accessed by a computing device.Define according to herein, computer
Computer-readable recording medium does not include non-temporary computer readable media (transitory media), the such as data-signal and carrier wave of modulation.
It is below in conjunction with the accompanying drawings and preferably real further to illustrate the effect of technological means that the application taken and acquirement
Example is applied, the technical scheme to the application carries out clear and complete description.
Fig. 1 illustrates a kind of method flow diagram for resource-sharing between process provided on one side according to the application, its
In, the method includes:
The process creations of S1 first open File Mapping kernel objects corresponding with shared drive, to be reflected by the file
Penetrate kernel objects and access the shared drive;
First process described in S2 determines the visit of the shared drive according to the corresponding Synchronization Control mark of all shared processes
Ask state;
When the access state of the shared drive is to may have access to, first process accesses the shared drive to S3, with
Data are write to the shared drive or read the data of other shared process writes from the shared drive.
In this embodiment, in step S1, the first process creation or opening file corresponding with shared drive reflect
Kernel objects are penetrated, to access the shared drive by the File Mapping kernel objects.Here, first process is all
Arbitrary process in shared process, for example, will realize the memory sharing between five processes, and first process is entered for this five
Arbitrary process in journey.Wherein, the address of the File Mapping kernel objects correspondence shared drive, all shared processes can lead to
Cross the address of cache of the corresponding shared drive of the File Mapping kernel objects to the address space of oneself, obtain sensing described
The pointer of shared drive, to realize the access to the shared drive.
Wherein, the first process creation or opening File Mapping kernel objects corresponding with shared drive, including:When not existing
The File Mapping kernel objects of other shared process creations, File Mapping kernel objects described in first process creation,
So that other shared processes open the File Mapping kernel objects;Or reflect when there are other files described in shared process creation
Kernel objects are penetrated, first process opens the File Mapping kernel objects.I.e. all shared processes are mapped by this document
Kernel objects realize the access to the shared drive.Specifically, the first process or other titles of shared process to arrange
The File Mapping kernel objects are created, and the File Mapping kernel objects are opened by the title of the agreement.
Continue in this embodiment, in step S2, first process is corresponding same according to all shared processes
Step control mark determines the access state of the shared drive;Further, in step S3, when the shared drive
When access state is to may have access to, first process accesses the shared drive, with to the shared drive write data or
The data of other shared process writes are read from the shared drive.Here, the Synchronization Control mark can be counter.
Preferably, wherein, it is described may have access to include it is writeable and readable, wherein, step S3 includes:When described shared interior
When the access state deposited is writeable, first process to the shared drive writes data or the visit when the shared drive
Ask state for it is readable when, first process is read by the data of the second shared process write from the shared drive.Here, institute
State the second process and refer to other arbitrary processes in all shared processes in addition to first process.Those skilled in the art should
It is understood that, for the access of shared drive includes writing data (such as changing data) and reads data etc., and writes data and read data
Can not carry out simultaneously, therefore, when the shared drive in can write state when, it is possible to achieve write data, when it is described it is shared in
Deposit in readable state when, it is possible to achieve read data.
Preferably, in this programme, by way of Synchronization Control being set and is marked the writeable of the shared drive is corresponded to
Or readable state, each shared process can correspond to Synchronization Control mark.Specifically, in one case, it is determined that working as
When the corresponding Synchronization Control mark of all shared processes is all writeable value, the access state for determining the shared drive be it is writeable,
Here, writeable value is certain numerical value set in advance, i.e., when the corresponding Synchronization Control mark of all shared processes is advance all for this
During certain numerical value of setting, the access state of the shared drive is writeable, and the generally numerical value is arranged to zero.
Wherein, first process also includes to after shared drive write data:By first process correspondence
Synchronization Control mark be set to can readings so that other shared processes are true according to the corresponding Synchronization Control mark of all shared processes
The access state of the fixed shared drive is readable.Those skilled in the art will be understood that the first process write data
Read data in order to other shared processes, it is described can readings be used to point out other shared process readable datas.
In another case, when exist the corresponding Synchronization Control of arbitrary other shared processes be labeled as can readings, it is described
First process determines that the access state of the shared drive is readable, therefore, first process reads from the shared drive
Data, after data are read, the corresponding Synchronization Control mark of process is shared in the first process modification described second, wherein,
After all shared process in addition to the second shared process reads data from the shared drive, the Synchronization Control mark
It is modified to writeable value.
In this programme, when arbitrary shared process is to after shared drive write data, can be by corresponding synchronous control
Mark processed be set to can readings, to point out other shared process readable datas, and other processes can be changed after data are read
This can readings, to represent that the process have read data, until except write data process in addition to all shared process all read
Data, the Synchronization Control mark is modified to writeable value.This mode, can realize when other all shared processes are all read
After the data of the last write of process of complete write data, new data could be write.
Preferably, methods described also includes:First process described in S4 (not shown) obtains the state of cue mark;It is preferred that
Ground, the cue mark includes event kernel objects or semaphore.Here, when the cue mark is in triggering state,
First process determines the access state of the shared drive according to the corresponding Synchronization Control mark of all shared processes.Its
In, the cue mark trigger first process determined according to the corresponding Synchronization Control mark of all shared processes it is described common
After enjoying the access state of internal memory, non-triggering state is reduced to;And first process is accessed after the shared drive, also
Including:The cue mark is set to triggering state by the first process described in S5 (not shown).
In this case, it is tactile to point out arbitrary shared process to be in the cue mark by way of cue mark
During hair-like state, the access state of the shared drive is determined according to the corresponding Synchronization Control mark of all shared processes, so as to reality
Now to the access of the shared process, and work as arbitrary shared process and access after the shared drive, the process can be carried described
Indicating note is set to triggering state, is determined according to the corresponding Synchronization Control mark of all shared processes for other shared processes
The access state of the shared drive.In this way, realize that multiple shared processes are accessed the shared drive is mutual
Scold.
In a preferred embodiment, writeable value can be arranged to zero, wherein, step S3 includes:Appoint when existing
When the corresponding Synchronization Control of one other shared processes is labeled as non-zero, first process is read by second from the shared drive
The data of shared process write, and the value that described second shares the corresponding Synchronization Control mark of process is subtracted one, while will be prompted to
Mark is set to triggering state;
When the corresponding Synchronization Control of all shared processes is labeled as zero, first process writes to the shared drive
Data, and the corresponding Synchronization Control mark of first process is set to preset value, while the cue mark is set to into triggering
State, wherein, the preset value is that the quantity of all shared processes subtracts one.
Fig. 2 is illustrated and illustrated according to a kind of interaction for being used for resource-sharing between two processes of one preferred embodiment of the application
Figure, in this embodiment, comprising two processes, process 1 and process 2, comprising two Synchronization Control marks:Synchronization Control mark 1
With Synchronization Control mark 2, in this embodiment, event kernel objects as cue mark, wherein, event kernel objects have signal
Correspondence cue mark is in triggering state.Dotted line represents horizontal flow process between process in figure, and solid line represents longitudinal procedure in process.
Specifically, the establishment file of process 1 mapping kernel objects, process 1 is by File Mapping kernel objects corresponding internal memory ground
Location is mapped to the address space of oneself, and a view of mapping object obtains pointing to the pointer of shared drive, in addition, process 1 is created
Build event kernel objects and make it have signal, process 2 opens File Mapping kernel objects with the name of File Mapping kernel objects
Its handle is obtained, process 2 is by the corresponding memory address mappings of File Mapping kernel objects to the address space of oneself, mapping object
A view, obtain point to shared drive pointer, so, process 1 and process 2 can be realized to the File Mapping kernel
The corresponding shared drive of object conducts interviews.
By taking process 1 as an example, when process 1 will write data to the shared drive, process 1 waits event kernel objects to have letter
Number, when it has signal, process 1 judges whether the corresponding Synchronization Control mark 2 of process 2 is 0, when the Synchronization Control mark 2 is 0,
And the corresponding Synchronization Control mark 1 of process 1 is also 0, process 1 can write data, and Synchronization Control mark 1 is set to into 1, so that
Process 2 reads data, and the event kernel objects of making have signal, to point out process 2 to may have access to the shared drive.
And work as Synchronization Control mark 2 and do not write data for 0, i.e. process 2, then process 1 reads the data, and by synchronous control
The value of mark processed 2 subtracts 1, and the event kernel objects of making have signal, to point out process 2 to may have access to the shared drive.
When Synchronization Control mark 2 is 0, and Synchronization Control mark 1 did not write data for 0, i.e. process 1, but process 2 is not read
The data are taken, then process 1 makes event kernel objects have signal, to point out process 2 to may have access to the shared drive, so as to ensure only
Have after digital independent, can just there is new data write.
Compared with prior art, the application is by the first process creation or opens in File Mapping corresponding with shared drive
Verification is as to access the shared drive by the File Mapping kernel objects, then first process is according to all common
The access state that the corresponding Synchronization Control mark of process determines the shared drive is enjoyed, when the access state of the shared drive is
When addressable, first process accesses the shared drive, to write data to the shared drive or share from described
Internal memory reads the data of other shared process writes, realizes in this way multiple two-way correct between multiple processes
Communication, improves the sharing efficiency of resource.
Fig. 3 illustrates a kind of equipment schematic diagram for resource-sharing between process provided on one side according to the application, its
In, the equipment includes:
First device, for controlling the first process creation or opening File Mapping kernel objects corresponding with shared drive,
To access the shared drive by the File Mapping kernel objects;
Second device, institute is determined for controlling first process according to the corresponding Synchronization Control mark of all shared processes
State the access state of shared drive;
3rd device, for when the access state of the shared drive is to may have access to, controlling first process and accessing
The shared drive, to write data to the shared drive or read other shared process writes from the shared drive
Data.
In this embodiment, the first device controls the first process creation or opening file corresponding with shared drive reflects
Kernel objects are penetrated, to access the shared drive by the File Mapping kernel objects.Here, first process is all
Arbitrary process in shared process, for example, will realize the memory sharing between five processes, and first process is entered for this five
Arbitrary process in journey.Wherein, the address of the File Mapping kernel objects correspondence shared drive, all shared processes can lead to
Cross the address of cache of the corresponding shared drive of the File Mapping kernel objects to the address space of oneself, obtain sensing described
The pointer of shared drive, to realize the access to the shared drive.
Wherein, the first process creation or opening File Mapping kernel objects corresponding with shared drive, including:When not existing
The File Mapping kernel objects of other shared process creations, File Mapping kernel objects described in first process creation,
So that other shared processes open the File Mapping kernel objects;Or reflect when there are other files described in shared process creation
Kernel objects are penetrated, first process opens the File Mapping kernel objects.I.e. all shared processes are mapped by this document
Kernel objects realize the access to the shared drive.Specifically, the first process or other titles of shared process to arrange
The File Mapping kernel objects are created, and the File Mapping kernel objects are opened by the title of the agreement.
Continue in this embodiment, it is corresponding same according to all shared processes that the second device controls first process
Step control mark determines the access state of the shared drive;Further, when the access state of the shared drive is to visit
When asking, the 3rd device controls first process and accesses the shared drive, with to the shared drive write data or
Person reads the data of other shared process writes from the shared drive.
Preferably, wherein, it is described may have access to include it is writeable and readable, wherein, the 3rd device is used for:When described shared
When the access state of internal memory is writeable, first process writes data or when the shared drive to the shared drive
When access state is readable, first process is read by the data of the second shared process write from the shared drive.Here,
Second process refers to other the arbitrary processes in all shared processes in addition to first process.Those skilled in the art
It will be understood that for the access of shared drive includes writing data (such as changing data) and reads data etc., and write data and reading
According to can not carry out simultaneously, therefore, when the shared drive in can write state when, it is possible to achieve write data, when described shared
When internal memory is in readable state, it is possible to achieve read data.
Preferably, in this programme, by way of Synchronization Control being set and is marked the writeable of the shared drive is corresponded to
Or readable state, each shared process can correspond to Synchronization Control mark.Specifically, in one case, it is determined that working as
When the corresponding Synchronization Control mark of all shared processes is all writeable value, the access state for determining the shared drive be it is writeable,
Here, writeable value is certain numerical value set in advance, i.e., when the corresponding Synchronization Control mark of all shared processes is advance all for this
During certain numerical value of setting, the access state of the shared drive is writeable, and the generally numerical value is arranged to zero.
Wherein, the 3rd device controls first process to after shared drive write data, be additionally operable to by
The corresponding Synchronization Control mark of first process be set to can readings so that other shared processes are according to all shared processes correspondences
Synchronization Control mark determine that the access state of the shared drive is readable.Those skilled in the art will be understood that described
First process writes data and reads data in order to other shared processes, it is described can readings be used to point out other shared processes readable
Fetch data.
In another case, when exist the corresponding Synchronization Control of arbitrary other shared processes be labeled as can readings, it is described
First process determines that the access state of the shared drive is readable, therefore, first process reads from the shared drive
Data, after data are read, it is corresponding same that the 3rd device controls the first process modification second shared process
Step control mark, wherein, after all shared process in addition to the second shared process reads data from the shared drive,
The Synchronization Control mark is modified to writeable value.
In this programme, when arbitrary shared process is to after shared drive write data, can be by corresponding synchronous control
Mark processed be set to can readings, to point out other shared process readable datas, and other processes can be changed after data are read
This can readings, to represent that the process have read data, until except write data process in addition to all shared process all read
Data, the Synchronization Control mark is modified to writeable value.This mode, can realize when other all shared processes are all read
After the data of the last write of process of complete write data, new data could be write.
Preferably, the equipment also includes:4th device (not shown), for controlling first process prompting mark is obtained
The state of note;Preferably, the cue mark includes event kernel objects or semaphore.Here, at the cue mark
When triggering state, first process determines the shared drive according to the corresponding Synchronization Control mark of all shared processes
Access state.Wherein, the cue mark is triggering first process according to the corresponding Synchronization Control mark of all shared processes
After the access state of the note determination shared drive, non-triggering state is reduced to;And first process accesses described common
After enjoying internal memory, the equipment also includes:5th device (not shown), for controlling first process by the cue mark
It is set to triggering state.
In this case, it is tactile to point out arbitrary shared process to be in the cue mark by way of cue mark
During hair-like state, the access state of the shared drive is determined according to the corresponding Synchronization Control mark of all shared processes, so as to reality
Now to the access of the shared process, and work as arbitrary shared process and access after the shared drive, the process can be carried described
Indicating note is set to triggering state, is determined according to the corresponding Synchronization Control mark of all shared processes for other shared processes
The access state of the shared drive.In this way, realize that multiple shared processes are accessed the shared drive is mutual
Scold.
In a preferred embodiment, writeable value can be arranged to zero, wherein, the 3rd device is used for:Work as presence
When the corresponding Synchronization Control of arbitrary other shared processes is labeled as non-zero, first process is read by the from the shared drive
The data of two shared process writes, and the value that described second shares the corresponding Synchronization Control mark of process is subtracted one, while will carry
Indicating note is set to triggering state;
When the corresponding Synchronization Control of all shared processes is labeled as zero, first process writes to the shared drive
Data, and the corresponding Synchronization Control mark of first process is set to preset value, while the cue mark is set to into triggering
State, wherein, the preset value is that the quantity of all shared processes subtracts one.
Compared with prior art, the application is by the first process creation or opens in File Mapping corresponding with shared drive
Verification is as to access the shared drive by the File Mapping kernel objects, then first process is according to all common
The access state that the corresponding Synchronization Control mark of process determines the shared drive is enjoyed, when the access state of the shared drive is
When addressable, first process accesses the shared drive, to write data to the shared drive or share from described
Internal memory reads the data of other shared process writes, realizes in this way multiple two-way correct between multiple processes
Communication, improves the sharing efficiency of resource.
It is obvious to a person skilled in the art that the invention is not restricted to the details of above-mentioned one exemplary embodiment, Er Qie
In the case of spirit or essential attributes without departing substantially from the present invention, the present invention can be in other specific forms realized.Therefore, no matter
From the point of view of which point, embodiment all should be regarded as exemplary, and be nonrestrictive, the scope of the present invention is by appended power
Profit is required rather than described above is limited, it is intended that all in the implication and scope of the equivalency of claim by falling
Change is included in the present invention.Any reference in claim should not be considered as and limit involved claim.This
Outward, it is clear that " including ", a word was not excluded for other units or step, and odd number is not excluded for plural number.That what is stated in device claim is multiple
Unit or device can also be realized by a unit or device by software or hardware.The first, the second grade word is used for table
Show title, and be not offered as any specific order.
Claims (20)
1. a kind of method for resource-sharing between process, wherein, the method includes:
First process creation opens File Mapping kernel objects corresponding with shared drive, with by the File Mapping kernel
Shared drive described in object accesses;
First process determines the access state of the shared drive according to the corresponding Synchronization Control mark of all shared processes;
When the access state of the shared drive is to may have access to, first process accesses the shared drive, with to described
Shared drive writes data or reads the data of other shared process writes from the shared drive.
2. method according to claim 1, wherein, the first process creation or open File Mapping corresponding with shared drive
Kernel objects, including:
When the File Mapping kernel objects that there are no other shared process creations, file described in first process creation reflects
Kernel objects are penetrated, so that other shared processes open the File Mapping kernel objects;
Or when there are other File Mapping kernel objects described in shared process creation, first process is opened the file and is reflected
Penetrate kernel objects.
3. method according to claim 1, wherein, it is described may have access to include it is writeable and readable, wherein, it is described when described common
When enjoying the access state of internal memory to may have access to, first process accesses the shared drive to be included:
When the access state of the shared drive is writeable, first process to the shared drive writes data.
4. method according to claim 3, wherein, first process is according to the corresponding Synchronization Control of all shared processes
Mark determines that the access state of the shared drive includes:
When the corresponding Synchronization Control mark of all shared processes is all writeable value, the access state for determining the shared drive is
It is writeable,
First process also includes to after shared drive write data:
By first process corresponding Synchronization Control mark be set to can readings so that other shared processes according to it is all share into
The corresponding Synchronization Control mark of journey determines that the access state of the shared drive is readable.
5. method according to claim 1, wherein, it is described may have access to include it is writeable and readable, wherein, it is described when described common
When enjoying the access state of internal memory to may have access to, first process accesses the shared drive to be included:
When the access state of the shared drive is readable, first process reads from the shared drive to be shared by second
The data of process write.
6. method according to claim 5, wherein, first process is according to the corresponding Synchronization Control of all shared processes
Mark determines that the access state of the shared drive includes:
When exist the corresponding Synchronization Control of arbitrary other shared processes be labeled as can readings, determine the access shape of the shared drive
State is readable;
First process is read after data from the shared drive, is also included:
Change described second and share the corresponding Synchronization Control mark of process, wherein, when all common in addition to the second shared process
Enjoy process to read after data from the shared drive, the Synchronization Control mark is modified to writeable value.
7. method according to claim 1, wherein, the method also includes:
First process obtains the state of cue mark;
First process determines the access state of the shared drive according to the corresponding Synchronization Control mark of all shared processes
Including:
When cue mark is in triggering state, first process determines according to the corresponding Synchronization Control mark of all shared processes
The access state of the shared drive.
8. method according to claim 7, wherein, the cue mark is triggering first process according to all shared
After the access state of the process corresponding Synchronization Control mark determination shared drive, non-triggering state is reduced to;
And first process is accessed after the shared drive, is also included:
The cue mark is set to triggering state by first process.
9. method according to claim 8, wherein, described when the access state of the shared drive is to may have access to, institute
Stating the first process access shared drive includes:
When there is the corresponding Synchronization Control of arbitrary other shared processes and being labeled as non-zero, first process from it is described it is shared in
Deposit and read by the data of the second shared process write, and the value that described second shares the corresponding Synchronization Control mark of process is subtracted
One, while will be prompted to mark is set to triggering state;
When the corresponding Synchronization Control of all shared processes is labeled as zero, first process to the shared drive writes number
According to, and the corresponding Synchronization Control mark of first process is set to preset value, while the cue mark is set to trigger shape
State, wherein, the preset value is that the quantity of all shared processes subtracts one.
10. the method according to any one of claim 7 to 9, wherein, the cue mark include event kernel objects or
Person's semaphore.
A kind of 11. equipment for resource-sharing between process, wherein, the equipment includes:
First device, for controlling the first process creation or opening File Mapping kernel objects corresponding with shared drive, with logical
Cross the File Mapping kernel objects and access the shared drive;
Second device, for control first process determined according to the corresponding Synchronization Control mark of all shared processes it is described common
Enjoy the access state of internal memory;
3rd device, accesses described for when the access state of the shared drive is to may have access to, controlling first process
Shared drive, to write data to the shared drive or read the number of other shared process writes from the shared drive
According to.
12. equipment according to claim 11, wherein, the first device is used for:
When the File Mapping kernel objects that there are no other shared process creations, text described in first process creation is controlled
Part maps kernel objects, so that other shared processes open the File Mapping kernel objects;
Or when there are other File Mapping kernel objects described in shared process creation, controlling first process and opening the text
Part maps kernel objects.
13. equipment according to claim 11, wherein, it is described may have access to include it is writeable and readable, wherein, it is described 3rd fill
Put for:
When the access state of the shared drive is writeable, controls first process and write data to the shared drive.
14. equipment according to claim 13, wherein, the second device is used for:
When the corresponding Synchronization Control mark of all shared processes is all writeable value, the access state for determining the shared drive is
It is writeable,
The 3rd device controls first process and is additionally operable to after shared drive write data:
By first process corresponding Synchronization Control mark be set to can readings so that other shared processes according to it is all share into
The corresponding Synchronization Control mark of journey determines that the access state of the shared drive is readable.
15. equipment according to claim 11, wherein, it is described may have access to include it is writeable and readable, wherein, it is described 3rd fill
Put for:
When the access state of the shared drive is readable, first process reads from the shared drive to be shared by second
The data of process write.
16. equipment according to claim 15, wherein, the second device is used for:
When exist the corresponding Synchronization Control of arbitrary other shared processes be labeled as can readings, determine the access shape of the shared drive
State is readable;
The 3rd device controls first process and is additionally operable to from after shared drive reading data:
Change described second and share the corresponding Synchronization Control mark of process, wherein, when all common in addition to the second shared process
Enjoy process to read after data from the shared drive, the Synchronization Control mark is modified to writeable value.
17. equipment according to claim 11, wherein, the equipment also includes:
4th device, for controlling the state that first process obtains cue mark;
The second device is used for:
When cue mark is in triggering state, first process is controlled according to the corresponding Synchronization Control mark of all shared processes
Determine the access state of the shared drive.
18. equipment according to claim 17, wherein, the cue mark is triggering first process according to all common
Enjoy the corresponding Synchronization Control mark of process to determine after the access state of the shared drive, be reduced to non-triggering state;
And first process is accessed after the shared drive, is also included:
5th device, triggering state is set to for controlling first process by the cue mark.
19. equipment according to claim 18, wherein, the 3rd device is used for:
When there is the corresponding Synchronization Control of arbitrary other shared processes and being labeled as non-zero, first process from it is described it is shared in
Deposit and read by the data of the second shared process write, and the value that described second shares the corresponding Synchronization Control mark of process is subtracted
One, while will be prompted to mark is set to triggering state;
When the corresponding Synchronization Control of all shared processes is labeled as zero, first process to the shared drive writes number
According to, and the corresponding Synchronization Control mark of first process is set to preset value, while the cue mark is set to trigger shape
State, wherein, the preset value is that the quantity of all shared processes subtracts one.
20. equipment according to any one of claim 17 to 19, wherein, the cue mark includes event kernel objects
Or semaphore.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611261263.3A CN106648939A (en) | 2016-12-30 | 2016-12-30 | Method and equipment for inter-process resource sharing |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611261263.3A CN106648939A (en) | 2016-12-30 | 2016-12-30 | Method and equipment for inter-process resource sharing |
Publications (1)
Publication Number | Publication Date |
---|---|
CN106648939A true CN106648939A (en) | 2017-05-10 |
Family
ID=58838013
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201611261263.3A Pending CN106648939A (en) | 2016-12-30 | 2016-12-30 | Method and equipment for inter-process resource sharing |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106648939A (en) |
Cited By (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108171862A (en) * | 2018-01-08 | 2018-06-15 | 北京值得买科技股份有限公司 | A kind of hair method and impulse sender |
CN109086146A (en) * | 2018-07-26 | 2018-12-25 | 郑州云海信息技术有限公司 | A kind of relatively reliable inter-process communication methods based on Boost |
CN109144725A (en) * | 2018-08-02 | 2019-01-04 | 北京达佳互联信息技术有限公司 | Document handling method, device, electronic equipment and storage medium |
CN109542648A (en) * | 2018-11-23 | 2019-03-29 | 凌云光技术集团有限责任公司 | A kind of method and device of striding course communication |
CN109783144A (en) * | 2017-11-13 | 2019-05-21 | 深圳市创客工场科技有限公司 | Processing method, device and the storage medium of variable in virtual environment interaction realization |
CN110069346A (en) * | 2019-04-26 | 2019-07-30 | 杭州迪普科技股份有限公司 | Resource share method, device, electronic equipment between multi-process |
CN111796948A (en) * | 2020-07-02 | 2020-10-20 | 长视科技股份有限公司 | Shared memory access method and device, computer equipment and storage medium |
CN112883003A (en) * | 2021-04-27 | 2021-06-01 | 智道网联科技(北京)有限公司 | Data sharing method and device for vehicle-mounted terminal |
CN113127218A (en) * | 2019-12-31 | 2021-07-16 | 深圳市优必选科技股份有限公司 | Real-time communication method, device and system for robot, controller and robot |
CN114020481A (en) * | 2021-10-22 | 2022-02-08 | 山东浪潮科学研究院有限公司 | Method for preventing multiple processes from accessing same arbitrary waveform generator |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1740978A (en) * | 2004-08-23 | 2006-03-01 | 华为技术有限公司 | Method for realing sharing internal stored data base and internal stored data base system |
US20110265093A1 (en) * | 2010-04-27 | 2011-10-27 | Hitachi, Ltd. | Computer System and Program Product |
CN103441831A (en) * | 2013-08-22 | 2013-12-11 | 焦点科技股份有限公司 | Full-duplex communication between double courses, and mutual protection method and system between double courses |
CN103514053A (en) * | 2013-09-22 | 2014-01-15 | 中国科学院信息工程研究所 | Shared-memory-based method for conducting communication among multiple processes |
-
2016
- 2016-12-30 CN CN201611261263.3A patent/CN106648939A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1740978A (en) * | 2004-08-23 | 2006-03-01 | 华为技术有限公司 | Method for realing sharing internal stored data base and internal stored data base system |
US20110265093A1 (en) * | 2010-04-27 | 2011-10-27 | Hitachi, Ltd. | Computer System and Program Product |
CN103441831A (en) * | 2013-08-22 | 2013-12-11 | 焦点科技股份有限公司 | Full-duplex communication between double courses, and mutual protection method and system between double courses |
CN103514053A (en) * | 2013-09-22 | 2014-01-15 | 中国科学院信息工程研究所 | Shared-memory-based method for conducting communication among multiple processes |
Non-Patent Citations (4)
Title |
---|
FARSIGHT2009: "linux实现共享内存同步的四种方法", 《HTTP:// HOME.EEWORLD.COM.CN/MY/SPACE-UID-138607-BLOGID-226618.HTML》 * |
LANMANCK: "linux进程通信(一)--共享内存+信号量,代码示例", 《HTTPS://BLOG.CSDN.NET/LANMANCK/ARTICLE/DETAILS/6100019》 * |
张华等: "基于Linux 的同步共享内存的研究与实现", 《湖南工业职业技术学院学报》 * |
沙漠里的海豚: "Linux下用信号量实现对共享内存的访问保护(一)", 《WEB.ARCHIVE.ORG/WEB/20111009043940/HTTP://WWW.CPPBLOG.COM/ZJL-1026-2001/ARCHIVE/2010/03/03/108768.HTML》 * |
Cited By (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109783144A (en) * | 2017-11-13 | 2019-05-21 | 深圳市创客工场科技有限公司 | Processing method, device and the storage medium of variable in virtual environment interaction realization |
CN108171862A (en) * | 2018-01-08 | 2018-06-15 | 北京值得买科技股份有限公司 | A kind of hair method and impulse sender |
CN109086146A (en) * | 2018-07-26 | 2018-12-25 | 郑州云海信息技术有限公司 | A kind of relatively reliable inter-process communication methods based on Boost |
CN109144725A (en) * | 2018-08-02 | 2019-01-04 | 北京达佳互联信息技术有限公司 | Document handling method, device, electronic equipment and storage medium |
CN109144725B (en) * | 2018-08-02 | 2020-11-17 | 北京达佳互联信息技术有限公司 | File processing method and device, electronic equipment and storage medium |
CN109542648A (en) * | 2018-11-23 | 2019-03-29 | 凌云光技术集团有限责任公司 | A kind of method and device of striding course communication |
CN110069346A (en) * | 2019-04-26 | 2019-07-30 | 杭州迪普科技股份有限公司 | Resource share method, device, electronic equipment between multi-process |
CN110069346B (en) * | 2019-04-26 | 2021-07-23 | 杭州迪普科技股份有限公司 | Method and device for sharing resources among multiple processes and electronic equipment |
CN113127218A (en) * | 2019-12-31 | 2021-07-16 | 深圳市优必选科技股份有限公司 | Real-time communication method, device and system for robot, controller and robot |
CN111796948A (en) * | 2020-07-02 | 2020-10-20 | 长视科技股份有限公司 | Shared memory access method and device, computer equipment and storage medium |
CN111796948B (en) * | 2020-07-02 | 2021-11-26 | 长视科技股份有限公司 | Shared memory access method and device, computer equipment and storage medium |
CN112883003A (en) * | 2021-04-27 | 2021-06-01 | 智道网联科技(北京)有限公司 | Data sharing method and device for vehicle-mounted terminal |
CN114020481A (en) * | 2021-10-22 | 2022-02-08 | 山东浪潮科学研究院有限公司 | Method for preventing multiple processes from accessing same arbitrary waveform generator |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106648939A (en) | Method and equipment for inter-process resource sharing | |
CN104238963B (en) | A kind of date storage method, storage device and storage system | |
CN105468300B (en) | The management method and device of IP hard disks | |
CN105359097B (en) | Beam file for shared file is permitted | |
CN107315547A (en) | A kind of method and device for reading distributed meta data file | |
CN105830059A (en) | Fine pitch connector socket | |
US8621134B2 (en) | Storage tiering with minimal use of DRAM memory for header overhead | |
CN107111605A (en) | Manage the method and system of file access | |
CN106487850A (en) | The methods, devices and systems of mirror image are obtained under a kind of cloud environment | |
CN106095337A (en) | A kind of cloud disk based on SAN network storage is quickly shared method | |
CN105579977A (en) | File access method, device and storage system | |
CN106096441A (en) | Date storage method and data storage device | |
US9411513B2 (en) | Sensitive data file attribute | |
CN108399050A (en) | A kind of data processing method and device | |
CN107562367A (en) | Method and device based on software implementation storage system read-write data | |
US9703593B2 (en) | Apparatus and method for memory overlay | |
CN107451271A (en) | A kind of Hash table processing method, device, equipment and storage medium | |
CN111581647B (en) | File encryption and decryption method and device | |
US9330016B2 (en) | Systems and methods for managing read-only memory | |
CN106294423A (en) | Data base divides wiring method and the device of table | |
US20110307525A1 (en) | Virtual storage device | |
US9875190B2 (en) | Delegated media translation layer in a storage appliance | |
EP3477463A1 (en) | Method and system for using wear-leveling using a multi-gap progress field | |
CN108614671A (en) | Key-data access method based on NameSpace and solid storage device | |
CN104378431A (en) | Metadata distributed-memory method suitable for cloud storage system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20170510 |