20.3 Execution Domains

As mentioned in Chapter 1, a neat feature of Linux is its ability to execute files compiled for other operating systems. Of course, this is possible only if the files include machine code for the same computer architecture on which the kernel is running. Two kinds of support are offered for these "foreign" programs:

·         Emulated execution: necessary to execute programs that include system calls that are not POSIX-compliant

·         Native execution: valid for programs whose system calls are totally POSIX-compliant

Microsoft MS-DOS and Windows programs are emulated: they cannot be natively executed, since they include APIs that are not recognized by Linux. An emulator like DOSemu or Wine (which appeared in the example at the end of the previous section) is invoked to translate each API call into an emulating wrapper function call, which in turn uses the existing Linux system calls. Since emulators are mostly implemented as User Mode applications, we don't discuss them further.

On the other hand, POSIX-compliant programs compiled on operating systems other than Linux can be executed without too much trouble, since POSIX operating systems offer similar APIs. (Actually, the APIs should be identical, although this is not always the case.) Minor differences that the kernel must iron out usually refer to how system calls are invoked or how the various signals are numbered. This information is stored in execution domain descriptors of type exec_domain.

A process specifies its execution domain by setting the personality field of its descriptor and storing the address of the corresponding exec_domain data structure in the exec_domain field. A process can change its personality by issuing a suitable system call named personality( ); typical values assumed by the system call's parameter are listed in Table 20-6. The C library does not include a corresponding wrapper routine because programmers are not expected to directly change the personality of their programs. Instead, the personality( ) system call should be issued by the glue code that sets up the execution context of the process (see the next section).

Table 20-6. Main personalities supported by the Linux kernel

Personality

Operating system

PER_LINUX

Standard execution domain

PER_SVR4

System V Release 4

PER_SVR3

System V Release 3

PER_SCOSVR3

SCO Unix Version 3.2

PER_OSR5

SCO OpenServer Release 5

PER_WYSEV386

Unix System V/386 Release 3.2.1

PER_ISCR4

Interactive Unix

PER_BSD

BSD Unix

PER_SUNOS

SunOS

PER_XENIX

Xenix

PER_IRIX32

SGI Irix-5 32 bit

PER_IRIXN32

SGI Irix-6 32 bit

PER_IRIX64

SGI Irix-6 64 bit

PER_RISCOS

RISC OS

PER_SOLARIS

Sun's Solaris

PER_UW7

Caldera's UnixWare 7