Linux - KernelThis forum is for all discussion relating to the Linux kernel.
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.
Click Here to receive this Complete Guide absolutely free.
I have a embedded device with kernel 220.127.116.11-rt26 and compact flash WITHOUT swap partition and 256 Mb of RAM.
Well, when application startup, at the begin it works fine, but a piece of time later, application does not work fine.
After check all my configuration, I see that compact flash have not SWAP partition, then I made a new compact flash with SWAP partition. After do it, I run my application and I notice that it works fine.
So, what is the difference to use or not SWAP partition??
SWAP partitions are not necessary, but depending on what you do, and your hardware (mostly RAM), you'd better have one.
If you have lots of programs running, you eventually run out of RAM memory(if you don't understand why, you'd better start by stfw for this), when that happens you'd just the data you are not going to use for a while in that SWAP partition, and retrieve it when needed again.
So, most of the time, you'd need one. But of course if you don't have such worries (have lots of RAM memory, etc) you may not need it.
You know you can actually just make a swap-file in your linux partition and mount it as a swap partition too.
YES. Swap effectively prevents a machine from getting into out of memory at certain level. Many programs die or show problems at low memory scenario. The example below should give you a clear picture why. (You won't see this clear example in any text book)
Let's assume you have 300 programs in disk, 2 pages each. Each program mallocs 2-page buffer to process data. Each program needs 4 pages of memory when it is running (2 pages for code, 2 pages for data).
Given 100 pages of RAM the system can run approximately 25 programs concurrently. Anything above that VM needs to reclaim memory by kicking out programs. Let's see what happen when more than 25 programs run.
=== Scenario 1: (no SWAP)
disk: 1000 pages (0 pages for swap, 1000 pages for files and directories)
Memory 100 pages
Without swap the buffers have to stay in memory. Only memory used by code can be freed because the can be refetched from disk. Eventaully your 100 pages of memory will be filled with buffers, only 2 page is left for the running program. Total 49 programs can be running.
memory (2-page buffer * 49 + 2-page code).
=== Scenario 2: (with SWAP, swap space == memory size)
disk: 1000 pages (100 pages for swap, 900 pages for files and directories)
Memory 100 pages
With 100 pages of swap space 50 2-page buffers from 50 programs can be stored there. Total 99 programs can be running concurrently.
=== Scenario 3: (with SWAP. swap space = 2*memory size)
disk: 1000 pages (200 pages for swap, 800 pages for files and directories)
Memory 100 pages
memory (2-page buffer * 49 + 2 page code)
swap(2-page buffer * 100)
149 programs can run concurrently.
The system starts to experience out of memory at 50th program without swap, at 100th program with one time memory size swap, 150th with two times memory size swap. That says a system without swap hits out of memory much easier and programs that cannot handle out of memory start to show problems.
You have the option of not configuring swap in the kernel.
I wouldn't normally recommend it, but can certainly see the applicability for embedded. Mind you, it makes memory sizing and decent (non-leaking) application code even more important.