The present invention relates to virtualized computers, and more particularly to sharing class data among virtual machine applications running on guests in a virtualized environment using a memory management facility.
Some computer systems can simultaneously execute multiple operating systems. In such computer systems, the operating systems share computer resources, so that one physical computer can act as many computers. In some instances, a main operating system allows multiple guest operating systems to share a computer's physical resources, such as disk, memory, network adapters, CPUs etc. The main operating system can includes a hypervisor, which manages such resource sharing.
In some instances, computer systems can derive efficiencies from sharing data between software running in different guest operating systems. For example, such data sharing can reduce the amount of memory needed for executing application programs in the different guest operating systems.
The present embodiments may be better understood, and numerous objects, features, and advantages made apparent to those skilled in the art by referencing the accompanying drawings.
In some embodiments, an apparatus includes hardware components including one or more central processing units and main memory, wherein a portion of the main memory is configured to store shared Java classes. The apparatus can also include a hypervisor configured to control access to the hardware components, and to host a plurality of operating systems. Each of the operating systems can include a character device driver configured to write directly to the portion of main memory configured to store the shared Java classes. The apparatus can also include one or more Java virtual machines configured to execute the shared Java classes and modify the shared Java classes using the character device driver.
Some embodiments also include a method for sharing Java classes in a computer system. Such a method can include loading program code and data into a shared memory, where the program code and includes Java classes, and wherein the shared memory is shared by a plurality of Java virtual machines (JVMs) each executing in a different operating system of the computer system. The method can also include modifying the program code and data in the shared memory, wherein the modifying is performed, at least in part, by a character device driver that directly writes to the shared memory. The method can also include executing, by one or more of the Java Virtual Machines, the program code in the shared memory.
The description that follows includes exemplary systems, methods, techniques, instruction sequences and computer program products that embody techniques of the present inventive subject matter. However, it is understood that the described embodiments may be practiced without these specific details. For instance, although examples refer to Java® virtual machines, some embodiments work with other virtual machines. In some instances, well-known instruction instances, protocols, structures and techniques have not been shown to avoid obfuscating the description.
Some computers can host multiple operating systems. For example, a computer may simultaneously host a version of IBM's AIX operating system, and a version of the Linux operating system. Typically, a computer that hosts multiple operating systems includes a hypervisor that enables each operating system to utilize the computers' resources. In some instances, a hypervisor is a software layer between the computer's hardware and the operating systems. Thus, each operating system can interact with the hypervisor as if the operating system was interacting with computer hardware.
While the hypervisor can host multiple operating systems, each of the operating systems can host one or more Java virtual machines (JVMs). In some instances, all the JVMs may require the same classes (e.g., Java program code and data) for executing Java application programs. Instead of creating duplicates of the Java classes, some embodiments of the inventive subject matter enable the JVMs to share a single instance of the classes. These embodiments facilitate class sharing where the JVMs are operating in multiple operating systems, and where the operating systems are executing on a hypervisor.
In
Although
The application programs 112 include Java program code, which includes Java byte codes. Java is an objected-oriented programing language that organizes code into Java class files. Thus, the Java program code can also include data. A JVM 114 executes an application program 112 by processing the Java program code. The Java program code may call other Java code included in the class files. In turn, the JVM 114 fetches and executes the Java class files (e.g., from persistent storage 106).
In some instances, JVMs in different environments 118 need the same class files. For example, JVMs 114 in the Linux and z/OS environments may need a particular class file. There may be two identical copies of the class file residing in the Linux and z/OS environments. Alternatively, there is a single copy of the needed class file residing on a file system shared by the Linux and z/OS environments. Instead of loading multiple copies of the needed class files into the main memory 104, some embodiments facilitate Java class sharing between JVMs in different environments 118. For example, some embodiments enable the JVMs operating in the Linux and z/OS environments to share Java classes, avoiding duplicate instances of the shared Java class code in main memory 104. By eliminating duplicate instances of shared java class code, embodiments of the invention enable more of the computer's resources to be available for other purposes, such as for additional environments, JVMs, applications, etc.
The computer 200 also includes JVM 1, JVM 2, and JVM 3. Each of the JVMs includes local Java classes 212. In
In the past, some multi-environment operating systems supported DCSSs for sharing data between environments. However, DCSSs were not suitable for sharing Java classes because the DCSSs were not immediately updated after write operations. That is, if a JVM updated the shared class cache, the updates would not appear in the cache until after some delay. Such write delays would cause coherency issues if multiple JVMs attempted to update the shared class cache. Embodiments of the inventive subject matter facilitate direct and immediate write operations to data in the DCSS. Therefore, embodiments of the invention enable JVMs to share java classes in the DCSS, and thus across multiple guest operating systems.
In
The following discussion provides more details about how some embodiments share Java classes across multiple operating systems.
In
After executing the operations in
After processing Java code, the JVM determines whether it needs to update one or more shared Java classes, at block 504. If the JVM needs to update shared Java classes, the flow continues at block 506. Otherwise, the flow loops back to block 502. In some embodiments, shared Java classes are stored in a DCSS. As described vis-à-vis
At block 506, the JVM requests a lock that protects the shared Java classes. If the lock is available (block 508), the JVM uses a character device driver to write directly to the DCSS, modifying the shared Java classes (block 510). If the lock is not available, the flow loops back to block 506 and requests the lock again. After writing to the shared Java classes in the DCSS, the JVM releases the lock (block 512). After releasing the lock, the flow ends.
As will be appreciated by one skilled in the art, aspects of the present inventive subject matter may be embodied as a system, method or computer program product. Accordingly, aspects of the present inventive subject matter may take the form of an entirely hardware embodiment, an entirely software embodiment (including firmware, resident software, micro-code, etc.) or an embodiment combining software and hardware aspects that may all generally be referred to herein as a “circuit,” “module” or “system.” Furthermore, aspects of the present inventive subject matter may take the form of a computer program product embodied in one or more computer readable medium(s) having computer readable program code embodied thereon.
Any combination of one or more computer readable medium(s) may be utilized. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present inventive subject matter may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, etc. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider).
Aspects of the present inventive subject matter are described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the inventive subject matter. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer readable medium that can direct a computer, other programmable data processing apparatus, or other devices to function in a particular manner, such that the instructions stored in the computer readable medium produce an article of manufacture including instructions which implement the function/act specified in the flowchart and/or block diagram block or blocks.
The computer program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks.
Referring back to
While the embodiments are described with reference to various implementations and exploitations, it will be understood that these embodiments are illustrative and that the scope of the inventive subject matter is not limited to them. In general, techniques sharing Java classes between JVMs in a multi-OS environment, as described herein, may be implemented with facilities consistent with any hardware system or hardware systems. Many variations, modifications, additions, and improvements are possible.
Plural instances may be provided for components, operations or structures described herein as a single instance. Finally, boundaries between various components, operations and data stores are somewhat arbitrary, and particular operations are illustrated in the context of specific illustrative configurations. Other allocations of functionality are envisioned and may fall within the scope of the inventive subject matter. In general, structures and functionality presented as separate components in the exemplary configurations may be implemented as a combined structure or component. Similarly, structures and functionality presented as a single component may be implemented as separate components. These and other variations, modifications, additions, and improvements may fall within the scope of the inventive subject matter.