OS/2 V2 uses paging in addition to the above logical addressing. Paging is a mechanism which converts linear addresses to physical addresses and allows a consistent size ( 4k ) to be moved back and forth to auxiliary storage ( SWAPPER.DAT ) when the demand for virtual memory exceeds the physical memory installed on the machine. Another hardware register, Control Register 3 or CR3, is used to locate a page directory which contains table entries that locate page tables. The page tables are used to locate the physical memory where the data really resides. Physical memory is sometimes referred to by page number. A page number is simply the twenty high-order bits of an address. The twelve low-order bits of a page address are all zero. One can convert a page number to an address by simply appending three hex zeros to it.
THE RESULT OF COMBINING A SEGMENT NUMBER AND AN OFFSET, OR THE ADDITION
OF AN OFFSET TO THE BASE ADDRESS FROM A DESCRIPTOR, IS A LINEAR ADDRESS.
Under OS/2 1.x, these would be physical addresses. Under OS/2 2.0 and following,
these are linear, or virtual addresses.
The picture below shows how linear addresses are converted to physical addresses.
Only the top line in the picture below is a linear address - the rest are
physical.
The ten high order bits of the linear address are used to index into the Page Directory which has the twenty high order bits of the page table's physical address (page number). The next ten bits of the linear address are used to index into the page table. The twenty high order bits of the page frame's physical address (page number) are retrieved. The twelve low order bits of the linear address are also the twelve low order bits of the physical address. Therefore, the physical address is the twenty bits from the page table entry, followed by the 12 low-order bits from the linear address.
LINEAR ADDRESS
-----------------------------------------------------
| bits 31-22 | bits 21-12 | bits 11-00 |
-----------------------------------------------------
| | |
----- | -------------
| page | page page |
| directory | table frame |
| ------------ | ------- -------- |
| | | | | | | | |
| |------------| | |-------| | | |
| | | ---->| |-- | | |
| |------------| |-------| | | data | |
--->| |------ | | | | | | |
|------------| | |-------| | | | | |
| | | | | | | |<-------
|------------| | |-------| | | | |
| | | | | | | | |
--> ------------ --> ------- --> ---------
|
CR3 CR3 and the table entries all have PHYSICAL addresses!