Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab 10 Paging.

Similar presentations


Presentation on theme: "Lab 10 Paging."— Presentation transcript:

1 Lab 10 Paging

2 NCHU System & Network Lab
Paging A memory management scheme that permit the physical-address space of a process to be noncontiguous Physical memory is broken into fixed-sized blocks called frames Logical memory is also broken into blocks of the same size called pages NCHU System & Network Lab

3 NCHU System & Network Lab
Paging Basic method f logical address physical address f d CPU p d f d target cont. f p f page table physical memory NCHU System & Network Lab

4 NCHU System & Network Lab
Basic method Address format page number page offset p d m-n n m size of logical address space = 2m block size = 2n bytes there are 2m-n pages NCHU System & Network Lab

5 NCHU System & Network Lab
Hierarchical Paging logical address p1 d p2 p1 p2 d outer-page table physical memory page of page table NCHU System & Network Lab

6 NCHU System & Network Lab
Hierarchical Paging Address format page number page offset p1 d p2 10 10 12 block size = 4 Kbytes = 212 bytes page of page table size = 1block size, each entry need 4bytes=>210 entries 210 * 210 * 4 Kbytes = 4 Gbytes (32-bit machine) NCHU System & Network Lab

7 NCHU System & Network Lab
fopen #include <stdio.h> FILE *fopen(const char *filename, const char *mode); Mode: r - open for reading w - open for writing (file need not exist) a - open for appending (file need not exist) r+ - open for reading and writing, start at beginning w+ - open for reading and writing (overwrite file) a+ - open for reading and writing (append if file exists) Return : FILE pointer for success, 0 for error. NCHU System & Network Lab

8 NCHU System & Network Lab
Example One memory states file 2000 addresses ( 0x000 ~ 0x7d0 ) Three frames, 256~511, 768~1023, 1536~1791 have data Map them to continue logic address 0x000~0x2ff Basic method paging program Input one logic address Output physical address and its data NCHU System & Network Lab

9 NCHU System & Network Lab
Example Graph 000 logical address p d 100 1 a b 256 index 1ff Phy_addr = ab 100 1 300 300 2 600 ab 3ab content page table 3ff 600 frame size = 256 bytes = 28 3 frames => logical address : 000 to 2ff 6ff 7d0 physical memory NCHU System & Network Lab

10 NCHU System & Network Lab
Example code NCHU System & Network Lab

11 NCHU System & Network Lab
Example Result NCHU System & Network Lab

12 NCHU System & Network Lab
A program that use 2 Layer Hierarchical Paging method one input files (have physical memory states) frame size = 16 bytes first layer have 3 entries second layer need 3 pages, each page has 16 entries Input logical address Output physical address and its content NCHU System & Network Lab

13 NCHU System & Network Lab
Lab Graph zoom out 000 000 p1 p2 d a 00a 100 a b 1a0 000 020 040 index outer page table 1 2 020 1a0 1ff 16 entries 300 040 3ff 04f page of page tables 600 1a0 b content 1ab 1af 16 bytes zoom out 6ff 7d0 Phy_addr=1a0+00b physical memory NCHU System & Network Lab

14 NCHU System & Network Lab
Reference Advanced Programming in the UNIX Environment 2nd Author : Richard Stevens, Stephen A.Rago, Publisher : Addison-Wesley Beginning Linux Programming Author : Richard Stones, Neil Matthew Publisher : Wrox Operating System Concepts 6th edition Author : Abraham Silberschatz, Peter Baer Galvin, Greg Gagne Publisher : John Wiley & Sons, inc. NCHU System & Network Lab


Download ppt "Lab 10 Paging."

Similar presentations


Ads by Google