|
|
< Previous PageNext Page > |
There are two additional VM subsystems: pagers and the working set detection subsystem. In addition, the VM shared memory server subsystem is closely tied to (but is not part of) the VM subsystem. This section describes these three VM and VM-related subsystems.
Pagers
Working Set Detection Subsystem
VM Shared Memory Server Subsystem
Mac OS X has three basic pagers: the vnode pager, the default pager (or anonymous pager), and the device pager. These are used by the VM system to actually get data into the VM objects that underlie named entries. Pagers are linked into the VM system through a combination of a subset of the old Mach pager interface and UPLs.
The default pager is what most people think of when they think of a VM system. It is responsible for moving normal data into and out of the backing store. In addition, there is a facility known as the dynamic pager that sits on top of the default pager and handles the creation and deletion of backing store files. These pager files are filled with data in clusters (groups of pages).
When the total fullness of the paging file pool reaches a high–water mark, the default pager asks the dynamic pager to allocate a new store file. When the pool drops below its low water mark, the VM system selects a pager file, moves its contents into other pager files, and deletes it from disk.
The vnode pager has a 1:1 (onto) mapping between objects in VM space and open files (vnodes). It is used for memory mapped file I/O. The vnode pager is generally hidden behind calls to BSD file APIs.
The device pager allows you to map non–general-purpose memory with the cache characteristics required for that memory (WIMG). Non–general–purpose memory includes physical addresses that are mapped onto hardware other than main memory—for example, PCI memory, frame buffer memory, and so on. The device pager is generally hidden behind calls to various I/O Kit functions.
To improve performance, Mac OS X has a subsystem known as the working set detection subsystem. This subsystem is called on a VM fault; it keeps a profile of the fault behavior of each task from the time of its inception. In addition, just before a page request, the fault code asks this subsystem which adjacent pages should be brought in, and then makes a single large request to the pager.
Since files on disk tend to have fairly good locality, and since address space locality is largely preserved in the backing store, this provides a substantial performance boost. Also, since it is based upon the application’s previous behavior, it tends to pull in pages that would probably have otherwise been needed later. This occurs for all pagers.
The working set code works well once it is established. However, without help, its performance would be the baseline performance until a profile for a given application has been developed. To overcome this, the first time that an application is launched in a given user context, the initial working set required to start the application is captured and stored in a file. From then on, when the application is started, that file is used to seed the working set.
These working set files are established on a per-user basis.
They are stored in /var/vm/app_profile
and
are only accessible by the super-user (and the kernel).
The VM shared memory server
subsystem is a BSD service that is closely tied to VM, but is not
part of VM. This server provides two submaps that are used for shared
library support in Mac OS X. Because shared libraries contain
both read-only portions (text segment) and read-write portions (data
segment), the two portions are treated separately to maximize efficiency.
The read-only portions are completely shared between tasks, including
the underlying pmap
entries.
The read-write portions share a common submap, but have different
underlying data objects (achieved through copy-on-write).
The three functions exported by the VM shared memory server
subsystem should only be called by dyld
.
Do not use them in your programs.
The function load_shared_file
is
used to load a new shared library into the system. Once such a file
is loaded, other tasks can then depend on it, so a shared library
cannot be unshared. However, a new set of shared regions can be
created with new_system_shared_regions
so
that no new tasks will use old libraries.
The function reset_shared_file
can
be used to reset any changes that your task may have made to its
private copy of the data section for a file.
Finally, the function new_system_shared_regions
can
be used to create a new set of shared regions for future tasks.
New regions can be used when updating prebinding with new shared
libraries to cause new tasks to see the latest libraries at their
new locations in memory. (Users of old shared libraries will still
work, but they will fall off the pre-bound path and will perform
less efficiently.) It can also be used when dealing with private libraries
that you want to share only with your task’s descendents.
< Previous PageNext Page > |
Last updated: 2006-11-07
|
Get information on Apple products.
Visit the Apple Store online or at retail locations. 1-800-MY-APPLE Copyright © 2007 Apple Inc. All rights reserved. | Terms of use | Privacy Notice |