Page (computer memory)

Page (computer memory)
"Page size" redirects to this article. For information on paper see Paper size

A page, memory page, or virtual page is a fixed-length contiguous block of virtual memory that is the smallest unit of data for the following:

  • memory allocation performed by the operating system for a program; and
  • transfer between main memory and any other auxiliary store, such as a hard disk drive.

Virtual memory allows a page that does not currently reside in main memory to be addressed and used. If a program tries to access a location in such a page, an exception called a page fault is generated. The hardware or operating system is notified and loads the required page from the auxiliary store automatically. A program addressing the memory has no knowledge of a page fault or a process following it. Thus a program can address more (virtual) RAM than physically exists in the computer.

A transfer of pages between main memory and an auxiliary store, such as a hard disk drive, is referred to as paging or swapping.[1]

Contents

Page size trade-off

Page size is usually determined by processor architecture. Traditionally, pages in a system had uniform size, for example 4096 bytes. However, processor designs often allow two or more, sometimes simultaneous, page sizes due to the benefits and penalties. There are several points that can factor into choosing the best page size.

Page size versus page table size

A system with a smaller page size uses more pages, requiring a page table that occupies more space. For example, if a 232 virtual address space is mapped to 4KB (212 bytes) pages, the number of virtual pages is 220 =( 232 / 212). However, if the page size is increased to 32KB (215 bytes), only 217 pages are required.

Page size versus TLB usage

Since every access to memory must be mapped from virtual to physical address, reading the page table every time can be quite costly. Therefore, a very fast kind of cache, the Translation Lookaside Buffer (TLB), is often used. The TLB is typically of limited size, and when it cannot satisfy a given request (a TLB miss) the page tables must be searched manually (either in hardware or software, depending on the architecture) for the correct mapping. Larger page sizes mean that a TLB cache of the same size can keep track of larger amounts of memory, which avoids the costly TLB misses.

Internal fragmentation of pages

Rarely do processes require the use of an exact number of pages. As a result, the last page will likely only be partially full, wasting some amount of memory. Larger page sizes clearly increase the potential for wasted memory this way, as more potentially unused portions of memory are loaded into main memory. Smaller page sizes ensure a closer match to the actual amount of memory required in an allocation.

As an example, assume the page size is 1024KB. If a process allocates 1025KB, two pages must be used, resulting in 1023KB of unused space (where one page fully consumes 1024KB and the other only 1KB).

Page size versus disk access

When transferring from disk, much of the delay is caused by seek time, the time it takes to correctly position the read/write heads above the disk platters. Because of this, large sequential transfers are more efficient than several smaller transfers. Transferring the same amount of data from disk to memory often requires less time with larger pages than with smaller pages.

Determining the page size in a program

Most operating systems allow programs to discover the page size at runtime. This allows programs to use memory more efficiently by aligning allocations to this size and reducing overall internal fragmentation of pages.

Unix and POSIX-based operating systems

Unix and POSIX-based systems may use the system function sysconf(), as illustrated in the following example written in the C programming language.

#include <stdio.h>
#include <unistd.h> /* sysconf(3) */
 
int main(void) {
        printf("The page size for this system is %ld bytes.\n",
               sysconf(_SC_PAGESIZE)); /* _SC_PAGE_SIZE is OK too. */
 
        return 0;
}

In many Unix systems the command line utility getconf can be used. For example getconf PAGESIZE will return the page size in bytes.

Windows-based operating systems

Win32-based operating systems, such as Windows 9x, and NT may use the system function GetSystemInfo() from kernel32.dll.

#include <stdio.h>
#include <windows.h>
 
int main(void) {
        SYSTEM_INFO si;
        GetSystemInfo(&si);
 
        printf("The page size for this system is %u bytes.\n", si.dwPageSize);
 
        return 0;
}

Huge pages

Huge page size depends on processor architecture, processor type, and operating (addressing) mode. The operating system selects one from the sizes supported by the architecture. Note that not all processors implement all defined Huge/Large page sizes.

Architecture Page Size Huge Page Size Large Page Size
i386 4KB 4M (2M in PAE mode) 1GB
ia64 4KB 4K, 8K, 64K, 256K, 1M, 4M, 16M, 256M -
ppc64 4KB 16M -

