Save
OPERATING SYSTEM
FINALS
Save
Share
Learn
Content
Leaderboard
Learn
Created by
hehehe
Visit profile
Subdecks (1)
DBMS
OPERATING SYSTEM > FINALS
101 cards
Cards (238)
Memory
Management
Ensuring
memory
is shared efficiently and free from
errors
Issues in memory management
Protecting
memory spaces of processes from
unauthorized
access
Ensuring each process has enough
memory space
to execute
Keeping track of
memory locations
used by each process and
free
memory
Absolute address
Unique, actual address of a memory location
Relative address
Address based on a
reference
point or
base
address
Dynamic run-time loading
1.
Relative address
generated
2. Converted to
absolute address
by CPU
3. Enabled by
memory management unit
(MMU)
Memory management unit (MMU)
Converts
logical address
to
physical address
Main memory allocation strategies
Fixed-partition strategies
Variable-partition strategies
Fixed-partition memory allocation
Main memory divided into fixed number of
equal
or
unequal
partitions
Problems with fixed-partition memory allocation
Internal
fragmentation
External
fragmentation
Degree of multiprogramming
limited
Variable-partition memory allocation
Exact
memory space
needed by a process is allocated, no
fixed
partitions
Strategies for variable-partition memory allocation
First-fit
Best-fit
Worst-fit
External fragmentation
can be solved by compaction, where processes are moved towards the beginning of
memory
to group holes together
Placement strategies
1.
First-fit
2.
Best-fit
3.
Worst-fit
If first-fit strategy is used, P4 will be placed in the
4-MB
hole
If best-fit strategy is used, P4 will be placed in the
3-MB
hole
If worst-fit strategy is used, P4 will be placed in the 6-MB hole
External fragmentation
The free space is not
contiguous
Compaction
1. Processes are moved towards the
beginning
of the main memory
2. Holes are
grouped
together, forming one large block of
free
memory
After compaction, a
12-MB
process can be assigned
Compaction
It is only possible if dynamic
run-time loading
is used
It uses a significant amount of
CPU
time, especially if it involves moving hundreds of
processes
Paging
A process is allowed to occupy
non-contiguous
memory space
Paging
Processes are divided into
equal-sized
blocks called
pages
Main memory is divided into
equal-sized
blocks called
frames
A page fits a frame
Logical address to physical address
translation
1. Determine the page number of the
logical address
2. Use the page number to
index
into the page table
3. Add the offset field of the
logical address
to the frame number to form the
physical address
Logical address
Composed of
page number
and
offset
Physical address
Composed of frame
number
and
offset
The page table
maintains
the frame
numbers
of all the pages of the process
Paging
Eliminates external fragmentation
Internal fragmentation only occurs on the
last
page of each process
Page size
If too
small
,
increases
the size of the page table
If too
large
,
increases
internal fragmentation
Page table implementation
1.
Dedicated registers
2.
Main memory
3.
Cache memory
(translation look-aside buffer)
Virtual memory
Allows a process to execute even though not all of its
pages
are inside the
main
memory
Locality of
reference
Only some
portions
of the program are used at any
one
time
Demand paging
1. Initially, all processes are stored in the
hard
disk
2. Pages are loaded in main
memory
only if needed
Valid-invalid bit
Identifies if a page is located in main
memory
or on the
hard
disk
If the valid-invalid bit is 1, the page is in
main memory.
If the valid-invalid bit is 0, the page is on the
hard disk.
Whenever a logical address is generated, the
MMU hardware
first verifies if the page is in
main memory
If the valid-invalid bit is 0, the page is not in
main memory.
This is called a
page fault.
Demand paging
Pages are loaded in main memory only if
needed
Working set
The group of
pages
of a process in
main memory
Virtual memory page table
Uses a valid-invalid bit for each entry to identify if a page is located in main
memory
or on the
hard
disk
If the valid-invalid bit is 1, the page is in main memory. If the valid invalid bit is 0, the page is on the
hard disk.
See all 238 cards