Virtual Memory: Operatin G Systems: Internals and Design Principle S
Virtual Memory: Operatin G Systems: Internals and Design Principle S
Virtual Memory: Operatin G Systems: Internals and Design Principle S
g
Systems:
Internals
and
Design
Principle
s
Lecture 08
Virtual Memory
Dr. Muhammed J. Al-Muhammed
Operating Systems:
Internals and Design Principles
Steven Spielberg,
2
Operating Systems
JAWS, 1975
characteristics fundamental to
memory management:
1) all memory references are logical addresses that
Operating Systems
Execution of a
Process
Operating
As
However,
5
Operating Systems
Continued . . .
Execution of a
Process
6
Operating Systems
Implications
Virtual memory
memory on disk
allows for effective multiprogramming and
relieves the user of tight constraints of main
memory
8
Operating Systems
Table 8.2
Characteristi
cs of
Paging and
Segmentatio
n with and
without use
of virtual
memory
9
Operating Systems
Thrashing
The operating
system must deal
with swapping in
and out with care;
otherwise, some
pieces may be
swapped out just
before they are
used. The operating
system must swap
in back these
pieces. Too much of
this is called
thrashing.
10
Operating Systems
A state in which
the system
spends most of
its time
swapping
process pieces
rather than
executing
instructions
Principle of Locality
11
Operating Systems
Paging
Operating Systems
Memory
Management
Formats
When virtual
memory used, we
still need a page
table for each
process. The page
table entries
become more
complicated. We
need some control
bits
- P indicates
whether a page is
in main memory.
- M indicates
whether the
14
content
of the
page
has
Operating
Systems
Address Translation
*Reading a word
from memory
involves the
translation of a
virtual address,
consisting of page
number
and offset, into a
physical address,
consisting of
frame number and
offset, using a
page table.
* Register holds
the starting
address of page
table.
15
Operating Systems
18
Operating Systems
19
Operating Systems
20
Operating Systems
Process
Control
Chain
identifi
bits
pointer
er
the
includes
the index
process
flags and
value of
that owns
protection
the next
this page
and
entry in
locking
the chain
informatio
n
Translation Lookaside
Buffer (TLB)
Each virtual
memory reference
can cause two
physical memory
accesses:
21
Operating Systems
To overcome the
effect of doubling the
memory access time,
most virtual memory
schemes make use of
a special high-speed
cache called a
translation
lookaside buffer
(TLB)
Use of a TLB
22
Operating Systems
TLB
Operatio
n
23
Operating Systems
Associative
Mapping
24
Operating Systems
Direct Versus
Associative Lookup
25
Operating Systems
26
Operating Systems
Page Size
The physical characteristics of most secondary27memory devices (disks) favor a larger page size for
more
efficient block transfer of data
Operating
Systems
Paging Behavior of a
Program
29
Operating Systems
Page Size
30
Contemporary programming
techniques (OO & multithreading) used in large
programs tend to decrease
the locality of references
within a process
Operating Systems
Segmentation
Segmentation
allows the
programmer to
view memory
as consisting of
multiple
address spaces
or segments
31
Operating Systems
Segmentation
32
Operating Systems
Segment
Organization
33
Operating Systems
Address
Translation
34
Operating Systems
35
Operating Systems
Address Translation
36
Operating Systems
Combined Segmentation
and Paging
37
Operating Systems
Protection and
Sharing
38
Operating Systems
Shared Pages
Reentrant code
39
Operating Systems
Protection
Relationship
s
40
Operating Systems
Operating System
Software
41
Operating Systems
issue:
performance
42
Operating Systems
Fetch Policy
Determines when
a page should be
brought into
memory
43
Operating Systems
Demand Paging
Demand Paging
only brings pages into main memory when a
reference is made to a location on the page
many page faults when process is first started
principle of locality suggests that as more and more
pages are brought in, most future references will be
to pages that have recently been brought in, and
page faults should drop to a very low level
44
Operating Systems
Prepaging
45
Prepaging
pages other than the one demanded by a page fault
are brought in
exploits the characteristics of most secondary
memory devices
if pages of a process are stored contiguously in
secondary memory (disk) it is more efficient to
bring in a number of pages at one time
ineffective if extra pages are not referenced
should not be confused with swapping (all pages
are moved out)
Operating Systems
Placement Policy
Determines
Important
Paging
46
Operating Systems
Replacement Policy
Deals
The
Frame Locking
48
Operating Systems
Basic Algorithms
49
Operating Systems
Optimal Policy
Selects the page for which the time to the next
reference is the longest (need perfect knowledge
of future events)
Produces three page faults after the frame
allocation has been filled
50
Operating Systems
Difficult to implement
one approach is to tag each page with the time of
last reference
this requires a great deal of overhead
51
Operating Systems
LRU Example
52
Operating Systems
First-in-First-out
(FIFO)
53
Operating Systems
FIFO Example
54
Operating Systems
Clock Policy
55
Operating Systems
Clock
Policy
56
Operating Systems
57
Operating Systems
Combined Examples
58
Operating Systems
Comparison of
Algorithms
59
Operating Systems
Clock
Policy
Used bit + Modified bit
60
Operating Systems
Page Buffering
Improves
paging
performance
and allows the
use of a
simpler page
replacement
policy
61
Operating Systems
62
Operating Systems
Resident Set
Management
63
Operating Systems
gives a process a
fixed number of
frames in main
memory within
which to execute
64
Operating Systems
Variableallocation
Replacement Scope
65
Operating Systems
Resident Set
Management Summary
66
Operating Systems
67
Operating Systems
Variable Allocation
Global Scope
Easiest to implement
adopted in a number of operating systems
68
Operating Systems
Variable Allocation
Local Scope
69
Operating Systems
Variable Allocation
Local Scope
70
Operating Systems
Figure
8.19
Working
Set of
Process as
Defined by
Window
Size
71
Operating Systems
72
Operating Systems
Cleaning Policy
74
Operating Systems
Load Control
Operating Systems
Process Suspension
76
Operating Systems
Summary
Desirable to:
maintain as many processes in main memory as
possible
free programmers from size restrictions in program
development