Compilation study notes (22) - memory paging mechanism

Brief

  The aforementioned segmentation mechanism virtual address is obtained, then the tab is to achieve direct virtual address to physical address mapping, because maple mechanism may be closed, then the time is equivalent to one mapping virtual addresses to physical addresses directly on

  4K page aligned holding position, so that the former 32-bit virtual address 20 is used to find the corresponding page within the page offset 12 as used to locate the specific location.

 

Paging mechanism

  Paging mechanism has two tables, called a page directory table, called a page table entries in both tables use the same configuration, a 4-byte entry 32

  Here's physical address is represented by 20, because the pages are 4K-aligned, that is to say 12 always all-0 after the beginning of a page, so only 20 to a page address, the address 20 is left 12 the actual physical address.

  A bit indicates whether the data is accessed, each visit to the CPU will be set to 1 this, the operating system may be the periodic zero, waiting for the CPU 1 set again used to determine which pages busy, sequentially as feed basis

  D bit indicates that data is written, the operating system can be used in order to determine the basis for the decision, whether the page needs to be written back to disk files

  U / S bit can be used to drive the system user mode page, and the page, the user program sequentially isolating permissions

  R / W page can be used to control whether to protect the data write

    This bit can also be used to implement copy-on-write function, the page read-only when an application tries to write the interrupt will trigger an exception, an exception handler can replicate the physical memory from this page and directed to the new physical memory while allowing write this page, thus completing the copy-on-write functionality.  

  P indicates this page would like to describe whether a formal presence in physical memory, if there is no time to visit when the page fault occurs, the page fault handler then processed this need to re-set 1, CPU can continue He ran down.

 

 Conversion method

  

  

 

 

 

STEP1. The 32-bit address is first cut into [10] [10] [12] The three, namely To facilitate the X, Y, Z

STEP2. By CR3 page directory to find, and multiplied 4 with X as an index to find the corresponding page directory entry

SETP3. Remove the page directory entry interrupt to get the physical address of the page table

SETP4. Y is used as an index multiplied by 4 to find the page table entry in the page table

SETP5. Remove the memory address also from the page table entry

SETP5. Z is positioned directly in memory pages

 

 other instructions

note:

1. 页表中寻址都是使用的物理地址,因为也变本本身就是用作虚拟地址防疫到物理地址的,如果页表还用虚拟地址,就无线重入了。

2. 这只是80386提供的分页管理功能,80386都是老的不能再老CPU了,现在都64位的,分页机制肯定变化很大。

Guess you like

Origin www.cnblogs.com/alwaysking/p/12348322.html