Info from: http://wiki.debian.org/Hugepages (todo: supplement information for processors manufactures documentations)

Some instruction set architectures can support multiple page sizes, including pages significantly larger than the standard page size. Starting with the Pentium Pro, x86 processors support 4MB pages (called Page Size Extension) (2MB pages if using PAE) in addition to their standard 4kB pages; newer x86-64 processors, such as AMD's newer AMD64 processors and Intel's Westmere[2], processors can use 1GB pages in long mode. IA-64 supports as many as eight different page sizes, from 4kB up to 256MB, and some other architectures have similar features.[specify] This support for huge pages (known as superpages in FreeBSD, and large pages in Microsoft Windows terminology) allows for "the best of both worlds", reducing the pressure on the TLB cache (sometimes increasing speed by as much as 15%, depending on the application and the allocation size) for large allocations while still keeping memory usage at a reasonable level for small allocations.

Huge pages, despite being available in the processors used in most contemporary personal computers, are not in common use except in large servers and computational clusters. Commonly, their use requires elevated privileges, cooperation from the application making the large allocation (usually setting a flag to ask the operating system for huge pages), or manual administrator configuration; operating systems commonly, sometimes by design, cannot page them out to disk.

Linux has supported huge pages on several architectures since the 2.6 series via the hugetlbfs filesystem[3] and without hugetlbfs since 2.6.38 [4]. Windows Server 2003 (SP1 and newer), Windows Vista and Windows Server 2008 support huge pages under the name of large pages. Windows 2000 and Windows XP support large pages internally[5], but do not expose them to applications. Solaris beginning with version 9 supports large pages on SPARC and x86.[6][7] FreeBSD 7.2-RELEASE features superpages.[8] Note that until recently in Linux, applications needed to be modified in order to use huge pages. The 2.6.38 kernel introduced support for transparent use of huge pages.[9] On FreeBSD and Solaris, applications take advantage of huge pages automatically, without the need for modification.[8]

References

Further reading

  • Dandamudi, Sivarama P. (2003). Fundamentals of Computer Organization and Design (1st ed.). Springer. pp. 740–741. ISBN 038795211X. 

See also


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • computer science — computer scientist. the science that deals with the theory and methods of processing information in digital computers, the design of computer hardware and software, and the applications of computers. [1970 75] * * * Study of computers, their… …   Universalium

  • Memory segmentation — is the division of computer memory into segments or sections. Segments or sections are also used in object files of compiled programs when they are linked together into a program image, or the image is loaded into memory. In a computer system… …   Wikipedia

  • Memory management — is the act of managing computer memory. The essential requirement of memory management is to provide ways to dynamically allocate portions of memory to programs at their request, and freeing it for reuse when no longer needed. This is critical to …   Wikipedia

  • Computer security compromised by hardware failure — is a branch of computer security applied to hardware. The objective of computer security includes protection of information and property from theft, corruption, or natural disaster, while allowing the information and property to remain accessible …   Wikipedia

  • Memory (disambiguation) — Memory is an organism s ability to store, retain, and recall information. Memory or Memories may also refer to: Contents 1 Music 1.1 Songs 1.2 Alb …   Wikipedia

  • Memory ordering — is a group of properties of the modern microprocessors, characterising their possibilities in memory operations reordering. It is a type of out of order execution. Memory reordering can be used to fully utilize different cache and memory banks.… …   Wikipedia

  • Page 6 (computer magazine) — Page 6 (subtitled Atari User s Magazine , and later known as New Atari User ) was an independent British publication aimed at users of Atari home computers. It was published between 1982 and 1998. The magazine supported both the Atari 8 bit… …   Wikipedia

  • Memory test — may refer to: mental status examination – human memory memory test software – computer memory Neuropsychological tests – formal psychological tests of human memory Announcer s test – a popular repetitive test and tongue twister performed by Jerry …   Wikipedia

  • Computer — For other uses, see Computer (disambiguation). Computer technology redirects here. For the company, see Computer Technology Limited. Computer …   Wikipedia

  • Computer data storage — 1 GB of SDRAM mounted in a personal computer. An example of primary storage …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”