Welcome to Linux Knowledge Base and Tutorial
"The place where you learn linux"
Let The Music Play: Join EFF Today

 Create an AccountHome | Submit News | Your Account  

Tutorial Menu
Linux Tutorial Home
Table of Contents
Up to --> Introduction to Operating Systems

· Processes
· Virtual Memory Basics

Glossary
MoreInfo
Man Pages
Linux Topics
Test Your Knowledge

Site Menu
Site Map
FAQ
Copyright Info
Terms of Use
Privacy Info
Disclaimer
WorkBoard
Thanks
Donations
Advertising
Masthead / Impressum
Your Account

Communication
Feedback
Forums
Private Messages
Recommend Us
Surveys

Features
HOWTOs
News
News Archive
Submit News
Topics
User Articles
Web Links

Google
Google


The Web
linux-tutorial.info

Who's Online
There are currently, 256 guest(s) and 1 member(s) that are online.

You are an Anonymous user. You can register for free by clicking here

  
Linux Tutorial - Introduction to Operating Systems - Processes - Virtual Memory Basics
  Processes ---- Files and Directories  


Virtual Memory Basics

One interesting aspect about modern operating systems is the fact that they can run programs that require more memory than the system actually has. Like the Tardis in Dr. Who, Linux memory is much bigger on the inside than on the outside.

At the extreme end, this means that if your CPU is 32-bit (meaning that it has registers that are 32-bits), you can access up to 232 bytes (that 4,294,967,296 or 4 billion). That means you would need 4 Gb of main memory (RAM) in order to to completely take advantage of this. Although many systems are currently available (2003) with 256 MB or even 512 MB, more RAM than that is rare; and 4 Gb is extremely rare for a home PC.

The interesting thing is that when you sum the memory requirements of the programs you are running,you often reach far beyond the physical memory you have. Currently my system appears to need about 570 Mb. although my machine only has 384 Mb. Surprisingly enough I don't notice any performance problems. So, how is this possible?

Well, Linux, Unix and many other operating systems take advantage of the fact that most programs don't use all of the memory that they "require", as you typically do not use every part of the program at once. For example, you might be using a word processor, but not currently using the spell checking feature, or printing function, so there is no need to keep these in memory at the same time. Also, while you are using your word processor, your email program is probably sitting around doing nothing.

From the user's perspective the email program (or parts of the word processor) are loaded into memory. However, the system only loads what it needs. In some cases, they might all be in memory at once. However, if you load enough programs, you eventually reach a point where you have more programs than you have memory.

To solve this problem, Linux uses something called "virtual memory". It's virtual because it can use more than you actually have. In fact, with virtual memory you can use the whole 232 bytes. Basically, what this means is that you can run more programs at once without the need for buying more memory.

When a program starts, Linux does not load all of it, just the portion it takes to get started. One aspect of virtual memory is keeping parts of the program that are not needed on the hard disk. As the process runs, when it finds it needs other parts of the program, it goes and gets them. Those parts that are never needed are never loaded and the system does not use all of the memory it appears to "require".

If you have more data than physical memory, the system might store it temporarily on the hard disk should it not be needed at the moment. The process of moving data to and from the hard disk like this is called swapping, as the data is "swapped" in and out. Typically, when you install the system, you define a specific partition as the swap partition, or swap "space". However, Linux can also swap to a physical file, although with older Linux versions this is much slower than a special partition. An old rule of thumb is that you have at least as much swap space as you do physical RAM, this ensures that all of the data can be swapped out, if necessary. You will also find that some texts say that you should have at least twice as much swap as physical RAM. We go into details on swap in the section in installing and upgrading.

In order to do all this, the system needs to manage your memory. This function is logically called "memory management" and is one of the core aspects of any modern operating system. Although the details are different from one operating system to the next, the basic principles apply, even between different CPU types.

In other sections of the tutorial, we will talk about the details of memory management from both the perspective of the CPU and the operating system kernel.

 Previous Page
Processes
  Back to Top
Table of Contents
Next Page 
Files and Directories


MoreInfo

Test Your Knowledge

User Comments:


Posted by lsatenstein on August 18, 2014 08:20pm:

2014 Most PCs sold today (purchased) have 4 gigs memory as a minimum, and may contain up to 16 gigs. We see many pcs with 6 gigs memory, as the comprimise.


You can only add comments if you are logged in.

Copyright 1997-2004 by James Mohr. Licensed under modified GNU Free Documentation License. See here for details. All rights reserved.
  
Show your Support for the Linux Tutorial

Purchase one of the products from our new online shop. For each product you purchase, the Linux Tutorial gets a portion of the proceeds to help keep us going.


Login
Nickname

Password

Security Code
Security Code
Type Security Code


Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Help if you can!


Amazon Wish List

Did You Know?
The Linux Tutorial welcomes your suggestions and ideas.


Friends



Tell a Friend About Us

Bookmark and Share



Web site powered by PHP-Nuke

Is this information useful? At the very least you can help by spreading the word to your favorite newsgroups, mailing lists and forums.
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters. Articles are the property of their respective owners. Unless otherwise stated in the body of the article, article content (C) 1994-2013 by James Mohr. All rights reserved. The stylized page/paper, as well as the terms "The Linux Tutorial", "The Linux Server Tutorial", "The Linux Knowledge Base and Tutorial" and "The place where you learn Linux" are service marks of James Mohr. All rights reserved.
The Linux Knowledge Base and Tutorial may contain links to sites on the Internet, which are owned and operated by third parties. The Linux Tutorial is not responsible for the content of any such third-party site. By viewing/utilizing this web site, you have agreed to our disclaimer, terms of use and privacy policy. Use of automated download software ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and are therefore expressly prohibited. For more details on this, take a look here

PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.05 Seconds