LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Virtual Memory? (https://www.linuxquestions.org/questions/linux-general-1/virtual-memory-14155/)

mikeshn 02-12-2002 10:01 PM

Virtual Memory?
 
Why CPU need the Virtual Memory? The CPU has physical memory. What is the purpose of Virtual Memory?
Thanks

trickykid 02-12-2002 11:16 PM

is this related to linux somehow ??

definition of virtual memory:

An imaginary memory area supported by some operating systems (for example, Windows but not DOS) in conjunction with the hardware. You can think of virtual memory as an alternate set of memory addresses. Programs use these virtual addresses rather than real addresses to store instructions and data. When the program is actually executed, the virtual addresses are converted into real memory addresses.

The purpose of virtual memory is to enlarge the address space, the set of addresses a program can utilize. For example, virtual memory might contain twice as many addresses as main memory. A program using all of virtual memory, therefore, would not be able to fit in main memory all at once. Nevertheless, the computer could execute such a program by copying into main memory those portions of the program needed at any given point during execution.

To facilitate copying virtual memory into real memory, the operating system divides virtual memory into pages, each of which contains a fixed number of addresses. Each page is stored on a disk until it is needed. When the page is needed, the operating system copies it from disk to main memory, translating the virtual addresses into real addresses.

The process of translating virtual addresses into real addresses is called mapping. The copying of virtual pages from disk to main memory is known as paging or swapping.

dj_relentless 02-12-2002 11:34 PM

Does cpu have its own memory? closest thing I seen is cache..unless I got ripped off..or mine is very forgetful..

isajera 02-13-2002 12:50 AM

there are a couple of different types of memory - there's the cpu cache, which is usually just about 256k on today's machines, RAM memory - up to several gigs, and virtual memory, which is limited by the amount of swap space available on your hard drive.

cache is pretty small - but very fast.
RAM is getting pretty large nowadays, and is somewhat slow in cpu terms.
virtual memory is stored on the hd and is very large, but is EXTREMELY slow

virtual memory handling is one of the most difficult parts of o/s programming - there are debates daily on the kernel mailing list about it.

i think tricky's explaination was a bit obscure, so i'll give it a go here:

physical memory, RAM, is usually on the order of 128M+ on todays machines - this isn't really enough tho, for a full desktop system. so, in order to make more room, the kernel uses virtual memory - it writes memory stored in RAM to the hard drive, and frees up some RAM, enabling the computer to move significantly faster. if that memory is needed again, the kernel swaps out some memory in RAM for the memory on the hard drive, and so on and so forth.

dj_relentless 02-13-2002 01:35 AM

ooh ooh my turn my turn..

CPU Memory..Defined by Cache.
L2 Cache - Generaly 256k, but lower in celeron and lower grade cpus.
L1 Cache - Usually smaller again.

Ram - Random access memory - Running on the system bus but at a greater distance from the cpu than the L2/L1 cache. Common types are sdram Syncronis (i can't spell) dynamic random access memory..most modern machines use RDRAM which here in NZ cost twice as much as SDRAM..but my old favourite will always be good old edoram..oh how I loved my 4meg of 1meg simms..

Virtually memory - Defined by the operating system and used generally by application software and not system software. Limited tooo..I think 4gig at the moment..could be wrong..

So the answer to the question is..if you've got 1024meg of physical memory you generally don't need much if any virtual memory, most likely that will change in a year or so..

and for me..512meg ram and I hardly ever see it use virtual memory..

But like I said I could be wrong and in which case my cpu is going senile.

The lengths of boredom this job drives me to..

trickykid 02-13-2002 08:28 AM

Quote:

Originally posted by isajera
i think tricky's explaination was a bit obscure, so i'll give it a go here
yep, this is a type of question maybe the person asking could look into themselves.. that is why i looked up virtual memory and gave him the actual definition. it is obscure, but so is the question i think.

acid_kewpie 02-13-2002 09:46 AM

aww no fun, I missed my chance to wax lyrical about the differences between writeback and writethrough cache management schemes... I actually understand it tooo...! ahh well, another day.

teni 10-29-2002 12:00 PM

virtual memory
 
I have been reading on Virtual Memory. What Virtual Memory Management Techniques does Linux uses? :Pengy:

unSpawn 10-29-2002 01:12 PM

I guess it would be no use to search this site or Google the web for "linux+vm" or "linux+virtual+memory+management"?

doublefailure 10-29-2002 05:57 PM

i heard virtual memory is mainly for solving memory fragmentation..
:confused:

if i understand previous postings correct,
virtual memory concept = cache concept ?
cache :: ram
==
ram :: disk(where virtual memory informations will be stored, if ram is maxed out with other processes)

0x0001 10-30-2002 09:54 AM

Quote:

Originally posted by doublefailure
i heard virtual memory is mainly for solving memory fragmentation..
:confused:

if i understand previous postings correct,
virtual memory concept = cache concept ?
cache :: ram
==
ram :: disk(where virtual memory informations will be stored, if ram is maxed out with other processes)

well:
cache and vm are something entirely different.

cache is a concept to reduce access time to e.g. ram.
the trick is that ram is far away from the cpu and access is slow, so data is stored in the cache to be fast accessible.

vm is part of the abstraction current OSes do to you're system.
The idea behind this abstraction is that thus the programmer does not need to know about actual memory/hardware layout. the os does this for him.

So basically every program has it's own memory space. The OS translates this to physical memory.

ram is not the same as chace.
ram is slow and far away reachable over a bus. the caches are moved closer to the cpu and are much faster accesible.

iirc L1-cache is usually part of an cpu, wereas L2-cache is separated from the CPU but in it's close vicinity (sp?) so it can be accesed fast.

ram is not the same as swap (if that's what you mean with disk).

The crux of VM is here that the logical (the programs) adress space is much higher that physical memory. Thus it is possible that the various programs running use up more memory than is actually available, in such a case the data im memory is swapped to the disk (extra slow) to make physical memory available to running processes.

hopefully this did help a little.

btw: a good free encylopedia is http://www.wikipedia.org/.

coolamit78 01-15-2004 01:47 PM

Question on Shared Memory
 
ok...since this thread is discussing memory.....and i also have one important question to ask....

Linux uses /dev/shm as shared memory

Now we have a swap space which the kernel utilizes according to its own need, if required....Lets for example, take the output of 'mount' command on my machine :

/dev/hda2 on / type ext3 (rw)
none on /proc type proc (rw)
usbdevfs on /proc/bus/usb type usbdevfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
none on /dev/shm type tmpfs (rw)
/dev/hda1 on /mnt/c: type vfat (rw)

I've seen the concept of "shared memory" mostly in the case of P-III machines with the Intel 810 motherboards that share RAM between normal OS use and graphics....However, I have an AMD-K6 400 MHz processor and a SIS 6326 Video Card with 8 MB VRAM.....I also have 256 MB RAM and 512 MB swap space set in Linux.......

Firstly, If the kernel already has a swap space (virtual memory), then when and for what purpose does the kernel require shared memory? ( Yes, I can see that currently shared memory usage is zero!)

Secondly, can size of shared memory be increased? if yes then how is that done, and will that help in any way to make system speed or loading of graphics faster?

Pls clarify..

Regards,

amit


All times are GMT -5. The time now is 04:55 PM.