CN108829529A - Virutal machine memory sharing method, device, computer equipment and storage medium - Google Patents
Virutal machine memory sharing method, device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN108829529A CN108829529A CN201810613940.6A CN201810613940A CN108829529A CN 108829529 A CN108829529 A CN 108829529A CN 201810613940 A CN201810613940 A CN 201810613940A CN 108829529 A CN108829529 A CN 108829529A
- Authority
- CN
- China
- Prior art keywords
- shared drive
- data
- virtual machine
- sending terminal
- function
- 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
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 Transfer Between Computers (AREA)
Abstract
This application discloses a kind of virutal machine memory sharing method, device, computer equipment and storage mediums.This method includes:Create shared drive, and shared drive function corresponding with the shared drive;The shared drive function is encapsulated to wait communicate the local interface in virtual machine;If detecting the data sending request of data sending terminal, by parsing the shared drive function, the corresponding address of the shared drive is respectively mapped to data sending terminal and data receiver, connection will be established by local interface wait communicate the data sending terminal in virtual machine and data receiver;The shared drive obtains the communication data of the data sending terminal, and the communication data is sent to the data receiver.The method achieve passing through one piece of shared drive between different virtual machine to carry out reading and writing data, the data exchange rate between virtual machine is improved.
Description
Technical field
This application involves Java Virtual Machine technical field more particularly to a kind of virutal machine memory sharing methods, device, calculating
Machine equipment and storage medium.
Background technique
Currently, the communication between JVM (Java Virtual Machine, the i.e. abbreviation of Java Virtual Machine) generally all passes through
RMI method (Remote Method Invocation, i.e. remote invocation method), RMI method can allow empty in client Java
Subject image on quasi- machine calls native object equally to call the method on the object in server-side Java Virtual Machine;Or pass through
Socket method, such as exchange of two programs by a two-way communication connection realization data on network, this connection
One end be known as a Socket.
But not only communication efficiency is inefficient for above two mode, but also cannot access in other JVM in the object of local JVM
Deposit address.
Summary of the invention
This application provides a kind of virutal machine memory sharing method, device, computer equipment and storage mediums, it is intended to solve
The communication between virtual machine is realized by RMI method or Socket method in the prior art, leads to communication efficiency between virtual machine
Lowly, and between virtual machine the problem of cannot accessing the memory address of other virtual machines.
In a first aspect, this application provides a kind of virutal machine memory sharing methods comprising:
Create shared drive, and shared drive function corresponding with the shared drive;
The shared drive function is encapsulated to wait communicate the local interface in virtual machine;Wherein, wait communicate in virtual machine
Including an at least data sending terminal and an at least data receiver;
It, will be described shared by parsing the shared drive function if detecting the data sending request of data sending terminal
The corresponding address of memory is respectively mapped to data sending terminal and data receiver, will be wait communicate the data sending terminal in virtual machine
Connection is established by local interface with data receiver;
The shared drive obtains the communication data of the data sending terminal, and the communication data is sent to the number
According to receiving end.
Second aspect, this application provides a kind of virutal machine memory sharing means comprising:
Shared drive function creation unit, for creating shared drive, and shared drive corresponding with the shared drive
Function;
Function encapsulation unit, for encapsulating the shared drive function to wait communicate the local interface in virtual machine;Its
In, it include an at least data sending terminal and an at least data receiver in virtual machine wait communicate;
Connection establishment unit, if for detecting the data sending request of data sending terminal, it is described shared interior by parsing
The corresponding address of the shared drive is respectively mapped to data sending terminal and data receiver by store function, will void be communicated
Data sending terminal and data receiver in quasi- machine establish connection by local interface;
Data communication unit obtains the communication data of the data sending terminal for the shared drive, and will be described logical
News data are sent to the data receiver.
The third aspect, the application provide a kind of computer equipment again, including memory, processor and are stored in described deposit
On reservoir and the computer program that can run on the processor, the processor realize this when executing the computer program
The described in any item virutal machine memory sharing methods provided are provided.
Fourth aspect, present invention also provides a kind of storage mediums, wherein the storage medium is stored with computer program,
The computer program includes program instruction, and described program instruction makes the processor execute the application when being executed by a processor
The described in any item virutal machine memory sharing methods provided.
The application provides a kind of virutal machine memory sharing method, device, computer equipment and storage medium.This method passes through
Create shared drive, and shared drive function corresponding with the shared drive;The shared drive function is encapsulated to logical
Interrogate the local interface in virtual machine;If detecting the data sending request of data sending terminal, by parsing the shared drive letter
Number, is respectively mapped to data sending terminal and data receiver for the corresponding address of the shared drive, will virtual machine be communicated
In data sending terminal and data receiver connection established by local interface;The shared drive obtains the data sending terminal
Communication data, and the communication data is sent to the data receiver.The method achieve lead between different virtual machine
It crosses one piece of shared drive and carries out reading and writing data, improve the data exchange rate between virtual machine.
Detailed description of the invention
Technical solution in ord to more clearly illustrate embodiments of the present application, below will be to needed in embodiment description
Attached drawing is briefly described, it should be apparent that, the accompanying drawings in the following description is some embodiments of the present application, general for this field
For logical technical staff, without creative efforts, it is also possible to obtain other drawings based on these drawings.
Fig. 1 is a kind of schematic flow diagram of virutal machine memory sharing method provided by the embodiments of the present application;
Fig. 2 is a kind of sub-process schematic diagram of virutal machine memory sharing method provided by the embodiments of the present application;
Fig. 3 is a kind of another sub-process schematic diagram of virutal machine memory sharing method provided by the embodiments of the present application;
Fig. 4 is a kind of another sub-process schematic diagram of virutal machine memory sharing method provided by the embodiments of the present application;
Fig. 5 is a kind of another schematic flow diagram of virutal machine memory sharing method provided by the embodiments of the present application;
Fig. 6 is a kind of schematic block diagram of virutal machine memory sharing means provided by the embodiments of the present application;
Fig. 7 is a kind of subelement schematic block diagram of virutal machine memory sharing means provided by the embodiments of the present application;
Fig. 8 is a kind of another subelement schematic block diagram of virutal machine memory sharing means provided by the embodiments of the present application;
Fig. 9 is a kind of another subelement schematic block diagram of virutal machine memory sharing means provided by the embodiments of the present application;
Figure 10 is a kind of another schematic block diagram of virutal machine memory sharing means provided by the embodiments of the present application;
Figure 11 is a kind of schematic block diagram of computer equipment provided by the embodiments of the present application.
Specific embodiment
Below in conjunction with the attached drawing in the embodiment of the present application, technical solutions in the embodiments of the present application carries out clear, complete
Site preparation description, it is clear that described embodiment is some embodiments of the present application, instead of all the embodiments.Based on this Shen
Please in embodiment, every other implementation obtained by those of ordinary skill in the art without making creative efforts
Example, shall fall in the protection scope of this application.
It should be appreciated that ought use in this specification and in the appended claims, term " includes " and "comprising" instruction
Described feature, entirety, step, operation, the presence of element and/or component, but one or more of the other feature, whole is not precluded
Body, step, operation, the presence or addition of element, component and/or its set.
It is also understood that mesh of the term used in this present specification merely for the sake of description specific embodiment
And be not intended to limit the application.As present specification and it is used in the attached claims, unless on
Other situations are hereafter clearly indicated, otherwise " one " of singular, "one" and "the" are intended to include plural form.
It will be further appreciated that the term "and/or" used in present specification and the appended claims is
Refer to any combination and all possible combinations of one or more of associated item listed, and including these combinations.
Referring to Fig. 1, Fig. 1 is a kind of schematic flow diagram of virutal machine memory sharing method provided by the embodiments of the present application.
This method is applied in the terminals such as desktop computer, laptop computer, tablet computer, also can be applied in server.Such as Fig. 1 institute
Show, the method comprising the steps of S101~S104.
S101, creation shared drive, and shared drive function corresponding with the shared drive.
In the present embodiment, creation shared drive is same in one piece of physical memory of creation, the physical memory created
When map to multiple process address spaces, wherein each Java Virtual Machine can be considered as it is (multiple with its one-to-one process
Java Virtual Machine can operate in same terminal simultaneously, and in desktop computer or server, each process can correspond to progress
The commission calculation procedure of one enterprise staff), each process has the corresponding process address space.If in multiple Java Virtual Machines
There is a Java Virtual Machine to be updated the content in the shared drive, remaining Java Virtual Machine can be seen shared immediately
Content update in memory.As it can be seen that transmitting data between Java Virtual Machine is using shared drive as carrier, data to be transmitted are only
It need to first be transmitted to shared drive from data sending terminal, then request of data end is transmitted to by shared drive, in the above process only
Data twice have only been copied, and has avoided and needs to carry out in kernel and user's space if the communication modes such as pipeline and message queue
Four data copies improve the efficiency of communication.
When it is implemented, in creation shared drive, the shared drive function of corresponding creation, the format of shared drive function
It is as follows:
int shmget(key_tkey,size_t size,int shmflag);
Wherein, shmget is the shared drive function that value is integer type, and the function which includes passes
Entering value includes the key assignments (i.e. key, parameter type key_t) of shared drive, shared drive byte number (i.e. size, parameter
Type is size_t) and shared drive mark place value (i.e. shmflag, parameter type be integer);
Specifically, key value is configurable to IPC_PRIVATE, expression creates in the memory of current Java Virtual Machine
One piece of new shared drive;0 is set by key, then operating system will ignore key, establish a new shared drive, specify one
Then a key assignments returns to this block shared drive IPC identifier ID.And tell the identifier ID of this new shared drive to other
Process can be after establishing shared drive through derivation subprocess, or file or pipeline is written to realize.
The shared drive byte number that size is configured is the customized setting of user, is set according to actual needs, such as will
Size is configured to the arbitrary value in 0-1GB;If one section of process only applies for that the memory of one piece of only one byte, memory can also divide
It is with whole one page (the default size PACE_SIZE=4096 byte of one page in i386 machine) in this way, newly created shared interior
The size deposited is actually the page-size adjusted from this parameter of size.I.e. if size is 1 to 4096, practical Shen
The shared drive size that please be arrived is 4K (one page);4097 to 8192, then the practical shared drive size applied is 8K (page two),
The rest may be inferred.
Shmflag (the mark place value that can be understood as shared drive) is configurable to IPC_CREAT, indicates if shared
Memory is not present, then creates a shared drive, otherwise opening operation.If IPC_CREAT, shmget () letter is used alone
The operator of one already existing shared drive of number or return or the identifier for returning to a newly-built shared drive.
If IPC_CREAT with IPC_EXCL mark is used together, shmget () will return to the mark of a newly-built shared drive
Symbol;If the shared drive is existing, or returns to -1.There is no too big meanings for IPC_EXEL mark itself, but and
IPC_CREAT mark, which is used together, is to ensure that resulting object is newly-built, rather than opens existing object.For
User's reads and writees license specified SHM_R and SHM_W, (SHM_R>And (SHM_W 3)>3) it is one group to read and write perhaps
Can, and (SHM_R>And (SHM_W 6)>It 6) is that the overall situation reads and writees license.
S102, the shared drive function is encapsulated to wait communicate the local interface in virtual machine;Wherein, virtual wait communicate
It include an at least data sending terminal and an at least data receiver in machine.
In the present embodiment, when creating shared drive, for example, this shared drive can be it is virtual positioned at multiple Java
In wherein a certain Java Virtual Machine in machine, after creation is completed, the shared drive function, which is stored in, to be communicated
In virtual machine.Such as wait communicate including an at least data sending terminal and an at least data receiver in virtual machine, wherein data are sent out
Sending end and data receiver can be considered as a Java Virtual Machine, then encapsulate the shared drive function to data sending terminal
Local interface, and the shared drive function is encapsulated to the local interface of data receiver.When data sending terminal and data connect
Receiving end calls the shared drive function in respective local interface, can quickly establish communication connection.
In one embodiment, as described in Figure 2, include in step S102:
S1021, the shared drive function is compiled, obtains header file corresponding with the shared drive function;
S1022, the header file is introduced to the dynamic link library file wait communicate the local interface in virtual machine;
S1023, the dynamic link library file is configured to wait communicate the environmental variance in virtual machine, to complete in shared
Store function encapsulation.
In the present embodiment, after shared drive function being compiled, it is re-introduced into the local interface of data sending terminal
Dll file (Dynamic Link Library indicates dynamic link library file) neutralizes the DLL of the local interface of data receiver
In file.After completing the above process, then the dll file of the local interface of data sending terminal is configured to the environment of data sending terminal
Variable, and the dll file of the local interface of data receiver is configured in the environmental variance of data receiver, it can be completed altogether
Enjoy the encapsulation process of interior store function.After completing above-mentioned function encapsulation process, that is, it can ensure that the normal foundation of subsequent communications process.
It, will be described by parsing the shared drive function if S103, the data sending request for detecting data sending terminal
The corresponding address of shared drive is respectively mapped to data sending terminal and data receiver, will be wait communicate the hair of the data in virtual machine
Sending end establishes connection by local interface with data receiver.
In the present embodiment, if data sending terminal has data sending request, then it represents that need to be communicated with data receiver
Connection needs shared drive function packaged in the local interface by data sending terminal to parse at this time, while data being connect
Packaged shared drive function is parsed in the local interface of receiving end, is passing through shared drive function for the shared drive
Corresponding address is respectively mapped to data sending terminal and data receiver, can be visited with ensuring data sending terminal and data receiver
Ask the shared drive.
In one embodiment, as shown in figure 3, step S103 includes:
S1031, it obtains wait communicate the environmental variance in virtual machine, and corresponding dynamic link library is obtained according to environmental variance
File;
S1032, decompiling is carried out to the dynamic link library file, obtains the head text in the dynamic link library file
Part;
S1033, obtain shared drive function in the header file, obtain in shared in the shared drive function
Deposit byte number.
In the present embodiment, parsing memory sharing function is the reverse process for encapsulating memory sharing function.By above-mentioned
Reverse process can be realized and the corresponding address of the shared drive is quickly respectively mapped to data sending terminal and data receiver
End, to ensure that data sending terminal and data receiver can access the shared drive.
In one embodiment, as shown in figure 4, step S103 further includes:
S1034, according to the shared drive byte number in the shared drive function, obtain the starting point of the shared drive
Location and termination address;
S1035, initial address and termination address according to the shared drive, obtain the shared drive correspondingly
Location;
S1036, the sky that the corresponding address of the shared drive is respectively mapped to data sending terminal at random by null pointer
Between the space address of address and data receiver.
It in the present embodiment, can be specified by obtaining the shared drive byte number in the shared drive function
Java Virtual Machine correspond to and be randomly assigned an initial address in the spare space of the process address space, according to initial address and shared
Memory byte number summation positioning termination address can obtain described according to the initial address and termination address of the shared drive
The corresponding address of shared drive.Finally, the corresponding address of the shared drive is respectively mapped to data by null pointer at random
The space address of transmitting terminal and the space address of data receiver realize the accurate mapping of shared memory space.
S104, the shared drive obtain the communication data of the data sending terminal, and the communication data is sent to
The data receiver.
In the present embodiment, communication data is first to be input to shared drive from data sending terminal, then sent by shared drive
To data receiver, data twice have only been copied in the above process, improve the efficiency of communication.
In one embodiment, as shown in figure 5, further including after step S104:
It, will be described shared if the transmission of S105, the data sending terminal terminating communication data exceeds preset time threshold
Memory is discharged.
It in the present embodiment, is not always that read-write is a small amount of between Java Virtual Machine when being communicated by shared drive
It is just unmapped after data, then have again and re-establishes shared drive region when new communication again.And it is to maintain shared drive, directly
It (if the transmission of the data sending terminal terminating communication data exceeds preset time threshold, can be indicated until communication finishes
Communication finishes), such data content remains stored in shared drive, does not write back file, and the content in shared drive is past
Past is that file is just write back when unmapped.It therefore, is very high using the communication mode efficiency of shared drive.
As it can be seen that improving void the method achieve passing through one piece of shared drive between different virtual machine to carry out reading and writing data
Data exchange rate between quasi- machine.
The embodiment of the present application also provides a kind of virutal machine memory sharing means, and the virutal machine memory sharing means are for executing
Any embodiment of aforementioned virtual machine internal memory sharing method.Specifically, referring to Fig. 6, Fig. 6 is provided by the embodiments of the present application one
The schematic block diagram of kind virutal machine memory sharing means.Virutal machine memory sharing means 100 can be configured at desktop computer, plate
Computer, laptop computer, etc. in terminals, can also be configured in server.
As shown in fig. 6, virutal machine memory sharing means 100 include shared drive function creation unit 101, function encapsulation list
Member 102, connection establishment unit 103 and data communication unit 104.
Shared drive function creation unit 101, for creating shared drive, and it is corresponding with the shared drive it is shared in
Store function.
In the present embodiment, creation shared drive is same in one piece of physical memory of creation, the physical memory created
When map to multiple process address spaces, wherein each Java Virtual Machine can be considered as it is (multiple with its one-to-one process
Java Virtual Machine can operate in same terminal simultaneously, and in desktop computer or server, each process can correspond to progress
The commission calculation procedure of one enterprise staff), each process has the corresponding process address space.If in multiple Java Virtual Machines
There is a Java Virtual Machine to be updated the content in the shared drive, remaining Java Virtual Machine can be seen shared immediately
Content update in memory.As it can be seen that transmitting data between Java Virtual Machine is using shared drive as carrier, data to be transmitted are only
It need to first be transmitted to shared drive from data sending terminal, then request of data end is transmitted to by shared drive, in the above process only
Data twice have only been copied, and has avoided and needs to carry out in kernel and user's space if the communication modes such as pipeline and message queue
Four data copies improve the efficiency of communication.
When it is implemented, in creation shared drive, the shared drive function of corresponding creation, the format of shared drive function
It is as follows:
int shmget(key_tkey,size_t size,int shmflag);
Wherein, shmget is the shared drive function that value is integer type, and the function which includes passes
Entering value includes the key assignments (i.e. key, parameter type key_t) of shared drive, shared drive byte number (i.e. size, parameter
Type is size_t) and shared drive mark place value (i.e. shmflag, parameter type be integer);
Specifically, key value is configurable to IPC_PRIVATE, expression creates in the memory of current Java Virtual Machine
One piece of new shared drive;0 is set by key, then operating system will ignore key, establish a new shared drive, specify one
Then a key assignments returns to this block shared drive IPC identifier ID.And tell the identifier ID of this new shared drive to other
Process can be after establishing shared drive through derivation subprocess, or file or pipeline is written to realize.
The shared drive byte number that size is configured is the customized setting of user, is set according to actual needs, such as will
Size is configured to the arbitrary value in 0-1GB;If one section of process only applies for that the memory of one piece of only one byte, memory can also divide
It is with whole one page (the default size PACE_SIZE=4096 byte of one page in i386 machine) in this way, newly created shared interior
The size deposited is actually the page-size adjusted from this parameter of size.I.e. if size is 1 to 4096, practical Shen
The shared drive size that please be arrived is 4K (one page);4097 to 8192, then the practical shared drive size applied is 8K (page two),
The rest may be inferred.
Shmflag (the mark place value that can be understood as shared drive) is configurable to IPC_CREAT, indicates if shared
Memory is not present, then creates a shared drive, otherwise opening operation.If IPC_CREAT, shmget () letter is used alone
The operator of one already existing shared drive of number or return or the identifier for returning to a newly-built shared drive.
If IPC_CREAT with IPC_EXCL mark is used together, shmget () will return to the mark of a newly-built shared drive
Symbol;If the shared drive is existing, or returns to -1.There is no too big meanings for IPC_EXEL mark itself, but and
IPC_CREAT mark, which is used together, is to ensure that resulting object is newly-built, rather than opens existing object.For
User's reads and writees license specified SHM_R and SHM_W, (SHM_R>And (SHM_W 3)>3) it is one group to read and write perhaps
Can, and (SHM_R>And (SHM_W 6)>It 6) is that the overall situation reads and writees license.
Function encapsulation unit 102, for encapsulating the shared drive function to wait communicate the local interface in virtual machine;
It wherein, include an at least data sending terminal and an at least data receiver in virtual machine wait communicate.
In the present embodiment, when creating shared drive, for example, this shared drive can be it is virtual positioned at multiple Java
In wherein a certain Java Virtual Machine in machine, after creation is completed, the shared drive function, which is stored in, to be communicated
In virtual machine.Such as wait communicate including an at least data sending terminal and an at least data receiver in virtual machine, wherein data are sent out
Sending end and data receiver can be considered as a Java Virtual Machine, then encapsulate the shared drive function to data sending terminal
Local interface, and the shared drive function is encapsulated to the local interface of data receiver.When data sending terminal and data connect
Receiving end calls the shared drive function in respective local interface, can quickly establish communication connection.
In one embodiment, as described in Figure 7, include in function encapsulation unit 102:
Compilation unit 1021 obtains and the shared drive function pair for the shared drive function to be compiled
The header file answered;
Header file introduces unit 1022, for being introduced to the header file wait communicate the dynamic of the local interface in virtual machine
State links library file;
Environmental variance configuration unit 1023, for being configured to the dynamic link library file wait communicate the ring in virtual machine
Border variable, to complete the encapsulation of shared drive function.
In the present embodiment, after shared drive function being compiled, it is re-introduced into the local interface of data sending terminal
Dll file (Dynamic Link Library indicates dynamic link library file) neutralizes the DLL of the local interface of data receiver
In file.After completing the above process, then the dll file of the local interface of data sending terminal is configured to the environment of data sending terminal
Variable, and the dll file of the local interface of data receiver is configured in the environmental variance of data receiver, it can be completed altogether
Enjoy the encapsulation process of interior store function.After completing above-mentioned function encapsulation process, that is, it can ensure that the normal foundation of subsequent communications process.
Connection establishment unit 103, if for detecting the data sending request of data sending terminal, it is described shared by parsing
The corresponding address of the shared drive is respectively mapped to data sending terminal and data receiver by interior store function, will be wait communicate
Data sending terminal and data receiver in virtual machine establish connection by local interface.
In the present embodiment, if data sending terminal has data sending request, then it represents that need to be communicated with data receiver
Connection needs shared drive function packaged in the local interface by data sending terminal to parse at this time, while data being connect
Packaged shared drive function is parsed in the local interface of receiving end, is passing through shared drive function for the shared drive
Corresponding address is respectively mapped to data sending terminal and data receiver, can be visited with ensuring data sending terminal and data receiver
Ask the shared drive.
In one embodiment, as shown in figure 8, connection establishment unit 103 includes:
Environmental variance acquiring unit 1031, for obtaining wait communicate the environmental variance in virtual machine, and according to environmental variance
Obtain corresponding dynamic link library file;
Decompiling unit 1032 obtains the dynamic link library for carrying out decompiling to the dynamic link library file
Header file in file;
Shared drive function acquiring unit 1033 obtains and institute for obtaining the shared drive function in the header file
State the shared drive byte number in shared drive function.
In the present embodiment, parsing memory sharing function is the reverse process for encapsulating memory sharing function.By above-mentioned
Reverse process can be realized and the corresponding address of the shared drive is quickly respectively mapped to data sending terminal and data receiver
End, to ensure that data sending terminal and data receiver can access the shared drive.
In one embodiment, as shown in figure 9, connection establishment unit 103 further includes:
Address location unit 1034, for according to the shared drive byte number in the shared drive function, described in acquisition
The initial address and termination address of shared drive;
Address calculation 1035 obtains described total for the initial address and termination address according to the shared drive
Enjoy the corresponding address of memory;
Address mapping unit 1036, for the corresponding address of the shared drive to be respectively mapped at random by null pointer
The space address of data sending terminal and the space address of data receiver.
It in the present embodiment, can be specified by obtaining the shared drive byte number in the shared drive function
Java Virtual Machine correspond to and be randomly assigned an initial address in the spare space of the process address space, according to initial address and shared
Memory byte number summation positioning termination address can obtain described according to the initial address and termination address of the shared drive
The corresponding address of shared drive.Finally, the corresponding address of the shared drive is respectively mapped to data by null pointer at random
The space address of transmitting terminal and the space address of data receiver realize the accurate mapping of shared memory space.
Data communication unit 104 obtains the communication data of the data sending terminal for the shared drive, and will be described
Communication data is sent to the data receiver.
In the present embodiment, communication data is first to be input to shared drive from data sending terminal, then sent by shared drive
To data receiver, data twice have only been copied in the above process, improve the efficiency of communication.
In one embodiment, as shown in Figure 10, virutal machine memory sharing means 100 further include:
Shared drive releasing unit 105, if the transmission for the data sending terminal terminating communication data is beyond preset
Time threshold discharges the shared drive.
It in the present embodiment, is not always that read-write is a small amount of between Java Virtual Machine when being communicated by shared drive
It is just unmapped after data, then have again and re-establishes shared drive region when new communication again.And it is to maintain shared drive, directly
It (if the transmission of the data sending terminal terminating communication data exceeds preset time threshold, can be indicated until communication finishes
Communication finishes), such data content remains stored in shared drive, does not write back file, and the content in shared drive is past
Past is that file is just write back when unmapped.It therefore, is very high using the communication mode efficiency of shared drive.
As it can be seen that improving void the arrangement achieves passing through one piece of shared drive between different virtual machine to carry out reading and writing data
Data exchange rate between quasi- machine.
Above-mentioned virutal machine memory sharing means can be implemented as a kind of form of computer program, which can be with
It is run in computer equipment as shown in figure 11.
Figure 11 is please referred to, Figure 11 is a kind of schematic block diagram of computer equipment provided by the embodiments of the present application.The calculating
500 equipment of machine equipment can be terminal, be also possible to server.The terminal can be tablet computer, laptop, desktop
The electronic equipments such as brain, personal digital assistant.
Refering to fig. 11, which includes processor 502, memory and the net connected by system bus 501
Network interface 505, wherein memory may include non-volatile memory medium 503 and built-in storage 504.
The non-volatile memory medium 503 can storage program area 5031 and computer program 5032.The computer program
5032 include program instruction, which is performed, and processor 502 may make to execute a kind of shared side of virutal machine memory
Method.
The processor 502 supports the operation of entire computer equipment 500 for providing calculating and control ability.
The built-in storage 504 provides environment for the operation of the computer program 5032 in non-volatile memory medium 503, should
When computer program 5032 is executed by processor 502, processor 502 may make to execute a kind of virutal machine memory sharing method.
The network interface 505 such as sends the task dispatching of distribution for carrying out network communication.Those skilled in the art can manage
It solves, structure shown in Figure 11, only the block diagram of part-structure relevant to application scheme, is not constituted to the application side
The restriction for the computer equipment 500 that case is applied thereon, specific computer equipment 500 may include more than as shown in the figure
Or less component, perhaps combine certain components or with different component layouts.
Wherein, the processor 502 is for running computer program 5032 stored in memory, to realize following function
Energy:Create shared drive, and shared drive function corresponding with the shared drive;By the shared drive function encapsulate to
Communicate the local interface in virtual machine;It wherein, include an at least data sending terminal and at least a data connect wait communicate in virtual machine
Receiving end;If detecting the data sending request of data sending terminal, by parsing the shared drive function, by the shared drive
Corresponding address is respectively mapped to data sending terminal and data receiver, will be wait communicate data sending terminal and number in virtual machine
Connection is established by local interface according to receiving end;The shared drive obtains the communication data of the data sending terminal, and by institute
It states communication data and is sent to the data receiver.
In one embodiment, processor 502 also performs the following operations:The shared drive function is compiled, is obtained
Header file corresponding with the shared drive function;The header file is introduced to wait communicate the dynamic of the local interface in virtual machine
State links library file;The dynamic link library file is configured to wait communicate the environmental variance in virtual machine, to complete in shared
Store function encapsulation;Wherein the incoming value of the function in the shared drive function includes at least shared drive byte number.
In one embodiment, processor 502 also performs the following operations:It obtains wait communicate the environmental variance in virtual machine, and
Corresponding dynamic link library file is obtained according to environmental variance;Decompiling is carried out to the dynamic link library file, described in acquisition
Header file in dynamic link library file;The shared drive function in the header file is obtained, is obtained and the shared drive letter
Shared drive byte number in number.
In one embodiment, processor 502 also performs the following operations:According to the shared drive in the shared drive function
Byte number obtains the initial address and termination address of the shared drive;According to the initial address and termination of the shared drive
Address obtains the corresponding address of the shared drive;The corresponding address of the shared drive is reflected respectively at random by null pointer
It is incident upon the space address of data sending terminal and the space address of data receiver.
In one embodiment, processor 502 also performs the following operations:If the hair of the data sending terminal terminating communication data
It send beyond preset time threshold, the shared drive is discharged.
It will be understood by those skilled in the art that the embodiment of computer equipment shown in Figure 11 is not constituted to computer
The restriction of equipment specific composition, in other embodiments, computer equipment may include components more more or fewer than diagram, or
Person combines certain components or different component layouts.For example, in some embodiments, computer equipment can only include depositing
Reservoir and processor, in such embodiments, the structure and function of memory and processor are consistent with embodiment illustrated in fig. 11,
Details are not described herein.
It should be appreciated that in the embodiment of the present application, processor 502 can be central processing unit (Central
Processing Unit, CPU), which can also be other general processors, digital signal processor (Digital
Signal Processor, DSP), specific integrated circuit (Application Specific Integrated Circuit,
ASIC), ready-made programmable gate array (Field-Programmable GateArray, FPGA) or other programmable logic devices
Part, discrete gate or transistor logic, discrete hardware components etc..Wherein, general processor can be microprocessor or
The processor is also possible to any conventional processor etc..
A kind of storage medium is provided in another embodiment of the application.The storage medium can be computer-readable storage
Medium.The storage medium is stored with computer program, and wherein computer program includes program instruction.The program instruction is by processor
It is realized when execution:Create shared drive, and shared drive function corresponding with the shared drive;By the shared drive function
Encapsulation is to wait communicate the local interface in virtual machine;It wherein, include an at least data sending terminal and at least in virtual machine wait communicate
One data receiver;It, will be described by parsing the shared drive function if detecting the data sending request of data sending terminal
The corresponding address of shared drive is respectively mapped to data sending terminal and data receiver, will be wait communicate the hair of the data in virtual machine
Sending end establishes connection by local interface with data receiver;The shared drive obtains the communication number of the data sending terminal
According to, and the communication data is sent to the data receiver.
In one embodiment, realization when which is executed by processor:The shared drive function is compiled,
Obtain header file corresponding with the shared drive function;The header file is introduced to wait communicate the local interface in virtual machine
Dynamic link library file;The dynamic link library file is configured to wait communicate the environmental variance in virtual machine, to complete altogether
Enjoy interior store function encapsulation;Wherein the incoming value of the function in the shared drive function includes at least shared drive byte number.
In one embodiment, realization when which is executed by processor:It obtains and becomes wait communicate the environment in virtual machine
Amount, and corresponding dynamic link library file is obtained according to environmental variance;Decompiling is carried out to the dynamic link library file, is obtained
Header file in the dynamic link library file;Obtain the shared drive function in the header file, obtain with it is described it is shared in
Shared drive byte number in store function.
In one embodiment, realization when which is executed by processor:According to being total in the shared drive function
Memory byte number is enjoyed, the initial address and termination address of the shared drive are obtained;According to the initial address of the shared drive
And termination address, obtain the corresponding address of the shared drive;The corresponding address of the shared drive is random by null pointer
It is respectively mapped to the space address of data sending terminal and the space address of data receiver.
In one embodiment, realization when which is executed by processor:If the data sending terminal terminating communication number
According to transmission exceed preset time threshold, the shared drive is discharged.
The storage medium can be the internal storage unit of aforementioned device, such as the hard disk or memory of equipment.It is described to deposit
Storage media is also possible to the plug-in type hard disk being equipped on the External memory equipment of the equipment, such as the equipment, intelligent storage
Block (Smart Media Card, SMC), secure digital (Secure Digital, SD) card, flash card (Flash Card) etc..
Further, the storage medium can also both including the equipment internal storage unit and also including External memory equipment.
It is apparent to those skilled in the art that for convenience of description and succinctly, foregoing description is set
The specific work process of standby, device and unit, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
Those of ordinary skill in the art may be aware that unit described in conjunction with the examples disclosed in the embodiments of the present disclosure and algorithm
Step can be realized with electronic hardware, computer software, or a combination of the two, in order to clearly demonstrate hardware and software
Interchangeability generally describes each exemplary composition and step according to function in the above description.These functions are studied carefully
Unexpectedly the specific application and design constraint depending on technical solution are implemented in hardware or software.Professional technician
Each specific application can be used different methods to achieve the described function, but this realization is it is not considered that exceed
The scope of the present invention.
In several embodiments provided herein, it should be understood that disclosed unit and method, it can be with
It realizes by another way.For example, the apparatus embodiments described above are merely exemplary, for example, the unit
It divides, only a kind of logical function partition, there may be another division manner in actual implementation, can also will have identical function
The unit set of energy can be combined or can be integrated into another system at a unit, such as multiple units or components, or
Some features can be ignored or not executed.In addition, shown or discussed mutual coupling or direct-coupling or communication link
Connect can be through some interfaces, the indirect coupling or communication connection of device or unit, be also possible to electricity, it is mechanical or other
Form connection.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit
The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple
In network unit.Some or all of unit therein can be selected to realize the embodiment of the present invention according to the actual needs
Purpose.
It, can also be in addition, the functional units in various embodiments of the present invention may be integrated into one processing unit
It is that each unit physically exists alone, is also possible to two or more units and is integrated in one unit.It is above-mentioned integrated
Unit both can take the form of hardware realization, can also realize in the form of software functional units.
If the integrated unit is realized in the form of SFU software functional unit and sells or use as independent product
When, it can store in one storage medium.Based on this understanding, technical solution of the present invention is substantially in other words to existing
The all or part of part or the technical solution that technology contributes can be embodied in the form of software products, should
Computer software product is stored in a storage medium, including some instructions are used so that a computer equipment (can be
Personal computer, server or network equipment etc.) execute all or part of step of each embodiment the method for the present invention
Suddenly.And storage medium above-mentioned includes:USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), magnetic disk or
The various media that can store program code such as person's CD.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any
Those familiar with the art in the technical scope disclosed by the present invention, can readily occur in various equivalent modifications or replace
It changes, these modifications or substitutions should be covered by the protection scope of the present invention.Therefore, protection scope of the present invention should be with right
It is required that protection scope subject to.
Claims (10)
1. a kind of virutal machine memory sharing method, which is characterized in that including:
Create shared drive, and shared drive function corresponding with the shared drive;
The shared drive function is encapsulated to wait communicate the local interface in virtual machine;Wherein, include wait communicate in virtual machine
An at least data sending terminal and at least a data receiver;
If detecting the data sending request of data sending terminal, by parsing the shared drive function, by the shared drive
Corresponding address is respectively mapped to data sending terminal and data receiver, will be wait communicate data sending terminal and number in virtual machine
Connection is established by local interface according to receiving end;
The shared drive obtains the communication data of the data sending terminal, and the communication data is sent to the data and is connect
Receiving end.
2. virutal machine memory sharing method according to claim 1, which is characterized in that the letter in the shared drive function
The incoming value of number includes at least shared drive byte number;
It is described to encapsulate the shared drive function to wait communicate the local interface in virtual machine, including:
The shared drive function is compiled, header file corresponding with the shared drive function is obtained;
The header file is introduced to the dynamic link library file wait communicate the local interface in virtual machine;
The dynamic link library file is configured to wait communicate the environmental variance in virtual machine, to complete shared drive function envelope
Dress.
3. virutal machine memory sharing method according to claim 2, which is characterized in that the parsing shared drive letter
Number, including:
It obtains wait communicate the environmental variance in virtual machine, and corresponding dynamic link library file is obtained according to environmental variance;
Decompiling is carried out to the dynamic link library file, obtains the header file in the dynamic link library file;
The shared drive function in the header file is obtained, is obtained and the shared drive byte number in the shared drive function.
4. virutal machine memory sharing method according to claim 3, which is characterized in that described that the shared drive is corresponding
Address be respectively mapped to data sending terminal and data receiver, will be connect wait communicate the data sending terminal in virtual machine with data
Receiving end establishes connection by local interface, including:
According to the shared drive byte number in the shared drive function, obtains the initial address of the shared drive and terminate ground
Location;
According to the initial address and termination address of the shared drive, the corresponding address of the shared drive is obtained;
The corresponding address of the shared drive is respectively mapped to the space address of data sending terminal, and number at random by null pointer
According to the space address of receiving end.
5. virutal machine memory sharing method according to claim 1, which is characterized in that the shared drive obtains the number
It is sent to the data receiver according to the communication data of transmitting terminal, and by the communication data, further includes later:
If the transmission of the data sending terminal terminating communication data exceeds preset time threshold, the shared drive is released
It puts.
6. a kind of virutal machine memory sharing means, which is characterized in that including:
Shared drive function creation unit, for creating shared drive, and shared drive function corresponding with the shared drive;
Function encapsulation unit, for encapsulating the shared drive function to wait communicate the local interface in virtual machine;Wherein, to
Communicate includes an at least data sending terminal and an at least data receiver in virtual machine;
Connection establishment unit, if for detecting the data sending request of data sending terminal, by parsing the shared drive letter
Number, is respectively mapped to data sending terminal and data receiver for the corresponding address of the shared drive, will virtual machine be communicated
In data sending terminal and data receiver connection established by local interface;
Data communication unit, obtains the communication data of the data sending terminal for the shared drive, and by the communication number
According to being sent to the data receiver.
7. virutal machine memory sharing means according to claim 6, which is characterized in that the letter in the shared drive function
The incoming value of number includes at least shared drive byte number;
The function encapsulation unit, including:
Compilation unit obtains head text corresponding with the shared drive function for the shared drive function to be compiled
Part;
Header file introduces unit, for the header file to be introduced to the dynamic link library wait communicate the local interface in virtual machine
File;
Environmental variance configuration unit, for being configured to the dynamic link library file wait communicate the environmental variance in virtual machine,
To complete the encapsulation of shared drive function.
8. virutal machine memory sharing means according to claim 7, which is characterized in that the connection establishment unit, including:
Environmental variance acquiring unit for obtaining wait communicate the environmental variance in virtual machine, and is obtained according to environmental variance and is corresponded to
Dynamic link library file;
Decompiling unit obtains in the dynamic link library file for carrying out decompiling to the dynamic link library file
Header file;
Shared drive function acquiring unit, for obtaining the shared drive function in the header file, obtain with it is described it is shared in
Shared drive byte number in store function.
9. a kind of computer equipment, including memory, processor and it is stored on the memory and can be on the processor
The computer program of operation, which is characterized in that the processor is realized when executing the computer program as in claim 1-5
Described in any item virutal machine memory sharing methods.
10. a kind of storage medium, which is characterized in that the storage medium is stored with computer program, the computer program packet
Program instruction is included, described program instruction executes the processor such as any one of claim 1-5 institute
The virutal machine memory sharing method stated.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810613940.6A CN108829529A (en) | 2018-06-14 | 2018-06-14 | Virutal machine memory sharing method, device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810613940.6A CN108829529A (en) | 2018-06-14 | 2018-06-14 | Virutal machine memory sharing method, device, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108829529A true CN108829529A (en) | 2018-11-16 |
Family
ID=64141899
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810613940.6A Pending CN108829529A (en) | 2018-06-14 | 2018-06-14 | Virutal machine memory sharing method, device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108829529A (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111796901A (en) * | 2019-04-08 | 2020-10-20 | 维塔科技(北京)有限公司 | Method and device for switching shared memory area, storage medium and electronic equipment |
CN111797497A (en) * | 2020-05-21 | 2020-10-20 | 中国电力科学研究院有限公司 | Communication method and system for electromagnetic transient parallel simulation |
CN111796944A (en) * | 2019-04-08 | 2020-10-20 | 维塔科技(北京)有限公司 | Method and device for switching shared memory area, storage medium and electronic equipment |
CN112052100A (en) * | 2019-06-06 | 2020-12-08 | 华为技术有限公司 | Virtual machine communication method and equipment based on shared memory |
CN114327944A (en) * | 2021-12-24 | 2022-04-12 | 科东(广州)软件科技有限公司 | Method, device, equipment and storage medium for sharing memory by multiple systems |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050086661A1 (en) * | 2003-10-21 | 2005-04-21 | Monnie David J. | Object synchronization in shared object space |
CN101819564A (en) * | 2009-02-26 | 2010-09-01 | 国际商业机器公司 | Method and device for assisting communication between virtual machines |
CN107491354A (en) * | 2017-07-03 | 2017-12-19 | 北京东土科技股份有限公司 | A kind of inter-virtual machine communication method and device based on shared drive |
CN107943596A (en) * | 2016-10-12 | 2018-04-20 | 阿里巴巴集团控股有限公司 | Way of Process Communication, apparatus and system |
-
2018
- 2018-06-14 CN CN201810613940.6A patent/CN108829529A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050086661A1 (en) * | 2003-10-21 | 2005-04-21 | Monnie David J. | Object synchronization in shared object space |
CN101819564A (en) * | 2009-02-26 | 2010-09-01 | 国际商业机器公司 | Method and device for assisting communication between virtual machines |
CN107943596A (en) * | 2016-10-12 | 2018-04-20 | 阿里巴巴集团控股有限公司 | Way of Process Communication, apparatus and system |
CN107491354A (en) * | 2017-07-03 | 2017-12-19 | 北京东土科技股份有限公司 | A kind of inter-virtual machine communication method and device based on shared drive |
Non-Patent Citations (5)
Title |
---|
LINUX C函数库参考手册: "《Linux C函数库参考手册》", 31 January 2002 * |
XIAO-HUI CHENG: "A research of inter-process communication based on shared memory and address-mapping", 《PROCEEDINGS OF 2011 INTERNATIONAL CONFERENCE ON COMPUTER SCIENCE AND NETWORK TECHNOLOGY》 * |
吴洪贵: "《物联网应用系统开发》", 30 November 2012, 东软电子出版社 * |
西蒙: "《Windows 2000 API 超级宝典》", 30 June 2001 * |
马会彬: "基于知识发现的网络故障管理系统研究与实现", 《中国优秀博硕士学位论文全文数据库(硕士)信息科技辑》 * |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111796901A (en) * | 2019-04-08 | 2020-10-20 | 维塔科技(北京)有限公司 | Method and device for switching shared memory area, storage medium and electronic equipment |
CN111796944A (en) * | 2019-04-08 | 2020-10-20 | 维塔科技(北京)有限公司 | Method and device for switching shared memory area, storage medium and electronic equipment |
CN112052100A (en) * | 2019-06-06 | 2020-12-08 | 华为技术有限公司 | Virtual machine communication method and equipment based on shared memory |
CN112052100B (en) * | 2019-06-06 | 2023-05-12 | 华为技术有限公司 | Virtual machine communication method and device based on shared memory |
CN111797497A (en) * | 2020-05-21 | 2020-10-20 | 中国电力科学研究院有限公司 | Communication method and system for electromagnetic transient parallel simulation |
CN111797497B (en) * | 2020-05-21 | 2024-05-17 | 中国电力科学研究院有限公司 | Communication method and system for electromagnetic transient parallel simulation |
CN114327944A (en) * | 2021-12-24 | 2022-04-12 | 科东(广州)软件科技有限公司 | Method, device, equipment and storage medium for sharing memory by multiple systems |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108829529A (en) | Virutal machine memory sharing method, device, computer equipment and storage medium | |
US20210004245A1 (en) | Deploying service containers in an adapter device | |
CN105518611B (en) | A kind of remote direct data access method, equipment and system | |
US8010973B2 (en) | Class loader for managing a network | |
CN107580083A (en) | A kind of method and system of container IP address distribution | |
CN101150488B (en) | A receiving method for zero copy network packet | |
WO2005083984A1 (en) | Protocol stack with modification facility | |
CN103856554A (en) | Clustering support across geographical boundaries | |
US9456017B2 (en) | System and method for a connector being able to adapt to newer features introduced to a messaging provider with only configuration changes | |
CN108418874A (en) | Guiding method, device, computer equipment and storage medium are returned across wide area network data | |
KR101856486B1 (en) | Method for bi-direction calling between open system and mainframe system | |
CN107678778A (en) | Compatibility method, adapter, running gear and system based on Hybrid | |
CN113032166B (en) | Inter-core communication method, processor, inter-core communication system, and computer-readable storage medium | |
CN108228309A (en) | Data packet method of sending and receiving and device based on virtual machine | |
CN106873915A (en) | A kind of data transmission method and device based on RDMA registers memory blocks | |
CN106919442A (en) | Many GPU dispatching devices and distributed computing system and many GPU dispatching methods | |
CN105610730A (en) | Method and system for message interaction between CPU and network equipment | |
CN116113923A (en) | Container cluster management method and system | |
CN107888663A (en) | A kind of method of distribution of document, equipment and computer-readable medium | |
CN101138215B (en) | Asynchronous network stack operation in an operating system independent environment | |
CN116800616A (en) | Management method and related device of virtualized network equipment | |
CN108307286B (en) | Method and system for realizing communication between android devices based on NFC | |
CN109189705A (en) | A kind of usb expansion method, apparatus, equipment, storage medium and system | |
CN101917780B (en) | Function implementation method and device of wireless communication terminal network equipment | |
CN106845974B (en) | Method and device for realizing point-to-point communication of near field communication |
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 |
Application publication date: 20181116 |
|
RJ01 | Rejection of invention patent application after publication |