DIRECTORY 1 page directory (4k block holding 1024 entries) each entry points to a page table TABLE total of 1024 page tables each table is a 4k block holding 1024 entries each entry points to a page frame (see PAGE FRAME ADDRESS) FRAME total of 1048576 page frames each frame is a 4k block the frame is where the data/code is stored ---------------------------------------- LINEAR ADDRESS dir:10, page:10, offset:12 FORMAT of PAGE DIRECTORY and PAGE TABLE entries TABLE: addr:20, avail:3,g:1, RES:1,d:1,a:1,pcd:1, pwt:1,u:1,w:1,p:1 DIRECTORY: addr:20, avail:3,g:1, ps:1,RES:1,a:1,pcd:1, pwt:1,u:1,w:1,p:1 avail:3= OS usage g=blobal page, ignored for pgdir ps= page size (pgdir only) RES= reserved, must be zero d= dirty (page has been written to) (pgtbl only) a= accessed (page has been used, r/w) pcd= if set then do not cache page on-chip pwt= write-through if set u= user (cpl3) w= writable p= page present if P bit is zero then the page is not in memory and the other 31 bits may be used by the OS to locate the missing page. if P bit is zero and an attempt is made to access the page, a page-fault is generated. any unused entries in the page directory or page table should be cleared. if a page-fault is generated check for a cleared entry. if clear then an iilegal access was made. if not clear then find the page in swap and load it. the A bit can be used to track how often the page is used. if not used it can be swapped out. the D bit could be used when saving a file. check the D bits for each page of the file. if the page hasn't been written to, then do not write it to storage. after saving the file clear all D bits. this would speed up the time it takes to save a file. ---------------------------------------- set bit 31 of CR0 to enable paging CR3 (PDBR) is the physical address of the current page directory ---------------------------------------- if a page is physically moved or reloaded to a new location in memory the TLB entry for that page must be invalidated. a task switch or reloading CR3 will cause the TLB's to be invalidated. ---------------------------------------- page tables may be swapped out, but the page directory must always exist in memory while CR3 points to it. when a page is accesed the A bit of both the page table and page frame is set. the D bit is only used in the page frame entry. ----------------------------------------