ch8 Isra
ch8 Isra
ch8 Isra
Operating System Concepts – 8th Edition,! Silberschatz, Galvin and Gagne ©2009!
Chapter 8: Memory Management
■ Background"
■ Swapping "
■ Contiguous Memory Allocation"
■ Paging"
■ Segmentation"
Operating System Concepts – 8th Edition! 8.2! Silberschatz, Galvin and Gagne ©2009!
Objectives
Operating System Concepts – 8th Edition! 8.3! Silberschatz, Galvin and Gagne ©2009!
Background
!
Operating System Concepts – 8th Edition! 8.4! Silberschatz, Galvin and Gagne ©2009!
Base and Limit Registers
■ A pair of base and limit registers define the logical address space"
■ Base register: holds the smallest legal physical memory address."
■ Limit register: specifies the size of the range."
Operating System Concepts – 8th Edition! 8.5! Silberschatz, Galvin and Gagne ©2009!
HW address protection with base and limit registers
Operating System Concepts – 8th Edition! 8.6! Silberschatz, Galvin and Gagne ©2009!
Binding of Instructions and Data to Memory
"
■ Address binding of instructions and data to memory
addresses can happen at three different stages"
● Compile time: If memory location known a priori,
absolute code can be generated; must recompile
code if starting location changes"
● Load time: Must generate relocatable code if
memory location is not known at compile time"
● Execution time: Binding delayed until run time if the
process can be moved during its execution from one
memory segment to another. Need hardware support
for address maps (e.g., base and limit registers)"
Operating System Concepts – 8th Edition! 8.7! Silberschatz, Galvin and Gagne ©2009!
Multistep Processing of a User Program
Operating System Concepts – 8th Edition! 8.8! Silberschatz, Galvin and Gagne ©2009!
Logical vs. Physical Address Space
Operating System Concepts – 8th Edition! 8.9! Silberschatz, Galvin and Gagne ©2009!
Memory-Management Unit (MMU)
Operating System Concepts – 8th Edition! 8.10! Silberschatz, Galvin and Gagne ©2009!
Dynamic relocation using a relocation register
Operating System Concepts – 8th Edition! 8.11! Silberschatz, Galvin and Gagne ©2009!
Swapping
Operating System Concepts – 8th Edition! 8.13! Silberschatz, Galvin and Gagne ©2009!
Contiguous Allocation
Operating System Concepts – 8th Edition! 8.14! Silberschatz, Galvin and Gagne ©2009!
Hardware Support for Relocation and Limit Registers
Operating System Concepts – 8th Edition! 8.15! Silberschatz, Galvin and Gagne ©2009!
Contiguous Allocation (Cont)
■ 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)"
Operating System Concepts – 8th Edition! 8.16! Silberschatz, Galvin and Gagne ©2009!
Dynamic Storage-Allocation Problem
Operating System Concepts – 8th Edition! 8.17! Silberschatz, Galvin and Gagne ©2009!
Fragmentation
Operating System Concepts – 8th Edition! 8.18! Silberschatz, Galvin and Gagne ©2009!
Compaction
11M Process
3M Process
1M
32M 7M Process
11M Process
24M
21M
20M
7M Process 11M
9M
2M
1M
Operating System Concepts – 8th Edition! 8.19! Silberschatz, Galvin and Gagne ©2009!
Paging
Operating System Concepts – 8th Edition! 8.20! Silberschatz, Galvin and Gagne ©2009!
Address Translation Scheme
Operating System Concepts – 8th Edition! 8.21! Silberschatz, Galvin and Gagne ©2009!
Paging Hardware
Operating System Concepts – 8th Edition! 8.22! Silberschatz, Galvin and Gagne ©2009!
Paging Model of Logical and Physical Memory
Operating System Concepts – 8th Edition! 8.23! Silberschatz, Galvin and Gagne ©2009!
Paging Example
Animation
Operating System Concepts – 8th Edition! 8.25! Silberschatz, Galvin and Gagne ©2009!
Implementation of Page Table
Operating System Concepts – 8th Edition! 8.26! Silberschatz, Galvin and Gagne ©2009!
Associative Memory
Operating System Concepts – 8th Edition! 8.27! Silberschatz, Galvin and Gagne ©2009!
Paging Hardware With TLB
Operating System Concepts – 8th Edition! 8.28! Silberschatz, Galvin and Gagne ©2009!
Effective Access Time
Operating System Concepts – 8th Edition! 8.29! Silberschatz, Galvin and Gagne ©2009!
TLB miss and Hit ratio
■ TLB miss: "
Operating System Concepts – 8th Edition! 8.30! Silberschatz, Galvin and Gagne ©2009!
Effective Access Time (EAT)
Operating System Concepts – 8th Edition! 8.31! Silberschatz, Galvin and Gagne ©2009!
Memory Protection
Operating System Concepts – 8th Edition! 8.32! Silberschatz, Galvin and Gagne ©2009!
Valid (v) or Invalid (i) Bit In A Page Table
Operating System Concepts – 8th Edition! 8.33! Silberschatz, Galvin and Gagne ©2009!
Shared Pages
■ 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
"
■ Private code and data "
● Each process keeps a separate copy of the code and data"
● The pages for the private code and data can appear
anywhere in the logical address space"
Operating System Concepts – 8th Edition! 8.34! Silberschatz, Galvin and Gagne ©2009!
Shared Pages Example
Operating System Concepts – 8th Edition! 8.35! Silberschatz, Galvin and Gagne ©2009!
Segmentation
Operating System Concepts – 8th Edition! 8.36! Silberschatz, Galvin and Gagne ©2009!
User’s View of a Program
Operating System Concepts – 8th Edition! 8.37! Silberschatz, Galvin and Gagne ©2009!
Logical View of Segmentation
1"
4"
1"
2"
3" 2"
4"
3"
Operating System Concepts – 8th Edition! 8.38! Silberschatz, Galvin and Gagne ©2009!
Segmentation Architecture
Operating System Concepts – 8th Edition! 8.39! Silberschatz, Galvin and Gagne ©2009!
Segmentation Hardware
Operating System Concepts – 8th Edition! 8.40! Silberschatz, Galvin and Gagne ©2009!
Example of Segmentation
Operating System Concepts – 8th Edition! 8.41! Silberschatz, Galvin and Gagne ©2009!
Segmentation Architecture (Cont.)
■ 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 – 8th Edition! 8.42! Silberschatz, Galvin and Gagne ©2009!
Sharing of Segments
Operating System Concepts – 8th Edition! 8.43! Silberschatz, Galvin and Gagne ©2009!
Problems that still Remain
■ In simple paging and segmentation all pages and/or segments must be
loaded"
Operating System Concepts – 8th Edition! 8.44! Silberschatz, Galvin and Gagne ©2009!
End of Chapter 8
Operating System Concepts – 8th Edition,! Silberschatz, Galvin and Gagne ©2009!