Monday, August 08, 2005

what is the minor faults meaning in mpstat

Subject: SUMMARY: what is the minor faults meaning in mpstat

Thank you all for the responses. Russell's answer was the most clear one
and I think everybody can have benefith of reading this. Not only those
who don't know, but also the for the once already know it can be
refreshing to read this one:

A process running on a typical 32 bit system is allowed to address 4Gb
of memory. There is a really huge amount available to it on a 64bit system.
This memory isn't really there, so it is called "virtual memory". The
range of available addresses in virtual memory is called the process's
"addressspace."

Most of the time the process will be holding only a few pointers into
different parts of it's address space and will be attempting to read and
write memory through those pointers. All of these memory accesses are
intercepted by the operating system (OS) which maps the "virtual"
address the process in using to a real address in RAM.

Obviously there isn't enough RAM on most computers to even do a
one-to-one mapping from the processes virtual addresses to a physical
address. Fortunately, because the process can only access it's address
space through pointers, it can only access a few addresses at a time.
Moreover, generally each new access is to an address that is near the
most recent access.

Statistically, most of a process's pages will only get accessed once.
However, in the short run there will be a small block of pages that are
being accessed frequently, because most programs contain loops, and
repeatedly read certain pages. Only rarely, (hopefully!) a process will
access a page that it last accessed a relatively long time ago.

Here is how the OS manages all of this:

1. Chunks of real memory are allocated to the process in pages. On
Solaris, the page size is 4096 bytes. Each page is timestamped
whenever a process references it. If the process writes on the page it
is marked as
"dirty".

2. Periodically a kernel process called pageout (PID=2) sweeps through
physical memory and moves pages that haven't been accessed by a process
for a long time to a free list. These times are in the order of tens of
seconds. During a memory shortage, the sweep rate increases.

3. If there is a shortage of physical memory, the oldest, dirty pages in
the free list get written onto the swap device. When a process
accesses a virtual address, one of three things can happen:

1. The corresponding physical page is in memory. The access succeeds.

2. The page is not in memory - but it is on the disk. This is called a
"major fault". The process is blocked and a context switch occurs. While
the process is waiting, the page is brought off the disk into memory, the
processes Hardware Address Table (HAT) is updated and the process is
marked "runnable".

3. The page is no longer mapped into the process, but is on the free
list. This is called a "minor fault." (I got there at last!) In this case a
context switch still occurs and the page is removed from the free list
and mapped back into the process.

There is a more light-hearted explanation here:
http://www.netjeff.com/humor/item.cgi?file=TheThingKing

0 Comments:

Post a Comment

<< Home