由于一个进程只能在主存中执行,因此 这个存储器称作实存( real memory)。 但是程序员或用户感觉到的是一个更大 的存储器,通常是被分配在磁盘上,这 称作虚拟存储器( virtual memory),简 称虚存。 表8.1总结了使用虚存和不使用虚存的 情况下分页和分段的特点。(P32)
• 由于一个进程只能在主存中执行,因此 这个存储器称作实存(real memory)。 但是程序员或用户感觉到的是一个更大 的存储器,通常是被分配在磁盘上,这 称作虚拟存储器(virtual memory),简 称虚存。 • 表8.1总结了使用虚存和不使用虚存的 情况下分页和分段的特点。 (P322)
表8.1分页和分段的特点 箪分页 存分页 草分 虛存分 主存被划分成小的、大主存被划分成小的、大小固定的主存没有被划分 主存没有被划分 小固定的块,称作帧块,称作帧 程序被编译器或存储器程序被编译器或存储器管理系统由程序员给编译器指定程序段由程序员给编译器指定程序 管理系统划分成页划分成页 (也就是说,由程序员决定)段(也就是由程序员决定) 帧中有内部碎片帧中有内部碎片 没有内部碎片 没有内部碎片 没有外部碎片 没有外部碎片 外部碎片 外部碎片 操作系统必须为每个进操作系统必须为每个进程维护一操作系统必须为每个进程维护操作系统必须为每个进程 程维护一个页表,以说个页表,以说明每个页分别占据一个段表,以说明每一段中的护一个段表,以说明每一段 明每个页分别占据了哪了哪些帧 加载地址和长度 中的加载地址和长度 些帧 操作系统必须维护一个操作系统必须维护一个自由帧操作系统必须维护一个主存中操作系统必须维护一个主有 自由帧列表 列表 的自由空洞列表 中的自由空洞列表 处理器使用页号和偏移处理器使用页号和偏移量来计算处理器使用段号和偏移量来计处理器使用段号和偏移量 量来计算绝对地址绝对地址 算绝对地址 计算绝对地址 当进程运行时,它的所当进程在运行时,并不是它的所当进程在运行时,它的所有页当进程在运行时,井不 有页必须都在主存中,有页都必须在主存帧中。只在需都必须在主存中,除非使用了的所有段都必须在主存 除非使用了覆盖技术要时才读入页 覆盖技术 中。只在需要时才读入段 把一页读入主存可能需委把另 把一段读入主存可能需 页写出到磁盘 另外的一个段或几个 到磁盘
Locality and Virtual Memory The benefits of virtual memory are attractive but is the scheme practical:(虚存的优点是很具有吸 引力的,但这个方案切实可行吗?) Consider a large process, consisting of a long program plus a number of arrays of data. Over any short period of time, execution may be confined to a small section of the program(e.g, subroutine)and access to perhaps only one or two arrays of data.(考虑由 个很长的程序和许多数据数组组成的大进程,在任何一段 很短的时间内,执行可能会局限在很小的一段程序中(例如 个子程序),并且可能仅仅会访问一个或两个数据数组)
Locality and Virtual Memory •The benefits of virtual memory are attractive, but is the scheme practical ?(虚存的优点是很具有吸 引力的,但这个方案切实可行吗? ) •Consider a large process, consisting of a long program plus a number of arrays of data. Over any short period of time, execution may be confined to a small section of the program (e.g.,subroutine) and access to perhaps only one or two arrays of data. (考虑由 一个很长的程序和许多数据数组组成的大进程,在任何一段 很短的时间内,执行可能会局限在很小的一段程序中(例如 一个子程序),并且可能仅仅会访问一个或两个数据数组)
Principle of Locality (局部性原理 The principle of locality states that program and data references within a rocess tend to cluster:(局部性原理描述了 一个进程中程序和数据引用的簇聚性倾向) The assumption that only a few pieces of a process will be needed over a short period of time is valid.(假设在很短的时间 内仅需要进程的一部分块是合理的)
Principle of Locality (局部性原理) • The principle of locality states that program and data references within a process tend to cluster.(局部性原理描述了 一个进程中程序和数据引用的簇聚性倾向) • The assumption that only a few pieces of a process will be needed over a short period of time is valid.(假设在很短的时间 内仅需要进程的一部分块是合理的)
One way to confirm the principle of locality is to look at the performance of processes in a virtual memory environment. (see figure 8.1 P323) (证实局部性原理的一种方法是在虚 存环境中查看进程的执行情况)
• One way to confirm the principle of locality is to look at the performance of processes in a virtual memory environment .(see figure 8.1 P323) (证实局部性原理的一种方法是在虚 存环境中查看进程的执行情况)