Machine-Independent Virtual Memory Management for Paged Uniprocessor and Multiprocessor Architectures --- Rashid et al., 1988 - Main idea: separate hardware support from software memory management without performance sacrifice; have a simple, extensible kernel, concentrating on communication facilities; - "Unix systems have traditionally restricted the facilities provided, basing implementation for new architectures on versions for older machines;" - Mach provides: - large, sparse virtual address spaces - copy-on-write virtual copy operations - copy-on-write and read-write memory sharing between tasks - memory mapped files - user-provided backing store objects and pagers - Mach makes few assumptions about memory management hardware - Mach abstractions: - task: - environment in which threads may run; - basic unit of resource allocation; - thread: - basic unit of CPU utilization; - threads in a task access the same resources; - port: - communication channel (message queue); - similar to object reference in OOP; - used to perform object manipulation; - ports are protected by kernel-managed capabilities, or port rights; - message: - basic communication unit; - memory object: - segment abstraction? - data collection that can be mapped into an address space; - operations on objects are performed by sending messages to ports. This abstraction allows objects to be arbitrarily placed in the network. Also, by limiting all data operations to one mechanism, Mach is able to provide systemwide protection to its users by protecting the communications mechanism; - Most of the inefficiency of message handling in traditional operating systems is due to either the copying of messages from one task to another (shared memory) or low network transfer speed. - "The key to efficiency in Mach is the notion that virtual memory management can be integrated with a message-oriented communication facility." To bypass low network transfer speeds, Mach uses virtual-memory remapping to transfer the contents of large messages. (copy-on-write is used to avoid or delay the actual copying of the data.) - the Network Message Server (NMS) is a user-level capability-based networking daemon that forwards messages between hosts. It also provides a primitive networkwide name service. The NMS is protocol independent; Memory Management ----------------- - memory mapping basically maps a virtual address range to a memory object. Address space is limited by hardware restrictions; - the key to sparse address spaces is that page-table space is used for only currently allocated regions; - Mach maintains a cache of memory-resident pages of all mapped objects. However, a page fault occurring when a thread accesses a nonresident page is executed as a message to the object's port. Therefore, memory can be paged by user-written memory managers; - regions specified for virtual memory operations must be page aligned. Note that the page size is a boot parameter in Mach, and is a power of two multiple of the hardware page size; - read-write sharing is controled by the inheritance attribute, which can have the values "shared", "copy" or "none"; - like inheritance, protection is also specified on a per-page basis; - "virtual memory related functions such as pagein and pageout, can be performed directly by user-state tasks for memory objects they create." - the implementation of the VM uses: - a resident page table; - address map; - memory object; - pmap. - The resident page table keeps track of Mach pages residing in main memory (a Mach page may contain several physical pages but their number must be a power of 2); - The memory object: a unit of backing storage managed by the kernel or a user task; - The address map: a doubly linked list of map entries each which describes a mapping from a range of virtual addresses to a region of a memory object; all pages mapped by the same map entry have the same protection and inheritance attributes (page is to be copied, shared or ignored at fork() time) . - The p-map: the memory-mapping data structure used by the specific hardware (page tables for a VAX, inverted page table for the IBM RT, more complex structures on other machines); it does not have to be kept fully up-to-date except for the pages in the resident part of the kernel. - memory objects are used to manage secondary storage, and generally represent files, pipes, or other data that are mapped into virtual memory for reading and writing. Memory objects may be backed by user-level memory managers. - "the machine dependent part of Mach... has no knowledge of machine independent data structures and is not required to maintain full knowledge of valid mappings from virtual to hardware pages." - "all the page entries associated with a given object are linked together in a memory object list..." - "fast lookup of a physical page associated with an object/offset is performed using a bucket hash table..." - "addresses within a task address space are mapped to byte offsets in memory objects by a data structure called an address map." - "when a copy-on-write copy is performed, the two address maps which contain copies point to the same memory object." When one of the tasks writes the shared data, a shadow object is created (it basically holds modified pages which originally belonged to another object.) - "the purpose of Mach's machine dependent code is the management of physical address maps (called pmaps). For a VAX, a pmap corresponds to a VAX page table".