A heap organization is a memory area that may be used to store data for a plurality of tasks that are executed concurrently by a multitasking virtual machine. The data may include program objects and metadata for all of the tasks.
Conventionally, there are two classes of heap organization, shared heap and separated heap. For the shared heap class, the multitasking virtual machine may use a single heap to store data accessible by all of the tasks. For the separated heap class, the multitasking virtual machine may use a number of heaps that are logically separated. Each separated heap may be assigned to store the data that is only accessible by a single task.
The invention described herein is illustrated by way of example and not by way of limitation in the accompanying figures. For simplicity and clarity of illustration, elements illustrated in the figures are not necessarily drawn to scale. For example, the dimensions of some elements may be exaggerated relative to other elements for clarity. Further, where considered appropriate, reference labels have been repeated among the figures to indicate corresponding or analogous elements.
The following description describes techniques for heap organization for a multitasking virtual machine. In the following description, numerous specific details such as logic implementations, pseudo-code, methods to specify operands, resource partitioning/sharing/duplication implementations, types and interrelationships of system components, and logic partitioning/integration choices are set forth in order to provide a more thorough understanding of the current invention. However, the invention may be practiced without such specific details. In other instances, control structures, gate level circuits and full software instruction sequences have not been shown in detail in order not to obscure the invention. Those of ordinary skill in the art, with the included descriptions, will be able to implement appropriate functionality without undue experimentation.
References in the specification to “one embodiment”, “an embodiment”, “an example embodiment”, etc., indicate that the embodiment described may include a particular feature, structure, or characteristic, but every embodiment may not necessarily include the particular feature, structure, or characteristic. Moreover, such phrases are not necessarily referring to the same embodiment. Further, when a particular feature, structure, or characteristic is described in connection with an embodiment, it is submitted that it is within the knowledge of one skilled in the art to effect such feature, structure, or characteristic in connection with other embodiments whether or not explicitly described.
Embodiments of the invention may be implemented in hardware, firmware, software, or any combination thereof. Embodiments of the invention may also be implemented as instructions stored on a machine-readable medium that may be read and executed by one or more processors. A machine-readable medium may include any mechanism for storing or transmitting information in a form readable by a machine (e.g., a computing device). For example, a machine-readable medium may include read only memory (ROM); random access memory (RAM); magnetic disk storage media; optical storage media; flash memory devices; electrical, optical, acoustical or other forms of propagated signals (e.g., carrier waves, infrared signals, digital signals, etc.) and others.
The computing platform 10 may comprise one or more processors 101, memory 102, chipset 103, I/O devices 104, a firmware 105 and possibly other components. The one or more processors 101 may be communicatively coupled to various components. (e.g., the chipset 103) via one or more buses such as a processor bus. The processors 101 may be implemented as an integrated circuit (IC) with one or more processing cores that may execute codes under a suitable architecture, for example, including Intel® Xeon™, Intel® Pentium™, Intel® Itanium™ architectures, available from Intel Corporation of Santa Clara, Calif.
The memory 102 may store instructions and data in the form of a plurality of software applications 1021, a multitasking virtual machine 1022 and an operation system 1023. Examples for the memory 102 may comprise one or any combination of the following semiconductor devices, such as synchronous dynamic random access memory (SDRAM) devices, RAMBUS dynamic random access memory (RDRAM) devices, double data rate (DDR) memory devices, static random access memory (SRAM), and flash memory devices.
The plurality of software applications 1021 may be input from any suitable devices, such as the I/O devices 106. In other embodiments, the software applications may also be generated by other components within the computing platform 10. Examples for the software applications 1021 may comprise JAVA applications (e.g., JAVA.class files), .NET application (e.g., .NET codes), or applications in possibly other programming languages.
The multitasking virtual machine 1022 may run above the operating system 1023 to concurrently execute the plurality of software applications 1021. Each software application 1021 may include one or more tasks, each of which may represent an instantiation of a single software application 1021. In a JAVA virtual machine, if two ‘tasks’ share the same class path (i.e., same ordered table of the class files), the two ‘tasks’ may belong to one application.
Examples for the multitasking virtual machine 1022 may comprise a multitasking JAVA virtual machine available from Sun Microsystems Inc., Santa Clara, Calif., and a multitasking NET virtual machine available from Microsoft® Corporation, Redmond, Wash. The operation system 1023 may include, but is not limited to, different versions of Linux®, Microsoft® Windows®, and real time operating systems such as VxWorks®, etc.
In an embodiment, the chipset 103 may provide one or more communicative paths among the one or more processors 101, memory 102 and other components, such as the I/O device 104 and firmware 105. The chipset 103 may comprise a memory controller hub 1031, an input/output controller hub 1032 and a firmware hub 1033.
In an embodiment, the memory controller hub 1031 may provide a communication link to the processor bus that may connect with the processors 101 and to a suitable device such as the memory 102. The memory controller hub 102 may couple with the I/O controller hub 1032 to provide an interface to the I/O devices 104 for the computing platform. Examples for the I/O devices 104 may comprise a keyboard, mouse, network interface, a storage device, a camera, a blue-tooth device, and an antenna.
In an embodiment, the memory controller hub 1031 may communicatively couple with a firmware hub 1033 via the input/output controller hub 1032. The firmware hub 1033 may couple with the firmware 105 that may store BIOS routines that the computing platform executes during system startup in order to initialize the processors 101, chipset 103, and other components of the computing platform and/or EFI routines to interface the firmware 105 with an operating system of the computer platform and provide a standard environment for booting the operating system.
Other embodiments may implement other technologies for the structure of the computing platform 10. For example, the multitasking virtual machine 1022 may execute one software application 1021 in one instantiation of the virtual machine. In other words, the multitasking virtual machine 1022 may concurrently execute a plurality of tasks belonging to one application in one instantiation of the virtual machine, and the plurality of tasks are respectively instantiations of the application.
The loader 201 may load files (including classes, interfaces, native methods) from various resources. For example, the loader 201 may load the plurality of software applications 1021, libraries, runtime environment variables and possibly other files from the multitasking virtual machine vendor, the programmer and any third parties. The libraries may comprise various functions or routines to provide basic functionalities to user programs, such as bootstrap class libraries and non-bootstrap class libraries. The runtime environment variables may comprise configurations to help the multitasking virtual machine find the application resources. Examples of the loader may comprise class loaders, native method interface, and possibly other loading means.
The execution engine 202 may concurrently execute a plurality of tasks associated with the software applications 1021. More specifically, the execution engine 202 may concurrently translate the software applications and execute the translated codes.
The heap organization 203 may store data for the multitasking virtual machine 1022, such as metadata and program objects. The metadata may comprise information about the files loaded from the loader 201 or other components (e.g., software applications, libraries, runtime environment variables, etc.), translated codes of the files from the execution engine 202 and possibly other data. Examples of the metadata may comprise virtual machine internal representation of JAVA classes, methods, fields, bytecodes, JIT'ed (Just-in-time) codes, and the like. The program objects may comprise objects generated when executing the loaded files. Examples of the program objects may comprise user-defined class loaders and instances of class files.
The heap manager 204 may manage the heap organization 203, for example, with help from the loader 201.
The heap organization 203 may comprise a plurality of logically disjointed heaps, wherein each heap may comprise a plurality of logically contiguous memory blocks and no blocks may overlap between two heaps.
In the embodiment of
The system heap may store system data sharable for all of the tasks executed by the multitasking virtual machine 1022. Lifespan for the data stored in the system heap may be equal to one instantiation of the multitasking virtual machine 1022. Examples of the system data may comprise metadata of globally shared libraries (e.g., bootstrap class libraries, globally shared runtime environment, platform-definition information), program objects having a lifespan equal to the instantiation of the multitasking virtual machine (e.g., the objects generated when executing the bootstrap class program), and possibly other data for the system. In the embodiment of
Each of the application heap 3021-N may be assigned to each ‘live’ application of the plurality of the software applications 1021, in which a ‘live’ application may have at least one task that is executed by the multitasking virtual machine 1022. A task may be an instantiation of its application. Each of the application heap 3021-N may store application data accessible by all of the task(s) belonging to the application and lasting as long as the application. For JAVA virtual machine specification, if two ‘tasks’ belong to one application, the two ‘tasks’ may share the same class path, namely, they may share the same ordered table of class files. In view of this, an application may represent executable binaries (including dynamically loaded binaries) and runtime environment for its tasks.
The application data stored in each of the application heap 3021-N may comprise metadata for the application and program objects that may have the same lifespan as the application. Examples of the metadata for the application may comprise information about application class files, translated codes of the application class files, application libraries and runtime environment variables for translating and executing the application class files, and possibly other data for the application. Examples of the program objects may comprise the objects generated when initializing the application class files. In the embodiment of
Each of the task heaps 3031-N may be assigned to each ‘live’ task executed by the multitasking virtual machine 1022. Each of the task heaps 3031-N may store task data only accessible by the associated task, which 10 means accessing of the task data by other tasks may be prohibited. The task data may have the same lifespan as the associated task. Examples of the task data may comprise program objects generated when executing the task and runtime environment variables for executing the task. In the embodiment of
As shown in
Other embodiments may implement other technologies for the structure of the heap organization 203 of
In block 401, the heap manager 204 or other suitable device may determine to create a task heap for a task that may be executed by the multitasking virtual machine 1022. In block 402, the heap manager 204 or other suitable device may determine an application that the task belongs to. As stated above, an application may represent executable binaries (including dynamically loaded binaries) and runtime environment for its task, therefore, the heap manager 204 or other suitable device may determine the application by introspecting executable binaries and runtime environment of the task.
In block 403, the heap manager 204 or other suitable device may determine whether an application heap has been assigned to the application. In an embodiment of block 403, the heap manager 204 or other suitable device may maintain a ‘live’ application table recording all of the ‘live’ applications. Each ‘live’ application may have at least one task that may be executed by the multitasking virtual machine 1022 and therefore may be assigned with an application heap. By this way, the heap manager 204 or other suitable device may determine the application heap has been assigned to the application if the application is listed in the ‘live’ application table and determine the application heap has not been assigned to the application if not listed.
If the application has not been assigned with an application heap, the heap manager 204 or other suitable device may create an application heap for the application in block 404. In block 405, the heap manager 203 or other suitable device may load application data into the application heap. The application data may comprise metadata for the application and program objects having a lifespan equal to the application.
In block 406, the heap manager 203 or other suitable device may mark the existence of the created application heap. In an embodiment of block 408, the heap manager 203 or other suitable device may add the application corresponding to the application heap into the ‘live’ application table.
In block 407, the heap manager 203 or other suitable device may bind the task to the application heap created in block 404, so that the task may access the application data in the application heap. In an embodiment of block 407, the heap manager 203 or other suitable device may add the task into a ‘live’ task table maintained for the application which records each task belonging to the application and executed by the multitasking virtual machine 1022.
Then, in block 408, the heap manager 203 or other suitable device may create a task heap for the task that may be executed by the multitasking virtual machine 1022. The task heap may be created by adding the task heap address, application heap address and system heap address into stacks of the task so that the task may access the data in those heaps. Finally, in block 409, the execution engine 202 of the multitasking virtual machine 1022 may run the task on its task heap.
Referring back to block 403, if an application heap has been assigned to the application corresponding to the task, the heap manager 203 or other suitable device may bind the task to the application heap in block 407, create a task heap for the task in block 408 so that the execution engine 202 may run the task on its task heap in block 409.
In block 501, a task may be terminated, for example, when the execution engine 202 completes the execution of the task. In block 502, the heap manager 203 or other suitable device may free a task heap assigned to the task. In an embodiment of block 502, the heap manager 203 may return memory region of the task heap to the operating system as a whole. Then, in block 503, the heap manager 203 or other suitable device may determine whether the task is the last task of the application it belongs to. The heap manager 203 or other suitable device may implement block 203 in various ways, for example, by checking the above-described ‘live’ task table maintained for the application to determine whether the task is the last one in the ‘live’ task table.
If the task is not the last task of the application, the heap manager 203 or other suitable device may unbind the task from an application heap assigned to the application in block 506. The unbinding may be implemented by deleting the task from the ‘live’ task table maintained for the application. However, if the task is the last task of the application, the heap manager 203 or other suitable device may reclaim the application heap for the application in block 504. The heap manager 203 or other suitable device may implement block 504 in various ways, for example, by returning memory region of the application heap to the operation system as a whole. Then, in block 505, the heap manager 203 or other suitable device may mark the reclamation of the application heap, for example, by deleting the corresponding application from the above-described ‘live’ application table.
The heap organization 203 may comprise a plurality of application heaps 6011-N and a plurality of task heaps 6021-N. Each of the application heaps 6011-N may be assigned to one of the applications 1021. Each application heap may comprise system data and application data only accessible by the task(s) belonging to the application and lasting as long as the application. The system data may comprise metadata and program objects of globally shared libraries and globally shared runtime environment, and the application data may comprise metadata and program objects of the application classes, application libraries and application runtime environment.
Each of the task heaps 6021-N may be assigned to each task executed by the multitasking virtual machine. Each task heap may store task data only accessible by the associated task and lasting as long as the associated task. The task data may comprise program objects and runtime environment for the task. Each of the task heaps 6021-N may be bound to one of the application heaps 6011-N, So that the task can access the data in the task heap as well as the application task.
Other embodiments may implement other technologies for the structure of the heap organization of
As shown, the heap organization 203 may comprise a system heap 701 and a plurality of task heaps 7021-N. The system heap 701 may store system data accessibly by all of the tasks executed by the multitasking virtual machine 1022 and lasting as long as an instantiation of the multitasking virtual machine 1022. The system data may comprise metadata for globally shared libraries and globally shared runtime environment variables, and program objects that may last as long as the instantiation of the multitasking virtual machine, and possibly other system data.
Each of the task heap 7021-N may be assigned to each task executed by the multitasking virtual machine 1022. Each task heap may store application data and task data only accessible by the associated task. The application data may comprise metadata and program objects for the application classes, application libraries and runtime environment, and possibly other data for the application. The task data may comprise program objects and runtime environment variables for the task.
Although the present invention has been described in conjunction with certain embodiments, it shall be understood that modifications and variations may be resorted to without departing from the spirit and scope of the invention as those skilled in the art readily understand. Such modifications and variations are considered to be within the scope of the invention and the appended claims.
Filing Document | Filing Date | Country | Kind | 371c Date |
---|---|---|---|---|
PCT/CN2006/001688 | 7/14/2006 | WO | 00 | 10/28/2009 |