Mac OS X Internals: A Systems Approach

8.1. Looking Back

Tom Kilburn, R. Bruce Payne, and David J. Howarth described the Atlas supervisor program in a 1961 paper.[1] A result of work that originated in the Computer Group at Manchester University, the Atlas supervisor controlled the functioning of the Atlas computer system. When inaugurated in late 1962, Atlas was considered the most powerful computer in the world. It also had the earliest implementation of virtual memorythe so-called one-level storage system that decoupled memory addresses and memory locations. The core memory system of Atlas used a form of indirect addressing based on 512-word pages and page-address registers. When access to a memory address was made, a hardware unit (the memory management unit, or MMU) automatically attempted to locate the corresponding page in core memory (primary memory). If the page was not found in core memory, there was a nonequivalence interruptiona page fault, which resulted in the supervisor transferring data from a sector of drum store (secondary memory) to core memory. This process was referred to as demand paging. Moreover, the Atlas system provided per-page protection that allowed the supervisor to lock certain pages such that they became unavailable except when on interrupt control. A page replacement scheme was also used to move pages that were less likely to be used back to the drum store.

[1] "The Atlas Supervisor," by Tom Kilburn, R. Bruce Payne, and David J. Howarth (American Federation of Information Processing Societies Computer Conference 20, 1961, pp. 279294).

Within the next few years, virtual memory concepts were widely adopted, as major processor vendors incorporated virtual memory support in their processors. Most commercial operating systems of the 1960s and 1970s were capable of virtual memory.

8.1.1. Virtual Memory and UNIX

What can be considered as the Zeroth Edition of UNIX (late 1969) was not multiprogrammedonly one program could exist in memory at a time. It employed swapping as a form of memory management policy wherein entire processes, rather than individual pages, were transferred between physical memory and the swap device. Third Edition UNIX (February 1973) introduced multiprogramming, but it would not be until 3BSD (1979) that a UNIX-based system would be capable of paged virtual memory.

8.1.2. Virtual Memory and Personal Computing

Compared with UNIX, virtual memory would become part of personal computing much later, with personal computer software lagging behind the hardware by several years. Table 81 shows the time frames in which virtual memory (and multiprogramming) were introduced in personal computing.

Table 81. Virtual Memory and Multiprogramming in Personal Computing

Product

Date Introduced

Notes

Intel 80286

February 1, 1982

16-bit, segment-based memory management and protection

Motorola 68020

June 1984

32-bit, support for a paged MMU as a coprocessor chipvirtual memory possible with the latter

Intel 80386

October 17, 1985

32-bit, integrated MMU with support for paging and segmentationvirtual memory possible

Macintosh System 4.2

October 1987

Cooperative multitasking introduced with the optional MultiFinder

Macintosh System 7

May 13, 1991

MultiFinder made nonoptional, virtual memory support introduced

Microsoft Windows 3.1

April 6, 1992

Cooperative multitasking introduced, virtual memory support introduced

Microsoft Windows 95

August 24, 1995

Preemptive multitasking introduced (a Win32-only feature), virtual memory support enhanced

Thrashing

Early virtual memory implementations all suffered from thrashinga severe loss of performance that occurred when a multiprogramming system was under heavy load. When thrashing, the system spent most of its time transferring data between primary and secondary memories. This problem was satisfactorily addressed by Peter J. Denning's Working Set Principle, using which the memory management subsystem could strive to keep each program's "most useful" pages resident to avoiding overcommitting.

8.1.3. Roots of the Mac OS X Virtual Memory Subsystem

We saw in Chapter 1 that the RIG and Accent operating systems were Mach's ancestors. One of Accent's prime goals was to use virtual memory to overcome RIG's limitations in the handling of large objects. Accent combined paged virtual memory and capability-based interprocess communication (IPC), allowing large IPC-based data transfers through copy-on-write (COW) memory mapping. The Accent kernel provided the abstraction of a memory object, which represented a data repository, and had a backing store such as a disk. Contents of disk blocksdisk pages, whether they corresponded to an on-disk file or a paging partitioncould be mapped into an address space.

Mach evolved from Accent as a system suited for general-purpose shared memory multiprocessors. Like Accent, Mach's VM subsystem was integrated with its IPC subsystem. However, Mach's implementation used simpler data structures, with a cleaner separation of machine-dependent and machine-independent components. Mach's VM architecture inspired several others. The VM subsystem of BSD Networking Release 2 (NET2) was derived from Mach. The 4.4BSD VM subsystem was based on Mach 2, with updates from Mach 2.5 and Mach 3. The 4.4BSD implementation was the basis for FreeBSD's VM subsystem. Moreover, Mach's VM architecture has several design similarities with that of SunOS/SVR4, which was independently designed around the same time as Mach.

The core of the Mac OS X VM architecture is a derivative of, and largely similar to, the Mach VM architecture. However, as the operating system has evolved and undergone various optimizations, several minor and a few major differences have appeared in its VM subsystem's implementation.

Virtual XYZ

It is worthwhile to somewhat deemphasize the "virtual" in virtual memory. As in a typical modern-day operating system, not just memory but all system resources are virtualized by the Mac OS X kernel. For example, threads execute in a virtual environment consisting of a virtual processor, with each thread having its own set of virtual processor registers. In that sense, it's all virtual.

Категории