Paging in memory management

memory managementoperating systemsvirtual-memory

I was just reading Operating System Principles by Silberschatz et al when I came across paging in memory management.I'm slightly confused about it.
It states that Physical Memory(I assume it's RAM) is divided into frames, and logical memory is divided into pages. CPU generates logical addresses containing page number and an offset. This page number is used to retrieve the frame number from a page table which gives the base address
so the physical address is calculated as base+offset.
My question is:

  • is the page table maintained for every process?
  • I logically think that the answer would be yes as every process will need to map its own pages to frames. I may be wrong. Please clarify.

    Also:

  • paging and segmentation(where 'holes' are created in memory) are two totally different techniques that are not used in combination. Correct?
  • Best Answer

    Segmentation yields Linear Addresses, Paging yields Physical Addresses

    Regarding logical and physical addresses, from Bovet & Cesati (Understanding the Linux Kernel), I've got this:

    how logical addresses map to physical

    As you can see, paging and segmentation are carried out by separate units of the hardware. Although they may take place at the same time, the OS can disable the segmentation unit (so addresses are effectively treated not as logical but linear ones).

    Generalities

    You may already know this stuff, but I put it here anyway for completeness.

    Pages occupy Frames: Swapping

    As far as Silberschatz chapters 8,f is concerned, frames refer to the layout of the physical memory. The OS divides RAM into areas of equal and conveniently sized (e.g. 4K) frames. Pages are frame-sized pieces of data, the basic unit of page replacement.

    There may be more pages than available frames. Some pages occupy frames, some pages are swapped out on disk.

    If a page is swapped in from disk, it is aligned with a certain frame in memory (whichever the page replacement algorithm saw fit).

    Operating Systems and the Hardware co-operate

    As with many OS objectives, memory management always works in concert with the hardware: both the OS and hardware co-operate, to get the job done. How they do it in a realistic scenario depends on

    1. the set of memory management primitives the hardware provides (paging, segmentation, and what the heck there exists), and
    2. which subset thereof the OS really uses on the particular architecture and situation (Linux@zArchitecture is different from Linux@Intel is different from Windows@Intel is different from Window@Intel@Boot-up)

    For example, only a few architectures provide segmentation and the figure above applies to x86. Linux, for portability reasons, does not very much exploit it. If I remember it correctly from Tanenbaum, OS/2 was the only operating system to exploit Intel's segmentation to its full extent.

    So far this Answer.

    Depending on why you need to know this, the following approach might help you (it has helped me).

    I suggest you first get familiar with the hardware and the individual primitives. If Silberschatz is to vague on this point, try Tanenbaum (Modern Operating Systems) or Hennessy&Patterson (Computer Architechture, A Quantitative Approach). If your curiosity is not satisfied by then, see how a particular OS uses it in various situations on a particular platform.

    Related Question