From: "David Schwartz" <davids@webmaster.com>
To: "Linux-Kernel@Vger. Kernel. Org" <linux-kernel@vger.kernel.org>,
"'Ankit Jain'" <ankitjain1580@yahoo.com>,
"'linux'" <linux-kernel@vger.kernel.org>
Subject: RE: VM Vs Swap Space
Date: Wed, 13 Oct 2004 16:35:08 -0700 [thread overview]
Message-ID: <MDEHLPKNGKAHNMBLJOLKOEMJOPAA.davids@webmaster.com> (raw)
In-Reply-To: <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAA2ZSI4XW+fk25FhAf9BqjtMKAAAAQAAAAdrZR1ip2x0S1aHNr193n7gEAAAAA@casabyte.com>
> A long but basic explanation of the difference between "Virtual
> Memory" and "Swap
> Space" follows:
One of the problems with a 'basic' explanation is that you always wind up
leaving out something that someone else things is important. ;)
> Imagine a computer with only five pages of memory. Imagine a
> moment when pages 1 3
> and 5 are in use, and the system needs to load a program that is
> two pages long. In
> the absence of virtual memory, that program couldn't be loaded
> because the two
> available pages (2 and 4) are not "next to each other" so the
> program would be broken
> in half.
Even if it only had one page, it could load half the program in one page.
When the program tried to access the other page, it would fault. The first
page could be discarded and the second loaded. So the system could operate
even if it didn't have enough pages or any swap space.
> Now, in the same way that you, were you playing a game with
> hundreds of cards, would
> like to be able to put some cards aside while sorting through
> things so that you can
> handle the most important cards in play; the computer sometimes
> would like to put
> aside pages of memory that are valid, but that nobody seems to
> need just now.
> A swap file (which is also called a "paging file" in some
> systems) represents a place
> where the system (linux/windows/whatever) can set aside (swap
> out) the data from a
> page of real RAM memory, so that it can reuse that piece of real
> memory for another
> purpose.
Or, if the data is already stored somewhere (if it's a page from a file
that hasn't been modified), it can just throw the page away.
> If the program that "owns" the original data tries to get to it a
> "page fault"
> happens and the system finds a (usually different) page of real
> memory that isn't in
> use (or that can be swapped out) and puts the data back (swaps)
> in this original data
> page into the new place, and makes that new/other piece of RAM
> appear (to the
> program) as if it had always been there and that it didn't move at all.
This works the same whether the place is a file or a swap page.
> "Virtual Memory" is a short-hand name for either the task of
> making and maintaining
> these logical maps/chunks, or the name for any one consistent
> logical chunk when seen
> from inside. If phrase is used without enough context it can get
> meaningless. But
> in no meaningful case is it "interchangeable" with the term "swap space".
Swap space, basically, allows a virtual memory system to move pages that it
can't discard out of precious physical memory.
DS
next prev parent reply other threads:[~2004-10-13 23:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-07 9:17 Ankit Jain
2004-10-07 19:30 ` Rik van Riel
2004-10-13 22:46 ` Robert White
2004-10-13 23:35 ` David Schwartz [this message]
2004-10-14 4:09 ` Lee Revell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MDEHLPKNGKAHNMBLJOLKOEMJOPAA.davids@webmaster.com \
--to=davids@webmaster.com \
--cc=ankitjain1580@yahoo.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®