HPlogo HP-UX Memory Management: White Paper > Chapter 1 MEMORY MANAGEMENT

THE ABSTRACTION OF VIRTUAL MEMORY

» 

Technical documentation

Complete book in PDF

 » Table of Contents

A computer has a finite amount of RAM available, but each HP-UX process has a 4GB virtual address space apportioned in four one-gigabyte quadrants, termed virtual memory.

Virtual memory is the software construct that allows each process sufficient computational space in which to execute. It is accomplished with hardware support.

Virtual Space in PA-RISC

As software is compiled and run, it generates virtual addresses that provide programmers with memory space many times larger than physical memory alone. The number of bits available for the space determines the ultimate size of the virtual address space. At PA-RISC 1.x, the operating system has 32-bit physical addressing and 48-bit virtual addressing (the latter consisting of 16-bit space and 32-bit offset to allow for 4 GB per space); the total virtual address range is

(2 ^ 16) * 4 GB = 262,144 GB

By comparison, Level 2 has a far greater total virtual address range of

( 2 ^ 32 ) * 4 GB = 17,179,869,184 GB

NOTE: Understand, however, that a single process has significant limitations on the virtual address space it is allowed to access. For example, a SHARE_MAGIC executable text is limited to 1 GB and data is limited to 1 GB. The total amount of shared virtual address space in the system is limited to 1.75 GB.

Physical Addresses

A physical address points to a page in memory that represents 4096 bytes of data. The physical address also contains an offset into this page. Thus, the complete physical address is composed of a physical page number(PPN) and page offset. The PPN is the 20 most significant bits of the physical address where the page is located. These bits are concatenated with an 12-bit page offset to form the 32-bit physical address.

Figure 1-3 Bit layout of physical address

[Bit layout of physical address]

To handle the translation of the virtual address to a physical address the virtual address also needs to be looked at as a virtual page number(VPN) and page offset. Since the page size is 4096 bytes, the low order 12 bits of the offset are assumed to be the offset into the page. The space ID and the high order 20 bits of the offset are the VPN.

For any given address you can determine the page number by discarding the least significant 12 bits. What remains is the virtual page number for a virtual address or the physical page number for the physical address.

The next figure shows the bit layout of a virtual address of 0x0.4873.

Figure 1-4 Bit layout of virtual page address

[Bit layout of virtual page address]

The virtual page number's address must be translated to obtain the associated physical page number, with page offset 0x873.