LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-12-2002, 10:01 PM   #1
mikeshn
Member
 
Registered: Feb 2002
Posts: 586

Rep: Reputation: 30
Virtual Memory?


Why CPU need the Virtual Memory? The CPU has physical memory. What is the purpose of Virtual Memory?
Thanks
 
Old 02-12-2002, 11:16 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
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.
 
Old 02-12-2002, 11:34 PM   #3
dj_relentless
Member
 
Registered: Jan 2002
Location: NZ, AKL
Distribution: Redhat 7.1
Posts: 168

Rep: Reputation: 30
Does cpu have its own memory? closest thing I seen is cache..unless I got ripped off..or mine is very forgetful..
 
Old 02-13-2002, 12:50 AM   #4
isajera
Senior Member
 
Registered: Jun 2001
Posts: 1,635

Rep: Reputation: 45
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.
 
Old 02-13-2002, 01:35 AM   #5
dj_relentless
Member
 
Registered: Jan 2002
Location: NZ, AKL
Distribution: Redhat 7.1
Posts: 168

Rep: Reputation: 30
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..

Last edited by dj_relentless; 02-13-2002 at 01:39 AM.
 
Old 02-13-2002, 08:28 AM   #6
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
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.
 
Old 02-13-2002, 09:46 AM   #7
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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.
 
Old 10-29-2002, 12:00 PM   #8
teni
LQ Newbie
 
Registered: Oct 2002
Location: Trinidad
Posts: 1

Rep: Reputation: 0
virtual memory

I have been reading on Virtual Memory. What Virtual Memory Management Techniques does Linux uses?
 
Old 10-29-2002, 01:12 PM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
I guess it would be no use to search this site or Google the web for "linux+vm" or "linux+virtual+memory+management"?
 
Old 10-29-2002, 05:57 PM   #10
doublefailure
Member
 
Registered: Mar 2002
Location: ma
Distribution: slackware
Posts: 747

Rep: Reputation: 30
i heard virtual memory is mainly for solving memory fragmentation..


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)
 
Old 10-30-2002, 09:54 AM   #11
0x0001
Member
 
Registered: Sep 2002
Distribution: Slackware 8.1
Posts: 84

Rep: Reputation: 15
Quote:
Originally posted by doublefailure
i heard virtual memory is mainly for solving memory fragmentation..


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/.
 
Old 01-15-2004, 01:47 PM   #12
coolamit78
Member
 
Registered: Aug 2003
Location: New Delhi, India
Distribution: RHEL AS 3/4, Windows XP
Posts: 546

Rep: Reputation: 31
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual Memory usage redhatrosh Linux - Software 1 03-20-2005 01:22 AM
mandrake virtual memory dreakon Linux - Newbie 5 11-15-2004 11:56 AM
C and virtual memory abdobl Programming 3 10-04-2004 12:14 PM
Enabling virtual memory seven212 Linux - Newbie 3 08-23-2003 01:05 PM
RH 8.0 Mapping Virtual Memory to get access to VMIC Reflective Memory PCI card. Merlin53 Linux - Hardware 0 05-05-2003 12:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration