Tuesday, 10 June 2014

Virtual Memory Inter View Questions

Virtual Memory Inter View Questions

Source - 1

Definition of:virtual memory

Simulating more random access memory (RAM) than actually exists, allowing the computer to run larger programs and multiple programs concurrently. A common function in most every OS and hardware platform, virtual memory uses the hard disk to temporarily hold what was in real memory.

Virtual memory allows multiple programs to load in memory at the same time. Each application addresses memory starting at zero, but virtual memory takes control of the memory addressing and lets each application function as if it had unlimited memory.

Note that virtual "memory" and virtual "machine" are not the same. Virtual memory is used all the time, whereas a virtual machine is an optional approach for running applications (see virtual machine).

Virtual Memory Pages
The computer's real memory is broken up into smaller segments, called "pages," typically 4KB in size. When real memory fills up, pages not currently in use by open applications are written to a virtual memory "swap file" on the disk for temporary storage. When any swapped out page is required again, once again a page in real memory is written to the disk to make room, and the disk page is retrieved. Memory is the computer's workspace, and since there is often a hundred times more disk space than memory space, virtual memory dramatically increases the computer's capacity to do work. However, there is a penalty. When a user has too many open programs, there can be excessive amounts of page swapping, causing applications to slow down. In addition, switching between applications is no longer immediate (see thrashing).

Hardware Is Required
Virtual memory can be implemented in software only, but efficient operation requires specialized hardware circuits. All modern, general-purpose CPUs have memory management units (MMUs) that support virtual memory. They provide "page tables" that are used to translate between the program's "virtual" addresses and the "real" addresses in memory and disk, which may change at any time. Although a program may initially load as a contiguous block of code, it can wind up in pages randomly scattered around real memory.

Virtual memory claims are sometimes made for specific applications that bring additional parts of the program in as needed; however, true virtual memory is built into the operating system and hardware and works with all applications. See Windows swap file.

Memory Is Extended to Disk
Virtual memory allows more programs to be opened simultaneously by using the hard disk as temporary storage of memory pages.

Page Out, Page In
When memory is full and the current program needs instructions that are not in memory, pages are swapped. In this example, program A needs a page from the disk, and a page from program C is swapped out to make room.

Source - 2

Memory is hardware that your computer uses to load the operating system and run programs. It consists of one or more RAM chips that each have several memory modules. The amount of real memory in a computer is limited to the amount of RAM installed. Common memory sizes are 256MB, 512MB, and 1GB.

Because your computer has a finite amount of RAM, it is possible to run out of memory when too many programs are running at one time. This is where virtual memory comes in. Virtual memory increases the available memory your computer has by enlarging the "address space," or places in memory where data can be stored. It does this by using hard disk space for additional memory allocation. However, since the hard drive is much slower than the RAM, data stored in virtual memory must be mapped back to real memory in order to be used.

The process of mapping data back and forth between the hard drive and the RAM takes longer than accessing it directly from the memory. This means that the more virtual memory is used, the more it will slow your computer down. While virtual memory enables your computer to run more programs than it could otherwise, it is best to have as much physical memory as possible. This allows your computer to run most programs directly from the RAM, avoiding the need to use virtual memory. Having more RAM means your computer works less, making it a faster, happier machine.


Post a Comment