Module 9: Memory Management Background(背景) ° Logical versus Physical Address Space(逻辑与物理地址空间) ° Swapping(交换) ° Contiguous Allocation(连续分配) Paging(分页) ° Segmentation(分段) ° Segmentation with Paging(段页式) Applied Operating System Concepts 9.1 Silberschatz, Galvin, and Gagne @1999
Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts 9.1 Module 9: Memory Management • Background(背景) • Logical versus Physical Address Space(逻辑与物理地址空间) • Swapping (交换) • Contiguous Allocation(连续分配) • Paging(分页) • Segmentation(分段) • Segmentation with Paging(段页式)
Background Program must be brought into memory and placed within a process for it to be executed.(程序必需放入一个进程,并且送 入内存才能被执行) e Input queue- collection of processes on the disk that are waiting to be brought into memory for execution.(输入队列 磁盘上等待进入内存并执行的进程的集合) User programs go through several steps before being executed.(用户程序在执行之前必需经历很多步骤) Applied Operating System Concepts 9.2 Silberschatz, Galvin, and Gagne @1999
Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts 9.2 Background • Program must be brought into memory and placed within a process for it to be executed.(程序必需放入一个进程,并且送 入内存才能被执行) • Input queue – collection of processes on the disk that are waiting to be brought into memory for execution.(输入队列 — 磁盘上等待进入内存并执行的进程的集合) • User programs go through several steps before being executed. (用户程序在执行之前必需经历很多步骤)
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) .(如果进程在执行时可以在内存中移 动,则地址绑定要延迟到运行时。需要硬件对地址映射的支持,例如基 址和限长寄存器) Applied Operating System Concepts 3 Silberschatz, Galvin, and Gagne @1999
Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts 9.3 Binding of Instructions and Data to Memory • 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). (如果进程在执行时可以在内存中移 动,则地址绑定要延迟到运行时。需要硬件对地址映射的支持,例如基 址和限长寄存器) Address binding of instructions and data to memory addresses can happen at three different stages.(指令和数据结合到内存地址可以在三 个不同的阶段发生。)
Dynamic Loading Routine is not loaded until it is called.(例程在调用之前并不执行) Better memory-space utilization; unused routine is never loaded. 更好的内存空间利用率;没有被使用的例程不被载入。) Useful when large amounts of code are needed to handle infrequently occurring cases.(当需要大量的代码来处理不经常发生的 事情时是非常有用的。) No special support from the operating system is required implemented through program design.(不需要操作系统的特别支持, 通过程序设计实现) Applied Operating System Concepts 94 Silberschatz, Galvin, and Gagne @1999
Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts 9.4 Dynamic Loading • Routine is not loaded until it is called.(例程在调用之前并不执行) • Better memory-space utilization; unused routine is never loaded.( 更好的内存空间利用率;没有被使用的例程不被载入。) • Useful when large amounts of code are needed to handle infrequently occurring cases.(当需要大量的代码来处理不经常发生的 事情时是非常有用的。) • No special support from the operating system is required implemented through program design.(不需要操作系统的特别支持, 通过程序设计实现)
Dynamic Linking Linking postponed until execution time.(链接被推迟到执行时期) Small piece of code, stub, used to locate the appropriate memory resident library routine.(小的代码片-存根,用来定位合适的保留在 内存中的库程序。) Stub replaces itself with the address of the routine, and executes the routine.(存根用例程地址来替换自己,以及执行例程。) Operating system needed to check if routine is in processes memory address.(操作系统需要检查例程是否在进程的内存空间) Applied Operating System Concepts 95 Silberschatz, Galvin, and Gagne @1999
Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts 9.5 Dynamic Linking • Linking postponed until execution time.(链接被推迟到执行时期) • Small piece of code, stub, used to locate the appropriate memoryresident library routine.(小的代码片- 存根,用来定位合适的保留在 内存中的库程序。) • Stub replaces itself with the address of the routine, and executes the routine.(存根用例程地址来替换自己,以及执行例程。) • Operating system needed to check if routine is in processes’ memory address.(操作系统需要检查例程是否在进程的内存空间)