11.4. How the Kernel Organizes Memory
11.4.1. Dividing the RAM
When the kernel is first loaded into memory (at boot
time), it sets aside a certain amount of RAM for
itself as well as for all system and user processes: Main
categories in which RAM is divided are:
- Text: to hold the text segments of
running processes.
- Data: to hold the data segments of
running processes.
- Stack: to hold the stack segments of
running processes.
- Shared Memory: This is an area of memory which is available to
running programs if they need it. Consider a common use of shared memory:
Let assume you have a program which
has been compiled using a shared library (libraries that look like
libxxx.so; the C-library is a good example - all programs need it).
Assume that five of
these programs are running simultaneously. At run-time, the code they
seek is made resident in the shared memory area. This
way, a single copy of the library needs to be in memory, resulting
in increased efficiency and major cost savings.
- Buffer Cache: All reads and writes to the
filesystem are cached here first. You may have experienced situations
where a program that is writing to a file doesn't seem to work (nothing
is written to the file).
You wait a while, then a sync occurs, and the buffer cache is
dumped to disk and you see the file size increase.