Swap File, Swap Space, Page Swapping
A swap file is a file used by an operating system, or a specific program, as part of the virtual memory exchange of information between the random-access memory (RAM) chip drives and the read-only memory (ROM) disk drives. Swap files occupy swap space that is located in a specialized region of the hard drive reserved for use by the virtual memory system.
The movement of swap files is often coordinated by a scheduler or virtual memory system that mediates the transfer of files from the hard drive to RAM memory. The portion of the hard drive reserved for swap files is isolated from the remainder of the hard drive and is usually not fragmented. Because swap files are maintained in one localized region of the hard drive, their close physical proximity reduces the time required to find and access swap files. Hardware and software manufacturers recommend varying minimum and maximum values for the optimal size of the swap space allocated to swap files depending on the particular operating system in use. Usually the maximum size is determined as a function of the available RAM (e.g., a typical maximum size allocation recommendation might specify that swap files should be located in swap space no more than two or three times the size of the available RAM memory).
Although swap files differ from page files used by demand paging systems to transfer only a portion of a program file, the use of swap files also allows for use of programs larger than RAM memory space. Before a process can be executed, it must first load or move into RAM memory from the swap space on the hard drive via the virtual memory system. For example, programming code can only be executed after it is loaded into RAM memory. Virtual memory systems use swap files and swap space to rapidly interchange programming code between RAM and ROM memory. Using this system of file transfers, the entire programming code is not required to be in RAM memory in order to execute the program. The seamless exchange of swap files means that only the portion (block) of code actually needed by the system must be in RAM memory. Accordingly, the use of swap files and swap space allows the use of larger programs than could be held in RAM memory. In addition, the use of swap files and swap space enables those programs to run more quickly and efficiently.
The use of swap files essentially means that the maximum program size is dictated not by the smaller available RAM memory space, but rather by the size of the larger physical memory locate on the hard drive.
The virtual-memory systems in modern operating systems have replaced the need for earlier forms of physical file swapping and fragmentation of programs.
A page is a fixed number of bytes recognized as a related group by the operating system. In paging systems (typically virtual memory systems), the area of the hard drive dedicated to storing blocks of data to be swapped via virtual memory interface is also termed the page file. The exchange of these types of files is termed page swapping. As with swap files, in most operating systems, there is a preset size for the page file area of the hard disk. Page files, however, are able to exist on multiple drives (separate physical disks or other types of ROM memory storage). As with the page file size, although the actual size of the pages is preset, modern operating systems usually allow the user to vary the size of the pages swapped, but typical page sizes range from a thousand bites to many megabytes.
Page swapping allows an entire block of data or programming (e.g., an application process) to reside in virtual memory, while only the part of the code being executed is in RAM physical memory. Accordingly, the use of virtual memory allows operating systems to run many programs and thus, increase the degree of multiprogramming within an operating system.
Virtual memory exchanges between ROM and RAM memory are accomplished through either a process termed demand-segmentation or through another process termed demand-paging. Demand-paging processes, more common because it is simpler in design, do not swap pages from disk to RAM until the program calls for the page. With page swapping, paging processes track memory usage and constantly call data back and forth between RAM and the hard disk. Page states (the state of availability to the CPU) are monitored by the virtual page table. When applications attempt to access invalid pages, a virtual-memory manager that initiates page swapping intercepts the page fault message and initiates a swap into RAM memory. If the page needed is not available, the application is usually aborted through one of several interrupt sequences.
This is the complete article, containing 790 words
(approx. 3 pages at 300 words per page).