Movatterモバイル変換


[0]ホーム

URL:


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 PDF

Info

Publication number
CN108829529A
CN108829529ACN201810613940.6ACN201810613940ACN108829529ACN 108829529 ACN108829529 ACN 108829529ACN 201810613940 ACN201810613940 ACN 201810613940ACN 108829529 ACN108829529 ACN 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
Application number
CN201810613940.6A
Other languages
Chinese (zh)
Inventor
陈飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Life Insurance Company of China LtdfiledCriticalPing An Life Insurance Company of China Ltd
Priority to CN201810613940.6ApriorityCriticalpatent/CN108829529A/en
Publication of CN108829529ApublicationCriticalpatent/CN108829529A/en
Pendinglegal-statusCriticalCurrent

Links

Classifications

Landscapes

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

Virutal machine memory sharing method, device, computer equipment and storage medium
Technical field
This application involves Java Virtual Machine technical field more particularly to a kind of virutal machine memory sharing methods, device, calculatingMachine 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 throughRMI method (Remote Method Invocation, i.e. remote invocation method), RMI method can allow empty in client JavaSubject image on quasi- machine calls native object equally to call the method on the object in server-side Java Virtual Machine;Or pass throughSocket method, such as exchange of two programs by a two-way communication connection realization data on network, this connectionOne 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 JVMDeposit 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 solveThe communication between virtual machine is realized by RMI method or Socket method in the prior art, leads to communication efficiency between virtual machineLowly, 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 machineIncluding 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 terminalThe corresponding address of memory is respectively mapped to data sending terminal and data receiver, will be wait communicate the data sending terminal in virtual machineConnection 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 numberAccording 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 driveFunction;
Function encapsulation unit, for encapsulating the shared drive function to wait communicate the local interface in virtual machine;ItsIn, 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 parsingThe corresponding address of the shared drive is respectively mapped to data sending terminal and data receiver by store function, will void be communicatedData 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 logicalNews 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 depositOn reservoir and the computer program that can run on the processor, the processor realize this when executing the computer programThe 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 processorThe 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 throughCreate shared drive, and shared drive function corresponding with the shared drive;The shared drive function is encapsulated to logicalInterrogate the local interface in virtual machine;If detecting the data sending request of data sending terminal, by parsing the shared drive letterNumber, is respectively mapped to data sending terminal and data receiver for the corresponding address of the shared drive, will virtual machine be communicatedIn data sending terminal and data receiver connection established by local interface;The shared drive obtains the data sending terminalCommunication data, and the communication data is sent to the data receiver.The method achieve lead between different virtual machineIt 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 descriptionAttached 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 fieldFor 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, completeSite preparation description, it is clear that described embodiment is some embodiments of the present application, instead of all the embodiments.Based on this ShenPlease in embodiment, every other implementation obtained by those of ordinary skill in the art without making creative effortsExample, 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" instructionDescribed feature, entirety, step, operation, the presence of element and/or component, but one or more of the other feature, whole is not precludedBody, 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 embodimentAnd be not intended to limit the application.As present specification and it is used in the attached claims, unless onOther 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 isRefer 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 instituteShow, 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 createdWhen map to multiple process address spaces, wherein each Java Virtual Machine can be considered as it is (multiple with its one-to-one processJava Virtual Machine can operate in same terminal simultaneously, and in desktop computer or server, each process can correspond to progressThe commission calculation procedure of one enterprise staff), each process has the corresponding process address space.If in multiple Java Virtual MachinesThere is a Java Virtual Machine to be updated the content in the shared drive, remaining Java Virtual Machine can be seen shared immediatelyContent 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 onlyIt 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 onlyData 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 queueFour 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 functionIt 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 passesEntering value includes the key assignments (i.e. key, parameter type key_t) of shared drive, shared drive byte number (i.e. size, parameterType 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 MachineOne piece of new shared drive;0 is set by key, then operating system will ignore key, establish a new shared drive, specify oneThen a key assignments returns to this block shared drive IPC identifier ID.And tell the identifier ID of this new shared drive to otherProcess 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 willSize 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 divideIt is with whole one page (the default size PACE_SIZE=4096 byte of one page in i386 machine) in this way, newly created shared interiorThe size deposited is actually the page-size adjusted from this parameter of size.I.e. if size is 1 to 4096, practical ShenThe 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 sharedMemory is not present, then creates a shared drive, otherwise opening operation.If IPC_CREAT, shmget () letter is used aloneThe 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 driveSymbol;If the shared drive is existing, or returns to -1.There is no too big meanings for IPC_EXEL mark itself, but andIPC_CREAT mark, which is used together, is to ensure that resulting object is newly-built, rather than opens existing object.ForUser'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 perhapsCan, 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 communicateIt 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 JavaIn wherein a certain Java Virtual Machine in machine, after creation is completed, the shared drive function, which is stored in, to be communicatedIn 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 outSending end and data receiver can be considered as a Java Virtual Machine, then encapsulate the shared drive function to data sending terminalLocal interface, and the shared drive function is encapsulated to the local interface of data receiver.When data sending terminal and data connectReceiving 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 sharedStore function encapsulation.
In the present embodiment, after shared drive function being compiled, it is re-introduced into the local interface of data sending terminalDll file (Dynamic Link Library indicates dynamic link library file) neutralizes the DLL of the local interface of data receiverIn 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 terminalVariable, and the dll file of the local interface of data receiver is configured in the environmental variance of data receiver, it can be completed altogetherEnjoy 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 terminalThe 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 machineSending 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 receiverConnection needs shared drive function packaged in the local interface by data sending terminal to parse at this time, while data being connectPackaged shared drive function is parsed in the local interface of receiving end, is passing through shared drive function for the shared driveCorresponding address is respectively mapped to data sending terminal and data receiver, can be visited with ensuring data sending terminal and data receiverAsk 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 varianceFile;
S1032, decompiling is carried out to the dynamic link library file, obtains the head text in the dynamic link library filePart;
S1033, obtain shared drive function in the header file, obtain in shared in the shared drive functionDeposit byte number.
In the present embodiment, parsing memory sharing function is the reverse process for encapsulating memory sharing function.By above-mentionedReverse process can be realized and the corresponding address of the shared drive is quickly respectively mapped to data sending terminal and data receiverEnd, 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 driveLocation and termination address;
S1035, initial address and termination address according to the shared drive, obtain the shared drive correspondinglyLocation;
S1036, the sky that the corresponding address of the shared drive is respectively mapped to data sending terminal at random by null pointerBetween 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 functionJava 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 sharedMemory byte number summation positioning termination address can obtain described according to the initial address and termination address of the shared driveThe corresponding address of shared drive.Finally, the corresponding address of the shared drive is respectively mapped to data by null pointer at randomThe 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 toThe data receiver.
In the present embodiment, communication data is first to be input to shared drive from data sending terminal, then sent by shared driveTo 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 thresholdMemory 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 driveIt 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, directlyIt (if the transmission of the data sending terminal terminating communication data exceeds preset time threshold, can be indicated until communication finishesCommunication finishes), such data content remains stored in shared drive, does not write back file, and the content in shared drive is pastPast 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 dataData 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 executingAny 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 oneThe schematic block diagram of kind virutal machine memory sharing means.Virutal machine memory sharing means 100 can be configured at desktop computer, plateComputer, 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 listMember 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 inStore function.
In the present embodiment, creation shared drive is same in one piece of physical memory of creation, the physical memory createdWhen map to multiple process address spaces, wherein each Java Virtual Machine can be considered as it is (multiple with its one-to-one processJava Virtual Machine can operate in same terminal simultaneously, and in desktop computer or server, each process can correspond to progressThe commission calculation procedure of one enterprise staff), each process has the corresponding process address space.If in multiple Java Virtual MachinesThere is a Java Virtual Machine to be updated the content in the shared drive, remaining Java Virtual Machine can be seen shared immediatelyContent 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 onlyIt 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 onlyData 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 queueFour 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 functionIt 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 passesEntering value includes the key assignments (i.e. key, parameter type key_t) of shared drive, shared drive byte number (i.e. size, parameterType 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 MachineOne piece of new shared drive;0 is set by key, then operating system will ignore key, establish a new shared drive, specify oneThen a key assignments returns to this block shared drive IPC identifier ID.And tell the identifier ID of this new shared drive to otherProcess 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 willSize 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 divideIt is with whole one page (the default size PACE_SIZE=4096 byte of one page in i386 machine) in this way, newly created shared interiorThe size deposited is actually the page-size adjusted from this parameter of size.I.e. if size is 1 to 4096, practical ShenThe 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 sharedMemory is not present, then creates a shared drive, otherwise opening operation.If IPC_CREAT, shmget () letter is used aloneThe 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 driveSymbol;If the shared drive is existing, or returns to -1.There is no too big meanings for IPC_EXEL mark itself, but andIPC_CREAT mark, which is used together, is to ensure that resulting object is newly-built, rather than opens existing object.ForUser'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 perhapsCan, 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 JavaIn wherein a certain Java Virtual Machine in machine, after creation is completed, the shared drive function, which is stored in, to be communicatedIn 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 outSending end and data receiver can be considered as a Java Virtual Machine, then encapsulate the shared drive function to data sending terminalLocal interface, and the shared drive function is encapsulated to the local interface of data receiver.When data sending terminal and data connectReceiving 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 compiledThe 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 machineState links library file;
Environmental variance configuration unit 1023, for being configured to the dynamic link library file wait communicate the ring in virtual machineBorder 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 terminalDll file (Dynamic Link Library indicates dynamic link library file) neutralizes the DLL of the local interface of data receiverIn 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 terminalVariable, and the dll file of the local interface of data receiver is configured in the environmental variance of data receiver, it can be completed altogetherEnjoy 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 parsingThe corresponding address of the shared drive is respectively mapped to data sending terminal and data receiver by interior store function, will be wait communicateData 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 receiverConnection needs shared drive function packaged in the local interface by data sending terminal to parse at this time, while data being connectPackaged shared drive function is parsed in the local interface of receiving end, is passing through shared drive function for the shared driveCorresponding address is respectively mapped to data sending terminal and data receiver, can be visited with ensuring data sending terminal and data receiverAsk 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 varianceObtain corresponding dynamic link library file;
Decompiling unit 1032 obtains the dynamic link library for carrying out decompiling to the dynamic link library fileHeader file in file;
Shared drive function acquiring unit 1033 obtains and institute for obtaining the shared drive function in the header fileState 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-mentionedReverse process can be realized and the corresponding address of the shared drive is quickly respectively mapped to data sending terminal and data receiverEnd, 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 acquisitionThe 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 driveEnjoy 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 pointerThe 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 functionJava 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 sharedMemory byte number summation positioning termination address can obtain described according to the initial address and termination address of the shared driveThe corresponding address of shared drive.Finally, the corresponding address of the shared drive is respectively mapped to data by null pointer at randomThe 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 describedCommunication 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 driveTo 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 presetTime 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 driveIt 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, directlyIt (if the transmission of the data sending terminal terminating communication data exceeds preset time threshold, can be indicated until communication finishesCommunication finishes), such data content remains stored in shared drive, does not write back file, and the content in shared drive is pastPast 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 dataData 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 withIt 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 calculating500 equipment of machine equipment can be terminal, be also possible to server.The terminal can be tablet computer, laptop, desktopThe electronic equipments such as brain, personal digital assistant.
Refering to fig. 11, which includes processor 502, memory and the net connected by system bus 501Network 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 program5032 include program instruction, which is performed, and processor 502 may make to execute a kind of shared side of virutal machine memoryMethod.
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, shouldWhen 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 manageIt solves, structure shown in Figure 11, only the block diagram of part-structure relevant to application scheme, is not constituted to the application sideThe restriction for the computer equipment 500 that case is applied thereon, specific computer equipment 500 may include more than as shown in the figureOr 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 functionEnergy:Create shared drive, and shared drive function corresponding with the shared drive;By the shared drive function encapsulate toCommunicate 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 machineReceiving end;If detecting the data sending request of data sending terminal, by parsing the shared drive function, by the shared driveCorresponding address is respectively mapped to data sending terminal and data receiver, will be wait communicate data sending terminal and number in virtual machineConnection is established by local interface according to receiving end;The shared drive obtains the communication data of the data sending terminal, and by instituteIt 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 obtainedHeader file corresponding with the shared drive function;The header file is introduced to wait communicate the dynamic of the local interface in virtual machineState links library file;The dynamic link library file is configured to wait communicate the environmental variance in virtual machine, to complete in sharedStore 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, andCorresponding dynamic link library file is obtained according to environmental variance;Decompiling is carried out to the dynamic link library file, described in acquisitionHeader file in dynamic link library file;The shared drive function in the header file is obtained, is obtained and the shared drive letterShared drive byte number in number.
In one embodiment, processor 502 also performs the following operations:According to the shared drive in the shared drive functionByte number obtains the initial address and termination address of the shared drive;According to the initial address and termination of the shared driveAddress obtains the corresponding address of the shared drive;The corresponding address of the shared drive is reflected respectively at random by null pointerIt 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 dataIt 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 computerThe restriction of equipment specific composition, in other embodiments, computer equipment may include components more more or fewer than diagram, orPerson combines certain components or different component layouts.For example, in some embodiments, computer equipment can only include depositingReservoir 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 (CentralProcessing Unit, CPU), which can also be other general processors, digital signal processor (DigitalSignal Processor, DSP), specific integrated circuit (Application Specific Integrated Circuit,ASIC), ready-made programmable gate array (Field-Programmable GateArray, FPGA) or other programmable logic devicesPart, discrete gate or transistor logic, discrete hardware components etc..Wherein, general processor can be microprocessor orThe 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 storageMedium.The storage medium is stored with computer program, and wherein computer program includes program instruction.The program instruction is by processorIt is realized when execution:Create shared drive, and shared drive function corresponding with the shared drive;By the shared drive functionEncapsulation 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 communicateOne data receiver;It, will be described by parsing the shared drive function if detecting the data sending request of data sending terminalThe 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 machineSending end establishes connection by local interface with data receiver;The shared drive obtains the communication number of the data sending terminalAccording 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 machineDynamic link library file;The dynamic link library file is configured to wait communicate the environmental variance in virtual machine, to complete altogetherEnjoy 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 machineAmount, and corresponding dynamic link library file is obtained according to environmental variance;Decompiling is carried out to the dynamic link library file, is obtainedHeader file in the dynamic link library file;Obtain the shared drive function in the header file, obtain with it is described it is shared inShared drive byte number in store function.
In one embodiment, realization when which is executed by processor:According to being total in the shared drive functionMemory byte number is enjoyed, the initial address and termination address of the shared drive are obtained;According to the initial address of the shared driveAnd termination address, obtain the corresponding address of the shared drive;The corresponding address of the shared drive is random by null pointerIt 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 numberAccording 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 depositStorage 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 storageBlock (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 setThe 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 algorithmStep can be realized with electronic hardware, computer software, or a combination of the two, in order to clearly demonstrate hardware and softwareInterchangeability generally describes each exemplary composition and step according to function in the above description.These functions are studied carefullyUnexpectedly the specific application and design constraint depending on technical solution are implemented in hardware or software.Professional technicianEach specific application can be used different methods to achieve the described function, but this realization is it is not considered that exceedThe scope of the present invention.
In several embodiments provided herein, it should be understood that disclosed unit and method, it can be withIt realizes by another way.For example, the apparatus embodiments described above are merely exemplary, for example, the unitIt divides, only a kind of logical function partition, there may be another division manner in actual implementation, can also will have identical functionThe unit set of energy can be combined or can be integrated into another system at a unit, such as multiple units or components, orSome features can be ignored or not executed.In addition, shown or discussed mutual coupling or direct-coupling or communication linkConnect can be through some interfaces, the indirect coupling or communication connection of device or unit, be also possible to electricity, it is mechanical or otherForm connection.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unitThe component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multipleIn network unit.Some or all of unit therein can be selected to realize the embodiment of the present invention according to the actual needsPurpose.
It, can also be in addition, the functional units in various embodiments of the present invention may be integrated into one processing unitIt 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 integratedUnit 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 productWhen, it can store in one storage medium.Based on this understanding, technical solution of the present invention is substantially in other words to existingThe all or part of part or the technical solution that technology contributes can be embodied in the form of software products, shouldComputer software product is stored in a storage medium, including some instructions are used so that a computer equipment (can bePersonal computer, server or network equipment etc.) execute all or part of step of each embodiment the method for the present inventionSuddenly.And storage medium above-mentioned includes:USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), magnetic disk orThe 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, anyThose familiar with the art in the technical scope disclosed by the present invention, can readily occur in various equivalent modifications or replaceIt 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 rightIt is required that protection scope subject to.

Claims (10)

CN201810613940.6A2018-06-142018-06-14Virutal machine memory sharing method, device, computer equipment and storage mediumPendingCN108829529A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN201810613940.6ACN108829529A (en)2018-06-142018-06-14Virutal machine memory sharing method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201810613940.6ACN108829529A (en)2018-06-142018-06-14Virutal machine memory sharing method, device, computer equipment and storage medium

Publications (1)

Publication NumberPublication Date
CN108829529Atrue CN108829529A (en)2018-11-16

Family

ID=64141899

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201810613940.6APendingCN108829529A (en)2018-06-142018-06-14Virutal machine memory sharing method, device, computer equipment and storage medium

Country Status (1)

CountryLink
CN (1)CN108829529A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN111796944A (en)*2019-04-082020-10-20维塔科技(北京)有限公司Method and device for switching shared memory area, storage medium and electronic equipment
CN111797497A (en)*2020-05-212020-10-20中国电力科学研究院有限公司 A communication method and system for parallel simulation of electromagnetic transients
CN111796901A (en)*2019-04-082020-10-20维塔科技(北京)有限公司Method and device for switching shared memory area, storage medium and electronic equipment
CN112052100A (en)*2019-06-062020-12-08华为技术有限公司 Virtual machine communication method and device based on shared memory
CN112559203A (en)*2020-12-102021-03-26上海连尚网络科技有限公司Method and device for realizing data exchange between service layer and so library
CN114327944A (en)*2021-12-242022-04-12科东(广州)软件科技有限公司Method, device, equipment and storage medium for sharing memory by multiple systems
CN118550735A (en)*2024-07-302024-08-27天翼云科技有限公司Method and device for improving high-performance calculation

Citations (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20050086661A1 (en)*2003-10-212005-04-21Monnie David J.Object synchronization in shared object space
CN101819564A (en)*2009-02-262010-09-01国际商业机器公司Method and device for assisting communication between virtual machines
CN107491354A (en)*2017-07-032017-12-19北京东土科技股份有限公司A kind of inter-virtual machine communication method and device based on shared drive
CN107943596A (en)*2016-10-122018-04-20阿里巴巴集团控股有限公司Way of Process Communication, apparatus and system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20050086661A1 (en)*2003-10-212005-04-21Monnie David J.Object synchronization in shared object space
CN101819564A (en)*2009-02-262010-09-01国际商业机器公司Method and device for assisting communication between virtual machines
CN107943596A (en)*2016-10-122018-04-20阿里巴巴集团控股有限公司Way of Process Communication, apparatus and system
CN107491354A (en)*2017-07-032017-12-19北京东土科技股份有限公司A kind of inter-virtual machine communication method and device based on shared drive

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
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 (10)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN111796944A (en)*2019-04-082020-10-20维塔科技(北京)有限公司Method and device for switching shared memory area, storage medium and electronic equipment
CN111796901A (en)*2019-04-082020-10-20维塔科技(北京)有限公司Method and device for switching shared memory area, storage medium and electronic equipment
CN112052100A (en)*2019-06-062020-12-08华为技术有限公司 Virtual machine communication method and device based on shared memory
CN112052100B (en)*2019-06-062023-05-12华为技术有限公司 Virtual machine communication method and device based on shared memory
CN111797497A (en)*2020-05-212020-10-20中国电力科学研究院有限公司 A communication method and system for parallel simulation of electromagnetic transients
CN111797497B (en)*2020-05-212024-05-17中国电力科学研究院有限公司 A communication method and system for electromagnetic transient parallel simulation
CN112559203A (en)*2020-12-102021-03-26上海连尚网络科技有限公司Method and device for realizing data exchange between service layer and so library
CN114327944A (en)*2021-12-242022-04-12科东(广州)软件科技有限公司Method, device, equipment and storage medium for sharing memory by multiple systems
CN118550735A (en)*2024-07-302024-08-27天翼云科技有限公司Method and device for improving high-performance calculation
CN118550735B (en)*2024-07-302024-11-26天翼云科技有限公司 A method and device for improving high performance computing

Similar Documents

PublicationPublication DateTitle
CN108829529A (en)Virutal machine memory sharing method, device, computer equipment and storage medium
US12020042B2 (en)Deploying service containers in an adapter device
CN105518611B (en)Remote direct data access method, device and system
CN113986515B (en)Method and device for creating sandbox environment for plug-in operation and computing equipment
US8010973B2 (en)Class loader for managing a network
CN101150488B (en)A receiving method for zero copy network packet
CN112671760A (en)Socket-based client cross-platform network communication method and related equipment thereof
CN102694866B (en)Service request broker system in distributed network environment
CN113032166B (en)Inter-core communication method, processor, inter-core communication system, and computer-readable storage medium
CN108418874A (en)Guiding method, device, computer equipment and storage medium are returned across wide area network data
CN103856554A (en)Clustering support across geographical boundaries
WO2005083984A1 (en)Protocol stack with modification facility
CN107678778A (en)Compatibility method, adapter, running gear and system based on Hybrid
KR101856486B1 (en)Method for bi-direction calling between open system and mainframe system
CN116800616B (en)Management method and related device of virtualized network equipment
CN116113923A (en)Container cluster management method and system
CN106873915A (en)A kind of data transmission method and device based on RDMA registers memory blocks
CN108228309A (en)Data packet method of sending and receiving and device based on virtual machine
CN106919442A (en)Many GPU dispatching devices and distributed computing system and many GPU dispatching methods
Li et al.Interconnecting heterogeneous devices in the personal mobile cloud
CN105610730A (en)Method and system for message interaction between CPU and network equipment
CN101963924B (en) A process communication method, device and operating system
CN104965786B (en)A kind of adjustment method of application program, debugging host and operation host
CN115174659A (en)Vehicle-mounted service container, service calling method, device and medium
CN113722110B (en)Computer system, memory access method and device

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
RJ01Rejection of invention patent application after publication

Application publication date:20181116

RJ01Rejection of invention patent application after publication

[8]ページ先頭

©2009-2025 Movatter.jp