Beruflich Dokumente
Kultur Dokumente
MEMORY MANAGEMENT:
VIRTUAL MEMORY
Memory Allocation
• Page Memory Allocation
• Demand Page Memory Allocation
• Segmented Memory Allocation
• Segmented/Demand Page Memory Allocation
Understanding Operating Systems, Fourth Edition 7
Objectives:
You will be able to describe: (1)
• Define page memory allocation
• Familiarize the architecture, algorithm and tools used by
the page memory allocation
• Compute the displacement and page number of the line
in the memory using the page memory allocation
• Patience and accuracy in solving a problem
Understanding Operating Systems, Fourth Edition 8
Objectives:
• Define demand page memory allocation
• Familiarize the architecture, algorithm and tables used by
the page memory allocation
• Determine the success and failure ratio of the swapping
algorithm
Understanding Operating Systems, Fourth Edition 19
Page Requested: B A C A B D B A C D
Page Frame 1:
Page Frame 2:
Interrupt:
Time Snapshot:
Success Ratio: =
Failure Ratio: =
Page Requested: A B A C A B D B A C D
Page Frame 1:
Page Frame 2:
Interrupt:
Time Snapshot: 1 2 3 4 5 6 7 8 9 10 11
Success Ratio: =
Failure Ratio: =
Page Requested: A B A C A B D B A C D
Page Frame 1:
Page Frame 2:
Interrupt:
Time Snapshot: 1 2 3 4 5 6 7 8 9 10 11
Success Ratio: =
Failure Ratio: =
Page Requested: A B A C A B D E A C A B D
Page Frame 1:
Page Frame 2:
Page Frame 3:
Interrupt:
Time Snapshot: 1 2 3 4 5 6 7 8 9 10 11 12 13
Success Ratio: =
Failure Ratio: =
Understanding Operating Systems,
Fourth Edition
37
Understanding Operating Systems, Fourth Edition 38
Table 3.3: Page Map Table for Job 1 shown in Figure 3.5.
Understanding Operating Systems, Fourth Edition 41
Topics:
1. Segmented Memory Allocation
2. Segmented/Demand Page Memory Allocation
Understanding Operating Systems, Fourth Edition 45
Objectives:
• After the discussion, the students should be able to:
• Define segmented and segmented/page memory allocation
• Familiarize the architecture of segmented and segmented/page
memory allocation
• Determine the exact location of the line in the memory using the
segmented and segmented/page memory allocation
• Participate in the class discussion
Understanding Operating Systems, Fourth Edition 46
M=a*j;
printf(“\n%d %d %d”, j,k,m)
} Page 1
printf(“\n”);
An example of demand paging that causes a page swap each time the
loop is executed and results in thrashing. If only a single page frame
is available, this program will have one page fault each time the loop
is executed.
Understanding Operating Systems, Fourth Edition 48
• Disadvantages:
• Difficulty managing variable-length segments in secondary storage
• External fragmentation
Understanding Operating Systems, Fourth Edition 54
Sample Problem
• What is the exact address of the line 340 of segment #0?
Understanding Operating Systems, Fourth Edition 56
Segmented/Demand Paged
Memory Allocation
• What is the problem of the segmented memory allocation
that gives birth the idea of segmented/demand page
memory allocation?
• Dynamic allocation
• Subdivides segments into pages of equal size, smaller
than most segments, and more easily manipulated than
whole segments. It offers:
• Logical benefits of segmentation
• Physical benefits of paging
• Removes the problems of compaction, external
fragmentation, and secondary storage handling
• The addressing scheme requires segment number, page
number within that segment, and displacement within that
page
Understanding Operating Systems, Fourth Edition 59
Segmented/Demand Paged
Memory Allocation
• What is segmented/demand paged memory allocation?
• Subdivides segments into pages of equal size, smaller than most
segments, and more easily manipulated than whole segments. It
offers:
• Logical benefits of segmentation
• Physical benefits of paging
• Removes the problems of compaction, external
fragmentation, and secondary storage handling
• Removes the problem of thrashing
Understanding Operating Systems, Fourth Edition 60
Sample Problem
Topics:
1. Virtual and Cache Memory
Understanding Operating Systems, Fourth Edition 66
Objectives
• After the discussion, the students should be able to:
• Define virtual memory and cache memory
• Familiarize the architecture of computer with virtual memory and
cache memory
• Compute the efficiency of the cache memory using the hit ratio and
access time formula
• Appreciate the importance of virtual memory and cache memory
Understanding Operating Systems, Fourth Edition 67
Virtual memory
Main Memory
Main memory
Understanding Operating Systems, Fourth Edition 69
Needed Entire
Program Program
Cache Memory
• A small high-speed memory unit that a processor can
access more rapidly than main memory
• Used to store frequently used data, or instructions
• Movement of data, or instructions, from main memory to
cache memory uses a method similar to that used in
paging algorithms
Understanding Operating Systems, Fourth Edition 72
Summary
• Paged memory allocations allow efficient use of memory
by allocating jobs in noncontiguous memory locations
• Increased overhead and internal fragmentation are
problems in paged memory allocations
• Job no longer constrained by the size of physical
memory in demand paging scheme
• LRU scheme results in slightly better efficiency as
compared to FIFO scheme
• Segmented memory allocation scheme solves internal
fragmentation problem
Understanding Operating Systems, Fourth Edition 76
Summary (continued)
• Segmented/demand paged memory allocation removes
the problems of compaction, external fragmentation, and
secondary storage handling
• Associative memory can be used to speed up the
process
• Virtual memory allows programs to be executed even
though they are not stored entirely in memory
• Job’s size is no longer restricted to the size of main
memory by using the concept of virtual memory
• CPU can execute instruction faster with the use of cache
memory