Presentation is loading. Please wait.

Presentation is loading. Please wait.

VIRTUAL MEMORY By Thi Nguyen. Motivation  In early time, the main memory was not large enough to store and execute complex program as higher level languages.

Similar presentations


Presentation on theme: "VIRTUAL MEMORY By Thi Nguyen. Motivation  In early time, the main memory was not large enough to store and execute complex program as higher level languages."— Presentation transcript:

1 VIRTUAL MEMORY By Thi Nguyen

2 Motivation  In early time, the main memory was not large enough to store and execute complex program as higher level languages became popular.  In 1961, virtual memory was proposed to solve the problem of storage allocation.

3 Definition  Virtual memory is a memory management system that gives a computer the appearance of having more main memory than it really has.

4 Advantages  Main memory is used more efficiently. Only those portions of an executing program that are in use occupy main memory.  Programs that are bigger than main memory can still be executed

5 Implementation of Virtual Memory  The virtual memory abstraction is implemented by using secondary storage to augment the processor's main memory.  Data is transferred from secondary to main storage when necessary and the data replaced is written back to the secondary storage.

6 Implementation of Virtual Memory  If the data swapped is designated a fixed size, this swapping is called paging.  if variable sizes are permitted and the data is split along logical lines, it is called segmentation.  Some operating systems combine segmentation and paging.

7 Paging  In a simple paging system view,  user programs consists of fixed-length blocks called pages.  Main memory consists of fixed-length blocks called frames.  When an operating system loads a user program into memory, it loads each page into any available frame.

8 Page Table  To keep track of the location of each page in the memory, the operating system builds a one-dimensional array called Page Table.

9 Page Number Frame Number Valid bit 000 100 221 351 0 means not in memory

10 Mapper  The mapper is the part of the operating system that translates the logical page number generated by the program into the physical page frame number where the main memory holds the page.  This translation is accomplished by using page table. If the page table reveals that the page is not resident in the main memory, the mapper issues a page fault to the operating system so that execution is suspended on the process until the desired page can be read in from the secondary storage and placed in main memory.

11

12 Page in  The corresponding operation of reading them in again later when one of the pages is referenced is called a page in.

13 Page out  The operation of writing one inactive page, or a cluster of inactive memory pages to disk is called a page out.

14 Advantages  Paging is effective because programs typically only use a small proportion of their virtual memory pages actively at any one a time.  Allows a program that is too big to fit into memory to be executed

15 Disadvantages  Once the memory is allocated for modules they cannot vary in size. This restriction results in either wastage or shortage of memory.  In paging system, stack is put at the top of its logical address space; data and code are put at the bottom. The gap between them requires a page table that is too big.

16 Segmentation  the program is divided into functional segments such as code segment, stack segment, data segment…

17 Segmentation  some computer systems have their main memory divided into many independent address spaces. Each of these address spaces is called a segment. The address of each segment begins with 0 and segments may be compiled separately.

18 Segmentation  Each segment in the program can be transferred into segments in main memory. However, it may happen that the program segment is too big to fit in main memory segment.

19 Segmentation with Paging  Some operating systems allow for the combination of segmentation with paging. If the size of a segment exceeds the size of main memory, the segment may be divided into equal size pages.

20 Segmentation with Paging  Each segment has its own page table.  The used gap in the address space would not be represented by any page table.

21

22 Virtual Address  The address consists of three parts:  (1) segment number  (2) the page within the segment  (3) the offset within the page.  The segment number is used to find the segment descriptor and the address within the segment is used to find the page frame and the offset within that page.

23 Comparison between Paging and Segmentation  SEGMENTATION  Involves programmer  Separate compiling  Separate protection  Shared code  PAGING  Transparent to programmer  No separate compiling  No separate protection  No shared code


Download ppt "VIRTUAL MEMORY By Thi Nguyen. Motivation  In early time, the main memory was not large enough to store and execute complex program as higher level languages."

Similar presentations


Ads by Google