CS 3733 Operating Systems
Lecture 10 [9/29/97]: Paging
Reading: Tanenbaum Section 3.3
Paging
- Method of choice on most systems.
- Programs do not have to be loaded contiguously.
- Physical memory is divided into fixed-size blocks called frames.
- The logical memory of the programs is broken into fixed-size blocks
called pages.
- A logical address generated by the CPU is divided into a page number
(p) and a page offset (d).
- The page number is used as an index into the page table which contains
the frame number of the actual page in memory.
- The page offset gives the position within the page. If the page size
is 2n, the offset will be n bits long.
- When a process enters the system, the required number of pages is
allocated from the free list of pages.
- There is no external fragmentation.
- There is a small amount of internal fragmentation because frames are
allocated as units.
Paging Implementation
- The page table is usually kept in main memory, so the address translation
will take two memory references rather than just one. This effectively
doubles the memory access time.
- To make paging more efficient, part of the page table is kept
in a fast memory which is content or key addressable (translation lookaside buffer).
- The percentage of times that a page number is found in the associative
memory is called the hit ratio.
Example
If the associative memory access time is 50 ns, the main memory access time
is 250 ns and the hit ratio is 80%, calculate the effective memory access
time.
Virtual Memory
- Each page table entry has a bit indicating whether the page
actually occupies a page frame.
- Initially when the process is allocated resources, the page
table is set up with all (or most) of the entries marked invalid.
- When a particular page is referenced, the hardware checks to see
if the page operation is permitted (e.g. writable) and if not,
the program aborts.
- When a particular page is referenced, the hardware checks to see
if the page table entry is valid. If it is, everything is as before.
- If an invalid page is referenced, a page fault trap will occur and
the following must be done:
- Remove the process from the CPU. When restarted, the instruction
which caused the page fault will be reexecuted.
(Be careful to undo operations such as MOV -(R2), (R3)+
.)
- Find a free frame from the free frame list and update this list.
- Schedule a disk operation to read page into frame.
- Update the page table.
- If the process never attempts to access a particular page of memory,
it is never brought in.
-
PSECTS
in VAX assembly language are defined on page boundaries.
You can put restrictions such as noexc
or nowrt
on pages and keep
the protection information in the page table.
Revision Date: 10/1/97