The page table also contains information about the whereabout of the program store on disk.
The memory is divided into equal sizes called frames.
A common pages size is 1 to 4 Kbytes, because hard disks performs better when a larger chunch of data is transfered. (The access data on a hard disk, the hard disk has to move the disk head over the track that contains the data which is pretty slow).
The page table defines a mapping between program pages and memory frames:
|
So pages 0, 1 and 4 are present in memory.
So pages 2 and 3 are not present in memory (the mapping results in invalid).
We make sure (by choosing the right page size) that the page size is always some power of 2 so that it is very easy to determine the page number for any given address.
For example, if the page size (and frame size) is 1 K bytes, the the left most 22 bits in a program address is equal to the page number:
|
Similarly, if the page size (and frame size) is 2 K bytes, the the left most 21 bits in a program address is equal to the page number, and so on.
This is the crux of the paging technique. Note that the mapping must be dynamic.
A simple and efficient dynamic mapping can be constructed by using a address translation table that map program page numbers to memory frame numbers.
Because the total number of program pages is much larger than the number of frames in memory, no all pages of the program will be present in memory.
The mapping function has a special bit to indicate whether a page is present in memory and the address mapping is only valid when the page is present in memory.
|
This location will be needed when the program tries to access a program location in a page that is not present in memory
The computer system can use the location on disk stored in the associated entry to read the page from disk and put it into the memory !program
|
The reason is:
Clearly they can be of different length....
|
E.g., the address indicated by "Label" in the assembler instruction "MOVE Label, D0", refers to an address in the program