164 Chapter 6. Typical Architectural Styles
6.5 VIRTUAL MACHINE
A. Structural pattern
A software system of virtual machine architecture usually consists of 4 components
interconnected as follows (Figure 6.18).
Figure 6.18 Virtual machine architecture
B. Computational model and design vocabulary
Virtual machines are software systems that simulate a computer system, but with
some functionality that is not native to the hardware and/or software on which it is
implemented.
Similar to the hardware architecture of a computer, the structure of a virtual
machine consists of three passive data components and one active component as
shown in Figure 6.18. Their functions are as follows.
(a) The program component stores the ‘program’ being interpreted, which is
an abstract representation of the process of data. It is usually in the form of a
sequence of structured data elements. Each element represents an ‘instruction’ or
statement’ for how to process the data. It is analogous to the program instructions
run on the hardware computer system, hence called ‘program’.
(b) The data component stores the information to be processed. Such
information is analogous to the values assigned to variables in the execution of a
program. The data component is analogou to the memory of computer hardware.
(c) The interpretation engine is the active component in the system. It selects
an instruction from the ‘program’ being interpreted, updates the program’s data
Data
(Program State)
Program
Internal
State
Interpretation
Engine
Input
Output
State Data
Data
Updates
Selected Instruction
Selected Data
Program
Instruction
Software Design Methodology 165
according to the instruction, and updates its internal state. It is analogous to the
CPU in computer hardware.
(d) The internal state stores the current state of the interpretation engine. It is
analogous to the registers or the instruction count in computer hardware.
C. Properties derived from the architecture
Virtual machine architectures have the goal of achieving the quality of portability.
Executing a program via an interpreter also adds flexibility through the ability to
interrupt and query the program and introduce modifications at run-time, but there
is a performance cost.
This can be useful in a number of ways. It can allow one to simulate and test
platforms that have not yet been built such as new hardware, and it can simulate
‘disaster’ mode that would be too complex, costly or dangerous to test with the real
system.
D. Examples
Common examples of virtual machines are interpreters, rule-based systems,
syntactic shells, and command language processors. For example, the Java
language is built to run on top of the Java virtual machine, which allows the Java
programs to be platform independent. A Java program can therefore be executed on
all computer platforms that have an implementation of Java virtual machine.
A Java virtual machine is a software system that enables compiled Java
programs to be executed. However, the term Java virtual machine also refers to the
abstract specification of any specific implementation of such a system. This
specification defines the architecture of the software, its dynamic behaviour, format
of the object code generated from a compilation of Java programs, as well as
various issues that may affect the portability of the Java programs. There are a
number of implementations of the abstract specifications on various hardware and
software platforms. The term Java virtual machine may also refer to any run-time
instances of the software. The following gives a very brief introduction to the
architecture of Java virtual machine as specified in the abstract specification in [
3].
Figure 6.19 shows the components and their connections in a Java virtual machine.

Get Software Design Methodology now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.