Emulators help you run existing applications on a wider variety of OSes
Barry Nance
You do your engineering under Unix, you do graphics on a Mac, and you use a Windows-based word processor. Do you need three computers? Maybe not. Maybe you just need a good emulator. Emulating an OS goes beyond recognizing one CPU's instructions and translating them to another CPU's architecture. Emulators need to provide an environment in which specific hardware devices (e.g., video adapters and parallel ports) appear to be present. They also need to compensate for the differences between the native file system and the emulated file system, as well as provide networking support, file sharing, and record locking.
Despite these challenges, several companies offer
OS-emulation products
, including
Insignia Solutions (SoftPC and SoftWindows), Locus Computing (DOS Merge), and SunSelect (Wabi). In Windows NT, Microsoft's emulation of 16-bit Windows is a version of SoftWindows. IBM is the hands-down winner, though. Over the years, IBM has emulated many CPUs and OSes, ranging from second-generation 1401 and 7074 I/O Control Systems (IOCSes) hosted on mainframes (i.e., 370 architecture) to IBM PC-DOS hosted on an RS/6000.
Some of these emulators, such as the DOS-on-RS/6000 product (called PC Simulator), are no longer on the market. IBM's two most popular emulators run DOS and Windows programs in the OS/2 environment. The programs run directly on the Intel CPU in virtual-8086 mode, yet they can access files on a High Performance File System (HPFS) drive and perform port-level I/O through OS/2's serial, parallel, DMA, and other virtual device drivers (VDDs).
Differences Exist
Emulators take different approaches
. The one chosen depends on whether the t
arget CPU can execute the emulated OS's instructions and whether the emulator developers have access to the OS's source code.
Insignia Solutions' SoftWindows can run x86-based Windows programs on RISC or 680x0 CPUs, hosted by either Unix or Macintosh System 7. Insignia Solutions licenses Windows source code from Microsoft. DOS Merge, from Locus, runs DOS and Windows programs on Unix-based Intel CPUs (e.g., running SCO Unix). Like Insignia Solutions, Locus has licensed Windows source code from Microsoft. SunSelect's Windows Application Binary Interface (Wabi) can run some but not all Windows programs on Unix-based non-Intel machines. Instead of licensing Windows source code, SunSelect chose to use the published Windows API to engineer its emulator.
PC video hardware presents special problems for the emulator. To run Windows programs, most emulators provide Windows video drivers that act as a liaison between the host (native) video system and Windows. Often, the emulator offers both a full-screen an
d a windowed (seamless) video driver.
Under Unix, for example, a Windows application can appear in its own X Window System window. Similarly, OS/2 can show a Windows program running on the OS/2 desktop. On Macs, SoftWindows contains a Windows video driver that translates screen updates into QuickDraw calls. So complete is the video support that emulators on Unix, OS/2, and Mac System 7 can properly process an application's changes to the Windows color palette as well as changes to the mouse-cursor shape. In the latter case, the emulator changes the mouse cursor to the appropriate shape depending on whether it's in the emulated Windows screen region.
The emulator might allocate a portion of the host OS's file system for use by the emulated OS, or it might go a step further to translate the emulated OS's file information into host file information. Translated file information lets both the host OS and the emulated OS share the same files and directories (or Mac folders). Because products such as Mic
rosoft Word and WordPerfect use the same file layout on the Mac and the PC (depending on the version of the product), the result is transparent file sharing between different operating environments.
Emulators usually allow cut, copy, and paste operations between the host OS and the emulated OS. In the Win-OS/2 environment, IBM uses a technique called
deferred rendering
to speed up Clipboard access. Win-OS/2 renders the Clipboard in an application's desired format (e.g., CF_TEXT) when the application asks for the data. OS/2 thus avoids having to render the data in all possible formats at the time the data is placed on the Clipboard.
The Insignia Solutions products interleave Clipboard translations with window redrawing. When you switch from one window to another, SoftWindows uses a small amount of time to process the Clipboard data. SoftWindows implements Clipboard sharing with a pair of programs called Smart Copy, one a Windows application and one a native-OS application.
You can co
nfigure printer emulation in a variety of ways. In Win-OS/2, you can print to a printer port named LPTx.OS2, a serial COM port, or a file. In SoftWindows running in a Unix environment, you can choose to send LPTx data to a Unix file, to
/dev/lp
, or through a pipe to the Unix
lpr
utility. On the Mac, SoftWindows simply sends print data to the System 7 print manager.
Speed It Up!
When you leave the world of x86, things get really complicated. RISC and 680x0 CPUs don't understand x86 instructions, of course. The emulator parses each x86 instruction, decodes it to determine its intended effect, and executes RISC or 680x0 instructions to produce the same result an Intel CPU would have produced. Along the way, the emulator faithfully imitates the registers, flags, internal arithmetic, and logic states of the Intel CPU.
A GUI application, especially one that's highly interactive, spends much of its time inside OS service routines. Emulators take advantage of the
application's loitering inside the OS to make the application run faster. For example, SoftWindows contains precompiled ("static") functions that implement often-used Windows API and DOS functions. The emulator can quickly execute some native code that achieves the same result as if it had examined and translated each system instruction in the API library. Also, SoftWindows contains an optimizing compiler that dynamically evaluates the code it's emulating, looking for ways to speed up program execution.
Wabi uses the workstation's native X display protocols to manage the appearance of Windows applications on Unix workstations. Wabi translates DOS I/O into Unix I/O, and it similarly manages memory allocations and other resources.
Using technology from Praxsys Technologies, Wabi decodes and imitates individual x86 instructions that are not inside a Windows API or DOS function call. Within such a system call, Wabi switches to native mode to perform the DOS or Windows function in terms of equivalent
X or Unix system calls.
SunSelect engineered Wabi not by acquiring a Windows source code license, but rather by establishing an environment in which each published, well-known Windows API call or DOS function call is available as a Wabi library routine. SunSelect publishes a list of 24 applications that it guarantees Wabi will run. Wabi can't run all Windows programs, especially those that have intimate knowledge of the Windows environment.
Windows applications running under Wabi have the look and feel of an X-based Unix GUI such as Motif or OpenLook, rather than that of Windows. And instead of running the entire Windows desktop environment within a single window, as SoftWindows does, Wabi opens a new window on the Unix desktop for each Windows-based application.
Wabi runs Windows programs fairly quickly because it contains precompiled equivalents for each Windows API function. Wabi doesn't have to translate instructions in Windows system files (e.g., USER.EXE and GDI.EXE).
The
Same CPU Issues
Just as OS/2 gives DOS and Windows programs partial control of the CPU yet retains sufficient ownership to virtualize I/O ports and the file system, SCO Unix uses DOS Merge to run DOS and Windows programs directly on the Intel CPU. DOS Merge runs DOS and Windows programs full-screen or within an X Window System 11 window at VGA or higher resolution. DOS Merge consists of three levels of emulation: DOS, ROM BIOS, and direct-to-hardware screen memory. Besides offering a bridge between DOS and Unix resources, DOS Merge also supports direct exclusive access to hardware devices (e.g., scanners) with no equivalent Unix device driver.
The Mac 6100 can run DOS programs on a 486 coprocessor, without the need to emulate Intel instructions on the RISC CPU. Apple placed a 25-MHz 486SX processor, a Chips & Technologies BIOS, a VGA chip set, and some of its custom ASICs on a 68040 Processor Direct Slot plug-in board. The DOS card can have up to 32 MB of RAM on it, or it can share mem
ory on the Mac's main logic board. At boot-up time, the Mac scans the board for RAM. If none is found, the emulator dedicates a user-configurable amount of RAM on the main logic board to the DOS environment.
Hardware transceivers in a custom ASIC on the DOS card do the byte swapping required by the different processor architectures (Intel CPUs store integers low byte first). Memory-controller hardware keeps the address spaces of the two environments separate. The DOS-emulation environment maps the Mac's floppy drive as DOS drive A. Apple even provides an MSCDEX extension; on a Mac with a built-in CD-ROM drive, DOS programs can access CD-ROMs.
The DOS coprocessor board operates independently of the Mac's CPU, which means that DOS/Windows applications can run concurrently with the Mac OS. You hot-key between the two environments. And selecting a printer via the Mac Chooser selects the same printer for the DOS environment. The emulation software routes DOS print streams to the selected printer. The c
oprocessor approach has a huge edge over CPU instruction translation -- DOS programs run full-speed on the 486 and actually multitask with programs running on the Mac's CPU.
Taking Care of Windows 95
The biggest challenge for emulators isn't running an oddly written device driver or virtualizing an unusual adapter. It's Windows 95. Emulator developers are hard at work exploring the instructions that make up the new version of Windows. Insignia Solutions and Locus are arranging to acquire Windows 95 source code from Microsoft, which will make the job much easier. But even with source code at hand, emulating Windows 95 is a formidable task. A Windows 95 emulator has to manage Win32 API functions, frequent switches between protected and real mode, virtual device driver (VxD) -- ring 0 -- CPU operation, and a minefield of combined 32- and 16-bit memory accesses.
Locus and Insignia Solutions have announced they'll support Windows 95 in future versions of their products. To date
, IBM has said only that it will supply an OS/2 library of Win32 functions that OS/2 programs can use (thus easing the chore of porting Win32 programs to OS/2). Rumors abound, however, that IBM may eventually provide a full Windows 95 emulator in OS/2 Warp.
Emulation for Windows 95 will be an important issue for the field of OS emulation. However, Windows 95 is just one of many OSes that users will want supported.
The range of CPUs and OSes that
must be supported
is growing all the time. Users will increasingly demand that they be able to run existing applications on whatever platform and OS they choose. And, as time goes by, that will only serve to elevate the role of OS emulators in organizations.
PRODUCT INFORMATION
DOS Merge........bundled with many OSes
Locus Computing Corp.
Inglewood, CA
(800) 955-6287
(310) 670-6500
fax: (310) 670-2980
SoftPC...........$249
SoftWindows......$499
Insignia Solutions, Inc.
Mountain View, CA
(800) 848-7677
(415) 335-7100
fax: (415) 335-7105
Wabi.............$225
SunSoft, Inc.
Mountain View, CA
(800) 786-7638
(415) 960-3200
fax: (415) 336-2473
An OS-emulation product must not only translate CPU instructions but
also establish an environment in which these hardware elements appear
to be present and functioning.
*
VGA or SVGA video adapter
*
serial (COM) ports
*
parallel ports
*
Ethernet or Token Ring network adapter
*
file system (directories, filenames, and file contents)
*
floppy drive
*
extended, expanded, and conventional memory
*
ROM BIOS
*
CMOS configuration data
The d
evelopers of an OS emulator must provide support for a wide
range of software, including different versions of the OS itself.
*
Windows 95
*
Windows 3.1 and 3.11, and Windows for Workgroups
*
various versions of DOS
*
486 and Pentium instruction sets
*
file compressors, disk defragmenters, and other file system utilities
illustration_link (32 Kbytes)

Emulation programs let DOS and Windows programs run on many platforms and OSes.
Barry Nance is a BYTE consulting editor. He is the author of Using OS/2 Warp (Que,
1994) and Introduction to Networking (Que, 1994). You can reach him on the Internet or BIX at
barryn@bix.com
.