Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!

Notices

Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

Put simply, swapping (the precise term is "paging") is a method used to optimize RAM. In a computer, RAM memory is usually a limited resource in regards to what users demand. Take for example a common combination of programs in a session: operating system + system services + graphical environment + browser with many tabs + office suite + instant messenger + media player. These alone would normally "eat up" almost, if not all available RAM in the system.

Operating systems get around this limitation by sparing space for "simulating" extra RAM. Because of this, "swap space" is frequently termed as "virtual memory". The extra space is spared usually in your next common place to store things, that is, your hard disk.

The simulation basically works by tracking (several ways exist to do this tracking) how your RAM is used. RAM that is currently "less used" is marked as such, and eventually gets copied to the reserved disk space, freeing that area of RAM for things that could need it more. Whenever the area that was copied to disk is needed again, it will be copied back to RAM, perhaps forcing the previous process to be applied to some other RAM area. This exactly is why the process is called "swapping".

This is all done transparently by the Memory Manager of an Operating System, a core component of the kernel. The programs running always see their virtual RAM as real RAM, and don't care if it's swapped or not.

This way you are allowed to use much more RAM than you really have, but at the cost of getting too much swapping if you abuse of it. In that case you'll see a lot of disk activity and the system will slow to a crawl (because obviously, reading and writing to hard disk is WAY much slower than RAM). To get back to normal, just close some programs and documents.

yea the processor has limited memory cache.
so it fetches the info it needs from the virtual memory system.
if the processor decides it wants to hold on to something
it sticks it in RAM memory.
the processor maintains page tables to keep track of the virtual to actual memory translations.
the processor will only load pages into physical RAM that are currently needed by it.
the kernel space pages are given a dedicated space in physical RAM.
everything else is virtual.
this mean that when a process starts up it's executable image is loaded only into virtual memory not physical memory.
A file containing it is opened and its contents are mapped into the processes virtual memory.
as the application runs it generated page faults that are resolved by using the processes memory map and reading the virtual memory from disk into physical RAM and making an entry in the page table.
the swap file comes in when there is not enough physical RAM and some needs to be freed AND the data in the loaded page has been changed from the original image. This is called dirty pages. these dirty pages need to be saved so they get written to the swap partition.