Chapter 7 Memory Management Goals of memory management subdividing memory to accommodate multiple processes(为支持多道程序将内存进行划分) Memory needs to be allocated to ensure a reasonable supply of ready processes to consume available processor time(内存管理应确保有适当数目的就 绪进程使用处理器时间)
2 Chapter 7 Memory Management • Goals of memory management • subdividing memory to accommodate multiple processes(为支持多道程序将内存进行划分) • Memory needs to be allocated to ensure a reasonable supply of ready processes to consume available processor time(内存管理应确保有适当数目的就 绪进程使用处理器时间)
Chapter 7 Memory Management The external view of the Memory Manager Application Program VirtualAlloc( exec o) shmalloc( tulloCk( VirtualFree( getrlimit( ZeroMemory( UNIX Windows Hardware
Chapter 7 Memory Management • The External View of the Memory Manager 3
Chapter 7 Memory Management 7.1 Memory management Requirements 7.2 Memory Partitioning ·7.3 Paging 7.4 Segmentation 7.5 Summary
4 Chapter 7 Memory Management • 7.1 Memory Management Requirements • 7.2 Memory Partitioning • 7.3 Paging • 7.4 Segmentation • 7.5 Summary
7.1 Memory Management Requirements 7. 1. 1 Five requirements 7.1.2 Preparing program for Execution
5 7.1 Memory Management Requirements • 7.1.1 Five requirements • 7.1.2 Preparing Program for Execution
7.1.1 Five requirements(1/6) ·1.Re| ocation We need to relocate the process to a different area of memory Programmer does not know where the program will be placed in memory when it is executed While the program is executing, it may be swapped(交换) to disk and returned to main memory at a different location(relocated) Memory references(访问) found in the code must be translated to actual physical memory address(物理内存地址)
7.1.1 Five requirements(1/6) • 1. Relocation • We need to relocate the process to a different area of memory. • Programmer does not know where the program will be placed in memory when it is executed. • While the program is executing, it may be swapped(交换) to disk and returned to main memory at a different location (relocated). • Memory references(访问) found in the code must be translated to actual physical memory address(物理内存地址). 6
7.1.1 Five requirements(276) 1. Relocation Relocation could raise some technical concerns Process control information 'rpces Control Bloc Entry point to program Increasing address Reference to data Data Current top of stack Figure 7.1 Addressing Requirements for a Process
7.1.1 Five requirements(2/6) • 1. Relocation • Relocation could raise some technical concerns related to addressing 7
7.1.1 Five requirements(376) ·2. Protection Processes should not be able to reference memory locations in another process without permission Normally, processes cannot access any portion of the os, neither program nor data Impossible to check absolute addresses at compile time, must be checked at rum time Memory protection requirement must be satisfied by the processor(hardware)rather than the operating system Operating system cannot anticipate all of the memory references a program will make
7.1.1 Five requirements(3/6) • 2. Protection • Processes should not be able to reference memory locations in another process without permission Normally, processes cannot access any portion of the OS, neither program nor data. • Impossible to check absolute addresses at compile time, must be checked at rum time. • Memory protection requirement must be satisfied by the processor (hardware) rather than the operating system • Operating system cannot anticipate all of the memory references a program will make 8
7.1.1 Five requirements(4/6) 3. Sharing Allow several processes to access the same portion of memory Share same copy of the program Share data structure to cooperate on some task The memory management system must allow controlled access to shared areas of memory without compromising essential protection
7.1.1 Five requirements(4/6) • 3. Sharing • Allow several processes to access the same portion of memory • Share same copy of the program • Share data structure to cooperate on some task • The memory management system must allow controlled access to shared areas of memory without compromising essential protection. 9
7.1.1 Five requirements(5/6) 4. Logical Organization(逻辑组织) Programs are written in modules Modules can be written and compiled independently Different degrees of protection given to modules (read-only, execute-only) Share modules among processes
7.1.1 Five requirements(5/6) • 4. Logical Organization(逻辑组织) • Programs are written in modules • Modules can be written and compiled independently • Different degrees of protection given to modules (read-only, execute-only) • Share modules among processes 10
7.1.1 Five requirements(6/6) 5. Physica| Organization(物理组织) Memory is organized into at least two levels, referred to as main memory and secondary memory Memory available for a program plus its data may be insufficient(内存对程序和其数据来说可能不足) Overlaying(覆盖) allows various modules to be assigned the same region of memory Programmer does not know how much space will be available and where his / her program will be loaded in memory
11 7.1.1 Five requirements(6/6) • 5. Physical Organization(物理组织) • Memory is organized into at least two levels, referred to as main memory and secondary memory • Memory available for a program plus its data may be insufficient(内存对程序和其数据来说可能不足) • Overlaying(覆盖) allows various modules to be assigned the same region of memory • Programmer does not know how much space will be available and where his/her program will be loaded in memory