Memory Management Paging
Memory Management Paging
Memory Management Paging
Background
Swapping
Contiguous Memory Allocation
Paging
Structure of the Page Table
Segmentation
Example: The Intel Pentium
A pair of base and limit registers define the logical address space
The user program deals with logical addresses; it never sees the
real physical addresses
Major part of swap time is transfer time; total transfer time is directly
proportional to the amount of memory swapped
Multiple-partition allocation
Hole – block of available memory; holes of various size are
scattered throughout memory
When a process arrives, it is allocated memory from a hole
large enough to accommodate it
Operating system maintains information about:
a) allocated partitions b) free partitions (hole)
OS OS OS OS
process 8 process 10
Shared code
One copy of read-only (reentrant) code shared among
processes (i.e., text editors, compilers, window systems).
Shared code must appear in same location in the logical
address space of all processes
4
1
3 2
4
Protection
With each entry in segment table associate:
validation bit = 0 illegal segment
read/write/execute privileges
Protection bits associated with segments; code sharing
occurs at segment level
Since segments vary in length, memory allocation is a
dynamic storage-allocation problem
A segmentation example is shown in the following diagram
Operating System Concepts Essentials – 8th Edition Silberschatz, Galvin and Gagne ©2011
Chapter 9: Virtual Memory
Background
Demand Paging
Copy-on-Write
Page Replacement
Allocation of Frames
Thrashing
Memory-Mapped Files
Allocating Kernel Memory
Other Considerations
Operating-System Examples
Lazy swapper – never swaps a page into memory unless page will be
needed
Swapper that deals with pages is a pager
Page replacement – find some page in memory, but not really in use,
page it out
Algorithm – terminate? swap out? replace the page?
Performance – want an algorithm which will result in minimum
number of page faults
3. Bring the desired page into the (newly) free frame; update the page
and frame tables
4. Continue the process by restarting the instruction that caused the trap
Note now potentially 2 page transfers for page fault – increasing EAT
1 7 2 4 0 7
2 0 3 2 1 0 15 page faults
3 1 0 3 2 1
Counter implementation
Every page entry has a counter; every time page is referenced
through this entry, copy the clock into the counter
When a page needs to be changed, look at the counters to find
smallest value
Search through table needed
Stack implementation
Keep a stack of page numbers in a double link form:
Page referenced:
move it to the top
requires 6 pointers to be changed
But each update more expensive
No search for replacement
LRU and OPT are cases of stack algorithms that don’t have Belady’s
Anomaly
Operating System Concepts 8.75 Silberschatz, Galvin and Gagne ©2005
Use Of A Stack to Record The
Most Recent Page References
If a process does not have “enough” pages, the page-fault rate is very
high
Page fault to get page
Replace existing frame
But quickly need replaced frame back
This leads to:
Low CPU utilization
Operating system thinking that it needs to increase the degree
of multiprogramming
Another process added to the system