Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSI 400/500 Operating Systems Spring 2009 Lecture #9 – Paging and Segmentation in Virtual Memory Monday, March 2 nd and Wednesday, March 4 th, 2009.

Similar presentations


Presentation on theme: "CSI 400/500 Operating Systems Spring 2009 Lecture #9 – Paging and Segmentation in Virtual Memory Monday, March 2 nd and Wednesday, March 4 th, 2009."— Presentation transcript:

1 CSI 400/500 Operating Systems Spring 2009 Lecture #9 – Paging and Segmentation in Virtual Memory Monday, March 2 nd and Wednesday, March 4 th, 2009

2 2 Virtual Memory  Not physical  Concept of “extending” primary memory by having an address refer to a piece of secondary storage loaded into primary storage  Saves data-loading time and saves storage space

3 3 Virtual Memory Allocation  Means of using storage to hold address space portions of all processes in system  Two basic methods:  Paging  Segmentation

4 4 Virtual Paging  Fixed size block  Entire address space divided into pages  Subset of pages loaded into primary storage at a time  Primary storage block of same size called “page frame”

5 5 Page Allocation  Operating System maintains Page Table  Holds start address of all loaded pages  Data is referenced by translating virtual address  Virtual address contains index into page table and offset within page where specific data is located

6 6 Page Translation

7 7 Paging Algorithmic Policies  Fetch  Placement  Replacement  Determines when to load page into primary storage  Determines where to place loaded page  Determines when and how to remove a page to make room for new page (necessary when all page slots are full)

8 8 Fetch Policies  Prefetch  Obtain page prior to execution  Needs to know first data references  Demand  Load page when data requested  Dynamic  # of pages varies during execution

9 9 Placement Policies  Contiguous  Pages are loaded in contiguous storage  Reuse  Frames that held pages that have been removed will be reused, in order of removal  References a free space chain (FIFO)

10 10 Replacement Policies  Random  Not preferred – not efficient  Least Recently Used  Least Frequently Used  FIFO  Optimal  Clock  We’ll discuss this a bit later

11 11 Replacement Example  Suppose 8-page working set  Following pages have been accessed # of times: 0 – 51 – 32 – 63 – 4 4 – 25 – 36 – 17 – 2 using references 0,1,2,3,4,2,0,5,3,6,0,2,1,7,2,3,5,0,4,1,2,7,0,5,3,2  Consider the following page references: 8,0,2,7,9,6,3,4,2,5,1  What happens with LRU, LFU, and FIFO?

12 12 Paging Performance Measures  Fault rate: frequency of loads (when a data value has no virtual address)  Loads occur at beginning and with each replacement  Transfer time: time to write changed code back and load new page  Shortened by replacing non-edited page  Clock replacement deals with this concept

13 13 Clock Replacement  Two flags per page frame: referenced and changed  Replacement pointer moves along page frames in consecutive order  Looking for 1 st page with both flags off  Replaces that page and moves pointer forward  As finds changed pages, saves changes and clears both flags, then moves pointer forward  If no page frame found with both flags off, uses 1 st referenced but not changed page

14 14 Dynamic Paging  Processes can have different number of pages allocated at any times  Varies based upon computational needs  Demands each process define a “working set”  Number of pages needed at particular time  Handled by user-specified parameters (like BUFFERS or PAGESIZE) or by compiler optimization  Process held until additional pages are loaded

15 15 Segmentation  Variable sized  Allocated dynamically  Segments placed in contiguous storage  Method used to allocate system stacks

16 16 Segment Allocation  Operating System maintains Segment Table  Contains starting address and length of all segments  Data is referenced by translating virtual address  Virtual address contains index into segment table, offset within segment where specific data is located, and size of data  Size is needed to ensure it does not exceed boundary

17 17 Segment Translation index offset length address length Data OK?

18 18 Linux Virtual Addressing  Uses dynamic on-demand paging  Uses triple page translation scheme  1 st part of virtual address is index into page directory  2 nd part is index in page middle directory, whose address was obtained from page directory entry  3 rd part is index into page table, whose address was obtained from middle directory entry  Last part is offset into page

19 19 Linux Page Translation Data index page Offset directory address


Download ppt "CSI 400/500 Operating Systems Spring 2009 Lecture #9 – Paging and Segmentation in Virtual Memory Monday, March 2 nd and Wednesday, March 4 th, 2009."

Similar presentations


Ads by Google