C Interview Questions and Answers


What is page thrashing?

Some operating systems (such as UNIX or Windows in enhanced mode) use virtual memory.
Virtual memory is a technique for making a machine behave as if it had more memory
than it really has, by using disk space to simulate RAM (random-access memory).
In the 80386 and higher Intel CPU chips, and in most other modern microprocessors
(such as the Motorola 68030, Sparc, and Power PC), exists a piece of hardware called
the Memory Management Unit, or MMU.

The MMU treats memory as if it were composed of a series of pages. A page of memory
is a block of contiguous bytes of a certain size, usually 4096 or 8192 bytes. The
operating system sets up and maintains a table for each running program called the
Process Memory Map, or PMM. This is a table of all the pages of memory that program
can access and where each is really located.

Every time your program accesses any portion of memory, the address (called a virtual
address) is processed by the MMU. The MMU looks in the PMM to find out where the
memory is really located (called the physical address). The physical address can
be any location in memory or on disk that the operating system has assigned for
it. If the location the program wants to access is on disk, the page containing
it must be read from disk into memory, and the PMM must be updated to reflect this
action (this is called a page fault).

Posted by:Richards