external hard drive and virtual memory

June 14, 2010 at 23:15:22
Specs: Linux i686
Virtual memory gives an illusion to the programmer that all the auxillary memory is at his disposal as the main memory. But 32-bit processors have 32-bit address lines, ans so can address only 4GiB of memory. If the external memory (hard disk) is 160GB, how can the entire external memory be virtualized as being available to the programmer. ?

See More: external hard drive and virtual memory

June 15, 2010 at 01:16:38
It isn't because memory and hard disk space are two completely different things that just happen to use the same unit of measurement.

Your external hard disk is no different than your internal hard disk when it comes to the way the computer uses it.


Report •

June 15, 2010 at 06:07:37
Thanks. Just some confusion. In a 32 bit system, the user is presented with virtual addresses from 0 to 2^32-1. Each process is given a set of these addresses and when the process finishes these addresses are given to another process. What if all these addresses are utilized and none of the processes have finished and a new process is in waiting ?

Also, in a 32 bit system, virtual memory is limited to 4GiB ?

Report •

June 15, 2010 at 10:34:18
Also, in a 32 bit system, virtual memory is limited to 4GiB ?

No, physical memory is limited to 4 GB. In reality it is something less than that because some address space has to be allocated to memory mapped devices.

Virtual memory is practically unlimited although in reality there comes a point where is can start slowing things down if the swap file gets too big. Virtual memory is stored on the hard disk in the swap file. It is stored in block of 4Kb. When a block is retrieved from the hard dsik it may be allocated different address then when it was first stored.

Virtual memory and memory management on the whole is a complex subject. Their are loads of articles on the Internet is you really want to know ho wit work. But you need to learn the difference between physical memory, virtual memory and hard disk space. They are all different.

If all memory addresses are utilised and there are no more available then you get an out of memory error.



Report •

Related Solutions

June 15, 2010 at 11:27:10
In Windows each application is given a 4GB virtual address space. The upper 2GB is shared among all running processes and is used only by kernel level code. However, the lower 2GB is private to each application, it is not shared. You can have many processes running and each will have a separate 2GB address space. All of this is completely independent of RAM size. The system and CPU map virtual addresses to physical addresses in RAM. The process is very complex.

So virtual address space is almost unlimited. Buts since some portion of each virtual address space must be mapped to RAM there are practical limits. The more RAM you have the more of an applications code and data can be kept in RAM. The remainder will be in the the pagefile, application executable files, or DLL's as appropriate.

Memory management in Windows is very complex. The Microsoft Publication "Windows Internals" devotes over 150 pages to it and many aspects are only briefly described. It is not an easy read.

Report •

June 16, 2010 at 07:52:16
Thanks a lot. I really couldn't figure this:
During runtime when a program asks for a memory block (say, by malloc()), its provided with a block of virtual addresses, say 0x10000000 to 0x1000A00 (for 32 bit). During the execution, other processes are incorporated into the main memory and pages 0x10000000-0x100000A0 are paged out. After some time, the program requests the page 0x10000000. Its incorporated back into the main memory (at the cost of some other page) but its assigned a new virtual address, but the program is oblivious of the new virtual address assigned to it and references the it using 0x10000000. How is this problem resolved ? Does it proceed in any other way ?

Report •

June 16, 2010 at 08:58:19
This situation should never occur. When data is paged back in it will always be to the original virtual address. The physical address in RAM probably will be different but that doesn't matter to the application. The application never sees or cares about physical addresses. Paging for memory management purposes is totally transparent to the application.

Each process has a private 2GB address space that cannot be accessed by any other process (unless it has been explicitly shared). The system and CPU maps portions of this virtual address space to physical addresses in RAM. The process has no idea of and doesn't care about these physical addresses.

Report •

Ask Question