Fifth Edition
Chapter 3
Memory Management:
Virtual Memory
Introduction
Evolution of virtual memory
Paged, demand paging, segmented,
segmented/demand paging
Foundation for current virtual memory methods
Improvement areas
Need for continuous program storage
Need for placement of entire program in memory
during execution
Fragmentation
Overhead due to relocation
Understanding Operating Systems, Fifth Edition
Introduction (continued)
Page replacement policies
First-In First-Out
Least Recently Used
Clock replacement and bit-shifting
Mechanics of paging
The working set
Virtual memory
Concepts and advantages
Cache memory
Concepts and advantages
Understanding Operating Systems, Fifth Edition
Address resolution
Translating job space address into physical address
Relative address into absolute address
10
11
Disadvantages
Increased overhead from address resolution
Internal fragmentation in last page
Must store entire job in memory location
12
Demand Paging
Pages brought into memory only as needed
Removes restriction: entire program in memory
Requires high-speed page access
Examples
User-written error handling modules
Mutually exclusive modules
Certain program options: mutually exclusive or not
accessible
Tables given fixed amount of space: fraction used
Understanding Operating Systems, Fifth Edition
13
14
15
16
17
18
19
Thrashing (contd.)
Generally, thrashing is caused by processes not having
enough pages in memory
using global replacement, can occur when process steal frames
from each other
but, can even happen using local replacement
thrashing processes lead
to low CPU utilization
OS (long-term scheduler) thinks
it needs to increase degree
of multiprogramming
more processes are added to
the system (taking frames from
existing processes)
worse thrashing
Disadvantages
Increased overhead caused by tables and page
interrupts
Understanding Operating Systems, Fifth Edition
21
22
First-In First-Out
Removes page in memory the longest
Efficiency
Ratio of page interrupts to page requests
FIFO example: not so good
Failure rate is 9/11 or 82% or Success rate is 18%
Beladys/FIFO anomaly
More memory does not lead to better performance
23
24
25
Beladys Anomaly
Normally, increasing the number of frames allocated to a
process will reduce the number of page faults
however, not always the case
1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
With this reference string,
actually have more page faults
with 4 frames than with 3
This rare but highly
undesirable
situation is known as
Belady's anomaly
27
28
29
Referenced bit
Indicates if page referenced recently
Used by LRU to determine page to swap
Modified bit
Indicates if page contents altered
Used to determine if page must be rewritten to
secondary storage when swapped out
30
31
32
33
34
35
36
37
38
Advantages
Internal fragmentation is removed
Memory allocated dynamically
Disadvantages
Difficulty managing variable-length segments in
secondary storage
External fragmentation
39
Segmented/Demand Paged
Memory Allocation
Subdivides segments into pages of equal size
40
Segmented/Demand Paged
Memory Allocation (continued)
Scheme requires four tables
Job Table
Lists every job in process (one for the whole system)
41
Segmented/Demand Paged
Memory Allocation (continued)
42
Segmented/Demand Paged
Memory Allocation (continued)
Advantages
Large virtual memory
Logical benefits of segmentation
Physical benefits of paging
Disadvantages
Table handling overhead
Memory needed for page and segment tables
43
Virtual Memory
Allows program execution even if not stored entirely
in memory
Requires cooperation between memory manager
and processor hardware
Advantages
44
45
46
Cache Memory
Small high-speed intermediate memory unit
Performance of computer system increased
Memory access time significantly reduced
Faster processor access compared to main memory
Stores frequently used data and instructions
47
48
Efficiency measures
Cache hit ratio (h)
Percentage of total memory request found in cache
49
50